Repository navigation
feat(wsl): account env for agent tabs on a WSL orcad host (WSL-via-orcad C9b) - #27940
Conversation
db082c5 to
03a2bce
Compare
973166a to
bd305fe
Compare
03a2bce to
3f9b83d
Compare
bd305fe to
35e7639
Compare
0727e51 to
375e4b5
Compare
273707d to
5817b05
Compare
375e4b5 to
ce642f1
Compare
3f949b6 to
93113ed
Compare
…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.
ce642f1 to
ad8c85d
Compare
📝 Walkthrough
Priority: ➖ Normal Merge Risk: 🔵 Low · up to
|
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:
b96c33a3-5a61-451f-90ed-90adabd69622
📒 Files selected for processing (28)
src/main/ipc/runtime-environment-connectivity-handlers.tssrc/main/runtime/agent-session-account-env.tssrc/main/runtime/orca-runtime-agent-session-account-env.test.tssrc/main/runtime/orca-runtime-create-agent-session.tssrc/main/runtime/orca-runtime-get-agent-session-execution-namespace.tssrc/main/startup/wsl-orcad-account-env-wiring.test.tssrc/main/startup/wsl-orcad-account-env-wiring.tssrc/main/wsl/wsl-orcad-account-env.test.tssrc/main/wsl/wsl-orcad-account-env.tssrc/main/wsl/wsl-orcad-host-environments.test.tssrc/main/wsl/wsl-orcad-host-environments.tssrc/preload/api/runtime-api.tssrc/preload/api/runtime-environments-bridge.tssrc/renderer/src/hooks/ipc-events/app-lifetime-ipc-bridge.tssrc/renderer/src/hooks/ipc-events/wsl-account-notice-ipc-bridge.test.tssrc/renderer/src/hooks/ipc-events/wsl-account-notice-ipc-bridge.tssrc/renderer/src/hooks/useIpcEvents-lifecycle.test.tssrc/renderer/src/i18n/locales/en.jsonsrc/renderer/src/i18n/locales/es.jsonsrc/renderer/src/i18n/locales/fr.jsonsrc/renderer/src/i18n/locales/ja.jsonsrc/renderer/src/i18n/locales/ko.jsonsrc/renderer/src/i18n/locales/zh.jsonsrc/shared/agent-session-create-capabilities.tssrc/shared/agent-session-host-authority.tssrc/shared/rpc-contract/agent-session-params-account-env.test.tssrc/shared/rpc-contract/agent-session-params.tssrc/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) |
There was a problem hiding this comment.
🎯 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.
…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).
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
terminal.createAgentSessionand an explicitterminal.ensureAgentSession(new tabs, restores, sleeping agents waking one by one) accept an optionalaccountEnv. It uses the same validator as C9'sagent.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 capabilityagent-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.wsl-orcad-account-env.ts). The oneruntimeEnvironments:callhandler addsaccountEnvto those two methods only when the WSL orcad advertises the capability. It learns the capabilities from anystatus.getanswer 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.runtimeEnvironments:wslAccountNotApplied) feedstoast.infowith 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:
terminal.createwith env on older hosts: it gives up the host-authority create and its replay protection.Wire compatibility
agent-session.account-env.v1)accountEnvsent and applied (real host)accountEnvis outside bothcreateAgentSessionfingerprints (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.Linked Issue
Internal WSL-via-orcad tracker, step C9b.
Visual Proof
N/A for screenshots: the only UI is a stock
toast.infofrom 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
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=falseplaced before its first boot (PID 1 wasinit) and a useru. The fakeclaudeandcodexbinaries print their env. The harness was bundled from this branch:WslOrcadConnectionManager.ensure, then the realwithWslOrcadAccountEnvwithwslOrcadHostSupportsagainst livestatus.get, and stand-in account services that answer like the WSL routers. For the new host, I overlaid this branch'spnpm build:orcadJS 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).0.1.0+dd16abe15cea,createAgentSessionclaudeCLAUDE_CONFIG_DIR=/home/u/.c9b-accounts/claude-a/config, injected marker equal, pointer,CODEX_HOME=/home/u/.c9b-accounts/codex-bensureAgentSessioncodex resume (automatic-restore)CODEX_HOMECODEX_HOME=/home/u/.c9b-accounts/codex-b0.1.0+7d2c134906c4, both methodsnone); both calls succeeded; notice raisedTwo things to know about the real-host run:
claudeshell function correctly treats the selection as System default. The harness writes the pointer, as the WSL router's setup does.codexhung on the shell function'scodex --helpprobe, so I read the pane's env directly.Cleanup:
%TEMP%\orca-c9b-*and closed the terminal.wsl -l -vmatches the starting state, apart from another agent's probe distro, which I left alone.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, observedstatus.getanswers, 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:
preflight-agent-detection"does not double-count…" also fails on the C9 base.preflight-runnable-local-clitimed out under load and passes alone.pnpm tcand oxlintcheck:code-quality:changedandcheck:react-doctor:changedverify:rpc-params-catalogpnpm formatgit rev-parse v1.4.224), not because of this change.AI Disclosure
Review
Agent skill upstream boundary
Notes
agent.launch.accountEnv, and only for terminal agents. Structured sessions remain on the host default (C9 decision 3).status.getper WSL connection, and only when the renderer has not already fetched one.Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)