Repository navigation
One spawn step writes a terminal's pane identity for both ways Orca opens terminals - #29884
Conversation
…oth spawn lanes The window spawn controller and the host runtime's caller each wrote ORCA_PANE_KEY/ORCA_TAB_ID/ORCA_WORKTREE_ID and jcode's runtime dir, in different layers, so per-pane env behavior drifted (the jcode daemon pre-warm exists only on the window lane). stampPtySpawnPaneEnv now writes them in both controllers from the spawn's own tab/leaf/worktree ids; buildTerminalWorkspaceEnv no longer stamps them. No behavior change: a TEMPORARY prewarmsJcodeOnDaemonHost input keeps host daemon spawns from pre-warming until its own PR.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Priority: ⬇️ Low Merge Risk: ⚪ Minimal · 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:
7f55a281-11b4-4eb7-85e2-9c7ecf65ab62
📒 Files selected for processing: 24
src/main/ipc/pty-daemon-spawn-session-identity.test.tssrc/main/ipc/pty/ipc/spawn-env.tssrc/main/ipc/pty/runtime/spawn-preflight.tssrc/main/ipc/pty/spawn-pane-env.tssrc/main/runtime/opencode-finished-session-authority.test.tssrc/main/runtime/orca-runtime-create-agent-session.tssrc/main/runtime/orca-runtime-terminal-create-idempotency.test.tssrc/main/runtime/orca-runtime-test-fixtures.spec.tssrc/main/runtime/orca-runtime-tests/agent-status-and-waits.spec.tssrc/main/runtime/orca-runtime-tests/mobile-session-tabs-part-04.spec.tssrc/main/runtime/orca-runtime-tests/terminal-creation-and-readiness-part-02.spec.tssrc/main/runtime/orca-runtime-tests/terminal-creation-and-readiness-part-03.spec.tssrc/main/runtime/orca-runtime-tests/terminal-creation-and-readiness-part-04.spec.tssrc/main/runtime/orca-runtime-tests/terminal-creation-and-readiness-part-05.spec.tssrc/main/runtime/orca-runtime-tests/terminal-creation-and-readiness-part-12.spec.tssrc/main/runtime/orca-runtime-tests/terminal-creation-and-readiness.spec.tssrc/main/runtime/orca-runtime-tests/worktree-native-chat-setup.spec.tssrc/main/runtime/orca-runtime-tests/worktree-setup-and-startup-part-02.spec.tssrc/main/runtime/orca-runtime-tests/worktree-setup-and-startup-part-03.spec.tssrc/main/runtime/orca-runtime-tests/worktree-setup-and-startup-part-04.spec.tssrc/main/runtime/orca-runtime-tests/worktree-setup-and-startup.spec.tssrc/main/runtime/terminal/launch/terminal-create.tssrc/main/runtime/terminal/launch/terminal-split-surface.tssrc/main/runtime/terminal/launch/terminal-workspace-scope.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 0 remain after this review.
…nd leaf, as the runtime does
…2-pane-identity-env
…2-pane-identity-env
|
Terminal identity was written in two different layers, so desktop and host-created terminals could drift when per-pane behavior changed. This PR gives both spawn controllers one writer that takes the new terminal’s own ids. Normal terminal identity, launch commands and visible behavior stay the same. The review found and fixed one regression: when the managed jcode folder could not be prepared, a host-created terminal lost a working caller-supplied folder. Host preparation now remains asynchronous and supplies its result to the shared writer; a real filesystem regression checks the native spawn environment for both host and window paths. The window retains its existing preparation behavior. A stale provider comment was also corrected. No unresolved review findings remain. The architecture challenger, correctness review, dedicated performance/readiness pass, three-model design panel and correction review are complete. The panel retained the shared writer with prepared-directory data. Early daemon prewarm remains window-only until the planned follow-up; this is the sole temporary preparation difference. The retained folder-preparation boundaries and early-adoption filesystem side effect are intended. Terminal-handle trust and account-preparation timing remain outside this change. Validation: Full PR workflow passed on 060d3fe, including the aggregate gate, all test shards, static analysis and packaging; the final check watch also passed all registered jobs. Remote hidden Electron QA on M4Air passed all three requested main-versus-PR rows on this exact head. I independently checked all eight shell captures for own-tab identity and runtime-folder hashes, plus split relationships, and viewed all six final sanitized images. Both builds used the same store-inspection flag. The lane owner explicitly authorized the existing signed-in Codex worker to drive Playwright/CDP without a separately launched driver CLI; all app/CLI homes remained isolated. Real config hashes were unchanged and recorded processes exited.. No local package commands, builds or test copies ran on the working Mac. No timing benchmark, native-focus, folder-workspace, phone, Windows, Linux or SSH interaction QA is claimed; source review found no new wire, persistence or platform contract. For Brennan’s review
Rendered focus was checked after each environment probe; automatic focus before the probe and native focus were not independently measured. Workspace-id/path and prompt lines are masked; the main split image has an extra conservative redaction. Exact environment captures supplied the primary identity evidence. Judgment points:
|
The tab context menu imports both the agent account items and the new close-split item. SortableTab was at its 400-line limit on main, so the terminal tab's hover card (with its account lines) moves to its own TerminalTabHoverCard. Since stablyai#29884 a host spawn names its pane from its own tab and leaf ids, so the kept-launch host test passes those instead of ORCA_PANE_KEY in the caller's env. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>






