Skip to content

One spawn step writes a terminal's pane identity for both ways Orca opens terminals - #29884

Merged
brennanb2025 merged 6 commits into
mainfrom
brennanb2025/conv-c5c2-pane-identity-env
Oct 17, 2026
Merged

brennanb2025 merged 6 commits into
mainfrom
brennanb2025/conv-c5c2-pane-identity-env

Conversation

@brennanb2025

@brennanb2025 brennanb2025 commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 19 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​149 $\color{#cf222e}{\Huge{\mathbf{−}}}$​58 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​91
Prod 9 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​182 $\color{#cf222e}{\Huge{\mathbf{−}}}$​89 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​93

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 covers orca terminal create, mobile, orchestration, worktree startup and splits. Its identity was written earlier, by the runtime code that asked for it (buildTerminalWorkspaceEnv in terminal-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.

  • Window controller: still checks the pane key the renderer sends. That check only decides which restore bookkeeping runs at commit; the value written is always the spawn's own tab and leaf.
  • Host controller: passes the spawn's own tabId/leafId/worktreeId, which are exactly the values the runtime used to write (ptySpawnPaneFromIds).
  • Runtime caller: buildTerminalWorkspaceEnv no 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. prewarmsJcodeOnDaemonHost is true for the window and false for 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:

  • A shared helper called from both existing places, the window controller and the runtime caller. It's smaller, but it keeps two call sites at two layers, so they can still drift.
  • Leaving the runtime caller's write in place as well. That keeps two writers of the same fact.

Known differences, both intended:

  • Terminal handle: ORCA_TERMINAL_HANDLE is 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.
  • Antigravity account prep: it still runs in both paths with different inputs, before vs after the host env.

A host spawn whose own ids name no pane gets no identity. A host-controller spawn that passes no valid tabId/leafId now gets no ORCA_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 through createTerminal or 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 fd1c6a5 versus this PR’s exact head 060d3fe. The plus terminal, orca terminal create against 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.

Flow Main PR
Window + terminal Main: Window + terminal PR: Window + terminal
CLI-created terminal Main: CLI-created terminal PR: CLI-created terminal
Split CLI terminal Main: Split CLI terminal PR: Split CLI terminal

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

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

Notes

  • Remote and SSH: an ssh: connection is refused at provider lookup in both paths, before this step, so nothing changes for SSH.
  • Wire and saved data: no RPC, wire or saved-data change.
  • Folder workspaces: ORCA_WORKTREE_ID is still the folder workspace key, and the folder-workspace keys are unchanged.
  • Windows: jcode's runtime folder isn't used on Windows in either path, same as before.

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)

X: @BrennanKB5

…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.
@brennanb2025
brennanb2025 marked this pull request as ready for review October 16, 2026 23:33
@coderabbitai

coderabbitai Bot commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

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: f3a6301a-822d-4ea2-a7ad-03c74e3175dc
📥 Commits

Reviewing files that changed from the base of the PR and between 0dcdad4 and f7a4fe4.

📒 Files selected for processing: 17
  • src/main/ipc/pty-serializer-settlement-mapping.test.ts
  • src/main/ipc/pty-spawn-env-terminal-basics.test.ts
  • src/main/ipc/pty/ipc/spawn-env.ts
  • src/main/ipc/pty/runtime/spawn-preflight.ts
  • src/main/ipc/pty/spawn-pane-env.ts
  • src/main/providers/local-pty-spawn.ts
  • src/main/runtime/opencode-finished-session-authority.test.ts
  • src/main/runtime/orca-runtime-test-fixtures.spec.ts
  • src/main/runtime/orca-runtime-tests/agent-status-and-waits.spec.ts
  • src/main/runtime/orca-runtime-tests/terminal-creation-and-readiness-part-04.spec.ts
  • src/main/runtime/orca-runtime-tests/terminal-creation-and-readiness-part-05.spec.ts
  • src/main/runtime/orca-runtime-tests/terminal-creation-and-readiness.spec.ts
  • src/main/runtime/orca-runtime-tests/worktree-setup-and-startup-part-02.spec.ts
  • src/main/runtime/orca-runtime-tests/worktree-setup-and-startup-part-03.spec.ts
  • src/main/runtime/orca-runtime-tests/worktree-setup-and-startup-part-04.spec.ts
  • src/main/runtime/orca-runtime-tests/worktree-setup-and-startup.spec.ts
  • src/main/runtime/spawned-pty-env-fixtures.ts
🚧 Files skipped from review as they are similar to previous changes: 1
  • src/main/runtime/orca-runtime-tests/worktree-setup-and-startup-part-03.spec.ts

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

📝 Walkthrough

PTY spawn paths now derive pane identity from spawn IDs and stamp pane-related and Jcode environment values. Terminal workspace environment construction is synchronous and no longer sets pane, tab, or worktree identity. Runtime tests use a shared helper to derive the effective spawned environment. Daemon tests cover identity stamping and Jcode prewarming.

Priority: ⬇️ Low

Merge Risk: ⚪ Minimal · up to f7a4f

The supplied evidence identifies no unresolved behavior change that would prevent merging after normal checks.

Pre-merge checks: Passed 3 · Failed 2

Failed Failed checks: 2 warnings

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 37.50% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 8 functions across 28 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Description check Warning No description was added, so the required template sections and information are missing. Add a description using the repository template. Explain the change and why it is needed, include a linked issue when required, provide visual proof or state N/A with a reason, and document testing and platform coverage. Complete the applic…
Passed Passed checks: 3 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 summarizes the main change: a shared spawn step writes terminal pane identity for both terminal-opening paths.
Full details: Description check

Resolution

Add a description using the repository template. Explain the change and why it is needed, include a linked issue when required, provide visual proof or state N/A with a reason, and document testing and platform coverage. Complete the applicable AI disclosure, review, agent-skill boundary, notes, and checklist sections.

  • 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: 7f55a281-11b4-4eb7-85e2-9c7ecf65ab62
📥 Commits

Reviewing files that changed from the base of the PR and between d963f2a and 0dcdad4.

📒 Files selected for processing: 24
  • src/main/ipc/pty-daemon-spawn-session-identity.test.ts
  • src/main/ipc/pty/ipc/spawn-env.ts
  • src/main/ipc/pty/runtime/spawn-preflight.ts
  • src/main/ipc/pty/spawn-pane-env.ts
  • src/main/runtime/opencode-finished-session-authority.test.ts
  • src/main/runtime/orca-runtime-create-agent-session.ts
  • src/main/runtime/orca-runtime-terminal-create-idempotency.test.ts
  • src/main/runtime/orca-runtime-test-fixtures.spec.ts
  • src/main/runtime/orca-runtime-tests/agent-status-and-waits.spec.ts
  • src/main/runtime/orca-runtime-tests/mobile-session-tabs-part-04.spec.ts
  • src/main/runtime/orca-runtime-tests/terminal-creation-and-readiness-part-02.spec.ts
  • src/main/runtime/orca-runtime-tests/terminal-creation-and-readiness-part-03.spec.ts
  • src/main/runtime/orca-runtime-tests/terminal-creation-and-readiness-part-04.spec.ts
  • src/main/runtime/orca-runtime-tests/terminal-creation-and-readiness-part-05.spec.ts
  • src/main/runtime/orca-runtime-tests/terminal-creation-and-readiness-part-12.spec.ts
  • src/main/runtime/orca-runtime-tests/terminal-creation-and-readiness.spec.ts
  • src/main/runtime/orca-runtime-tests/worktree-native-chat-setup.spec.ts
  • src/main/runtime/orca-runtime-tests/worktree-setup-and-startup-part-02.spec.ts
  • src/main/runtime/orca-runtime-tests/worktree-setup-and-startup-part-03.spec.ts
  • src/main/runtime/orca-runtime-tests/worktree-setup-and-startup-part-04.spec.ts
  • src/main/runtime/orca-runtime-tests/worktree-setup-and-startup.spec.ts
  • src/main/runtime/terminal/launch/terminal-create.ts
  • src/main/runtime/terminal/launch/terminal-split-surface.ts
  • src/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.

@brennanb2025

Copy link
Copy Markdown
Contributor Author

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

Flow Main PR
Window + terminal Main: Window + terminal PR: Window + terminal
CLI-created terminal Main: CLI-created terminal PR: CLI-created terminal
Split CLI terminal Main: Split CLI terminal PR: Split CLI terminal

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:

@brennanb2025
brennanb2025 merged commit 6287ff6 into main Oct 17, 2026
44 checks passed
@brennanb2025
brennanb2025 deleted the brennanb2025/conv-c5c2-pane-identity-env branch October 17, 2026 20:41
QichangZheng added a commit to QichangZheng/orca that referenced this pull request Oct 18, 2026
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]>
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