Repository navigation
Keep idle Claude sessions selected during nested Codex work - #29386
Conversation
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 11 minutes. View limit details
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 |
|
Adversarial review completed with a sub-agent and independent parent review. Findings addressed in
Final local verification: 197 tests across 24 files passed, full Reviewed ownership authority, host/workspace boundaries, legacy peer behavior, genuine replacement after exit/suspension, unavailable reads, startup/stop concurrency, and durable replay. No remaining blocking review findings. Live model-backed nested turns, live SSH/WSL hosts, Windows Electron, and a physical phone remain unverified; #10105 and #22767 remain open. Merge is pending the exact current commit's full |
ELI5
A finished Claude turn still belongs to the running Claude session. A background Codex worker must not take over its chat, mobile transcript, or resume command.
What Changed
Keep the identified Claude process as the session owner after a turn finishes or its status ages. Before accepting another provider, the execution host checks the existing process: confirmed exit or suspension permits replacement; an unavailable read preserves ownership. Local and relay ingestion use the same rule, including ordered, durable startup replay. Older hosts without this support retain their previous behavior.
Why
A timestamp or
Stophook describes a turn, not whether the foreground CLI exited. Reusing the existing process check avoids guessing from elapsed time or adding polling. Adversarial review also fixed pending requests publishing after stop or disable/re-enable, and a queued restart reviving a listener after a second stop. Regression tests cover these alongside suspension/resume and durable replay.The incomplete done/stale replacement policy is present in merged PR #3990 (source-history attribution). #29264 fixed active-turn nested hooks but left this existing idle-session gap; it did not introduce it. The overlapping #10109 and #22866 are closed as superseded; #25687 is also superseded by the merged host ownership guard.
Linked Issue
Resolves the reproduced ownership paths in #10105 and #22767; both are closed with verification limits documented. Windows/unidentified processes and older hosts retain the previous fallback, and this verification used controlled hooks/transcripts rather than live model-backed nested turns.
Visual Proof
Before: the original #10105 report shows the incorrect Codex resume error:
After: controlled hooks/transcripts on the fixed macOS build, with an identified stand-in process running in the actual terminal. Claude's reply remains after six nested Codex hooks, the paired mobile client reads the same transcript, and Show terminal returns without an error. Three recorded runs passed; screenshots inspected. This uses a foreground process fixture, not a live Claude model turn.
page@355880a3f9e9162abd7d55cacde6a058.webm
Testing
Red/green: eight failing assertions across three new test files on the prior production code, then passing with the fix.
Final focused suite: 197 tests / 24 files passed (75.69s).
Hidden Electron UI + paired mobile transport: 3/3 recorded runs passed on macOS (52.2s), screenshots inspected.
pnpm tc, changed-code quality, reliability manifest validation, and Electron/CLI builds passed.Reproduced the CI Linux failure in an isolated Linux container: the old test claimed the Playwright worker owned a terminal left at a shell prompt. The corrected test starts an identified foreground stand-in in the actual PTY and verifies it remains owned before nested hooks. Final Linux build: 3/3 hidden Electron runs passed (51.3s). Recording-enabled Linux attempts timed out during Electron startup, before the test ran; attached video is from macOS.
Reproduce UI proof:
ORCA_BACKGROUND_LAUNCH=1 ORCA_E2E_RECORD_VIDEO=1 pnpm exec playwright test --config tests/playwright.config.ts tests/e2e/nested-agent-idle-session-owner.spec.ts --project=electron-headless --workers=1 --repeat-each=3.I manually tested these changes locally
Automated tests added/updated
Tested on macOS with a real OS process identity and authenticated hook requests. Relay tests cover transport boundaries, legacy peers, cold replay, and genuine provider replacement. The Electron test uses the actual chat UI, paired mobile transport/resolver/transcript reader, and Show terminal action. Linux Electron is also exercised in an isolated container. No live SSH/WSL host, Windows Electron runtime, physical phone, or new live Claude/Codex model turn was tested.
Review
Adversarial sub-agent and parent reviews found and fixed stale HTTP/probe publications after stop or status disable/re-enable, a fixed-token relay restart race, and a second-stop queued-restart race. Regression tests pass; the sub-agent found no remaining blocking issue. The Linux E2E fixture now uses the actual foreground PTY process instead of the test runner.
Agent skill upstream boundary
Notes
Process checks execute on the owning host; remote PIDs are never probed locally. New presence fields are optional for wire compatibility. No polling/timers added; conflicting hooks reuse the existing bounded process probe and concurrent-check deduplication. Folder workspaces use the existing host/workspace ownership scope. Windows/no-identity fallback remains a known limitation.
Checklist
N/Awith reason