Repository navigation
fix(terminal): run Orca's cmd.exe, path-named and setup-gated Codex launches without the shared server - #23933
Conversation
Plain bash, zsh and fish tabs were never wrapped, so a typed codex skipped the shell function that adds --no-daemon. Wrap them (bash keeps its prompt and DEBUG trap untouched unless Orca asked for command markers), add --no-daemon host-side where no function can run (cmd.exe, path-named binaries), and move new tabs to a v38 terminal daemon so they get the new wrappers.
|
Comments Outside DiffThese findings could not be posted inline.
|
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (5)
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 5 remain after this review. 📝 WalkthroughWalkthroughThe change adds shared POSIX, fish, and PowerShell Codex shell preflight generators, updates shell launch configuration for zsh and fish, and adds local PTY command planning that inserts Priority: ➖ Normal Merge Risk: 🟡 Moderate · up to Native Windows Codex launches that wait for setup can still use the shared server, so this launch mode misses the PR’s isolation behavior. Resolve or explicitly accept this gap before merging. Security Architecture ReviewSecurity architecture risk: 🔵 Low · up to The change improves separation between Codex sessions while preserving explicit shared-server choices. A new pre-launch process does not participate in launch cancellation or verified descendant cleanup, creating a limited local failure-containment concern. No new remote access or privilege escalation was established. Retained concerns
Security review detailsSecurity Blast Radius
Trust Boundaries and Controls
Resilience and Maintainability Implications
Hardening Proposals
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
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 |
There was a problem hiding this comment.
Important
The cmd.exe and plain-shell wrapping changes look correct, but a supported wait-for-setup worktree launch still runs Codex without --no-daemon, so #22873 persists on that path. Details inline; two smaller scope notes below.
Reviewed changes
- Host-side
--no-daemoninjection — newsrc/main/pty/codex-no-daemon-launch-command.tsadds the flag after a Codex executable for cmd.exe and path-named launches where the shell codex function never runs, applying the same exclusions,ORCA_CODEX_ISOLATE=0opt-out, and--helpcapability probe. Wired into both PTY spawn-options builders and skipped for SSH and WSL. - Plain shells always wrapped —
getShellLaunchConfig(daemon + local) and the Windows Git Bash launch now wrap bash/zsh/fish even with zero features, so a hand-typedcodexreaches the wrapper-defined function. The bash rcfiles gate their OSC 133 / DEBUG trap / bracketed-paste / startup block behind themarkersfeature and return early when it is off. WSL bash exportsORCA_SHELL_FEATURES=markersto keep its prior lifecycle. - Daemon protocol 37 → 38 — content-addressed wrapper bump so new tabs get the new wrappers, with prior versions still attachable; contract json/ts and tests updated consistently.
ℹ️ Plain zsh and fish tabs on SSH/relay hosts still share the server
The host-side planner is intentionally skipped when args.connectionId is set, delegating to the codex function on the remote host. But the relay only wraps remote bash unconditionally — src/relay/pty-shell-launch.ts:109 still returns the unwrapped login shell for zsh when features.length === 0, and fish is not handled at all — so a hand-typed codex in a plain remote zsh or fish tab has no function to reach. The PR body states SSH is unchanged, so this may be a deliberate follow-up, but the plain-shell coverage described in the PR does not hold over SSH. Worth stating explicitly, or covering in a follow-up.
Technical details
# Relay plain shells still bypass the codex function
## Affected sites
- `src/relay/pty-shell-launch.ts:109-111` — `if (shellName !== 'bash' && features.length === 0) return unwrapped`, so plain zsh never gets a wrapper; fish returns `unwrapped` earlier at `:90-92`.
- `src/main/ipc/pty/ipc/spawn-options.ts:82` and `src/main/ipc/pty/runtime/spawn-options.ts:103` — host-side planner skipped for `connectionId`.
## Required outcome
Either accept and document that SSH plain zsh/fish Codex launches are not covered, or wrap plain zsh (and fish) on the relay so the remote codex function exists too.
## Open questions for the human
Is the relay's plain-shell path intended as a follow-up to this PR?ℹ️ Nitpicks
local-pty-shell-ready.ts:71-74can appendstartupwithoutmarkers, but the new bash early-return gates the startup block onmarkers. Production callers always sethasStartupCommandwhen a startup command exists, so this is not reachable today — but a guard coupling the two (or keying the early-return off the startup-command env) would remove the silent-drop landmine.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
| args.connectionId || ctx.codexSelectionTarget.runtime === 'wsl' | ||
| ? null | ||
| : planCodexNoDaemonLaunch({ | ||
| command: ctx.launchCommand, |
There was a problem hiding this comment.
This planner only receives the PTY launch command, so a wait-for-setup Codex launch slips through: runtime-local-worktree-terminal-startup.ts:79-93 replaces the launch command with a sequencing gate and moves the real Codex command into env ORCA_SEQUENCED_STARTUP_COMMAND, whose gate shell (bash -lc on POSIX, -NoProfile -NonInteractive PowerShell on Windows) never sources the Orca wrapper — so neither this flag nor the shell function reaches Codex, and #22873 persists. The runtime call site at src/main/ipc/pty/runtime/spawn-options.ts:105-110 has the same gap.
Technical details
# Sequenced setup launches never get `--no-daemon`
## Affected sites
- `src/main/ipc/pty/ipc/spawn-options.ts:84-89` — planner sees only `ctx.launchCommand`
- `src/main/ipc/pty/runtime/spawn-options.ts:105-110` — same, using `ctx.daemonShellOverride`
- `src/main/runtime/runtime-local-worktree-terminal-startup.ts:79-93` — swaps the launch command for the gate, real Codex command goes to `ORCA_SEQUENCED_STARTUP_COMMAND`
- `src/shared/setup-agent-sequencing.ts:82` — POSIX gate `bash -lc 'eval "$ORCA_SEQUENCED_STARTUP_SCRIPT"'`; `:268` — Windows gate evals `$env:ORCA_SEQUENCED_STARTUP_COMMAND` under a profile-less PowerShell
- `src/main/ipc/pty/host-env/codex-resume.ts:120-137` — existing precedent for rewriting the sequenced env (`stripSequencedStartupResumeArgv`)
## Required outcome
A Codex launch under the `wait-for-setup` policy must receive exactly one `--no-daemon`, including on cmd.exe/Git Bash where no shell function exists.
## Suggested approach
When the env carries `ORCA_SEQUENCED_STARTUP_COMMAND`, apply the same `planCodexNoDaemonLaunch` rule to that string and write the result back into the spawn env (mirroring how resume argv is stripped from it), or emit the flag into the sequenced command before it is stored. Cover the sequenced path in `codex-no-daemon-launch-command.test.ts`.
## Open questions for the human
Is `wait-for-setup` deliberately out of scope for this PR, or should the host-side planner also handle the sequenced command?There was a problem hiding this comment.
Valid, fixed in 985498a. This is a pre-existing gap from #23900 rather than a regression: setup-agent-sequencing-codex-no-daemon.test.ts runs the real POSIX gate and shows main running codex --yolo. Instead of a host-side rewrite, the gate's bash -lc script now defines the same codex function (moved to src/shared/codex-shell-function.ts). That way it checks the binary the gate actually runs after the login profile, and it also covers SSH gates. The PowerShell gate (native Windows runner) is left as-is: it is typed as an -EncodedCommand whose size is limited by cmd.exe's 8191-character command line. That remains a documented gap.
…the codex function Plain bash and Git Bash tabs launch exactly as before again: the rcfile wrapper would have made every one a non-login shell. Plain tabs on the user's configured shell args stay unwrapped on both transports. The wait-for-setup gate's bash -lc now defines the codex function, so a sequenced Codex launch gets --no-daemon from the binary it actually runs.
There was a problem hiding this comment.
ℹ️ No new issues in this incremental delta. The POSIX
wait-for-setupgap from the prior review is fixed and tested; the plain bash/Git Bash launch behavior is back to main's.
Reviewed changes
- Reverted plain bash and Git Bash to their login-shell launch, so only a wrapped pane (a feature or startup command present) runs the bash rcfile that defines the codex function.
- Moved the
codexshell-function text intosrc/shared/codex-shell-function.tsso main, relay, the PowerShell bootstrap, and the setup gate embed one definition;codex-shell-launch-preflight.tsnow only exportsresolveCodexShellLaunchPreflightCommand. - Taught the POSIX
wait-for-setupgate to prepend the codex function to its script, closing the sequenced-launch--no-daemongap raised in the prior review. - Added
keepsConfiguredShellUnwrappedso a plain tab launched on the user's configured shell args stays exactly the user's shell on both the daemon and local transports. - Updated tests, fixtures, and the daemon-v38 comment to describe plain zsh and fish only.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
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: 28ffeaf7-29ef-4861-9209-abed62b34fc4
📒 Files selected for processing (23)
config/scripts/pr-code-change-scope.mjssrc/main/daemon/daemon-bash-shell-ready-rcfile.tssrc/main/daemon/daemon-protocol-version.tssrc/main/daemon/pty-subprocess/shell-launch-plan.tssrc/main/daemon/shell-ready.tssrc/main/powershell-osc133-bootstrap.tssrc/main/providers/configured-shell-args-wrapping.test.tssrc/main/providers/local-pty-finalize-environment.tssrc/main/providers/local-pty-shell-ready-bash-rcfile.tssrc/main/providers/local-pty-shell-ready-wrapper-generation.test.tssrc/main/providers/local-pty-shell-ready.tssrc/main/pty/codex-launch-shell-wrapping.test.tssrc/main/pty/codex-no-daemon-binary-contract.test.tssrc/main/pty/codex-no-daemon-launch-command.tssrc/main/pty/codex-shell-launch-preflight.test.tssrc/main/pty/codex-shell-launch-preflight.tssrc/main/pty/codex-shell-no-daemon.test.tssrc/main/shell-startup-features.tssrc/main/zsh-startup-wrapper-builder.tssrc/relay/pty-shell-overlay-wrappers.tssrc/shared/codex-shell-function.tssrc/shared/setup-agent-sequencing-codex-no-daemon.test.tssrc/shared/setup-agent-sequencing.ts
💤 Files with no reviewable changes (1)
- src/main/pty/codex-shell-launch-preflight.ts
🚧 Files skipped from review as they are similar to previous changes (1)
- src/main/daemon/daemon-protocol-version.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.
…ishes Setup can be what puts codex on PATH, so defining the function before the marker wait found no binary and skipped --no-daemon.
There was a problem hiding this comment.
ℹ️ No new issues in this incremental delta. The previous commit defined the gate's codex function before the setup wait, so it found no binary; this commit moves that definition after setup finishes.
Reviewed changes
- Moved the
codexshell-function definition from the prologue of the POSIXwait-for-setupgate script into its post-setupstatus = 0branch, so the function probes thecodexbinary that setup may have just installed onPATH. - Reworked
setup-agent-sequencing-codex-no-daemon.test.tsaroundprepareGate/finishSetuphelpers and added a case that installscodexonly after the gate is already waiting, asserting the launch gets exactly one--no-daemon.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
…ner and bound the gate test
There was a problem hiding this comment.
ℹ️ No new issues in this incremental delta. The new commit is a behavior-preserving refactor plus test hardening; the earlier
wait-for-setupPowerShell-gate limitation is unchanged and remains documented.
Reviewed changes
- Folded the SSH/WSL skip into
planCodexNoDaemonLaunchas a requiredexecutesOnThisHostflag, so both spawn-options builders pass it instead of guarding the call with a ternary. Equivalent behavior: the planner still returnsnullsynchronously for remote and WSL launches. - Un-exported the daemon
UNWRAPPEDsentinel;createPtyShellLaunchPlannow usesnullfor the configured-shell-unwrapped branch and foldsterminalShellArgsinto a??chain, preserving the old ternary's precedence. - Bounded the sequenced-gate test with
waitTimeoutSeconds: 5and anafterEachthat kills spawned gates, so a failed assertion can no longer leave a two-hour poll running.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
There was a problem hiding this comment.
Actionable comments posted: 2
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Advanced
Run ID: e18a0805-faec-4da5-b774-cdfee1de05da
📒 Files selected for processing (7)
src/main/daemon/pty-subprocess/shell-launch-plan.tssrc/main/daemon/shell-ready.tssrc/main/ipc/pty/ipc/spawn-options.tssrc/main/ipc/pty/runtime/spawn-options.tssrc/main/pty/codex-no-daemon-launch-command.test.tssrc/main/pty/codex-no-daemon-launch-command.tssrc/shared/setup-agent-sequencing-codex-no-daemon.test.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 3 remain after this review.
…heck Also pin the setup-gate test's fake codex ahead of path_helper's PATH.
There was a problem hiding this comment.
ℹ️ No new issues in this incremental delta. The one new commit deletes the pane's requested env keys from the merged environment before the Codex launch planner reads the
ORCA_CODEX_ISOLATEopt-out, plus a setup-gate test hardening.
Reviewed changes
- Threaded
envToDeletethroughLocalCodexLaunch, soplanCodexNoDaemonLaunchnow deletes those keys from the merged{ ...process.env, ...launch.env }before checkingORCA_CODEX_ISOLATE. Both spawn-options builders pass their deletion lists (ctx.combinedEnvToDelete,ctx.spawnOptions.envToDelete); the overlay scrub alone could not remove a value inherited fromprocess.env. - Added coverage that fails without the fix: a stubbed inherited
ORCA_CODEX_ISOLATE=0plusenvToDelete: ['ORCA_CODEX_ISOLATE']now resolves to a single--no-daemon, withvi.unstubAllEnvs()in teardown. - Hardened the sequenced-gate test:
.bash_profilere-prepends the fixturebinahead of macOSpath_helper's PATH reordering, andCODEX_HOMEis pinned to the temp root so no real~/.codexis touched.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
Drops the always-wrap for plain zsh and fish, the configured-args guard that only served it, and the v38 daemon bump: the daemon's launch configs and generated wrappers are byte-identical to main again. Keeps the host-side --no-daemon for cmd.exe and path-named launches and the setup gate's codex function.
There was a problem hiding this comment.
ℹ️ No new issues in this incremental delta. The one new commit reverts the plain zsh/fish wrapping added earlier in the PR, so those tabs launch exactly as on main again.
Reviewed changes
- Reverted plain zsh and fish tabs to their main launch config on both the daemon and local PTY transports, so only an Orca-launched agent (or a pane with a startup command) reaches the codex wrapper. A hand-typed
codexin a plain zsh/fish tab no longer gets--no-daemon, matching main and the PR body's "Not covered". - Removed the now-unused
keepsConfiguredShellUnwrappedhelper, theUNWRAPPEDre-export, the two wrapping test files, and the daemon protocol 38 bump.PROTOCOL_VERSIONis back to main's 37 and the compatibility contract json/ts are untouched. - Left the host-side
planCodexNoDaemonLaunchpath, the POSIX setup gate, andsrc/shared/codex-shell-function.tsunchanged.
ℹ️ Nitpicks
- The "Not covered" bullet explains plain tabs are left unwrapped because "bash would lose login-shell mode", but that reason is bash-specific: zsh and fish keep their
-llogin shell. Worth stating why plain zsh/fish were reverted too, so the scope decision is legible.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
#23933 added a --help capability probe that runs on every Codex launch and is deliberately uncached. This spec puts a fake codex on PATH that records every invocation, so the probe landed in the spawn ledger and the first-mount assertion saw two launches where one was expected. Verified on plain main: 8/8 repetitions fail at spec line 617 with [{args:['--help']}, {args:['--dangerously-bypass-approvals-and-sandbox',...]}], so the breakage is independent of the retention change this branch makes.
…aunches without the shared server (#23933) * fix(terminal): give plain shells and cmd.exe Codex launches --no-daemon Plain bash, zsh and fish tabs were never wrapped, so a typed codex skipped the shell function that adds --no-daemon. Wrap them (bash keeps its prompt and DEBUG trap untouched unless Orca asked for command markers), add --no-daemon host-side where no function can run (cmd.exe, path-named binaries), and move new tabs to a v38 terminal daemon so they get the new wrappers. * fix(terminal): keep plain bash a login shell and give the setup gate the codex function Plain bash and Git Bash tabs launch exactly as before again: the rcfile wrapper would have made every one a non-login shell. Plain tabs on the user's configured shell args stay unwrapped on both transports. The wait-for-setup gate's bash -lc now defines the codex function, so a sequenced Codex launch gets --no-daemon from the binary it actually runs. * fix(terminal): define the setup gate's codex function after setup finishes Setup can be what puts codex on PATH, so defining the function before the marker wait found no binary and skipped --no-daemon. * refactor(terminal): fold the SSH/WSL guard into the Codex launch planner and bound the gate test * fix(terminal): honour the pane's env deletions in the Codex opt-out check Also pin the setup-gate test's fake codex ahead of path_helper's PATH. * revert(terminal): launch plain zsh and fish tabs exactly as on main Drops the always-wrap for plain zsh and fish, the configured-args guard that only served it, and the v38 daemon bump: the daemon's launch configs and generated wrappers are byte-identical to main again. Keeps the host-side --no-daemon for cmd.exe and path-named launches and the setup gate's codex function. (cherry picked from commit 26bb7c2)
…spawn (#24440) * test(e2e): fake Codex answers the --no-daemon --help probe without a spawn Since #23933 Orca runs `codex --help` before a path-named Codex launch. The fakes logged it as an agent spawn and held the probe for its 5 s timeout. Move the app-server refusal and --help answer into one shared FAKE_CODEX_LAUNCH_PROBES_SOURCE used by every fake Codex. * test(e2e): stop asserting the dispatch capability column a current worker no longer has #23994 stopped minting the per-dispatch capability, so capability_hash is null. The --help spawn failure used to stop this test before it got here.

ELI5
Codex 0.156+ runs every Codex window through one shared background server unless it is started with
--no-daemon. Orca already adds that flag through a smallcodexshell function (#23900). Some Codex launches that Orca builds itself never reached that function:/opt/homebrew/bin/codex)Those launches still shared one server. Every tab then reported its status as the first tab, and closing the first tab killed the others (#22873 / STA-8467). This PR gives those launches
--no-daemontoo.What Changed
Before: those three kinds of launch ran Codex on the shared server.
After: they run with exactly one
--no-daemon, following the same rule as the shell function. Nothing else changes: plain bash, zsh, fish, Git Bash, WSL and PowerShell tabs launch exactly as on main.--no-daemonitself where no shell function can run. When Orca starts a local Codex terminal, the spawn step puts--no-daemonright after the Codex program. This covers the Codex button,worktree create --agent, worker start, resume/restore, and custom command overrides. The code is insrc/main/pty/codex-no-daemon-launch-command.ts, called from both spawn-option builders.agents,queue,--no-daemon,--remoteand--remote=*; skip when the terminal's final environment hasORCA_CODEX_ISOLATE=0(after the pane's own env deletions); add the flag only ifcodex --helplists it.runProcess, with a 5 s limit and no cache.bash -lc, which never reads Orca's shell wrapper.src/shared/codex-shell-function.tsso shared code can embed it.codex, and SSH gates get it too.ORCA_CODEX_LAUNCH_PREFLIGHT … prepare-codex) before starting Codex, which gated launches previously skipped.The terminal daemon's launch configs and generated wrappers are byte-identical to main. I compared launch configs for plain, history, overlay and startup-command tabs across bash, zsh, fish, pwsh and PowerShell on both transports, plus Git Bash, cmd.exe, PowerShell and WSL on Windows. The wrapper snapshots are unchanged. So no daemon protocol bump is needed.
Not covered (unchanged from main)
codextyped by hand in a plain shell tab. Wrapping plain tabs would change how they start: bash would lose login-shell mode.-EncodedCommandlimited by cmd.exe's 8191-character command line.Why
codexthan the one the tab runs, a 0.155 binary would get--no-daemonand exit with status 2. For cmd.exe and absolute paths the check is exact. For the same reason, the setup gate carries the function rather than a host-side rewrite.-c features.daemon_auto_start=false: it does not stop a TUI from joining a server that is already running.ORCA_CODEX_ISOLATE=0into the spawn environment works here too.Linked Issue
Refs #22873 (STA-8467). Follow-up to #23900 and #23907.
Visual Proof
N/A. Nothing on screen changes; the effect is Codex's argv.
Testing
Unit tests:
codex-no-daemon-launch-command.test.tscovers each exclusion, the opt-out, an opt-out the pane deletes, SSH/WSL, an unsupported binary, barecodexleft to the function, and cmd.exe PATH lookup.setup-agent-sequencing-codex-no-daemon.test.tsruns the real gate under bash with a fakecodexpinned ahead of path_helper. It covers a supported binary, an old binary,agents, the opt-out, andcodexinstalled by setup. The supported case fails on main.pnpm tc, oxlint andcheck:code-quality:changedpass.repro-13767tests that also fail on main on this machine.Live runs (earlier commits; the host-side code is unchanged in substance since):
terminal create --command,worktree create --agent codexand an absolute-path command each got exactly one--no-daemon.~/.codexstayed byte-identical.codex --yoloran real Codex 0.159 ascodex.js --no-daemon --yolo.← for agentsfooter and of popup windows on Windows. That needs a signed-in Codex and a visible desktop.