ELI5
Every terminal Orca opens carries a few environment variables that say which pane it lives in:
ORCA_PANE_KEY,ORCA_TAB_ID,ORCA_WORKTREE_ID, plus jcode's per-pane runtime folder. Agents and hooks read them to report status for the right pane. Orca has two ways to open a terminal, and each one wrote those variables in its own place. This PR makes one spawn step write them for both, from the ids of the terminal being opened. Nothing a user sees changes.What Changed
Before: a terminal opened from a desktop window had its pane identity written by the window's spawn controller (
src/main/ipc/pty/ipc/spawn-env.ts). A terminal opened by the host runtime was handled differently. That coversorca terminal create, mobile, orchestration, worktree startup and splits. Its identity was written earlier, by the runtime code that asked for it (buildTerminalWorkspaceEnvinterminal-workspace-scope.ts), before the spawn controller ran.After:
stampPtySpawnPaneEnv(new,src/main/ipc/pty/spawn-pane-env.ts, beside the shared host-env step) writes the identity and jcode's runtime folder for both kinds of terminal. It runs before the host env in both spawn controllers. The host first prepares jcode’s managed folder asynchronously; the window keeps its existing preparation. The step receives the selected folder and publishes it only when selection succeeds, preserving a caller-supplied folder after host preparation fails.tabId/leafId/worktreeId, which are exactly the values the runtime used to write (ptySpawnPaneFromIds).buildTerminalWorkspaceEnvno longer writes identity or the jcode folder. It keeps hook env, Agent Teams env and the folder-workspace keys, which need the workspace scope. It is now synchronous.User-facing change: none. Every terminal gets the same identity values as before.
One input is TEMPORARY.
prewarmsJcodeOnDaemonHostistruefor the window andfalsefor the host, so host daemon spawns still don't start jcode's daemon early. A stacked follow-up PR removes it. That follow-up is a real behavior change: today a jcode agent opened from the CLI or mobile on a daemon-backed terminal starts its daemon cold. It will also move the early start onto the final env.Why
The bug class. One fact, which pane a terminal belongs to, was written by two pieces of code at two different layers. So every per-pane env behavior had to be added twice, and it drifted. The jcode daemon pre-warm (a7b9358) was added to the window path only. The Claude Agent Teams leader release on a failed spawn also exists only on the window path (tracked separately in Linear STA-10891).
The common pattern is one function that builds a new terminal's environment for every way a terminal can be opened. It writes the identity variables from the terminal's own ids and ignores identity values passed in by the caller. That is what this PR does. Afterwards a per-pane env change has one home.
Alternatives considered:
Known differences, both intended:
ORCA_TERMINAL_HANDLEis still written at a different stage in each path. Moving it means touching the handle trust rules, which is a separate mechanism, and nothing in the host env reads it.A host spawn whose own ids name no pane gets no identity. A host-controller spawn that passes no valid
tabId/leafIdnow gets noORCA_PANE_KEY/ORCA_TAB_ID/ORCA_WORKTREE_ID, even if its env carried them. That is the same rule the window path applies. No production caller does this: every host spawn goes throughcreateTerminalor split, and both always pass the ids. Two older tests that spawned with only an env pane key now pass the ids, as the runtime does.jcode folder preparation stays different to preserve existing behavior (intended). The host checks the managed folder asynchronously before the shared step writes it, so a caller-supplied folder survives if managed-folder creation fails. The window keeps its existing synchronous check for daemon spawns and provider validation for local spawns. The local provider still validates whichever folder was selected before starting a process. This does not add blocking filesystem work to local-provider launches.
An early adoption can skip an old folder-creation side effect (intended). It starts no process and does not change an existing process's environment. The temporary prewarm follow-up does not change the folder-fallback contract.
Linked Issue
N/A (internal launch-convergence work; no tracking issue). Related bug found while planning: Linear STA-10891.
Visual Proof
Real hidden Electron QA passed on M4Air for main
fd1c6a5versus this PR’s exact head060d3fe. The plus terminal,orca terminal createagainst the rig’s own runtime, and a split all retain the same own-pane/tab/workspace identity, per-pane runtime-folder formula, shell command, tab order, activation, setup, status and notices. Split leaves and runtime folders are distinct. Six final screenshots follow; private environment captures include the workspace ids masked in images. Main’s split image has one extra conservative redaction.Both builds used the same store-inspection flag. The existing signed-in Codex worker drove deterministic Playwright/CDP under the lane owner’s explicit ruling; no separate driver CLI or real agent ran in a pane. App/CLI homes were isolated, real config hashes stayed unchanged, and recorded processes exited. Rendered focus was checked after the probe; native focus, SSH, folder-workspace variants and adverse-filesystem UI QA were not exercised.
Testing
pty-daemon-spawn-session-identity.test.ts: new pin "both daemon lanes stamp the pane identity from the spawn ids; only the window pre-warms jcode". It runs both real spawn controllers with a stale caller pane key. It fails on main, where the host lane passes the stale key through.The real-controller parity tests (
pty-launch-parity.test.ts) still cover the identity key list on both paths.The runtime specs that read identity from a fake spawn's env now derive it with
spawnedPtyEnv, which runs the real stamping step on the captured call. They retain the caller identity assertions at the new boundary; real-controller tests cover the controller wiring separately.pty-spawn-env-terminal-basics.test.ts: one two-path regression uses an actual file blocking the managed folder and a writable caller folder. At the native spawn boundary, the host preserves its caller folder while the window retains its existing absence result; own identity and caller env are checked.AI Disclosure
Review
Agent skill upstream boundary
Notes
ssh:connection is refused at provider lookup in both paths, before this step, so nothing changes for SSH.ORCA_WORKTREE_IDis still the folder workspace key, and the folder-workspace keys are unchanged.Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)X: @BrennanKB5