Repository navigation
fix(codex): Orca-owned Codex homes never start Codex's shared background server - #23924
brennanb2025 wants to merge 9 commits into
Conversation
Problem: since Codex 0.157 the first interactive codex on a CODEX_HOME starts one shared background server that later sessions join. It runs every session's hooks and tools with the first tab's Orca environment (status and orchestration messages land on the wrong tab), dies with that tab, and on Windows runs without a console so every hook and command flashes a window. #23900 adds --no-daemon through Orca's codex shell function, but cmd.exe tabs, scripts and Quick Commands, absolute paths, npx, "command codex" and user overrides never reach it. Orca already wrote features.daemon_auto_start = false into the homes it owns, but only when the socket path was too long to bind, so short managed homes (every native Windows pane, Linux managed accounts) kept it on. Change (a backup behind #23900's flag, not a replacement): - The existing guard now writes daemon_auto_start = false into every home Orca owns: the managed runtime home (also the retained legacy shared home), managed account homes, resume homes and WSL managed homes, on every launch-prep path that already applied it. It never writes into a home named .codex (the user's own, host or WSL), and strips a stray one there. The marker is reworded; the old marker is still recognized so lines written by earlier builds are rewritten or stripped as Orca's own. - The setting stops Codex starting a server, not joining one already running (left from before the update, or started by codex agents, codex remote-control start or codex app-server daemon start). Launch prep (new launches and resumes) now checks the owned home's control socket in the background and logs once while a server is live (POSIX connect) or may be live (Windows: socket file present; Node cannot connect to AF_UNIX there). It never blocks the launch and never stops the server. WSL homes are not probed from the host. Whose setting wins: an explicit daemon_auto_start the user wrote (in ~/.codex/config.toml, which Orca mirrors in, or set inside the managed home, e.g. codex features enable) is kept as written, true or false, because the user asked for it. The one exception is a home whose socket path is too long to bind, where Orca still forces false as before (Codex cannot start otherwise). This matches #23900, which lets the user's explicit choice (ORCA_CODEX_ISOLATE=0, or arguments that need the server) turn its flag off. ORCA_CODEX_ISOLATE lives in the pane's shell, which the host cannot read, so it still governs only the --no-daemon flag: with ORCA_CODEX_ISOLATE=0 alone, owned homes no longer auto-start a server; setting daemon_auto_start = true in ~/.codex restores it. Needs owner confirmation. Trade-off, same as #23900: in Orca-owned homes nothing auto-starts the shared server, so "Run in background" does not outlive a tab and codex agents does not see Orca sessions. Older Codex (0.150-0.155) only logs an unknown feature key; 0.156 has it off by default. No wire change.
Review follow-up to the previous commit. - Orca-owned homes now always get features.daemon_auto_start = false, including over an explicit true mirrored in from ~/.codex (early 0.156 adopters turned it on from /experimental). Honouring that true would bring the shared-server bugs back only for cmd.exe and script launches, while #23900's shell function adds --no-daemon regardless of config. Orca logs once per home when it overrides a user's true; the user's ~/.codex is never changed. The earlier "user value wins" rule is gone. - The shared-server socket check at launch prep is removed. It only wrote a main-process log line; what Orca should do about a leftover server is an open owner question for a follow-up. - The warning for an inline features table now tells users to rewrite it as a [features] table instead of adding daemon_auto_start = false to ~/.codex, which would also turn the server off in their own terminals. - The ".codex home" name heuristic is replaced by the caller's ownership: every caller passes the mirror's runtime home, which Orca owns, and the user's ~/.codex reaches the mirror only as its read-only source. The parameter is renamed orcaOwnedHomePath to state that contract. - Comments now say what is actually new: most account homes were already over the socket limit, so the new reach is mainly the shared runtime home on Windows, and on Linux when it is not on the real-home lane.
Round-2 review follow-ups. - syncSystemConfigIntoManagedCodexHome and ensureCodexDaemonSocketGuard now refuse, and log once, when the target home is the source home after normalizeRuntimePathForComparison. The WSL ~/.codex was protected only by a plain === in WSL launch prep; differing spellings (\\wsl$ vs \\wsl.localhost, distro casing) could slip past it. - ensureCodexDaemonSocketGuard and its writer move to codex-owned-home-daemon-guard.ts, next to the refusal, keeping codex-config-mirror.ts under the line limit. - The override warning no longer claims ~/.codex/config.toml was the source; a true set only inside Orca's home is replaced there. - Documented that [profiles.X.features] and -c overrides still win.
…still strip it An older Orca recognizes only the original marker text. After a downgrade it could not strip a reworded line, so seeding ~/.codex/config.toml from the runtime config copied Orca's override into the user's home, and the stall check reported a false missing-source stall.
The override is now ownership policy, not a socket-path-length fix: rename the modules and functions to match, drop the socket-path measurement that only picked a warning sentence, and correct the override warning, which claimed Orca never edits ~/.codex/config.toml.
…ned-home-no-shared-server
…in Orca-owned homes Problem: ORCA_CODEX_ISOLATE=0 is the documented opt-out from the codex shell function's --no-daemon. Now that every Orca-owned Codex home carries [features] daemon_auto_start = false, skipping --no-daemon no longer brings the shared server back, so the opt-out silently did nothing. Change: with ORCA_CODEX_ISOLATE=0 the bash/zsh, fish and PowerShell functions prepend -c features.daemon_auto_start=true instead of --no-daemon, under the same conditions --no-daemon is added (no agents/queue/--no-daemon/--remote argument, and codex --help lists --no-daemon, so Codex 0.155 and older never see the key). The command-line value beats config.toml, and Codex allowlists features.daemon_auto_start among the -c overrides that do not force embedded mode. Stale test comments that tied the override to sun_path length are reworded. Caveat: a launch that also passes a -c override Codex does not allowlist (for example reasoning effort) still runs without the shared server.
…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.
Review status: code review done, Windows QA not done yetThe problem. Since Codex 0.156, the first What changes for users. Every Codex home Orca owns (the managed runtime home, managed account homes, resume homes, WSL managed homes) now always has Decided during review (owner calls). Orca-owned homes have no opt-out: Fixed in this review
Deferred (P3, no user impact)
Verified
Not verified
|
|
Closing: Codex deprecated daemon_auto_start, and #41873 stops Orca regenerating it. |
ELI5
Since Codex 0.156, the first
codexyou start runs one shared background program, and every later Codex quietly plugs into it. That shared program keeps the first tab's identity, dies when the first tab closes, and on Windows opens a new console window for every command or hook it runs. Orca's merged #23900 stops this for Codex started through Orca's shells, but not for Codex started in cmd.exe tabs, scripts or Quick Commands. This PR turns the shared program off in the Codex settings folders Orca itself owns, so no Codex launched there can start it, however it was launched.What Changed
The problem users see (Windows especially): in an Orca cmd.exe tab running Codex 0.157+, windows pop open every time Codex runs a hook or command, including right after starting Codex or interrupting it. It was recorded on 1.4.217 in cmd.exe; PowerShell and Git Bash were already fixed by #23900. In the same tabs, a second Codex reports as the first one, and closing the first tab ends the others. Scripts and Quick Command wrappers that call Codex directly behave the same way on every platform, for anyone using an Orca-managed Codex account.
Scope: Codex homes Orca owns: the managed runtime home, managed account homes, resume homes and WSL managed homes. On native Windows every local pane uses an Orca-owned home, so there it covers every local pane. Not affected: your own
~/.codex(never written; the config mirror refuses a target whose normalized path is the source home), Codex older than 0.156 (it ignores the setting), and SSH hosts. Not covered: panes that use your own home, namely the default account on macOS and Linux when it runs on your real~/.codex, and WSL panes with no WSL managed account. There only #23900's shell function applies, so cmd-style and script launches still start the shared program.Before: Orca wrote
features.daemon_auto_start = falseinto its homes only when the socket path was too long for the OS (the guard from #22878). That's why macOS managed homes mostly escaped and Windows/Linux homes didn't.After: every Orca-owned home always gets
features.daemon_auto_start = false, marked as Orca's line. Atruemirrored in from your~/.codex, for example from Codex 0.156's/experimentalmenu, is overridden in Orca's homes and logged once per home;~/.codexitself is untouched. Orca's line keeps the same marker comment earlier builds wrote, so a downgraded Orca still recognizes and strips it. The inline-table warning now tells you to convertfeatures = {...}to a[features]table instead of editing~/.codex.Mechanism: the existing guard's condition is widened rather than a second mechanism added. It no longer depends on the socket path's length: every caller already passes a home Orca owns (the parameter is now
orcaOwnedHomePath), and the config mirror refuses a target whose normalized path is the source home. The guard is renamed from a socket-path guard toapplyCodexDaemonAutoStartOverride/ensureCodexDaemonAutoStartOverride.Why
Codex will fix the console windows itself. Codex's main branch now opens hooks and git without a console window. It's expected in Codex 0.160/0.161 and isn't in any release up to 0.160.0-alpha.2. So the windows are a side benefit of this PR until users update. The main reason for this PR is the shared-server identity bugs, which Codex's console fix doesn't change: in cmd.exe tabs, scripts and Quick Commands, a second Codex reports as the first one, and closing the first tab ends the others. #23900 fixed these for PowerShell, Git Bash, bash, zsh and fish, but it can't reach those launch paths.
npxand user command overrides, which a shell function can't. This backs up fix(terminal): run Codex in Orca terminals without the shared background server #23900's--no-daemon; it doesn't replace it.--no-daemonhost-side would still miss scripts and hand-typed launches in cmd.exe.codex agents,codex remote-control startandcodex app-server daemon startstart one regardless. A leftover program from before the update keeps serving until it exits.codex agentsdoesn't see sessions in Orca-owned homes.ORCA_CODEX_ISOLATE=0still makes the shell function skip--no-daemon, but it no longer brings the shared program back in an Orca-owned home, because the home's setting keeps auto-start off. Orca doesn't pass-c features.daemon_auto_start=truefor it: in long homes (macOS managed accounts) the shared program can't bind its socket, and Codex exits when that start fails. The opt-out still applies in your own~/.codex.Linked Issue
Refs #22974 (Codex refusing to start in cmd.exe; it may no longer reproduce with Codex 0.159, so the Windows QA will check)
Related: #23591, #23518, #23240, #22836, #22217, #22873
Visual Proof
Pending. The review loop runs live QA on the Windows high spec machine (cmd.exe tab, Codex 0.159: start, run a command, interrupt) and will attach before/after recordings here.
Testing
I manually tested these changes locally
Automated tests added/updated, or explained why not below
66 named test files pass (763 passed, 6 skipped), including real mirror passes that check
~/.codexstays untouched and the override warning fires once. After the review fixes: 47 related codex, account and startup test files, 597 passed; the written marker text is pinned in tests.The key tests fail when the rule is removed: the socket-length check put back, the user-home refusal off, "your value wins" put back.
Typecheck clean (node, cli); oxlint, oxfmt and the changed-code quality gate clean.
Not yet run live on Windows or Linux. The review loop's QA covers Windows.
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
Ensure no issues in: Security, Cross-platoform support (Linux, Windows, Mac), Remote SSH, Mobile, general backwards compatibility, performance
[profiles.X.features] daemon_auto_start = trueor-c features.daemon_auto_start=truestill wins; only hand edits produce those. Per launch,codex -c features.daemon_auto_start=truein a short home (Windows, Linux) starts the shared program on purpose.Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)