Skip to content

feat(wsl): account env for agent tabs on a WSL orcad host (WSL-via-orcad C9b) - #27940

Merged
nwparker merged 3 commits into
mainfrom
nwparker/wsl-c9b-agent-tab-accounts
Oct 13, 2026
Merged

nwparker merged 3 commits into
mainfrom
nwparker/wsl-c9b-agent-tab-accounts

Conversation

@nwparker

@nwparker nwparker commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 7 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​395 $\color{#cf222e}{\Huge{\mathbf{−}}}$​2 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​393
Prod 21 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​277 $\color{#cf222e}{\Huge{\mathbf{−}}}$​18 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​259

Stacked on #27874 (C9, accounts shim). Do not merge.

ELI5

When Orca runs agents inside a WSL distro through that distro's own Orca server (orcad), the desktop app has to tell the server which Claude or Codex account to use. #27874 did that for some kinds of launch, but not for the one the app actually uses when you open a new agent tab, or when it wakes a sleeping agent. Those still ran under the distro's default account. This change covers them. If the distro's server is too old to accept the account, the agent still starts as before, and Orca shows a short note saying so instead of silently using the wrong account.

What Changed

  • Before: a new agent tab, or a restored or sleeping agent, on a WSL orcad host ran the distro's default Claude/Codex account even when a managed account was selected. After: it runs the selected account on a host that supports it. On an older host it runs the default account as before, and the desktop shows a one-time, non-blocking toast per distro: "Account selection not applied in <distro>".
  • Host side. terminal.createAgentSession and an explicit terminal.ensureAgentSession (new tabs, restores, sleeping agents waking one by one) accept an optional accountEnv. It uses the same validator as C9's agent.launch.accountEnv: only the four account variables, absolute guest paths, no .. or control characters. The host lays it over the agent's own launch env (withAgentSessionAccountEnv). Hosts advertise this with the new capability agent-session.account-env.v1, listed with the other agent-session create capabilities. The automatic ensure kind stays refused by hosts, so it gets no field.
  • Desktop shim (wsl-orcad-account-env.ts). The one runtimeEnvironments:call handler adds accountEnv to those two methods only when the WSL orcad advertises the capability. It learns the capabilities from any status.get answer that passes through the desktop. If it has seen none, it asks the host once. A redeploy or reconnect clears what it learned (wsl-orcad-host-environments.ts). The capability check runs before any account preparation, so an older host costs no account setup.
    • Capability absent, with a managed account selected for that distro: the call is sent unchanged and main broadcasts the toast at most once per distro per run.
    • A failed probe counts as unknown: the call is sent unchanged with no toast, because a failed probe says nothing about the host's version.
  • Notice UI. A main → renderer event (runtimeEnvironments:wslAccountNotApplied) feeds toast.info with a stable id, following the existing Codex notice toasts. It is optional on the preload API, so the web client, which has no desktop shim, doesn't implement it. Strings are added to all six locales.

Why

Both methods are strict schemas, so sending an unknown field to an older host makes it reject the whole call, and the user would get no agent at all. A capability the host advertises is the repo's standard fix for this (as with agentSession.create.tab-id.v1). The shim stays in the main-process handler C9 already uses, so the renderer and its four create paths, SSH, and every non-WSL host are unchanged.

I considered and rejected two alternatives:

  • Probing capabilities in the renderer: it would duplicate the shim's ownership of WSL account decisions.
  • Falling back to terminal.create with env on older hosts: it gives up the host-authority create and its replay protection.

Wire compatibility

Client Host Result
New desktop New host (advertises agent-session.account-env.v1) accountEnv sent and applied (real host)
New desktop Older host (no capability) Field never sent; the call parses as today; default account; one-time toast (real host)
Older desktop, mobile, web, CLI New host No field sent; the new optional field parses identically (tested)
Any client Host where the capability probe fails Treated as unknown: no field, no toast
  • Replay and dedupe: accountEnv is outside both createAgentSession fingerprints (request and resolved) and the derived execution operation id. A retry carrying a different env replays instead of conflicting (tested). Ensure claims key on provider-session identity only.
  • Mobile, web and CLI: they reach hosts directly, never through the desktop shim, so they never send the field. Mobile's allowlist still covers both methods, and a new host accepts their payloads unchanged.
  • Published content: only the capability list grows. No new opcodes.

Linked Issue

Internal WSL-via-orcad tracker, step C9b.

Visual Proof

N/A for screenshots: the only UI is a stock toast.info from the existing toaster, with no new layout. Its title, id and non-blocking behaviour are covered by a unit test. C7 adds the WSL host surface where it can be seen end to end.

Testing

  • I manually tested these changes locally
  • Automated tests added/updated, or explained why not below

Real host (win-lowspec, Windows 11, WSL 2.7.10, installed Orca 1.4.205 run as Node). I used a throwaway Ubuntu 24.04 distro, orca-c9b-probe, with [boot] systemd=false placed before its first boot (PID 1 was init) and a user u. The fake claude and codex binaries print their env. The harness was bundled from this branch: WslOrcadConnectionManager.ensure, then the real withWslOrcadAccountEnv with wslOrcadHostSupports against live status.get, and stand-in account services that answer like the WSL routers. For the new host, I overlaid this branch's pnpm build:orcad JS onto the daily orcad template, with the manifest re-hashed. All files reached the host only as base64 chunks typed into an Orca terminal (sha256 verified).

Host Capability Sent Agent saw
Branch orcad 0.1.0+dd16abe15cea, createAgentSession claude advertised 4 account vars CLAUDE_CONFIG_DIR=/home/u/.c9b-accounts/claude-a/config, injected marker equal, pointer, CODEX_HOME=/home/u/.c9b-accounts/codex-b
Branch orcad, ensureAgentSession codex resume (automatic-restore) advertised pointer + CODEX_HOME pane env: pointer + CODEX_HOME=/home/u/.c9b-accounts/codex-b
Daily orcad 0.1.0+7d2c134906c4, both methods absent nothing defaults (none); both calls succeeded; notice raised

Two things to know about the real-host run:

  • The Claude routing only applies once the pointer file names the account. With no pointer file, Orca's claude shell function correctly treats the selection as System default. The harness writes the pointer, as the WSL router's setup does.
  • In the resume pane, the fake codex hung on the shell function's codex --help probe, so I read the pane's env directly.

Cleanup:

  • I killed the holder, then terminated and unregistered the distro.
  • I removed %TEMP%\orca-c9b-* and closed the terminal.
  • wsl -l -v matches the starting state, apart from another agent's probe distro, which I left alone.
  • No orca-c9b- processes are left.

Automated:

  • agent-session-params-account-env.test.ts: new and old payloads for both methods; strictness, which is why the capability is needed; five refused shapes; the capability is advertised; an automatic ensure is refused.
  • orca-runtime-agent-session-account-env.test.ts: the env is laid over the launch env on create and on a restore ensure; outside the fingerprint (replay, not conflict); unchanged with no field.
  • wsl-orcad-account-env.test.ts: capability-gated attach; an older host gets no field and a notice; no notice without a managed account; unknown means no field and no notice; an automatic ensure and other environments are never probed.
  • wsl-orcad-host-environments.test.ts: the probe runs once, observed status.get answers, reset on reconnect, failures are unknown, and non-WSL environments are ignored.
  • wsl-orcad-account-env-wiring.test.ts: one notice per distro, case-insensitive.
  • wsl-account-notice-ipc-bridge.test.ts: the toast, and a client without the event is skipped.

Suites and gates:

  • Test suites: runtime, wsl, claude-accounts, codex-accounts, agent-launch, ipc, shared, terminal-pane, renderer runtime, ipc-events and startup ran 38,375 tests. Two failures remain, and both reproduce without this change:
    • preflight-agent-detection "does not double-count…" also fails on the C9 base.
    • preflight-runnable-local-cli timed out under load and passes alone.
  • Passing:
    • pnpm tc and oxlint
    • check:code-quality:changed and check:react-doctor:changed
    • reliability-gates, dead-classes and zustand-selector-fanout
    • the max-lines, ts-nocheck, runtime-electron, focus-read and layout-writer ratchets
    • node-runtime-pin and verify:rpc-params-catalog
    • the process-host and compat-boundary import checks
    • the localization catalogs, extraction and coverage checks
    • pnpm format
  • Cross-version-wire: these fail in this worktree only because the release tags are missing (git rev-parse v1.4.224), not because of this change.

AI Disclosure

Review

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: the same narrow validator as agent.launch.accountEnv, and only for terminal agents. Structured sessions remain on the host default (C9 decision 3).
  • SSH and folder workspaces: unaffected. Only environments the WSL connection manager registered are patched or probed.
  • Mobile and web: unaffected (see the table). The preload event is optional, and the web client omits it.
  • Performance: at most one extra status.get per WSL connection, and only when the renderer has not already fetched one.

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)

@nwparker
nwparker force-pushed the nwparker/wsl-c9-accounts-shim branch from db082c5 to 03a2bce Compare October 12, 2026 10:39
@nwparker
nwparker force-pushed the nwparker/wsl-c9b-agent-tab-accounts branch from 973166a to bd305fe Compare October 12, 2026 10:39
@nwparker
nwparker force-pushed the nwparker/wsl-c9-accounts-shim branch from 03a2bce to 3f9b83d Compare October 12, 2026 10:45
@nwparker
nwparker force-pushed the nwparker/wsl-c9b-agent-tab-accounts branch from bd305fe to 35e7639 Compare October 12, 2026 10:45
@nwparker
nwparker force-pushed the nwparker/wsl-c9b-agent-tab-accounts branch 2 times, most recently from 0727e51 to 375e4b5 Compare October 12, 2026 12:00
@nwparker
nwparker force-pushed the nwparker/wsl-c9-accounts-shim branch from 273707d to 5817b05 Compare October 12, 2026 12:00
@nwparker
nwparker force-pushed the nwparker/wsl-c9b-agent-tab-accounts branch from 375e4b5 to ce642f1 Compare October 12, 2026 16:25
@nwparker
nwparker force-pushed the nwparker/wsl-c9-accounts-shim branch from 3f949b6 to 93113ed Compare October 13, 2026 14:09
…cad C9b)

terminal.createAgentSession and an explicit terminal.ensureAgentSession (new
agent tabs, restored and sleeping agents) accept an optional accountEnv, gated
by the new agent-session.account-env.v1 capability because both schemas are
strict. The desktop shim attaches it only for an advertising WSL orcad, reading
its capabilities from status.get; an older host keeps its default account and
the desktop shows a one-time notice per distro. accountEnv stays outside the
create replay fingerprint.
@nwparker
nwparker changed the base branch from nwparker/wsl-c9-accounts-shim to main October 13, 2026 14:27
@nwparker
nwparker marked this pull request as ready for review October 13, 2026 14:27
@nwparker
nwparker force-pushed the nwparker/wsl-c9b-agent-tab-accounts branch 2 times, most recently from ce642f1 to ad8c85d Compare October 13, 2026 14:27
@coderabbitai

coderabbitai Bot commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

📝 Walkthrough

The change adds an optional account environment to agent-session creation and explicit resumption requests. WSL Orcad capability checks determine whether that environment is applied. If a selected managed account cannot be applied because the host does not support the capability, the main process sends a distro-specific notice through IPC. The renderer displays the notice with localized text. Tests cover request validation, capability checks, environment merging, and notice delivery.

Priority: ➖ Normal

Merge Risk: 🔵 Low · up to ad8c8

