Skip to content

fix(accounts): launches a WSL host starts itself use the account selected for its distro - #28464

Merged
nwparker merged 5 commits into
mainfrom
nwparker/wsl-e3-host-account-env
Oct 14, 2026
Merged

nwparker merged 5 commits into
mainfrom
nwparker/wsl-e3-host-account-env

Conversation

@nwparker

@nwparker nwparker commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 6 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​434 0 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​434
Prod 16 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​378 $\color{#cf222e}{\Huge{\mathbf{−}}}$​14 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​364

ELI5

When a WSL distro is added as a host (still behind an internal-only gate), the Orca server inside that distro has no account manager of its own. Agents it starts by itself (from the orca CLI, orchestration, automations, chats, and AI commit messages) ran on whatever login the distro happened to have, not the account the user picked in Orca. Now the desktop tells that server which account was picked for the distro, and the server uses it.

What Changed

  • Before: Only launches the desktop sent through itself carried the selected Claude/Codex account. A CLI agent, an orchestration worker, an automation run, a structured chat, a terminal split, a preset/bare command, or an AI commit message on the WSL host used the distro's default login. orca account list inside the host failed with "Account services are not configured on this runtime".
  • After: The desktop pushes the selected account env for the distro to the host's server, when the host comes up and whenever an account selection changes. The server lays it over every terminal it creates (after launch planning, so a bare claude/codex command is still recognised), over terminal splits, over structured chat launches and their child agents, and over AI commit text. What a caller passes explicitly still wins. SSH workspaces on that host are skipped (their shells run on another machine). orca account now says the accounts are managed in the desktop app for that WSL host.
  • Mechanism: a new accounts.setHostLaunchEnv RPC (accounts-admin; refused for phones; refused by any host that has account services of its own, such as the desktop). The payload is the same narrow, validated account env (AgentLaunchAccountEnv: four variables, absolute guest paths) the desktop already sends per launch. The server saves it in its own data folder, so after a server restart a launch that runs before the desktop reconnects keeps the account. A failed push is retried with backoff unless a newer push supersedes it.

Why

The alternative was porting the account services into the server (tracked as D5). That is a large change, and the desktop already prepares these exact homes for its own launches into the distro. Pushing the result once per change reuses that work and covers every launch path from one place. Sending env with each RPC (the existing shim) cannot reach launches that never pass through the desktop.

Wire compatibility: the push is gated on a new capability, accounts.host-launch-env.v1. An older host gets no push, and the existing one-time "account not applied" notice fires when a managed account is selected. Older desktops never send it.

Linked Issue

N/A (maintainer; WSL-via-orcad Track E, step E3, plus the orca account part of E2)

Visual Proof

N/A: no UI change. The behaviour is server-side launch env, covered by unit tests.

Testing

  • pnpm tc; pnpm run check:code-quality:changed; pnpm run verify:rpc-params-catalog

  • New tests: host-account-launch-env.test.ts (precedence, SSH skip, structured env, commit-text env, CLI message, restore/save), wsl-orcad-host-account-push.test.ts (wire validity, older host, unknown host retry, ordering, supersession), orcad-host-account-launch-env-store.test.ts, a split case in orca-runtime-terminal-split-authority.test.ts, and an RPC case in accounts.test.ts.

  • Ran src/main/runtime, src/main/wsl, and the RPC suites locally. One unrelated test, orca-runtime-agent-session-operation.test.ts > shapes the launch…, fails on a clean main checkout on this Mac too.

  • Real-host verification on Windows is pending; this code is dark behind the internal WSL host gate.

  • I manually tested these changes locally

  • Automated tests added/updated, or explained why not below

Review

An adversarial review (two rounds) found the split bypass, the missed child-agent env, the missing retry, the unknown-capability retry, and the SSH-workspace leak. All are fixed here. Remaining, documented in the tracker:

  • A brief window on the first connect, before the push lands, where a host-started launch uses the previous or default account.
  • A distro shell profile that exports its own CODEX_HOME can still override the selected one. This predates this PR and also affects the existing desktop shim.

Agent skill upstream boundary

  • Not applicable, or this change copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Notes

Security: only an owner or paired runtime client can call it, and phones are refused. Values are restricted to four account variables with absolute paths and no .., and the saved file is mode 0600. Cross-platform: the server side runs in Linux distros, and the desktop side runs only where WSL hosts exist. SSH: SSH workspaces are skipped explicitly, and SSH-managed servers never receive a push. Mobile: no change. Compatibility: the push is capability-gated and the field set is additive.

Checklist

  • This PR is small and focused
  • I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
  • Before/after screenshots or videos attached for UI changes, or N/A with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred)

@coderabbitai

coderabbitai Bot commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 6 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used all 10 included reviews currently available.

Learn how review limits work.

Review configuration:

⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: e099f070-ee44-4273-99b9-da09495b69a3
📥 Commits

Reviewing files that changed from the base of the PR and between 8c1cca8 and bb8e858.

