You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Keep Windows Codex chats on their own server so Stop is accurate - #48073
On Windows, with the experimental "Shared Codex servers" setting on, pressing Stop in a Codex chat could say the chat's command had ended while it was still running. Windows can't tell which chat started which process under a shared server. Until it can, Windows chats each get their own Codex server again, the same as with the setting off.
What Changed
Before: on Windows with the setting on, chats leased a thread on a shared Codex app-server. Stop treated an empty or fully stopped terminal list as proof the chat's work ended, but nothing checked that chat's own processes, and the shared server (and its job object) stayed alive for the other chats.
After: codexConnectionOpener returns the per-chat server on win32 whatever the setting says. Stopping the chat's own server ends its whole process tree, as it does with the setting off. macOS and Linux are unchanged.
The Windows shared-server job code stays in place, unused, until there is a per-chat way to prove a chat's processes ended.
Why
The other option was to keep sharing and report Stop as unverified on Windows. That would leave the long command running, and the chat would keep showing an unproven stop. Using a server per chat makes Stop accurate again and uses a path every Windows user already runs by default.
N/A: nothing in the UI changes. Which server a chat uses on Windows is decided in the main process.
Testing
I manually tested these changes locally
Automated tests added/updated, or explained why not below
Every added test fails without this change and avoids the test anti-patterns
codex-shared-server-pool.test.ts: the opener on win32 with the setting on and a pool available returns the per-chat spawner. This test fails on the old code.
pnpm check:changed passes.
Windows QA on Windows high spec, at this head, with the setting on and off: with the setting on, each chat got its own Codex server. Stop ended that chat's server within about 1.4 s, and the chat answered again after Stop. On now behaves exactly like off. The long command itself (ping -n 600) still survived Stop in both modes. That was already true before this PR; see Risk.
Performance
None for the default (setting off). With the setting on, Windows now starts one Codex server per chat, the same cost every Windows user already pays by default. No polling, timers or new work is added.
Risk
Level: Low. Only Windows users with the experimental setting on are affected; they lose the memory savings from sharing and get the default behavior instead. To back it out, revert this commit.
This PR doesn't fix a separate bug that was already there: on Windows, with the setting on or off, Stop can leave a command's child process running, because the command's PowerShell wrapper exits first and the server's tree kill can't reach the child. That is tracked in STA-17825 (proposed fix: a kill-on-close job object per Windows Codex server).
AI Disclosure
Review
Agent skill upstream boundary
Not applicable, or this change 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-platform support (Linux, Windows, Mac), Remote SSH, Mobile, general backwards compatibility, performance
Checklist
This PR is small and focused
I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
I stated the risk: what could break, for whom, and how to back it out
Before/after screenshots or videos attached for UI changes, or N/A with reason
Self-reviewed for correctness, security, and performance
Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred)
Path: chat start → codexConnectionOpener (once per chat start, Electron main) → on win32 it now returns the per-chat spawner before reading the setting.
Setting off (the default): same calls and the same spawner as base. The only work removed is the setting read on Windows.
Windows with the setting on: one Codex app-server per chat. That is the same as the default (setting off), which every Windows user already runs. The shared pool, the per-server job object and its process-table reads are no longer started on Windows. No new timers, polls, subscriptions or IPC, so idle wakeups/s match base on main, renderer and the daemon.
macOS and Linux: unchanged.
Regression classes: "expensive code newly reachable past a gate" was checked and does not apply. The gate is tighter, and the path it now routes to is the default one. No other class has matching code.
Six questions: 1, 3, 4 and 6 have no new work. For 2, ownership on Windows with the setting on is one server per chat, as in the default. For 5, Windows routes to the default path and other hosts are unchanged.
No actionable comments were generated in the recent review.
Walkthrough
codexConnectionOpener no longer accepts a Windows-sharing callback. On Windows, it selects a per-chat app-server connection regardless of shared-server availability. Tests now expect this Windows behavior and use Linux in the containment-failure test.
Merge Risk: Low · up to b3296
On Windows, enabling "Shared Codex servers" now starts one Codex server per chat, so the memory savings from sharing no longer apply. In exchange, Stop ends each chat's own process tree. Other platforms and the setting-off path are unchanged. The risk is low and limited to an opt-in experimental setting, and the memory cost is a deliberate tradeoff that the maintainers should explicitly accept.
Pre-merge checks: 4
Check name
Status
Explanation
Title check
The title names the main change: Windows Codex chats keep their own server so Stop reports accurately. The raw summary confirms the opener now returns the per-chat spawner on win32 regardless of the s…
Linked Issues check
Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check
Check skipped because no linked issues were found for this pull request.
Description check
The description is thorough and covers nearly every template section. It has a clear ELI5, a before/after account of what changed and why, a linked issue (STA-17671, follow-up to #46518), N/A visual p…
Full details: Title check
Explanation
The title names the main change: Windows Codex chats keep their own server so Stop reports accurately. The raw summary confirms the opener now returns the per-chat spawner on win32 regardless of the shared-server setting, which matches the title. The title is specific and concise.
Full details: Description check
Explanation
The description is thorough and covers nearly every template section. It has a clear ELI5, a before/after account of what changed and why, a linked issue (STA-17671, follow-up to #46518), N/A visual proof with a reason, detailed testing notes, a performance statement, and a risk section with a Low level and a revert plan. The Agent skill upstream boundary box is checked. Gaps: the 'Fixes #' line is not filled in, and it references a follow-up rather than a closing issue. The AI Disclosure section is empty. The Review section is empty. The 'Fixes #' gap matters for outside contributors, but the template says the linked issue requirement applies to outside contributors. The description is mostly complete, so the check passes.
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
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.
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 0 remain after this review.
Reviewers: two Codex reviews (gpt-6.1-sol and gpt-6.1-terra) both returned PASS with no findings. They checked the callers, macOS and Linux sharing, setting off, restart and recovery, and the updated tests.
Regression audit (blinded): SAFE.
Perf scan: clean. The marker is in the comment above; perf-surface-detect returns [].
Windows QA (Windows high spec, dev copy of this head, Codex through the real CLI):
Setting on: each chat got its own Codex server, not a shared one.
Stop ended the chat's own server in about 1.4 s.
After Stop, the chat answered again.
Setting off behaves the same as setting on.
Known, older issue: the long command's child (ping -n 600) survived Stop in both modes, setting on and off. The command's PowerShell wrapper exits first, so the server's tree kill can't reach the child. This PR doesn't change that; it's tracked separately (STA-17825).
Reference comparison (whole PR): I compared this against the established way of cleaning up one session's processes on Windows. The process that owns a session's work holds that work in its own kill-on-close job object; a tree kill (taskkill /t) only reaches processes whose parents are still alive. A server shared by many chats has no per-chat owner, so its Stop can't prove one chat's work ended. Giving each chat its own server (this PR) restores a per-chat owner. The orphan left after the wrapper exits is exactly what a per-server job object fixes, which is the plan in STA-17825.
CI: green.
Setting on:
Two chats, each with its own server:
After Stop:
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
ELI5
On Windows, with the experimental "Shared Codex servers" setting on, pressing Stop in a Codex chat could say the chat's command had ended while it was still running. Windows can't tell which chat started which process under a shared server. Until it can, Windows chats each get their own Codex server again, the same as with the setting off.
What Changed
codexConnectionOpenerreturns the per-chat server onwin32whatever the setting says. Stopping the chat's own server ends its whole process tree, as it does with the setting off. macOS and Linux are unchanged.Why
The other option was to keep sharing and report Stop as unverified on Windows. That would leave the long command running, and the chat would keep showing an unproven stop. Using a server per chat makes Stop accurate again and uses a path every Windows user already runs by default.
Linked Issue
STA-17671 (follow-up to #46518)
Visual Proof
N/A: nothing in the UI changes. Which server a chat uses on Windows is decided in the main process.
Testing
I manually tested these changes locally
Automated tests added/updated, or explained why not below
Every added test fails without this change and avoids the test anti-patterns
codex-shared-server-pool.test.ts: the opener onwin32with the setting on and a pool available returns the per-chat spawner. This test fails on the old code.pnpm check:changedpasses.Windows QA on Windows high spec, at this head, with the setting on and off: with the setting on, each chat got its own Codex server. Stop ended that chat's server within about 1.4 s, and the chat answered again after Stop. On now behaves exactly like off. The long command itself (
ping -n 600) still survived Stop in both modes. That was already true before this PR; see Risk.Performance
None for the default (setting off). With the setting on, Windows now starts one Codex server per chat, the same cost every Windows user already pays by default. No polling, timers or new work is added.
Risk
Level: Low. Only Windows users with the experimental setting on are affected; they lose the memory savings from sharing and get the default behavior instead. To back it out, revert this commit.
This PR doesn't fix a separate bug that was already there: on Windows, with the setting on or off, Stop can leave a command's child process running, because the command's PowerShell wrapper exits first and the server's tree kill can't reach the child. That is tracked in STA-17825 (proposed fix: a kill-on-close job object per Windows Codex server).
AI Disclosure
Review
Agent skill upstream boundary
Notes
Ensure no issues in: Security, Cross-platform support (Linux, Windows, Mac), Remote SSH, Mobile, general backwards compatibility, performance
Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)