fix(agents-login): detect the ANSI-fused Claude login chooser/REPL#741
Merged
Merged
Conversation
…s* not \s+)
Claude login still hung at "starting": after /login the CLI shows the
"Select login method" chooser, but the worker never pressed Enter to confirm
it. The TUI renders that menu with ANSI cursor-column moves (ESC[NNG) instead
of spaces, so stripAnsi() fuses the words ("Selectloginmethod",
"Claudeaccountwithsubscription"). The detector regexes used \s+ (requires
whitespace) and never matched the fused text -> no chooser Enter -> stall.
(forceLoginMethod=claudeai does not auto-skip the chooser on claude 2.1.186.)
Make detectClaudeLoginChooser and detectClaudeLoggedOutRepl whitespace-
insensitive (\s*), matching both spaced and fused forms. Add regression tests
that feed real ANSI cursor-column bytes (fail on the old \s+ patterns).
Co-Authored-By: Claude Opus 4.8 (1M context) <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.
Problem (live from worker logs)
After #740, Claude login still hung at
starting. The new/loginfallback fires and the CLI shows the "Select login method" chooser (option 1 "Claude account with subscription" highlighted), but the worker never pressed Enter to confirm it → stall.Cause: the TUI draws that menu with ANSI cursor-column moves (
ESC[NNG) instead of spaces, sostripAnsi()fuses the words →Selectloginmethod:❯1.Claudeaccountwithsubscription. The detectors used\s+(requires whitespace) and never matched the fused text. Verified against the real bytes: old\s+→ false, fixed\s*→ true. (forceLoginMethod=claudeaidoes not auto-skip the chooser on claude v2.1.186, so confirming it is required.)Fix
detectClaudeLoginChooseranddetectClaudeLoggedOutReplare now whitespace-insensitive (\s*), matching both the spaced and the ANSI-fused forms. Added regression tests that feed real cursor-column bytes (these fail on the old\s+).Tests
npm test: 102 pass, branch coverage 83.52% (≥80%). Lint clean.🤖 Generated with Claude Code