Repository navigation
feat(accounts): add Claude and Codex accounts on a remote server from a paired client - #31461
Conversation
… a paired client The server runs the login (Claude's pasted-code sign-in, Codex's device code) and keeps the credentials; the client only opens the page and relays the code. New capability-negotiated accounts.hostSignIn* methods; older servers degrade to an update message. Fixes #20009
…ng, guard stdin Review fixes: a cancel the login refused still reports the added account; the client pins each flow to its pairing revision; Claude's stdin EPIPE no longer crashes the host; both sides accept only the provider's sign-in host; pasted codes reject whitespace; a host-side supersede says so; Codex cancels its own login handle; opt-in real-CLI test.
…indow, scan Claude stdout only A Cancel clicked before the host answers the start is applied once it does; the client keeps polling through a short outage until the host would have ended the flow; Claude's link is read from stdout only; a timeout after the code was sent keeps its own message.
…he persistence ratchet
📝 Walkthrough
Priority: ➖ Normal Merge Risk: 🔵 Low · up to
|
One attempt per click owns the pairing pin, the cancel flag and the host's flow, so a Cancel during the capability check or the start is never lost; polls retry only lost answers; the stdout forwarder is removed on cleanup.
…chine per server and provider checking -> starting -> following -> settled, with Cancel as a flag the run loop delivers once the host names its flow and re-asks after any answer until the host takes it. A second Add joins the running attempt; a Cancel the server could not be told about is surfaced; retry policy tested.
…-in as cancelled however it ends
…ed code stays with its flow The host picker can move while a sign-in runs: Cancel now targets the running server sign-in (or the desktop's own login when none runs), and the pasted-code form is keyed by server and flow.
Cancel for a server sign-in now lives in the prompt bound to that server, which also reappears with its Cancel when Settings reopens mid-sign-in; the header Cancel is only for this desktop's own login.
…uns; narrow the prompt's status
…e a server sign-in runs
…er Settings now points Each Add Account records where it is signing in. Cancel stops that sign-in, on a server or this desktop, and is hidden only where that server's own prompt already offers Cancel.
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
- Configuration used: Repository UI
- Review profile: CHILL
- Plan: Advanced
- Run ID:
b3c98c4a-ebe9-4d05-9c8a-bfa6a54963db
📒 Files selected for processing: 5
src/renderer/src/components/settings/HostAccountSignInPrompt.tsxsrc/renderer/src/components/settings/account-add-cancel-target.test.tssrc/renderer/src/components/settings/account-add-cancel-target.tssrc/renderer/src/components/settings/accounts-pane-claude-section.tsxsrc/renderer/src/components/settings/accounts-pane-codex-section.tsx
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 4 remain after this review.
| /** A Cancel the server could not be told about yet; the sign-in keeps asking it to stop. */ | ||
| export function showHostCancelFailure(error: unknown): void { | ||
| // Why only lost answers: a refusal means the flow already ended, which the pane shows itself. | ||
| if (!isLostHostAnswer(error)) { | ||
| return | ||
| } | ||
| toast.error( | ||
| translate('accounts.hostSignIn.cancelFailed', 'Could not reach the server to cancel yet.'), | ||
| { description: error instanceof Error ? error.message : String(error) } | ||
| ) | ||
| } |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
sed -n '1,100p' src/renderer/src/components/settings/account-add-cancel-target.ts
rg -n -C 5 'showHostCancelFailure|deliverCancel|cancelHostAccountSignIn|cancelHostSignIn' src/renderer/src/runtime/runtime-host-account-sign-in-client.ts src/renderer/src/components/settings/HostAccountSignInPrompt.tsx src/main/runtime/rpc/methods/accounts.ts src/main/runtime/host-account-sign-in-flows.tsRepository: stablyai/orca
Length of output: 10212
🏁 Script executed:
set -e
printf '%s\n' '--- renderer client imports, call, error classification, and cancellation flow ---'
sed -n '1,180p' src/renderer/src/runtime/runtime-host-account-sign-in-client.ts
sed -n '180,330p' src/renderer/src/runtime/runtime-host-account-sign-in-client.ts
printf '%s\n' '--- server RPC and flow definitions ---'
rg -n -C 8 -F -- 'hostSignInCancel' src/main src/shared || test "$?" -eq 1
rg -n -C 8 -F -- 'cancelHostAccountSignIn' src/main src/shared || test "$?" -eq 1
rg -n -C 8 -e 'cancel.*SignIn|SignIn.*cancel|cancel.*flow' src/main/runtime src/main/claude-accounts src/main/codex-accounts src/shared || test "$?" -eq 1
printf '%s\n' '--- relevant tests ---'
rg -n -C 6 -e 'hostSignInCancel|cancelHostAccountSignIn|isLostHostAnswer|cancel.*ownership|ownership.*cancel' src --glob '*test*' || test "$?" -eq 1Repository: stablyai/orca
Length of output: 42308
🏁 Script executed:
set -e
printf '%s\n' '--- host sign-in flow implementation ---'
sed -n '1,280p' src/main/runtime/host-account-sign-in-flows.ts
printf '%s\n' '--- host sign-in flow tests ---'
sed -n '1,190p' src/main/runtime/host-account-sign-in-flows.test.ts
printf '%s\n' '--- RPC owner binding and surrounding account methods ---'
sed -n '1,270p' src/main/runtime/rpc/methods/accounts.ts
printf '%s\n' '--- renderer cancellation tests exact block ---'
sed -n '70,165p' src/renderer/src/runtime/runtime-host-account-sign-in-client.test.tsRepository: stablyai/orca
Length of output: 30042
🏁 Script executed:
set -e
printf '%s\n' '--- cancellation implementation ---'
nl -ba src/main/runtime/host-account-sign-in-flows.ts | sed -n '130,215p'
printf '%s\n' '--- ownership and lifecycle helpers ---'
nl -ba src/main/runtime/host-account-sign-in-flows.ts | sed -n '1,145p'
printf '%s\n' '--- pairing revision and RPC error classification ---'
rg -n -C 8 -e 'expectedEnvironmentPairingRevision|pairingRevision|Remote runtime unavailable|classifyTerminalProcessInspectionFailure' src/renderer/src/runtime src/main/runtime src/sharedRepository: stablyai/orca
Length of output: 45665
🏁 Script executed:
set -e
printf '%s\n' '--- caller identity ---'
rg -n -C 12 -F -- 'function rpcCallerOperationKey' src/main src/shared src/renderer || test "$?" -eq 1
rg -n -C 8 -F -- 'rpcCallerOperationKey(' src/main src/shared src/renderer || test "$?" -eq 1
printf '%s\n' '--- expected pairing revision guard ---'
rg -n -C 12 -F -- 'expectedEnvironmentPairingRevision' src/main src/renderer/src/runtime --glob '*.ts' || test "$?" -eq 1
printf '%s\n' '--- RPC caller type and connection lifecycle ---'
rg -n -C 8 -e 'caller:|connectionId|pairingRevision' src/main/runtime/rpc src/main/runtime --glob '*.ts' | head -n 260Repository: stablyai/orca
Length of output: 45667
🏁 Script executed:
set -e
printf '%s\n' '--- runtime RPC client pairing guard ---'
rg -n -C 10 --glob '*.ts' -- 'expectedEnvironmentPairingRevision|pairing revision|pairing_revision|re-pair|repaired' src/renderer/src/runtime/runtime-rpc-client.ts src/renderer/src/runtime/runtime-rpc-client-pairing-revision.test.ts src/main/runtime src/shared/runtime-environments.ts || test "$?" -eq 1
printf '%s\n' '--- terminal failure classifier ---'
rg -n -C 12 --glob '*.ts' -- 'function classifyTerminalProcessInspectionFailure|classifyTerminalProcessInspectionFailure' src/renderer/src src/shared || test "$?" -eq 1Repository: stablyai/orca
Length of output: 42816
🏁 Script executed:
set -e
printf '%s\n' '--- runtime RPC pairing call helper ---'
nl -ba src/renderer/src/runtime/runtime-rpc-client.ts | sed -n '1,190p'
printf '%s\n' '--- pairing revision test complete ---'
nl -ba src/renderer/src/runtime/runtime-rpc-client-pairing-revision.test.ts | sed -n '1,150p'
printf '%s\n' '--- runtime environment bridge revision guard ---'
rg -n -C 12 --glob '*.ts' -- 'callRuntimeEnvironmentWithRevision|The server connection was reset|unavailable\(' src/renderer/src/runtime src/main | head -n 240Repository: stablyai/orca
Length of output: 33884
Show feedback when pairing invalidates an active cancellation.
If the server is re-paired during sign-in, the captured pairing revision becomes stale. The cancellation request then rejects with “Runtime environment pairing changed,” while the old server flow can remain active until its 90-second silence timeout. showHostCancelFailure suppresses this non-transport error, so the user gets no cancellation feedback.
Keep suppression only for the explicit inactive-flow response.
Suggested fix
import {
- cancelHostAccountSignIn,
- isLostHostAnswer
+ cancelHostAccountSignIn
} from '@/runtime/runtime-host-account-sign-in-client'
@@
export function showHostCancelFailure(error: unknown): void {
- // Why only lost answers: a refusal means the flow already ended, which the pane shows itself.
- if (!isLostHostAnswer(error)) {
+ // The host retains the final status for an inactive flow. Other refusals,
+ // including a stale pairing, can leave the remote flow active.
+ if (error instanceof Error && error.message === 'This sign-in is no longer active in this client.') {
return
}
ELI5
If your Orca app is connected to a remote Orca server, the Claude and Codex Add Account buttons were greyed out. The only way to add an account was to open a terminal on the server and run
orca account add. Now the button works: the server runs the sign-in, and this device just opens the sign-in page. For Codex you type in the one-time code it shows. For Claude you paste back the code the page shows after you sign in.What Changed
How it works:
orca account addalready uses:claude auth login --claudeaiandcodex login --device-auth. Their output and stdin are piped instead of attached to a terminal. The link (and for Codex, the code) is read from a captured transcript of each CLI's output. A link or code that comes from anywhere other than the provider's own sign-in host is ignored.accounts.hostSignInStart,accounts.hostSignInWait(a long poll, at most 20 seconds per call),accounts.hostSignInSubmitCodeandaccounts.hostSignInCancel. A sign-in belongs to the paired device that started it: no other client can read it, answer it or cancel it. The server runs one at a time. If the client stops polling for 90 seconds (it closed, slept or lost its connection), the server ends the sign-in so the server's account queue isn't left waiting on it.accounts.host-sign-in.v1controls who uses this. A client talking to an older server gets "update Orca on that server, or runorca account addthere" instead of a request the server doesn't know. Older clients never call the new methods.claude/codexlogins run in a console window of their own, so their input and output can't be piped. Those users get theorca account addguidance.Why
The login has to run on the server: that is where the account folder and the credentials live, which is why the add methods only accepted the server's own callers. But nothing requires the person to be at the server. Both CLIs already support a sign-in finished on another device: Claude's pasted-code link and Codex's device code. So the server runs the process, and the client shows the link and passes the code back. tobolik proposed this design in the issue. It follows the pattern Orca already uses for Antigravity chat sign-in (start, cancel and complete, tied to the caller), but uses a long poll instead of a stream, which keeps the client simpler.
Alternatives considered:
Linked Issue
Fixes #20009
Thanks to @LucasOliveira-dev2026 for the report and the server-side diagnosis. Thanks to @shaggydo0 and @tobolik for the diagnostics and the device/paste-code design, and to @denis-sj for #20043, whose guidance approach this replaces.
Visual Proof
Not attached. The flow needs a paired remote server, and this is noted in Testing.
Testing
New unit tests (they fail on main, where the methods don't exist and the remote-scope buttons are disabled):
src/main/runtime/host-account-sign-in-flows.test.ts: passing the link and code, owner isolation, cancel, failure messages, the silence watchdog, the Windows refusal.src/main/claude-accounts/claude-pasted-code-login.test.ts: parsing a captured Claude 2.1.306 transcript, writing to stdin, the message for a refused code, cancel.src/main/codex-accounts/codex-device-auth-prompt.test.ts: parsing a captured codex-cli 0.163.0 transcript.src/main/codex-accounts/service-device-code-login.test.ts: the service adds an account through--device-auth.src/main/runtime/rpc/methods/accounts.test.ts: a paired device's flow through the RPC methods, and a second device being refused.src/renderer/src/components/settings/AccountsPane.test.tsx: both remote-scope Add Account buttons are enabled.src/renderer/src/runtime/runtime-host-account-sign-in-client.test.ts: pairing pin, a Cancel at every stage, joining a running sign-in, a cancel that is asked again, and the retry policy (with fake timers).src/main/claude-accounts/claude-command-process.test.ts: EPIPE on stdin.New opt-in real-CLI test
src/main/claude-accounts/host-sign-in-real-cli.test.ts(ORCA_REAL_CLAUDE_CLI_TEST=1/ORCA_REAL_CODEX_CLI_TEST=1): it ran on the final head (4fe8dd7) locally on macOS against Claude Code 2.1.306 and codex-cli 0.163.0, and both cases passed (Claude: link published, bogus code refused with exit 1; Codex: device page and code parsed, cancel stopped the process).Verified live (macOS, real CLIs, throwaway config folders): the real
claude auth login --claudeaiprinted its pasted-code link, which the new code picked up. A bogus code written to its stdin was refused with the new message (Claude prints the link on stdout, does not re-prompt, and exits 1). The realcodex login --device-authprinted the device page and code, which were parsed, and Cancel killed the process. No processes or folders were left behind.Only in tests: the RPC round trip between a paired client and a real
orca serve, the renderer panel, and finishing a real sign-in with a real account (that needs a human to sign in).I manually tested these changes locally
Automated tests added/updated
Review
Agent skill upstream boundary
Notes
httpslinks to the provider's sign-in hosts, and the client opens onlyhttpslinks. Pasted codes are never logged. Error text has terminal escape codes removed and is capped at 600 characters.Checklist