fix(agents-login): finalize Claude capture on parsed token (stuck-waiting bug)#731
Merged
Merged
Conversation
…success line claude setup-token prints the OAuth token after the redirect URL is pasted but can keep the PTY open without printing a recognized success line, so the session stayed awaiting_url forever and never captured or POSTed to agents-api. The worker now treats a parsed Claude OAuth token as the completion signal and immediately finalizes, captures, and posts; post-submission CLI failure output now transitions the session to failed instead of being ignored. Adds a regression test.
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.
Symptom
After pasting the Claude auth code/redirect URL, the credentials page stuck forever on "Authorization submitted. Waiting for the session to finish." and nothing was ever stored.
Root cause
In the worker session lifecycle, Claude finalization (capture + POST to agents-api) only ran after a recognized success line or process exit. In production
claude setup-tokenprintsCLAUDE_CODE_OAUTH_TOKEN=...after paste-back while keeping the PTY open and without matching the success regex, so the session stayedawaiting_urlindefinitely and never captured/posted. (Not an agents-api-side fault.)Fix
After redirect submission, a parsed Claude OAuth token is now treated as the completion signal — the worker immediately finalizes, captures, and POSTs to agents-api, advancing the session to
succeeded. Post-submission CLI failure output now transitions the session tofailed(with a reason) instead of being swallowed into a hang.Tests
Failing-first regression test added: after redirect submission a fake
setup-tokenemits the token without exiting/printing a success phrase — failed withexpected 'awaiting_url' to be 'succeeded'before the fix, passes after. Full suite: 79 tests + typecheck + lint pass.