Shared login: press Enter separately from the pasted code #64

Merged
jknapp merged 1 commits from fix/shared-login-submit-enter into main 2026-09-27 13:29:30 +00:00
Owner

Problem

Shared login never completes: after submitting the code the dialog sits at Code sent. Waiting for setup-token to finish… until it times out.

Cause

submit_claude_token_code sent the code and \r in a single write. Claude Code's prompt treats a multi-byte chunk as a paste and swallows the \r inside it, so the code filled the prompt but was never submitted.

Reproduced against claude setup-token 2.1.283 under a real pty with a dummy code:

Write pattern Result
code + \r in one write (old behaviour) code masked in prompt, nothing submitted
code, then \r 20/50/150 ms later submitted; CLI replies OAuth error: … Press Enter to retry

Fix

  • New type_code_then_enter: writes the code, flushes, waits SUBMIT_ENTER_DELAY (250 ms — headroom over the measured 20 ms for Docker exec socket coalescing), then writes \r on its own.
  • submit_claude_token_code now sends only the code; the flow presses Enter.
  • Test the_code_and_its_enter_are_separate_writes uses a write-recording AsyncWrite to assert two distinct writes separated by the delay.

Testing

  • cargo test --lib: 677 passed.
  • Not yet verified end-to-end with a real sign-in — please confirm the shared login completes on a preview build.

Note

2.1.283 now reports a refused code as Request failed with status code 400 rather than Invalid code. Rejection detection still works via the Press Enter to retry marker, but the user-facing "full code was not copied" message may be inaccurate for expired/reused codes. Left for a follow-up.

🤖 Generated with Claude Code

## Problem Shared login never completes: after submitting the code the dialog sits at *Code sent. Waiting for setup-token to finish…* until it times out. ## Cause `submit_claude_token_code` sent the code **and** `\r` in a single write. Claude Code's prompt treats a multi-byte chunk as a paste and swallows the `\r` inside it, so the code filled the prompt but was never submitted. Reproduced against `claude setup-token` 2.1.283 under a real pty with a dummy code: | Write pattern | Result | |---|---| | code + `\r` in one write (old behaviour) | code masked in prompt, nothing submitted | | code, then `\r` 20/50/150 ms later | submitted; CLI replies `OAuth error: … Press Enter to retry` | ## Fix - New `type_code_then_enter`: writes the code, flushes, waits `SUBMIT_ENTER_DELAY` (250 ms — headroom over the measured 20 ms for Docker exec socket coalescing), then writes `\r` on its own. - `submit_claude_token_code` now sends only the code; the flow presses Enter. - Test `the_code_and_its_enter_are_separate_writes` uses a write-recording `AsyncWrite` to assert two distinct writes separated by the delay. ## Testing - `cargo test --lib`: 677 passed. - Not yet verified end-to-end with a real sign-in — please confirm the shared login completes on a preview build. ## Note 2.1.283 now reports a refused code as `Request failed with status code 400` rather than `Invalid code`. Rejection detection still works via the `Press Enter to retry` marker, but the user-facing "full code was not copied" message may be inaccurate for expired/reused codes. Left for a follow-up. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
jknapp added 1 commit 2026-09-27 13:15:18 +00:00
Shared login: press Enter separately from the pasted code
Secret Scan / scan (push) Successful in 4s
Build App (Preview) / compute-version (pull_request) Successful in 3s
Secret Scan / scan (pull_request) Successful in 4s
Build App (Preview) / create-release (pull_request) Successful in 2s
Build App (Preview) / build-macos (pull_request) Successful in 2m54s
Build App (Preview) / test (pull_request) Successful in 4m36s
Build App (Preview) / build-windows (pull_request) Successful in 5m50s
Build App (Preview) / build-linux (pull_request) Successful in 7m19s
Build App (Preview) / prune-previews (pull_request) Successful in 2s
08779fa397
The code and its Enter were sent to `claude setup-token` in one write.
Claude Code's prompt reads a multi-byte chunk as a paste and swallows a
`\r` inside it, so the code filled the prompt but was never submitted and
the flow sat at "Waiting for setup-token to finish" until the 15-minute
timeout.

Measured against 2.1.283 under a pty: joined write never submits; the
same code with Enter 20 ms later submits every time. Now the code is
written, then Enter follows 250 ms later as its own write.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
jknapp merged commit 292fc907fb into main 2026-09-27 13:29:30 +00:00
jknapp deleted branch fix/shared-login-submit-enter 2026-09-27 13:29:30 +00:00
Sign in to join this conversation.
No Reviewers
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: CyberCoveLLC/Triple-C#64