Skip to content

fix(agents-login): match the space-less paste prompt (credential hang)#734

Merged
ExtraToast merged 1 commit into
mainfrom
fix/credential-pty-write
Jun 25, 2026
Merged

fix(agents-login): match the space-less paste prompt (credential hang)#734
ExtraToast merged 1 commit into
mainfrom
fix/credential-pty-write

Conversation

@ExtraToast

Copy link
Copy Markdown
Owner

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-token renders its Paste code here if prompted > prompt with cursor-position ANSI (\x1b[8G…), not literal spaces, so after stripAnsi the buffer is Pastecodehereifprompted>. detectClaudeCodePrompt required \s+ between words, so it never matched the real prompt → the paste-prompt gate in maybeSubmitPendingClaudeCode() never fired → the queued code was never written → infinite hang. (A local PTY reproduction of setup-token confirmed plain <code>\r is accepted once it reaches the PTY.)

Fix

  • detectClaudeCodePrompt now uses \s*, matching both the spaced and the cursor-positioned (space-less) prompt forms.
  • submitRedirectUrl / maybeSubmitPendingClaudeCode now fail the session (failed, logged) if there is no live PTY handle, instead of silently no-oping — backed by the bounded redirect timeout.

Tests

detectClaudeCodePrompt true for the real bytes \x1b[2GPaste\x1b[8Gcode…\x1b[30G>; missing-process → failed; live PTY receives <code>\r. Suite 90 tests + typecheck + lint pass.

…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.
@ExtraToast ExtraToast added the bug Something isn't working label Jun 25, 2026
@ExtraToast ExtraToast self-assigned this Jun 25, 2026
@ExtraToast ExtraToast merged commit c033685 into main Jun 25, 2026
22 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant