fix(agents-login): match the space-less paste prompt (credential hang)#734
Merged
Conversation
…ctually written The login hung after the user submitted the auth code because the worker never wrote it to the PTY. claude setup-token renders 'Paste code here if prompted >' using cursor-position ANSI (no literal spaces), so after stripAnsi the buffer is 'Pastecodehereifprompted>'. detectClaudeCodePrompt required whitespace between words (\s+), so it never matched, the paste-prompt gate never fired, and the queued code was never written. - detectClaudeCodePrompt now tolerates zero whitespace between words (\s*), matching both the spaced and cursor-positioned prompt forms. - submitRedirectUrl / maybeSubmitPendingClaudeCode fail loudly (phase failed) if there is no live PTY handle, instead of silently no-oping. - Tests cover the real cursor-positioned prompt bytes and the missing-process failure.
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 (determined from prod PTY bytes + local reproduction)
The login hung after the user submitted the auth code: the worker logged 1 redirect submission but 0 PTY stdin writes.
claude setup-tokenrenders itsPaste code here if prompted >prompt with cursor-position ANSI (\x1b[8G…), not literal spaces, so afterstripAnsithe buffer isPastecodehereifprompted>.detectClaudeCodePromptrequired\s+between words, so it never matched the real prompt → the paste-prompt gate inmaybeSubmitPendingClaudeCode()never fired → the queued code was never written → infinite hang. (A local PTY reproduction ofsetup-tokenconfirmed plain<code>\ris accepted once it reaches the PTY.)Fix
detectClaudeCodePromptnow uses\s*, matching both the spaced and the cursor-positioned (space-less) prompt forms.submitRedirectUrl/maybeSubmitPendingClaudeCodenow fail the session (failed, logged) if there is no live PTY handle, instead of silently no-oping — backed by the bounded redirect timeout.Tests
detectClaudeCodePrompttrue for the real bytes\x1b[2GPaste\x1b[8Gcode…\x1b[30G>; missing-process →failed; live PTY receives<code>\r. Suite 90 tests + typecheck + lint pass.