Repository navigation
fix(structured-sessions): don't pass an inherited pane identity to structured chat children - #26426
petersindex wants to merge 1 commit into
Conversation
…ructured chat children When Orca itself is started from one of its own terminals, the app process carries that pane's ORCA_PANE_KEY, ORCA_TAB_ID, ORCA_WORKTREE_ID, ORCA_WORKSPACE_ID, launch token, their scrub-safe aliases and its terminal handle. Structured Claude and Codex children inherited all of it, so their hook status landed on that unrelated pane. structuredSessionChildIdentityEnv now drops the inherited pane identity before adding the session's own values, which covers Claude. Codex merges the app's env under its overlay at spawn, so it also deletes the inherited keys there, sparing a registered worker's own handle. The key list lives once in spawn-env-keys.ts, and Pi and ACP reuse it instead of their own copies. Fixes stablyai#26417
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configuration
📒 Files selected for processing (8)
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review. 📝 WalkthroughWalkthroughThe change centralizes inherited pane identity keys and removes inherited identity from structured child environments. ACP and Pi use the shared key list in their child deletion rules. Codex now returns inherited identity keys for deletion and also removes the visuals directory key when visuals are absent. Tests cover identity cleanup and retention of session-specific values. Priority: ➖ Normal Severity of issue fixed: Medium Merge Risk: ⚪ Minimal · up to The intended Claude and Codex identity cleanup is supported by the inspected launch paths. No established issue currently blocks merging. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
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. Comment |
Fixes #26417
ELI5
Every Orca terminal carries a few variables that say which pane it is. If you start Orca itself from inside one of its own terminals (to restart a dev build, say), the new Orca process copies that pane's variables. Every Claude or Codex chat it opens then inherits them too, so the chat's status gets reported to that old terminal instead of its own workspace. The chat shows up as activity in an unrelated workspace. Now a chat never inherits another pane's identity.
What changed
ORCA_PANE_KEY,ORCA_TAB_ID,ORCA_WORKTREE_IDandORCA_WORKSPACE_ID, so its hook status lands on A's pane.ORCA_AGENT_SESSION_ID,ORCA_STRUCTURED_SESSIONand CLI settings, and a registered worker keeps its ownORCA_TERMINAL_HANDLE.structuredSessionChildIdentityEnvbuilds every structured child's identity. Its doc comment already says it must never put a pane key in a child's environment, but it passed through whatever the app inherited. It now removes the inherited pane identity before adding the session's own values. That covers Claude, whose launch hands it the full environment.codexStructuredChildEnvironmentalso puts the inherited keys inenvToDelete. It leaves out any key the session sets itself, becauseenvToDeleteruns after the overlay and would otherwise wipe a registered worker's handle.INHERITED_PANE_IDENTITY_ENV_KEYS) now lives once inspawn-env-keys.ts, beside the other inherited-env lists. Pi and ACP already stripped most of these keys with their own hand-written copies. They now use the shared list, which also addsORCA_WORKSPACE_IDto both.Why this approach
spawn-env.ts), and ACP and Pi already strip one. Claude and Codex were the two structured paths without it, and both build their identity instructuredSessionChildIdentityEnv, so the fix goes there.ORCA_AGENT_PANEandORCA_AGENT_LAUNCH, which the issue doesn't mention. A stale alias would misattribute status the same way.ORCA_*variable: the session's id, marker, CLI path, user data path and hook port all have to reach the child.Testing
ORCA_PANE_KEY,ORCA_TAB_ID,ORCA_WORKTREE_ID,ORCA_WORKSPACE_ID,ORCA_TERMINAL_HANDLEandORCA_AGENT_PANE.structured-session-child-identity-env.test.ts: inherited pane identity is dropped, and a registered worker's own handle replaces an inherited one.codex-structured-child-environment.test.ts: spawns a real child process through the Codex app-server connection, with the identity both in the app's environment and in the shell environment Codex launches with. The child reports it received none of it.claude-structured-launch-resolution.test.ts: the real Claude launch resolver, given an inherited environment with the pane identity, produces a launch environment without it.mainand pass with this change.src/main/acp,src/main/pi,src/main/codex,src/main/claude,src/main/ipc/ptyand the structured identity tests (610 files).pnpm tc:node, oxlint, oxfmt andcheck:code-quality:changedpass.claude-structured-*source, so I didn't run the real Claude CLI suite.Visual Proof
N/A: the change is to the environment a chat's child process starts with, and the tests check that environment directly, including through a real spawned child.
Follow-up (not in this PR)
ACP sessions also inherit the app's
ORCA_TERMINAL_HANDLEwhen the session has no registered handle. Fixing that needs the same rule Codex uses here, but it changes an exactenvToDeleteassertion in ACP's OpenCode tests, so I've kept this PR to Claude and Codex. I can send that as a separate PR.AI review
structuredSessionChildIdentityEnv, and Pi and the ACP agents (Grok, OpenCode, OMP) use the shared key list. Terminal agents are unchanged.X: @petersindex