Repository navigation
fix(terminal): run Codex in Orca terminals without the shared background server - #23900
Conversation
|
This comment has been minimized.
This comment has been minimized.
…implify it Wrap Git Bash and daemon fish only when Orca delivers a startup command, so plain tabs keep their login shell. One POSIX/fish/PowerShell body with a shared denylist, a flat PowerShell probe, and tests for probe skipping, the Windows PowerShell 5.1 lane and --no-daemon classification.
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
This run reviewed the whole PR: a shell-wrapper change that stops Orca Codex tabs from joining Codex 0.156+'s shared background app-server.
- Wrapper installed in every wrapped terminal —
codex()is now defined whenever a realcodexbinary resolves, rather than only when a managed hook preflight is set; theprepare-codexcall stays runtime-gated onORCA_CODEX_LAUNCH_PREFLIGHT. --no-daemonrule — prepended first unless a whole argument isagents/queue/--no-daemon/--remote/--remote=*, mirroring the denylist in bash, zsh, fish and PowerShell.- Support probe —
codex --helpis checked on every launch (no cache), so 0.155 and older keep launching unchanged; POSIX and fish redirect stdin for the probe. - Opt-out —
ORCA_CODEX_ISOLATE=0, read per call, plus WSLENV/upassthrough for WSL. - Windows Git Bash — always starts from Orca's rcfile when the wrapper tree exists (was managed-only).
- Relay and zsh layout — the wrapper moves outside the
overlayfeature guard; relay overlays install it without hook prep. - Tests and CI — a real-shell argv table plus a pinned real-binary contract, and new change-scope prefixes for the contract job.
ℹ️ Notes
src/main/providers/agent-foreground-process-git-bash.win32.test.tsstill labels its no-preflight caselogin shell; since this PR makes that path use the rcfile wrapper whenever the tree exists, the label (and the matching comment inwindows-shell-args.test.ts) no longer describes what runs. Worth a rename next time the file is touched.src/main/pty/wsl-orca-env.test.tsnever setsORCA_CODEX_ISOLATE, so the newORCA_CODEX_ISOLATE/upassthrough entry has no direct assertion; the existingORCA_CODEX_LAUNCH_PREFLIGHT/pcase is a natural place to add one.
I also checked the one place that looked risky — the fish denylist calling string match ... $argv with empty $argv on a piped stdin. Running the real wrapper against fish 3.7 with a fake codex showed stdin is preserved (printf piped | codex reaches Codex as ARGV|--no-daemon|stdin=piped), so there is no stdin-consumption regression.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
This run re-reviewed only what landed since the prior pullfrog review at fc79028: 4319993576 ("narrow the codex wrapper to Orca-launched shells and simplify it").
- Narrowed Windows Git Bash —
getGitBashLaunchCommand()uses Orca's rcfile only when a managed preflight or a startup command is present, so a plain Git Bash tab is a login shell again. - Simplified the flag rule — every shell now builds one argument list with
set -- --no-daemon "$@"/set argv --no-daemon $argvfrom a sharedCODEX_SHARED_SERVER_ARGSand pattern, instead of a separate if/else invocation. - PowerShell drops the child scope — hook prep and the
--helpprobe are each wrapped intry/catchrather than toggling StrictMode/ErrorActionPreference;$inputforwarding and the$LASTEXITCODEassignment are kept. - Wrapper is unconditional in the wrapper templates —
codexLaunchPreflightis removed fromZshWrapperRestoreSpec(local/daemon/relay specs updated); the relay overlays install it with the runtime env gate doing the gating. - Markerless fish wraps when a startup command exists — daemon
getShellLaunchConfiggainshasStartupCommand, mirrored by the local provider'sstartupCommandparameter. - Tests — new
codex-launch-shell-wrapping.test.ts, a Windows lane incodex-shell-no-daemon.test.ts(.cmdshim + powershell 5.1, no longer win32-skipped), and a plain-vs-launch Git Bash case. All pass locally (bash/pwsh; fish/zsh unavailable here).
ℹ️ Hand-typed codex is only covered inside a shell Orca wraps
The narrowing makes the fix depend on the pane being wrapped at all: a plain Windows Git Bash tab (--login -i) and a non-overlay plain bash/fish terminal never define the codex function, so a hand-typed codex there still joins the shared server. Orca-launched Codex (always carrying a startup command) and shells already wrapped for an overlay/history are covered, so the primary #22873 path is fixed — but the description's "the one function covers typed codex" now overstates it. Worth confirming this is intended and noting the exception in the description.
Technical details
# Typed-codex coverage after the narrowing
## Affected sites
- `src/main/providers/windows-shell-args.ts:220` — `getGitBashLaunchCommand(Boolean(codexLaunchPreflightCommand) || Boolean(startupCommand))`; `false` yields `GIT_BASH_UTF8_LOGIN_COMMAND`, which never sources Orca's rcfile, so no `codex()` exists.
- `src/main/providers/local-pty-finalize-environment.ts:117` — a plain terminal has no startup command and no overlay key, so `selectShellStartupFeatures` returns `[]` and `getShellLaunchConfig('/bin/bash', [])` returns `UNWRAPPED`.
- `src/main/daemon/shell-ready.ts:154` — same `features.length === 0` early return for bash.
## Required outcome
- Either accept the gap and make the description precise ("covers Codex that Orca launches; a hand-typed `codex` in an unwrapped plain terminal still joins the shared server"), or wrap those shells too.
- Codex started by Orca (startup command present) is unaffected: `hasStartupCommand` forces the `markers` feature and therefore the wrapper.
## Open questions for the human
- Is a plain Windows Git Bash tab intentionally outside the fix, given PowerShell panes still get the wrapper from the always-on OSC133 bootstrap?DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. 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 (2)
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review. 📝 WalkthroughWalkthroughShell wrappers now add Priority: ➖ Normal Severity of issue fixed: Medium Merge Risk: ⚪ Minimal · up to Relay Codex launches will not run the inherited hook-preparation command, matching the stated relay behavior. No material merge risk is apparent. Security Architecture ReviewSecurity architecture risk: 🔵 Low · up to Per-terminal Codex isolation addresses cross-tab identity mixing without a demonstrated new trust-boundary bypass. It remains conditional on the shell wrapper and installed Codex support, so some sessions can retain the older shared-server behavior. Retained concerns Security review detailsSecurity Blast Radius
Trust Boundaries and Controls
Resilience and Maintainability Implications
🚥 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.
✅ No new issues found.
Reviewed changes
This run reviewed the one commit that landed since the prior pullfrog review at 4319993 — 6288b3a ("never pass an inherited Codex preflight into relay panes").
- Relay drops the Codex preflight env —
PtyHandler.buildSpawnEnvnow deletesORCA_CODEX_LAUNCH_PREFLIGHTfrom every relay pane env, after the env augmenters and before theenvToDeletepass, so neither a value inherited from the relay process nor one forwarded by the client can reach a relay pane'scodex()wrapper. The relay never mints one of its own (the desktophost-env/assembly.tsis the only setter), so nothing legitimate is stripped. - Test covers both sources —
pty-handler-spawn-environment.test.tsasserts the variable is absent from the spawned env for both theprocessandclientorigins, withprocess.envrestored in afinally.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
…ORCA_CODEX_ISOLATE=0 The previous commit made the codex shell function pass -c features.daemon_auto_start=true when ORCA_CODEX_ISOLATE=0. In a home whose socket path exceeds sun_path (macOS managed account homes), that makes Codex auto-start a server it cannot bind, and Codex treats that failure as fatal, so codex would not start at all. Orca-owned homes now have no opt-out; the shell function is back to #23900's behaviour. A per-launch -c features.daemon_auto_start=true is the manual route in short homes. The test comment rewording from the previous commit stays.
…er (#23929) * feat(settings): add a setting to run Codex terminals on Codex's shared server Off injects ORCA_CODEX_ISOLATE=0 into new terminals on every host (local, daemon, SSH relay, WSL), which the codex shell wrapper from #23900 reads to skip --no-daemon. On (the default) injects nothing. * feat(terminal): announce per-terminal Codex servers once Shows a one-time toast the first time a Codex terminal starts, with an Open Settings action that lands on the new Codex server setting. The seen flag persists in UI state and is set when the toast is shown. * fix(settings): drop the status warning from the Codex server setting * fix(terminal): simplify the Codex shared-server notice * fix(terminal): say agent status in the Codex notice * fix(settings): hide the Codex server setting from paired web search Gives its search entry an id and gates it with includeCodexTerminalServerIsolation, as the other host-only rows are, so a paired web client cannot find a row it never renders. Its search keywords now use catalogued agents-search keys instead of missing ones; CODEX_ISOLATE_ENV is no longer exported; the toast id comment names the case it guards. * test(settings): assert the Codex server search gate through the metadata builder Calling getAgentsPaneSearchEntries directly stayed green with the web gate deleted; the metadata builder test fails without it.
…er (#23929) * feat(settings): add a setting to run Codex terminals on Codex's shared server Off injects ORCA_CODEX_ISOLATE=0 into new terminals on every host (local, daemon, SSH relay, WSL), which the codex shell wrapper from #23900 reads to skip --no-daemon. On (the default) injects nothing. * feat(terminal): announce per-terminal Codex servers once Shows a one-time toast the first time a Codex terminal starts, with an Open Settings action that lands on the new Codex server setting. The seen flag persists in UI state and is set when the toast is shown. * fix(settings): drop the status warning from the Codex server setting * fix(terminal): simplify the Codex shared-server notice * fix(terminal): say agent status in the Codex notice * fix(settings): hide the Codex server setting from paired web search Gives its search entry an id and gates it with includeCodexTerminalServerIsolation, as the other host-only rows are, so a paired web client cannot find a row it never renders. Its search keywords now use catalogued agents-search keys instead of missing ones; CODEX_ISOLATE_ENV is no longer exported; the toast id comment names the case it guards. * test(settings): assert the Codex server search gate through the metadata builder Calling getAgentsPaneSearchEntries directly stayed green with the web gate deleted; the metadata builder test fails without it. Backport: #23744 (workspace trust setting) is not on this branch, so its adjacent setting, search entry and test are left out. (cherry picked from commit a0abcb6)

ELI5
Since Codex 0.157, the first
codexyou open starts one shared background server, and every later Codex tab quietly plugs into it. That server runs every tab's hooks and tools with the first tab's Orca identity, and it dies when the first tab closes. So in Orca every Codex tab reported as the first tab, and closing that tab killed all the others. Orca now starts Codex with--no-daemonin the terminals it launches Codex in (and wherever its shell function is installed), so each tab runs its own server again.What Changed
Before (Codex 0.156+ in Orca):
After: each Orca Codex tab keeps its own in-process server, so status and orchestration stay with the tab that produced them, and closing one tab leaves the others running. Codex 0.155 and older launch exactly as before.
Mechanism: Orca already writes a
codexshell function into its terminals' startup files (codex-shell-launch-preflight.ts). Today it exists only in managed-account terminals and only runsagent hooks prepare-codex. This PR:prepare-codexstep stays gated onORCA_CODEX_LAUNCH_PREFLIGHT, exactly as today, so it never runs against~/.codex; the relay now drops any inheritedORCA_CODEX_LAUNCH_PREFLIGHTfrom pane env, so relay panes never run it.--no-daemonfirst unless any argument is exactlyagents,queue,--no-daemon,--remoteor--remote=*(those need the shared server or would make Codex exit 2). A subcommand is always a whole argument, so this also catchescodex -m x agents.codex --helpfor--no-daemonon every launch (25 ms native, ~80 ms npm). A cache would go stale across upgrades: a stale "yes" breaks 0.155 (exit 2), a stale "no" brings the shared server back.export ORCA_CODEX_ISOLATE=0in your shell rc, read on every call. It is forwarded into WSL throughWSLENV, and rides the existing SSHpty.spawnenv map (no new wire field).src/cli/codex-command-classification.tsknows--no-daemonis a flag, so it's no longer misread as a subcommand.Almost every launch path is typed into the shell, so the one function covers agent launch (
codex '<prompt>'),worktree create --agent,worker-start, automations and resume, plus hand-typedcodexin any wrapped tab.Trade-off: Codex "Run in background",
codex agents, and opening the same session from the Codex desktop app or an IDE while it's open in Orca don't see sessions started in Orca. Each tab also runs its own server, so many tabs use more memory. A settings toggle and a one-time notice are a follow-up;ORCA_CODEX_ISOLATE=0restores the old behaviour today.Why
--no-daemonboth stops a tab from starting the shared server and from joining one (0.156+). Orca's existingdaemon_auto_start = falseguard only stops starting, and it never applies to~/.codex.codex -- agents,-m agents,codex resume agents).codex. A host-side flag for Orca-built commands (which would also cover cmd.exe and a stale terminal daemon) is a follow-up.Borrowed from #23791, each for a concrete failure:
Set-StrictMode -Version Latest/$ErrorActionPreference = 'Stop'(where Windows PowerShell 5.1 turns redirected native stderr into an error), a noisy or failing prep or probe would otherwise abort the launch. A failed probe just launches without the flag.$MyInvocation.ExpectingInput): without it,'prompt' | codex exec -loses stdin once the function exists in every PowerShell pane.localfor the function's variables:warn_create_globalwould print a warning on every call.Not adopted: his argv parser and option allowlist (the denylist above instead); the
ORCA_CODEX_LAUNCH_POLICYenv marker (the function readsORCA_CODEX_ISOLATEitself); restoring$LASTEXITCODEaround prep/probe (the launch sets it anyway); loading the PowerShell wrapper from a file (the smaller wrapper here costs less of the command-line budget, see Notes); cmd.exe prep regating and setting the preflight in every pane (this PR doesn't change when the preflight is set); always wrapping Git Bash, relay PowerShell/fish login shells and plain fish tabs (that changes plain tabs' startup chain; listed as gaps).Linked Issue
Fixes #22873
Supersedes #23791
Visual Proof
N/A: no UI change. The difference is the Codex process argv (
--no-daemon) and where hooks report; see Testing.Testing
Automated:
codex-shell-no-daemon.test.tsruns the full argv table in real bash, zsh, fish, pwsh and (on Windows) Windows PowerShell 5.1 against a fakecodex: 18 argv shapes get the flag, 16 don't (denylist,--remote, a second--no-daemon, the known harmless skips), and denylisted launches never run the--helpprobe. Nothing is added when--helplacks the flag or withORCA_CODEX_ISOLATE=0(read per call); a version swap mid-shell re-probes; piped stdin and the exit status reach Codex; a useralias codex=…defined first still applies in bash and zsh; zsh underwarn_create_global+no_unsetstays silent; PowerShell under StrictMode Latest + Stop with a failing, noisy prep still launches. Droppingqueuefrom the denylist fails the table in every shell. CI'sshell contractsjob runs it withORCA_REQUIRE_PWSH=1.codex-launch-shell-wrapping.test.ts: an Orcacodex '<prompt>'launch wraps bash, zsh (no history file, no overlay) and fish on both the local and daemon transports. Daemon fish failed this before the fix.codex-no-daemon-binary-contract.test.ts:--helplists--no-daemon, and--no-daemon <sub> --helpexits 0 for every subcommandcodex --helplists except the wrapper's denylist. Passes on 0.156.1, 0.157.1, 0.158.0; fails on 0.155.1 as it should. Runs in CI in the existing Codex contract job against a pinned 0.158.0.ORCA_CODEX_LAUNCH_PREFLIGHTnever reaches the pane (fails without the fix), a classifier test forcodex --no-daemon resume|exec, and updated shell-wrapper snapshots (local, daemon, relay).src/main/pty,src/relay,src/cli,src/main/daemon,src/main/runtime,src/main/providers,src/main/ipcand the live-shell suites: 21,631 passed. The 2 failures arerepro-13767-shell-ready-marker-lost-to-exec, which fails identically onmainon macOS.pnpm tc, oxlint,check:code-quality:changedand oxfmt are clean.Live, macOS, real Codex (isolated headless dev runtime built from this branch, isolated
CODEX_HOME, real turns):ORCA_CODEX_ISOLATE=0, same asmain)--managed-daemonserver, child of A's Codexcodex --no-daemon, no server processcommand codexin tab E)--no-daemon, each turn reported on its own tab; closing E leaves F answeringworker-start --agent codex; A finishes,worker-releaseA, B (runningsleep 60) keeps goingworker_doneon its own taskworker-startreadiness, plain launch (no-c)ready/input_acceptedin 4–8 s, tasks completedterminal create --command "codex '…'"--no-daemoncodex login status,codex execLogged in, exec answeredcodex agents,codex -m x agents,codex resume --remote …codexLive, Windows (
windows 2): the argv-table suite above passed on the host under Windows PowerShell 5.1 and pwsh 7.6.6 (50 passed, including StrictMode/Stop and piped input). An earlier standalone run of the same table passed in Git Bash 5.3 and WSL Ubuntu 24.04 bash 5.2, and Git Bash started with Orca's generated rcfile added the flag.Not verified live: SSH relay (tests and snapshots only); an Orca build of this branch on Windows or WSL with a real Codex.
AI Disclosure
Review
Agent skill upstream boundary
docs/reference/agent-skill-sharing-upstream-boundary.mdand copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.Notes
Known gaps (unchanged from today's behaviour):
codexin tabs Orca doesn't wrap keeps using the shared server: plain bash, fish and Git Bash tabs with no startup command, zsh tabs with no Orca overlay and no history file, relay fish/PowerShell and native-Windows relay shells, relay zsh without the remote CLI bridge, and tabs with custom shell args. Orca-launched Codex in those shells is covered. Widening wrapping would replace users' login startup chain, so it's left for a follow-up.command codex, absolute paths,npx @openai/codex,env X=1 codex, scripts, user command overrides and cmd.exe terminals. In fish and PowerShell a user's own alias or function namedcodexalso wins.codex remote-control start/pairandcodex app-server daemon starttyped in an Orca terminal still start a shared server with that terminal's environment. No flag prevents that.Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred). Typecheck, changed-file lint and the suites above pass locally, and the build ran; CI covers the rest.