fix: /login shows provider menu and supports Ctrl+C cancellation - #55
Merged
Merged
Conversation
- /login now presents a numbered provider menu instead of always using the current provider (like /model does) - Anthropic login switched from sync stdin to async tokio stdin so it's cancellable - REPL wraps command dispatch in tokio::select! with ctrl_c() so /login (and all commands) can be interrupted with Ctrl+C Closes #54
Instead of a hardcoded list, use Provider::value_variants() from clap's ValueEnum and filter to those with a ProviderConfig. New providers added to the enum automatically appear in /login.
- Non-empty, excludes human, includes anthropic and google - Display names and env vars are non-empty, IDs are unique - Matches Provider enum variants (catches missing providers) - provider_config_by_id round-trips and rejects unknown IDs
There was a problem hiding this comment.
Pull request overview
This PR improves the REPL login experience by adding an interactive provider-selection menu to /login and making interactive command flows cancellable via Ctrl+C, aligning /login with existing menu-driven UX patterns in the REPL.
Changes:
- Add a provider selection menu to
/login, with current provider marking and conditional auth-status updates. - Make Anthropic’s “paste authorization code” prompt async to support cancellation.
- Wrap command dispatch in
tokio::select!withtokio::signal::ctrl_c()to allow interrupting interactive commands.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
src/provider.rs |
Switch Anthropic login code entry to async stdin and add all_login_providers() helper. |
src/main.rs |
Add Ctrl+C handling around command dispatch to interrupt interactive commands. |
src/commands/login.rs |
Implement provider selection menu and async stdin input for /login. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
New tests/login_test.rs covering: - build_provider detects OAuth, API key, and env var auth - build_provider model resolution: CLI override, config DB, precedence - logout clears credentials for all login providers - logout one provider preserves others - /login command handles stdin EOF gracefully
- Convert /model to async stdin (was blocking, prevented Ctrl+C) - Extract parse_menu_choice() helper with unit tests (5 tests) - Both /login and /model now use the shared helper - Make provider_config_by_id() dynamic from Provider::value_variants() instead of a hardcoded match (reduces provider registry duplication)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #54 —
/loginnow lets you choose a provider and can be cancelled with Ctrl+C.Changes
1. Provider selection menu (
src/commands/login.rs)/loginnow presents a numbered menu of all available providers (like/modeldoes for models), instead of always logging into the current provider:The current provider is marked. Auth status is only updated in the REPL when logging into the current provider.
2. Async stdin for Anthropic login (
src/provider.rs)Switched from blocking
io::stdin().read_line()to asynctokio::io::stdin().lines()so the "Paste the authorization code" prompt is cancellable by the tokio runtime.3. Ctrl+C support for all commands (
src/main.rs)Wrapped
commands.dispatch()intokio::select!withtokio::signal::ctrl_c(), so any interactive command (not just task execution) can be interrupted. This covers:4. New
all_login_providers()helper (src/provider.rs)Returns all providers that support login, used by the
/loginmenu.Testing
All 214 tests pass. Zero clippy warnings.
cargo fmtclean.