fix(agents-login): submit the pasted code with a separate Enter keystroke#735
Merged
Conversation
…ode submits The code was reaching the CLI (it echoed masked asterisks) but never submitted: claude setup-token is an Ink TUI with bracketed-paste mode, which treats a bulk 'code\r' write as a paste and swallows the trailing carriage return, so Enter never fired. - Write the authorization code, then send '\r' as a SEPARATE, slightly delayed write so Ink registers it as a submit keypress; retry the Enter once if no completion shortly after. - Clears the submit/retry timers on finalize/failure/cancel. - Keeps callback-URL code extraction, credentials-file fallback, token parsing, and the bounded redirect timeout.
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.
Root cause (from prod PTY logs)
After the prior fixes, the worker now writes the code (
worker PTY stdin write) andclaude setup-tokenechoes it as masked asterisks — but it never submits (no token, no error, no exit).setup-tokenis an Ink TUI with bracketed-paste mode (\x1b[?2004h); a bulkcode\rwrite is treated as a paste, so the trailing\ris swallowed instead of acting as Enter.Fix
Write the authorization code, then send
\ras a separate, slightly-delayed write so Ink registers it as a submit keypress; retry the Enter once if there's no completion shortly after. Timers are cleared on finalize/failure/cancel. Callback-URL code extraction, credentials-file fallback, token parsing, and the bounded redirect timeout are unchanged.Tests
Focused fake-PTY test asserts the write sequence is
[code, '\r'](two distinct writes) and that a parsed token is posted to agents-api and the session reachessucceeded. Suite 91 tests + typecheck + lint pass.