Repository navigation
fix(desktop): stop cold-start ACP init from awaiting Claude OAuth in-band - #10478
Conversation
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
|
Thanks for the focused fix here. The shape looks directionally right to me: extracting a non-blocking auth kickoff seam and reusing it from cold-start ACP init addresses the hang without dropping the OAuth flow entirely, and the new Vitest coverage guards the important ordering/rejection behavior. I’m not approving this yet because it touches the Claude auth/ACP initialization path and the required Desktop Swift test gate is currently failing. Before merge, I’d want a maintainer to verify the end-to-end desktop behavior with expired Claude credentials, especially that repeated first-send/auth-required attempts do not spawn confusing duplicate sign-in prompts and that successful OAuth still restarts/re-initializes ACP cleanly. No concrete code change request from me based on the static diff, but this needs the failing CI resolved or explained plus human maintainer sign-off for the auth-flow behavior. by AI on behalf of David — if you need David’s attention urgently, please @Git-on-my-level and escalate with |
…band initializeAcp() awaited startAuthFlow() when ACP returned -32000 (auth required) on cold start, then retried init. With expired credentials and no OAuth callback, init sat inside that await for the whole callback timeout — and because no turn was on the wire yet, the user's first send had nothing to terminalize behind and simply hung. Apply the same terminalize-first contract the active turn already follows (BasedHardware#10417): signal auth_required to Swift, then start — never await — the OAuth flow and return. isInitialized stays false, so the pending send reaches the ACP request, hits the same -32000, and terminalizes as `authentication` via the kernel's recoverable-error path instead of blocking. The flow is still started (not dropped): Swift startClaudeAuth needs the bridge-issued authUrl only that flow mints, so dropping it would strand the user with no way to sign in. The kickoff is extracted to acp.ts as beginProviderAuthWithoutBlocking, a shared seam with a real injectable boundary, so it is covered behaviourally rather than by index.ts source-scraping. This is the second instance of the same root cause (the first, BasedHardware#10417, hardened the active-turn path), so it declares Failure-Class: new and registers FC-in-band-auth-await-stall citing both PRs as the shared guard surface. Verify: - agent vitest: acp-init-auth-nonblocking (4) + acp-auth-terminal (2) green; mutation (reintroduce await-first) fails 3/4 as intended. - tsc --noEmit clean; scripts/failure-class validate ok. Failure-Class: new Co-Authored-By: Claude Opus 4.8 <[email protected]>
baf5d7b to
30fac1f
Compare
|
CI is resolved — 0 failing checks on the rebased head The failure was not this diff. Rather than argue that, I rebased onto current main and let CI answer it, but the diagnosis holds up on the evidence too:
Re-verified on the rebased head: agent suites 6/6 ( Your substantive ask stands and I have not tried to satisfy it from here: the end-to-end check with genuinely expired Claude credentials — no duplicate sign-in prompts across repeated first-send attempts, and a clean ACP re-init after successful OAuth — needs a maintainer on a real desktop build. I called that limitation out in the PR body and it is unchanged. |
|
Correcting my previous comment — I got the diagnosis partly wrong, and the green is weaker than I implied. What I got wrong. I attributed the four timed-out suites to a single contended runner. That is not right for the first one: What I overstated. What still holds — and is now better supported than my original argument: this failure is not caused by this PR. #10492 records that it reproduces on a branch with no product changes at all, so it is a main-side regression, and this PR's 5 files contain no Swift. The rest of my verification stands: agent suites 6/6, I am picking up #10492 separately rather than leaving it as a footnote here. |
|
Thanks for the follow-up and for correcting the CI interpretation. I re-reviewed the current head (
Static review still looks positive to me: the change preserves the needed OAuth kickoff while moving the interactive wait out of the cold-start init path, and the extracted seam covers the important ordering and rejection behavior. I do not see a concrete code change to request from this diff. I’m still not formally approving because this is Claude auth / ACP initialization behavior and the remaining risk is end-to-end desktop UX rather than just TypeScript correctness. Before merge, a maintainer should verify on a real desktop build with expired Claude credentials that repeated first-send/auth-required attempts do not create confusing duplicate sign-in prompts, and that completing OAuth restarts/re-initializes ACP cleanly. by AI on behalf of David — if you need David’s attention urgently, please @Git-on-my-level and escalate with |
What
Closes #10407.
Cold-start ACP
initializeAcp()awaitedstartAuthFlow()when the agent returned-32000(auth required), then retried init. With expired Claude credentials and no OAuth callback, init sat inside that await for the entire callback timeout — and because no turn was on the wire yet, the user's very first send had nothing to terminalize behind it and simply hung until the timeout elapsed.This applies the same terminalize-first contract the active turn already follows (#10417): signal
auth_requiredto Swift, then start — never await — the OAuth flow and return.isInitializedstaysfalse, so the pending send reaches the ACP request, hits the same-32000, and terminalizes asauthenticationthrough the kernel's existing recoverable-error path instead of blocking.The flow is still started, not dropped: Swift
ChatProvider.startClaudeAuthrefuses to open sign-in without the bridge-issuedauthUrlthat only this flow mints, so dropping the call would strand the user in an auth-required state with no way to sign in. The bug was theawait, not the call.Why a shared seam + failure class
index.tscannot be imported under vitest (module scope spawns the ACP subprocess and binds stdin), so its coverage is source-scraping — a static tripwire, not behavior. The kickoff is extracted toacp.tsasbeginProviderAuthWithoutBlocking, a seam with a real injectable boundary, and tested behaviourally.This is the second instance of one root cause — an ACP path awaiting interactive OAuth in-band so nothing can terminalize. The first (#10417) hardened the active-turn path. Per AGENTS.md ("two or more recent fixes share the cause → add a reusable guard surface"), this declares
Failure-Class: newand registersFC-in-band-auth-await-stall(.github/failure-classes/) citing both PRs, withbeginProviderAuthWithoutBlockingas the code-level guard.Test
desktop/macos/agent/tests/acp-init-auth-nonblocking.test.ts(new, mirrors the issue's falsifiable T1):auth_requiredbefore the flow produces anything, so a pending send terminalizes asauthentication.authUrl.Verification evidence
I exercised the extracted seam directly (the real code path init now runs); I did not boot the full macOS app for this change — the behaviour lives entirely in the agent bridge's auth kickoff, covered by the seam above.
Scope
Agent-bridge TypeScript only — no Swift touched. User-facing changelog fragment included.
Failure-Class: new