An informational notice about WSL account selection not being applied could be missed in rare cases, such as when the window closes at the wrong moment. Agent sessions still run with default accounts, so this is a small follow-up rather than a merge blocker.

Pre-merge checks · Passed 4 · Failed 1

Failed Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 35.71% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 28 functions across 22 files. (6 skipped:… Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks (4 passed)
Check name Status Explanation
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.
Title check Passed The title clearly identifies the main change: adding account environment support for agent tabs on WSL Orcad hosts.
Description check Passed The description is detailed and covers the user impact, implementation, rationale, compatibility, testing, visual proof, and checklist. It documents the two baseline test failures and the missing rele…
Full details: Docstring Coverage

Explanation

Docstring coverage is 35.71% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 28 functions across 22 files. (6 skipped: 6 unsupported.)

  • Fix all pre-merge checks with AI
✨ 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.

@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: b96c33a3-5a61-451f-90ed-90adabd69622
📥 Commits

Reviewing files that changed from the base of the PR and between 41e6ea5 and ad8c85d.

📒 Files selected for processing (28)
  • src/main/ipc/runtime-environment-connectivity-handlers.ts
  • src/main/runtime/agent-session-account-env.ts
  • src/main/runtime/orca-runtime-agent-session-account-env.test.ts
  • src/main/runtime/orca-runtime-create-agent-session.ts
  • src/main/runtime/orca-runtime-get-agent-session-execution-namespace.ts
  • src/main/startup/wsl-orcad-account-env-wiring.test.ts
  • src/main/startup/wsl-orcad-account-env-wiring.ts
  • src/main/wsl/wsl-orcad-account-env.test.ts
  • src/main/wsl/wsl-orcad-account-env.ts
  • src/main/wsl/wsl-orcad-host-environments.test.ts
  • src/main/wsl/wsl-orcad-host-environments.ts
  • src/preload/api/runtime-api.ts
  • src/preload/api/runtime-environments-bridge.ts
  • src/renderer/src/hooks/ipc-events/app-lifetime-ipc-bridge.ts
  • src/renderer/src/hooks/ipc-events/wsl-account-notice-ipc-bridge.test.ts
  • src/renderer/src/hooks/ipc-events/wsl-account-notice-ipc-bridge.ts
  • src/renderer/src/hooks/useIpcEvents-lifecycle.test.ts
  • src/renderer/src/i18n/locales/en.json
  • src/renderer/src/i18n/locales/es.json
  • src/renderer/src/i18n/locales/fr.json
  • src/renderer/src/i18n/locales/ja.json
  • src/renderer/src/i18n/locales/ko.json
  • src/renderer/src/i18n/locales/zh.json
  • src/shared/agent-session-create-capabilities.ts
  • src/shared/agent-session-host-authority.ts
  • src/shared/rpc-contract/agent-session-params-account-env.test.ts
  • src/shared/rpc-contract/agent-session-params.ts
  • src/shared/wsl-orcad-account-notice.ts

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

if (sent.has(key)) {
return
}
sent.add(key)

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

Record the distro only after a notice is delivered.

If the initiating window closes before the notice is broadcast, broadcastAccountNotApplied can send to no live window. Line 21 still records the distro. A later request for the same distro cannot show the notice in a new window. Have the broadcaster report whether it sent to a live window, and record the distro only after a successful send.

@nwparker
nwparker merged commit 5e9489c into main Oct 13, 2026
43 checks passed
registered2nd pushed a commit to registered2nd/orca that referenced this pull request Oct 14, 2026
…ht back (stablyai#28402)

* fix(ssh): a cancelled sign-in stays cancelled until the user reconnects

Co-Authored-By: Claude <[email protected]>

* test(ssh): drive the credential cancel through the IPC harness

Co-Authored-By: Claude <[email protected]>

* fix(ssh): an explicit server connect lifts the cancelled sign-in of its SSH host

Co-Authored-By: Claude <[email protected]>

* fix(ssh): the cancelled attempt may still offer a password; a successful sign-in lifts the decline

Co-Authored-By: Claude <[email protected]>

* test(ssh): build the managed-server link without the newer kind field

Co-Authored-By: Claude <[email protected]>

---------

Co-authored-by: m4air <[email protected]>
Co-authored-by: Claude <[email protected]>
(cherry picked from commit ed18c2c)

Release pick note: runtime-environment-connectivity-handlers.ts conflicted with main's WSL host series (stablyai#27874/stablyai#27940/stablyai#27933), which is not on this release. Kept only this PR's two lines there (the clearSshCredentialDeclinedForEnvironment import and call).
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