Skip to content

feat(accounts): add Claude and Codex accounts on a remote server from a paired client - #31461

Merged
nwparker merged 13 commits into
mainfrom
nwparker/remote-add-account
Oct 21, 2026
Merged

nwparker merged 13 commits into
mainfrom
nwparker/remote-add-account

Conversation

@nwparker

@nwparker nwparker commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 12 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​921 $\color{#cf222e}{\Huge{\mathbf{−}}}$​10 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​911
Prod 26 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​1311 $\color{#cf222e}{\Huge{\mathbf{−}}}$​53 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​1258

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

  • Before: with the default runtime (or the Settings host picker) set to a remote server, Add Account was disabled for both Claude and Codex. The note under it only said "add or re-authenticate accounts on that server", without saying how.
  • After: Add Account starts a sign-in on the server. A panel under the button shows:
    • Codex: the OpenAI device page (Open / Copy link) and the one-time code (Copy code). Once you finish on that page, the account shows up in the server's list.
    • Claude: the Claude sign-in page (Open / Copy link) and a box for the code the page shows after you sign in. The code goes to the server, which finishes the login.
    • Cancel stops the login on the server.

How it works:

  • The server runs the same CLI logins orca account add already uses: claude auth login --claudeai and codex 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.
  • The server reuses its existing account registration: Claude's per-account folder sign-in, and Codex's managed-home add. The credentials never leave the server. The client only sees the page address and the Codex code, and only sends the pasted Claude code.
  • There are four new RPC methods: accounts.hostSignInStart, accounts.hostSignInWait (a long poll, at most 20 seconds per call), accounts.hostSignInSubmitCode and accounts.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.
  • The capability accounts.host-sign-in.v1 controls who uses this. A client talking to an older server gets "update Orca on that server, or run orca account add there" instead of a request the server doesn't know. Older clients never call the new methods.
  • Windows servers refuse for now. Their claude/codex logins run in a console window of their own, so their input and output can't be piped. Those users get the orca account add guidance.
  • "Copy sign-in link instead" is hidden in remote scope, because that link calls back to localhost on the server.

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 --claudeai printed 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 real codex login --device-auth printed 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

  • Codex and independent Opus reviews ran several rounds. The final Codex review on the head found no issues. Fixed from their findings:
    • each flow is pinned to the pairing it started on
    • a cancel the login refused (it had already signed in) now reports the added account
    • Claude's stdin can no longer crash the server with EPIPE
    • only the provider's own sign-in hosts are accepted, on both sides
    • pasted codes may not contain spaces
    • a sign-in stopped by an account change on the server says so
    • Codex cancels its own login, not whichever login is current
    • Claude's link is read from stdout only
    • after review round 3, the client was rebuilt as one explicit state machine per server and provider (checking → starting → following → settled). A Cancel is a flag that the loop delivers once the server names its flow, and asks again until the server takes it. A second Add joins the running sign-in. The server sign-in's Cancel sits in its own prompt, so it always targets that server, and it reappears if Settings is reopened mid-sign-in. The header Cancel stops whichever login that Add started, even after the host picker moves. Only lost answers are retried, and only within the server's 90-second window.
  • Design check: this follows the usual shape for remote sign-in. The process and the tokens stay on the machine that uses them. Sign-in flows that call back to localhost (which would land on the wrong machine) are not offered. The client only opens the page and shows or relays a code. The approach did not change; only the client bookkeeping was simplified.
  • The local orcad terminal smoke fails on this Mac at the file-watcher step, an environment problem unrelated to accounts, so CI covers it. The Node 18 process-host smoke needs a Node 18 runtime, and this package is unchanged. Every other step of the static job passes locally.
  • Known follow-ups:
    • Cancel does not abort a long-poll Wait already in flight. The cancel reaches the server right away, so the only cost is waiting up to 20 seconds for that poll to return.
    • A re-pair during a sign-in is refused by the pairing pin rather than joined.
    • In one edge case (a local Add running while Settings shows a server that still has an earlier sign-in from before Settings reopened), two Cancel buttons appear with the same label. The header one stops the local login and the prompt one stops the server's. Both are correct, but the labels don't say which is which.
    • The header Cancel reads which login it should stop without subscribing to changes. It is only read while an add is running, and the pane re-renders whenever that changes, so the value is not stale in practice.
    • This client runs one server sign-in per provider at a time. A second server is told to finish or cancel the first.
    • Re-authenticating an existing account from a remote client, Windows servers, and WSL-distro account locations on a remote server are not covered yet.

Agent skill upstream boundary

  • Not applicable

Notes

  • Security: the server only publishes https links to the provider's sign-in hosts, and the client opens only https links. Pasted codes are never logged. Error text has terminal escape codes removed and is capped at 600 characters.
  • SSH/remote: everything runs on the server that owns the accounts. Mixed versions are covered by the capability check. Mobile is unchanged.

Checklist

  • I explained what changed and why
  • Before/after screenshots: not attached (see above)
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered

… 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.
@coderabbitai

coderabbitai Bot commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

📝 Walkthrough

The change adds remote-host account sign-in for Claude and Codex. Host-side flows accept Claude pasted codes or Codex device codes. RPC operations start, monitor, update, and cancel these flows. The renderer starts host sign-in, displays prompts and status, submits codes, and handles cancellation. Tests cover provider login, flow management, RPC access, retry behavior, and renderer behavior.

Priority: ➖ Normal

Merge Risk: 🔵 Low · up to 4fe8d

If the server is re-paired during sign-in, Cancel may appear to do nothing. This is a bounded issue, but cancellation failures should be shown to the user.

Pre-merge checks: Passed 3 · Failed 2

Failed Failed checks: 2 warnings

Check name Status Explanation Resolution
Description check Warning The description is detailed and covers the user impact, implementation, rationale, issue, testing, security, compatibility, and known limitations. However, the template requires visual proof for UI ch… Attach before-and-after screenshots or a video of the remote account sign-in UI, then mark the visual-proof checklist item as complete. If visual proof cannot be provided, document an approved exception explicitly.
Docstring Coverage Warning Docstring coverage is 41.86% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 43 functions across 31 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 3 passed
Check name Status Explanation
Title check Passed The title clearly and concisely describes the primary change: enabling Claude and Codex account sign-in on a remote server from a paired client.
Linked Issues check Passed The changes satisfy the coding requirements in [#20009]. Remote Claude and Codex Add Account buttons are enabled. The client starts capability-gated server sign-in flows through the new RPC methods. T…
Out of Scope Changes check Passed The changes remain within [#20009]. The RPC methods, capability, provider adapters, account-service changes, client state handling, renderer prompt, localization, cancellation tracking, security valid…
Full details: Linked Issues check

Explanation

The changes satisfy the coding requirements in [#20009]. Remote Claude and Codex Add Account buttons are enabled. The client starts capability-gated server sign-in flows through the new RPC methods. The server runs the provider CLIs, returns the sign-in link and Codex code, accepts the Claude code, and preserves server-side account registration. Ownership, cancellation, timeout, host validation, failure handling, and Windows refusal are covered by tests. The client also reports unsupported or failed flows instead of doing nothing.

Full details: Out of Scope Changes check

Explanation

The changes remain within [#20009]. The RPC methods, capability, provider adapters, account-service changes, client state handling, renderer prompt, localization, cancellation tracking, security validation, compatibility handling, and tests all support remote Claude and Codex account sign-in. The changes do not establish unrelated product behavior or unrelated feature work.

Full details: Description check

Explanation

The description is detailed and covers the user impact, implementation, rationale, issue, testing, security, compatibility, and known limitations. However, the template requires visual proof for UI changes, and the description provides no before-and-after screenshots or video. The related checklist item is also left unchecked.

Resolution

Attach before-and-after screenshots or a video of the remote account sign-in UI, then mark the visual-proof checklist item as complete. If visual proof cannot be provided, document an approved exception explicitly.

✨ Finishing Touches: 💡 1
📝 Generate docstrings: 💡
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

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.
…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.
…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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: b3c98c4a-ebe9-4d05-9c8a-bfa6a54963db
📥 Commits

Reviewing files that changed from the base of the PR and between 0723356 and 4fe8dd7.

📒 Files selected for processing: 5
  • src/renderer/src/components/settings/HostAccountSignInPrompt.tsx
  • src/renderer/src/components/settings/account-add-cancel-target.test.ts
  • src/renderer/src/components/settings/account-add-cancel-target.ts
  • src/renderer/src/components/settings/accounts-pane-claude-section.tsx
  • src/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.

Comment on lines +33 to +43
/** 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) }
)
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 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.ts

Repository: 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 1

Repository: 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.ts

Repository: 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/shared

Repository: 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 260

Repository: 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 1

Repository: 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 240

Repository: 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
   }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: 'Add account' button does nothing when default runtime is a remote server

1 participant