Repository navigation
fix(login): show device code immediately so /login no longer hangs - #3
Merged
Merged
Conversation
/login produced no output and deadlocked: the slash dispatcher only renders a command's resolved value, but the handler blocked in pollForToken before returning, so the device code stayed hidden and the user could never authorize it. Split device login into beginDeviceLogin (returns the code at once) + complete() (polls), and give the TUI a non-blocking /login branch that renders the verification URL + code first, then a completion card. Also refresh the CopilotTokenStore after re-login so the model picker keeps working once the old Copilot token rotates. Co-Authored-By: Claude <noreply@anthropic.com>
A rejected device-code poll (e.g. incorrect_device_code) previously escaped as an unhandled rejection and killed the process. Surface it as an error card with a clean message (strip the Error: prefix), and guard against a double Enter starting two concurrent device-code flows — the second code supersedes the first, so polling the first 401s. Co-Authored-By: Claude <noreply@anthropic.com>
After /logout (or an expired login), sending a chat message fired a request that just hung until the 120s turn timeout, then printed an opaque "no response". Add an optional pre-flight auth gate to makeOnChat that runs before each turn; production wires it to the long-lived tokenStore so a valid login is a cached, round-trip-free check, while a missing/expired token blocks the turn immediately with a "run /login" hint. Co-Authored-By: Claude <noreply@anthropic.com>
wangcansunking
added a commit
that referenced
this pull request
Jun 29, 2026
…plate, config, banner (#15) * feat(tui): scope+model status, chat-setup confirmation, parity, report template, config, banner - #6 /status + HUD show each client's scope AND pinned model, not a bare check - #5 chat setup_claude/codex require scope+model (ask first, never assume) - #7 add recent_errors + metrics chat tools to match slash commands - #4 /report body follows the #5 template (Summary/Environment/Repro) - #3 GitHub heartbeat interval/delay now configurable via AppConfig - #1 versioned "what's new" banner, shown ~3 launches then suppressed - #2 README reflects guards, runaway reporting, scope+model, config knobs Co-Authored-By: Claude <noreply@anthropic.com> * feat(report): add #5-style issue template; banner = major changes only - .github/ISSUE_TEMPLATE/bug.yml (Summary/Environment/Repro/Diagnostics/fixes) so manual issues match the rich #5 shape; /report still auto-fills the same sections. - what's-new banner trimmed to major changes only (the freeze fix); minor polish dropped. Co-Authored-By: Claude <noreply@anthropic.com> --------- Co-authored-by: Claude <noreply@anthropic.com>
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
Typing
/loginin the TUI produced no output and hung. Root cause: the slash-command dispatcher only renders a command's resolved return value, but the/loginhandler blocked inpollForToken(an infinite poll loop) before returning — so the device code/URL was buffered behind the poll and never shown. The user couldn't authorize a code they couldn't see → deadlock.Fix
src/cli/auth.ts— split device login into two phases:beginDeviceLogin()returns theDeviceCodeimmediately + acomplete()thunk that does the blocking poll + token write.runDeviceLoginnow reuses these (still used by the startup path and thecopilot-reverse loginCLI subcommand).src/tui/app.tsx— newlogin?prop + a non-blocking/loginbranch (modeled on the existing/modelspecial case): it pushes the verification URL + code to the UI immediately, then renders a completion/error card when the background poll resolves.src/cli/index.ts— wires the Apploginprop viabeginDeviceLogin; refreshesCopilotTokenStoreafter re-login so the model picker keeps working once the old Copilot token rotates (caught in review).Tests
tests/cli/auth.test.ts— new two-phase test: code is returned before any poll runs.tests/tui/app-interaction.test.tsx— new regression test: device code renders while the token poll is still pending (holds a gate open, asserts the code is on-screen, then releases).Verification
npm test→ 238 passed (47 files), up from 236npm run test:e2e→ 31 passed (4 files)tscbuild cleanslash.test.tscoverage).Includes a
patchchangeset.🤖 Generated with Claude Code