⛔ Files ignored due to path filters: 1
  • src/shared/rpc-contract/rpc-params-catalog.generated.ts is excluded by !**/*.generated.*
📒 Files selected for processing: 21
  • src/main/ipc/wsl-host-handlers.ts
  • src/main/orcad/orcad-entry.ts
  • src/main/orcad/orcad-host-account-launch-env-store.test.ts
  • src/main/orcad/orcad-host-account-launch-env-store.ts
  • src/main/orcad/orcad-push-startup.test.ts
  • src/main/runtime/host-account-launch-env.test.ts
  • src/main/runtime/orca-runtime-get-structured-agent-session-create-support.ts
  • src/main/runtime/orca-runtime-get-worktree-ps.ts
  • src/main/runtime/orca-runtime-resolve-worktree-removal-target.ts
  • src/main/runtime/orca-runtime-split-pty-backed-terminal.ts
  • src/main/runtime/orca-runtime-terminal-split-authority.test.ts
  • src/main/runtime/rpc/methods/accounts.test.ts
  • src/main/runtime/rpc/methods/accounts.ts
  • src/main/runtime/runtime-account-controller.ts
  • src/main/runtime/runtime-agent-terminal-startup.ts
  • src/main/runtime/runtime-service-command-surface.ts
  • src/main/wsl/wsl-orcad-account-env.ts
  • src/main/wsl/wsl-orcad-host-account-push.test.ts
  • src/main/wsl/wsl-orcad-host-account-push.ts
  • src/shared/host-account-launch-env.ts
  • src/shared/orcad-runtime-capabilities.ts

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: bc14c306-3035-4bf2-8636-765b026c560e
📥 Commits

Reviewing files that changed from the base of the PR and between 099afc8 and 8c1cca8.

⛔ Files ignored due to path filters: 1
  • src/shared/rpc-contract/rpc-params-catalog.generated.ts is excluded by !**/*.generated.*
📒 Files selected for processing: 20
  • src/main/ipc/wsl-host-handlers.ts
  • src/main/orcad/orcad-entry.ts
  • src/main/orcad/orcad-host-account-launch-env-store.test.ts
  • src/main/orcad/orcad-host-account-launch-env-store.ts
  • src/main/runtime/host-account-launch-env.test.ts
  • src/main/runtime/orca-runtime-get-structured-agent-session-create-support.ts
  • src/main/runtime/orca-runtime-get-worktree-ps.ts
  • src/main/runtime/orca-runtime-resolve-worktree-removal-target.ts
  • src/main/runtime/orca-runtime-split-pty-backed-terminal.ts
  • src/main/runtime/orca-runtime-terminal-split-authority.test.ts
  • src/main/runtime/rpc/methods/accounts.test.ts
  • src/main/runtime/rpc/methods/accounts.ts
  • src/main/runtime/runtime-account-controller.ts
  • src/main/runtime/runtime-agent-terminal-startup.ts
  • src/main/runtime/runtime-service-command-surface.ts
  • src/main/wsl/wsl-orcad-account-env.ts
  • src/main/wsl/wsl-orcad-host-account-push.test.ts
  • src/main/wsl/wsl-orcad-host-account-push.ts
  • src/shared/host-account-launch-env.ts
  • src/shared/orcad-runtime-capabilities.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 1 remain after this review.

📝 Walkthrough

The change adds a shared host account launch-environment schema and a runtime RPC for receiving those environments. Orcad persists and restores the selected environment. Runtime launch paths apply it to local terminals, structured-agent launches, and commit-message agent environments. WSL host handlers prepare and push Claude and terminal environments to ready hosts that support the capability.

Priority: ⬇️ Low

Merge Risk: 🔵 Low · up to 8c1cc

This change applies the selected account to agents launched by a WSL host. It is gated internally, and no concrete defect was found. Real Windows host verification is still pending, so confirm it before wider rollout.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 20.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 25 functions across 20 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Title check Passed The title identifies the main change: applying the account selected for a WSL distro to launches started by the WSL host. The wording is grammatically awkward, but the scope is clear.
Description check Passed The description follows the required template and explains the user impact, implementation, rationale, compatibility, security, testing, limitations, and checklist status. The maintainer correctly mar…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
✨ 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.

…ount

The desktop now pushes the account env it selected for a WSL host's distro
to that host's orcad (accounts.setHostLaunchEnv, capability-gated). orcad
lays it over every terminal create (CLI, orchestration, automations, bare
commands and presets), structured chats and AI commit text, as the
desktop's own launches into the distro do. `orca account` on the host now
points at the desktop that owns the accounts.
…spaces

Review follow-ups: terminal splits and structured chats' child agents take
the host account env too; an SSH workspace's terminals never get distro
paths; orcad saves the pushed env so a launch before the desktop reconnects
keeps the account; a failed push retries unless a newer one supersedes it.
@nwparker
nwparker force-pushed the nwparker/wsl-e3-host-account-env branch from 8c1cca8 to bb8e858 Compare October 14, 2026 00:46
@nwparker
nwparker merged commit 31e5003 into main Oct 14, 2026
56 checks passed
Jinwoo-H added a commit that referenced this pull request Oct 14, 2026
…28530)

Fixes main's lint: #28464 left orcad-entry.ts at 301 lines (max 300). No behaviour change.
@nwparker nwparker mentioned this pull request Oct 14, 2026
6 tasks done
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.

1 participant