Skip to content

fix(codex): run native Windows on the user's own ~/.codex - #19215

Closed
brennanb2025 wants to merge 10 commits into
mainfrom
brennanb2025/codex-windows-real-home-lane
Closed

brennanb2025 wants to merge 10 commits into
mainfrom
brennanb2025/codex-windows-real-home-lane

Conversation

@brennanb2025

@brennanb2025 brennanb2025 commented Sep 7, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 17 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​641 $\color{#cf222e}{\Huge{\mathbf{−}}}$​25 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​616
Prod 22 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​205 $\color{#cf222e}{\Huge{\mathbf{−}}}$​49 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​156

Problem

On native Windows, the system-default Codex route stayed on Orca's managed mirror and exported Orca's CODEX_HOME into the interactive shell. Programs launched from that pane inherited the private home. In the reported case, Codex's installer derived its install root from that variable, staged into Orca's directory, and then rejected the user's real global bin junction as "not managed by this installer."

Root cause

The real-home lane was disabled by a Windows platform guard because its original eligibility check depended on a POSIX startup-file probe. Windows persisted environment values are already present in the launch environment, but PowerShell profiles and Git Bash startup files can still change CODEX_HOME after process creation. Persistent terminal daemons add a second boundary: their inherited environment can outlive Electron and must not silently disagree with the home Electron prepared and attributed.

Change

  • Native Windows can use the same system-default real-home lane as macOS and Linux when no genuine custom CODEX_HOME is selected and the Codex hook trust grant succeeds.
  • A one-shot ORCA_CODEX_DEFAULT_HOME_AFTER_PROFILE instruction reapplies the prepared default home after PowerShell or Git Bash profiles load, then removes itself.
  • For a fresh default-home launch, the daemon applies Electron's prepared selection to that child environment before spawn. Marker-absent managed/custom launches and the daemon's own process environment are unchanged.
  • Git Bash shell-ready, OSC 133, OpenCode, and prompt integration remain available independently of the managed Codex preflight.
  • cmd, WSL, unsupported shells, and fallback paths scrub the one-shot marker when they cannot consume it.
  • Fresh sessions use persistent-daemon protocol v37; existing v36 sessions remain attachable to their current owner.

Scope and compatibility

Managed multi-account and genuine custom-CODEX_HOME users remain on their existing managed/custom routes. The change adds no mobile-facing behavior, SSH or relay-wire change, settings or persisted-state schema change, dependency, or new subprocess. Folder workspaces remain supported.

Validation

  • Same-model adversarial review and fix loop ended clean on exact head 3310201848c2e3d763481132246560bb1850dce8; no remaining P0–P2 findings.
  • The architecture challenge found one material delivery bug: a failed Git Bash wrapper write could retain a one-shot marker with no consumer. The final code derives marker retention from the resolved launch's actual capability, and the clean review found no stranded obligation or competing retry state.
  • Exact-head focused validation passed 271 tests across the shell, IPC, daemon, and Windows ownership paths, with 12 native-Windows-only cases skipped on macOS.
  • Native Windows high-spec validation passed 153 relevant tests. One direct zsh wrapper-root assertion is not portable to Windows; the Windows product paths and all PR CI jobs passed.
  • pnpm tc:node, changed-file code quality, formatting, commit hooks, and git diff --check passed.
  • Performance review found constant-size environment mutation and bounded Git Bash wrapper-file checks only during shell startup: no polling, timers, listeners, growing caches, additional subprocesses, or renderer hot-path work.
  • Merge-tree against current origin/main is conflict-free.
  • All GitHub checks are green, including Windows native smoke, Windows packaging, changed E2E coverage, SSH watcher isolation, static analysis, typecheck, and all eight test shards.

Windows Electron proof

Windows high-spec validation ran the exact PR checkout in hidden renderers with ORCA_BACKGROUND_LAUNCH=1, isolated user-data and profile roots, and Playwright over CDP. App identity matched this branch and worktree; renderers reported zero console errors and the v37 daemon remained healthy.

Remaining release evidence

This review is not claiming gap-free packaged-updater coverage. A true packaged protocol-v36 → v37 NSIS update and daemon reattach remains blocked. The exact PR CI builds the Windows app with electron-builder --dir and does not publish an exact-head NSIS installer. The repository updater harness requires a disposable Windows environment because the NSIS install replaces the registry-registered copy and its shortcuts. The available high-spec host has a live production Orca installation and no usable Windows Sandbox or admin-accessible VM, so running the harness there would risk that installation.

Closing this evidence gap requires an exact-head v37 orca-windows-setup.exe, a protocol-v36 baseline installer, and the repository win-update-e2e workflow on disposable Windows CI. An explicit managed-account pane was also not opened because no managed account was added; the equivalent managed/custom routing was exercised through a live explicit-custom-home launch and focused tests.

Windows was excluded from the real-home hook lane by a bare platform check,
so every Windows pane fell back to the managed mirror and exported Orca's
CODEX_HOME into the interactive shell. Anything the user then ran inherited
it -- including Codex's own installer, which derives its install root from
CODEX_HOME, installs into Orca's directory, and then refuses to retarget the
global bin junction because that junction points into the real ~/.codex.

The exclusion existed only because the lane's guard was the POSIX
startup-file probe. That probe answers "will the shell re-export CODEX_HOME
somewhere else?" -- a question Windows does not need it for: the persisted
user/machine environment block is inherited at process creation, so setx and
Control Panel values are already in process.env, where
hasCustomCodexHomeOverride reads them. On Windows the probe returned
undefined, which reads as a false all-clear; that is why the guard was on the
platform rather than the value.

Guard the lane on isLaunchEnvOverrideVisible() instead, which is true on
win32 and defers to the probe elsewhere. The rc parser stays POSIX-only.

Known blind spot, unchanged in kind from what the probe already accepts: a
CODEX_HOME assigned inside a PowerShell profile or a Git Bash startup file is
shell-runtime state in neither source. Worst case is a status-blind pane --
Orca still only ever mutates ~/.codex, the one path it can clean on
downgrade, and it keeps a pristine pre-Orca backup before touching it.

Managed multi-account and custom-CODEX_HOME users are unaffected and stay on
the mirror.
@coderabbitai

coderabbitai Bot commented Sep 7, 2026 •

Copy link
Copy Markdown
Contributor

Review Change StackReview Change Stack

Note

Reviews paused

It 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 reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Adds isLaunchEnvOverrideVisible() and uses it for host-system default home routing. Adds a post-profile default-home marker for Windows PTY and daemon launches. Updates shell wrappers, fallback handling, daemon protocol versioning, and tests for routing and marker behavior.

Priority: ➖ Normal

Merge Risk: 🟡 Moderate · up to dce80

Windows users who define CODEX_HOME in PowerShell or Git Bash startup files can be routed to the wrong Codex account or configuration. This should be fixed before merge.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 29.17% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 24 functions across 35 files. (1 skipped:… Write docstrings for the functions missing them to satisfy the coverage threshold.
Description check ⚠️ Warning The description is detailed and on topic, but it does not satisfy the repository template because it omits the required Linked Issue entry and several required checklist confirmations, including the A… Add a valid issue reference in the required Fixes #<issue-number> section. Add or explicitly complete the Agent skill upstream boundary, Notes, and Checklist sections. Confirm the required checks and cross-platform considerations, or stat…
✅ Passed checks (3 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly identifies the primary change: enabling native Windows to use the user's real Codex home.
Full details: Docstring Coverage

Explanation

Docstring coverage is 29.17% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 24 functions across 35 files. (1 skipped: 1 unsupported.)

Full details: Description check

Explanation

The description is detailed and on topic, but it does not satisfy the repository template because it omits the required Linked Issue entry and several required checklist confirmations, including the Agent skill upstream boundary and final validation checklist.

Resolution

Add a valid issue reference in the required Fixes #&lt;issue-number&gt; section. Add or explicitly complete the Agent skill upstream boundary, Notes, and Checklist sections. Confirm the required checks and cross-platform considerations, or state why they are not applicable.

  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ No new issues found.

Reviewed changes

  • isLaunchEnvOverrideVisible predicate — new seam in shell-startup-env.ts returning true on win32 (env block inherited at process creation) and deferring to the POSIX startup-file probe elsewhere; carries a clear doc comment.
  • Windows lane routing — isHostSystemDefaultRealHomeSelected no longer short-circuits on win32, so a native host with no custom CODEX_HOME takes the real-home lane, aligning it with isHostSystemDefaultSessionMigrationEligible (which already keyed off the override).
  • Test harness — isLaunchEnvOverrideVisible added to the mock so the single shellStartupEnvProbeSupported knob still governs lane routing for the suite's managed-fallback cases.
  • Tests — the Windows ownership test flips its pin and adds env-set and launch-env-set override cases; shell-startup-env.test.ts pins win32 launch-env authority.

The change is well-scoped and the reasoning holds: on Windows the persisted user/machine environment block is inherited at process creation, so hasCustomCodexHomeOverrideForLaunch already saw setx/Control Panel values in process.env; the old !isShellStartupEnvProbeSupported() guard was the only thing keeping Windows on the mirror. The blind spot (a CODEX_HOME assigned in a PowerShell profile or Git Bash startup file) is documented honestly as degradation-not-corruption, and the ship gate on real-Windows verification via setRealHomeLaneGate is the right call since Linux CI can't exercise the inheritance claim. Verified green locally: shell-startup-env.test.ts, runtime-home-windows-profile-ownership.test.ts, and the harness-dependent routing/retained-auth/per-account-home suites.

Pullfrog  | View workflow run | Using DeepSeek Pro (free via Pullfrog for OSS) | 𝕏

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Team

Run ID: cf70ee34-f52b-4808-833e-05cc2f56c4a8

📥 Commits

Reviewing files that changed from the base of the PR and between fa5ef99 and 59a7fa2.

📒 Files selected for processing (5)
  • src/main/codex-accounts/runtime-home-service-home-routing.ts
  • src/main/codex-accounts/runtime-home-service-test-harness.ts
  • src/main/codex-accounts/runtime-home-windows-profile-ownership.test.ts
  • src/main/pty/shell-startup-env.test.ts
  • src/main/pty/shell-startup-env.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.

normalizeCodexRuntimeSelection(settings).host !== null ||
!isShellStartupEnvProbeSupported()
) {
if (normalizeCodexRuntimeSelection(settings).host !== null || !isLaunchEnvOverrideVisible()) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🗄️ Data Integrity & Integration | 🟠 Major | 🏗️ Heavy lift

🔎 Supported by static analysis

🏁 Script executed:

#!/bin/bash
set -e
printf '%s\n' '--- target file ---'
sed -n '110,185p' src/main/codex-accounts/runtime-home-service-home-routing.ts
printf '%s\n' '--- direct definitions/usages ---'
rg -n -C 4 'isLaunchEnvOverrideVisible|hasCustomCodexHomeOverrideForLaunch|normalizeCodexRuntimeSelection|real-home|managed' src/main
printf '%s\n' '--- relevant tests ---'
rg -n -C 5 'profile|PowerShell|Git Bash|CODEX_HOME|isLaunchEnvOverrideVisible|hasCustomCodexHomeOverrideForLaunch' src test tests 2>/dev/null || true

Repository: stablyai/orca

Length of output: 50370


🤖 get_repo_knowledge executed:

get_repo_knowledge stablyai/orca /tmp/coderabbit-repo-knowledge/stablyai-orca-89dc44e4/learnings

Length of output: 35500


🏁 Script executed:

#!/bin/bash
set -e
log=/tmp/coderabbit-shell-logs/shell-output-vmx3XT
printf '%s\n' '--- target-file excerpts from prior output ---'
rg -n -A45 -B10 'runtime-home-service-home-routing\.ts' "$log" | head -n 240
printf '%s\n' '--- direct source symbols ---'
rg -n -C 8 'isLaunchEnvOverrideVisible|hasCustomCodexHomeOverrideForLaunch|normalizeCodexRuntimeSelection|real-home' src/main/codex-accounts src/main --glob '*codex*' --glob '*runtime-home*'
printf '%s\n' '--- focused tests ---'
rg -l 'isLaunchEnvOverrideVisible|hasCustomCodexHomeOverrideForLaunch|runtime-home-service-home-routing|CODEX_HOME' src/main/codex-accounts src/main --glob '*.test.ts' | while read -r f; do
  echo "### $f"
  rg -n -C 5 'isLaunchEnvOverrideVisible|hasCustomCodexHomeOverrideForLaunch|runtime-home-service-home-routing|CODEX_HOME|profile|Git Bash|PowerShell' "$f"
done

Repository: stablyai/orca

Length of output: 50370


🏁 Script executed:

#!/bin/bash
set -e
printf '%s\n' '--- files in codex-accounts ---'
git ls-files src/main/codex-accounts
printf '%s\n' '--- routing file outline and relevant sections ---'
wc -l src/main/codex-accounts/runtime-home-service-home-routing.ts
cat -n src/main/codex-accounts/runtime-home-service-home-routing.ts | sed -n '1,220p'

Repository: stablyai/orca

Length of output: 16704


🏁 Script executed:

#!/bin/bash
set -e
printf '%s\n' '--- shell startup environment implementation ---'
rg -n -C 12 'export function (isLaunchEnvOverrideVisible|hasCustomCodexHomeOverrideForLaunch)|function (isLaunchEnvOverrideVisible|hasCustomCodexHomeOverrideForLaunch)|isLaunchEnvOverrideVisible' src/main/pty/shell-startup-env.ts src/main/codex/codex-real-home-path.ts
cat -n src/main/pty/shell-startup-env.ts | sed -n '1,180p'
printf '%s\n' '--- real-home override helper ---'
cat -n src/main/codex/codex-real-home-path.ts | sed -n '1,180p'
printf '%s\n' '--- routing tests ---'
for f in src/main/codex-accounts/runtime-home-real-home-lane-routing.test.ts src/main/codex-accounts/runtime-home-windows-profile-ownership.test.ts; do
  echo "### $f"
  rg -n -C 12 'real-home|CODEX_HOME|override|profile|launchEnv|isHostSystemDefaultRealHomeSelected|isLaunchEnvOverrideVisible' "$f"
done

Repository: stablyai/orca

Length of output: 31277


🏁 Script executed:

#!/bin/bash
set -e
printf '%s\n' '--- route consumers and launch environment construction ---'
rg -n -C 8 'isHostSystemDefaultRealHome\(|isHostSystemDefaultRealHomeSelected\(|getSelectedHostCodexHomeRoute\(|getRuntimeHomePath\(|CODEX_HOME|ORCA_CODEX_HOME' src/main/codex-accounts/runtime-home-service.ts src/main/codex-accounts/runtime-home-service-*.ts src/main/pty src/main/providers --glob '*.ts' | head -n 500
printf '%s\n' '--- focused routing test file ---'
cat -n src/main/codex-accounts/runtime-home-real-home-lane-routing.test.ts | sed -n '1,260p'

Repository: stablyai/orca

Length of output: 50369


Keep the managed fallback for profile-only CODEX_HOME.

On Windows, isLaunchEnvOverrideVisible() treats the inherited environment as complete, despite the documented blind spot for PowerShell profiles and Git Bash startup files. hasCustomCodexHomeOverrideForLaunch(launchEnv) then sees no override, so isHostSystemDefaultRealHomeSelected() selects real-home while the launched shell can export another CODEX_HOME. Session discovery, migration, and auth synchronization can then target ~/.codex instead of the shell's home. Keep the managed fallback unless a shell-specific probe or trust result proves that no profile override exists. Add a regression test for a profile-only custom CODEX_HOME.

isShellStartupEnvProbeSupported: () => testState.shellStartupEnvProbeSupported,
// Why: the lane reads this, not the raw probe flag. Keeping the one knob
// authoritative stops a win32-forcing case from silently re-enabling it.
isLaunchEnvOverrideVisible: () => testState.shellStartupEnvProbeSupported

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Separate the launch-visibility mock from the startup-probe mock.

Production isLaunchEnvOverrideVisible() returns true on Windows even when isShellStartupEnvProbeSupported() returns false. This mock returns the same testState.shellStartupEnvProbeSupportedvalue for both functions, so the harness cannot model the Windows case added by this change. Tests that disable the startup probe can therefore exercise the mirror fallback instead of real-home routing. Add a separatelaunchEnvOverrideVisible` test control, or make the mock platform-aware.

…duction cannot reach

Review found the new predicate is total: isLaunchEnvOverrideVisible() is
`win32 || !win32`, so it never returns false and the routing site's second
disjunct is unreachable. The behaviour is what was intended -- the win32 lane
block is gone and POSIX is untouched -- but the expression read as a live
platform decision, and the surrounding comments then compounded that.

Deleting the seam outright would push ~30 mirror-lane cases onto a new lever
across 135 service constructions, so keep it as the single named gate and say
plainly in its doc that it is total today and why it still earns a name.

Correct three comments that now describe an impossible state:
- the fixtures claimed the mirror is "still live wherever the shell-startup
  probe is unavailable (Windows)" and that production "still uses" it there.
  Since the win32 block is gone, production reaches the mirror only via a host
  account selection, a custom CODEX_HOME, or an incapable trust-grant host.
  The knob is a test-only lane lever now, and says so.
- the new test claimed lane routing and session migration "read the same
  override". They agree only on process env: migration takes no launchEnv.

Pin that asymmetry instead of implying agreement -- a launch-scoped
CODEX_HOME steers the lane while migration stays eligible.

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ No new issues found.

Reviewed changes

  • isLaunchEnvOverrideVisible doc comment — now states plainly that the predicate is total today (win32 || !win32, never false in production) and why it still earns a named seam: one mock lever across the runtime-home harness instead of pushing ~30 mirror-lane cases onto a new lever across 135 service constructions.
  • Fixture knob comments — corrected to describe the mirror as reached via host-account selection, a custom CODEX_HOME, or an incapable trust-grant host, not by platform; the shellStartupEnvProbeSupported knob is now labeled a test-only lane lever rather than a mirror of a platform gate.
  • Asymmetry pin — the ownership test now asserts that a launch-scoped CODEX_HOME steers lane routing off the real home while isHostSystemDefaultSessionMigrationEligible() (which reads only process.env) stays eligible, and corrects the prior "read the same override" comment that implied false agreement.

The changes are documentation corrections plus one new characterization test; no production behavior changed. The new assertion is exact and verified against getLaunchEnvValue's process-env fallback semantics. runtime-home-windows-profile-ownership.test.ts (3 tests) and shell-startup-env.test.ts (51 tests) pass.

Pullfrog  | View workflow run | Using DeepSeek Pro (free via Pullfrog for OSS) | 𝕏

…t Windows fallback

Review pass 2 caught commit 2 reintroducing exactly what it set out to remove.
"migration reads no launchEnv" is false: only the eligibility precheck is
launch-env-blind. beginHostSystemDefaultSessionMigrationLaunch forwards
launchEnv into invalidateBackfillAfterManagedSystemDefaultLaunch, which
re-checks hasCustomCodexHomeOverrideForLaunch and refuses. The assertion was
right; the prose was not. Point it at the precheck and name the case that
pins the launch-side refusal.

Also cover the gap that pass 2 identified: nothing exercised the mirror lane
on Windows through realHomeLaneGate() === false. That is the likeliest real
Windows fallback -- an older codex binary whose trust grant is refused -- and
it is the reach behind the first-launch rollback path, which is newly live on
Windows and whose closest existing tests are skipIf(win32).

The shape it pins is deliberate: selection is true while the lane is false,
because the lane is selected before the grant is attempted.

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ No new issues found.

Reviewed changes

  • Incapable-host fallback test — added a Windows case pinning that a trust-grant-incapable host still reports isHostSystemDefaultRealHomeSelected true while isHostSystemDefaultRealHome is false, capturing the "selection precedes the grant" shipped shape the mirror fallback relies on.
  • Asymmetry comment correction — reworded the launch-scoped CODEX_HOME pin to distinguish the eligibility precheck (which takes no launchEnv) from the migration launch (which re-validates the home path and refuses), replacing the prior "reads the same override" phrasing that implied false agreement.

The new test is meaningful coverage: it would fail if isHostSystemDefaultRealHome ever stopped consulting realHomeLaneGate(), and it directly exercises the incapable-host path the PR description flags as a ship gate that Linux CI can't reach. The comment cross-reference (runtime-home-real-home-lane-routing.test.ts's toBeNull() case) is accurate, and the "precheck blind / launch re-checks" distinction matches beginHostSystemDefaultSessionMigrationLaunch re-validating eligibility and the home path. Verified the file passes (4 tests).

Pullfrog  | View workflow run | Using DeepSeek Pro (free via Pullfrog for OSS) | 𝕏

Merge Sim added 2 commits September 7, 2026 00:19
Review pass 3 found one more instance of the class commit 2 set out to purge,
in a file this PR does not otherwise touch: the per-account mirror case said
"a Windows host keeps the shared system-default mirror". That was true before
this change and is false after it -- the mirror there comes from the host
account selection on the line below, not from the platform.

Also name which of the two toBeNull() cases the precheck comment points at;
the file has one for a missing path and one for a launchEnv CODEX_HOME, and
only the second is the launch-side refusal being cited.
…ndows-real-home-lane

# Conflicts:
#	src/main/codex-accounts/runtime-home-settings-test-fixtures.ts

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ No new issues found.

Reviewed changes

  • Merge of origin/main — brought the branch up to date with base 374c676; the only PR-relevant conflict was in runtime-home-settings-test-fixtures.ts.
  • createSettings fixture resolution — kept the PR's setShellStartupEnvProbeSupportedForTest(...) mirror-lane lever and its comment, and adopted main's shared createCodexAccountSettings(fakeHomeDir, overrides) factory in place of the hand-written settings literal.

The conflict resolution is faithful: the mirror-lane defaulting lever is preserved, workspaceDir still resolves to testState.fakeHomeDir, and no production file changed in this delta. All 45 src/main/codex-accounts test files (338 tests) pass locally, including runtime-home-windows-profile-ownership.test.ts.

Pullfrog  | View workflow run | Using DeepSeek Pro (free via Pullfrog for OSS) | 𝕏

@brennanb2025

Copy link
Copy Markdown
Contributor Author

Review + validation status

Four adversarial review passes (converged CLEAN), two readiness-checklist passes, a precedent review, and validation on a real Windows host. Three rounds of fixes pushed; main merged to clear a conflict.

Validated on real Windows

Run against a dev build of this branch (HEAD c68baf6d7e) on a native-Windows host, under an isolated profile — a fresh profile gets localWindowsRuntimeDefault: windows-host, which is what puts it on the lane under test. Confirmed in the profile before measuring.

# Criterion Result
a Pane has no CODEX_HOME and no ORCA_CODEX_HOME PASS
b Orca hook in the user's own ~/.codex/hooks.json, with a pristine backup PASS
c Trust grant succeeded — lane installed, not a mirror fallback PASS
d Git Bash pane also free of both vars PASS

The baseline contrast is the proof. In a pane under the shipped Orca on that same box:

CODEX_HOME=[C:\Users\neil\AppData\Roaming\orca\codex-runtime-home\home]
ORCA_CODEX_HOME=[same]

That is the reported bug reproduced first-hand — the exact directory the Codex installer picked up. On this branch, Test-Path reports CH_EXISTS=False OCH_EXISTS=False (unambiguous about unset-vs-empty).

(b) ~/.codex/hooks.json went from {"hooks": {}} (md5 6743b3e1…) to 8 Orca entries, each pointing at C:\Users\neil\.orca\agent-hooks\codex-hook.cmd, with the pristine 18-byte hooks.json.pre-orca written under the dev user-data dir.

(c) From the dev main-process log:

[codex-trust-grant] granted 8 managed hook entries via codex app-server (host=native, wrote=true, 384ms)

Zero occurrences of managed lane kept / falling back / trust grant unavailable. Corroborated independently: the trust ledger is keyed on c:/users/neil/.codex — the real home, not the mirror — and config.toml gained 8 trusted_hash entries.

orca-win-lane-1.jpg

orca-win-lane-2.jpg

orca-win-lane-3.jpg

What review changed

Not one finding was in the logic — the predicate swap was correct from the first commit. Every defect was prose: four files carried comments asserting a "Windows keeps the mirror" rule that this diff deletes, including two files the PR does not otherwise touch. Removing a platform rule invalidates every comment that explained it, and no test catches that.

  • The new predicate is total (win32 || !win32). Kept as a named seam rather than deleted — removing it would push ~30 mirror-lane cases onto a new lever across 135 service constructions — and its doc now says so outright instead of implying a live platform decision.
  • A test comment claiming lane routing and session migration "read the same override" was disproved by the case three lines below it. The asymmetry is now pinned by an assertion: a launch-scoped CODEX_HOME steers the lane while the migration eligibility precheck stays true.
  • The incapable-trust-grant fallback — the likeliest real Windows path, an older codex binary — had no coverage. It does now, and the test was ablation-checked: remove the && this.realHomeLaneGate() conjunct and it fails.

Precedent

Aligned. Treating the inherited Windows environment block as authoritative rather than resolving a shell environment is the established position, as is installing a self-gated hook into the user's real config dir instead of relocating the config home — which Orca already does (codex-hook-script.ts:56-58 exits 0 outside an Orca pane). This change moves toward convention, not away from it.

Open items

  1. Not fixed, by design: managed multi-account users keep a session-wide CODEX_HOME on every platform and remain exposed to the same installer collision. The precedented shape for them is per-spawn env on launches Orca controls — a separate change.
  2. Accepted regression: a Windows user who sets CODEX_HOME in a PowerShell profile or Git Bash startup file selects the lane and gets status-blind panes. Not triggered on the validated box — no bash startup file there sets it — so this path remains untested rather than proven safe. Bounded by the pristine backup and a platform-neutral rollback.
  3. Untested here: the old-binary rollback restoring hooks.json byte-identical, and the downgrade sweep.
  4. test / tests node 24 6/8 is main-side, not caused by this PR: the failing file does not exist on this branch (arrived via feat(native-chat): resume an Agent Session History row into a new structured chat #19176) and an unrelated PR fails the identical assertion.

Note for Windows CI

pnpm build:cli on Windows dies in the native rebuild with FileTracker : error FTK1011 on a .tlog path of exactly 260 characters. TrackFileAccess=false clears it; subst does not, because the script uses process.cwd(), which resolves back through the mapping.

@coderabbitai

coderabbitai Bot commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

Note

GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer.

@brennanb2025

Copy link
Copy Markdown
Contributor Author

The reported failure, proven fixed on real Windows

The earlier validation showed CODEX_HOME is no longer injected. This closes the loop: it proves the installer guard that actually failed now passes — using install.ps1's own logic, on a real NTFS junction, on a native-Windows host.

Dev build of this branch, isolated profile (localWindowsRuntimeDefault: windows-host), PowerShell pane.

A — lane state

CODEX_HOME       set? : False
ORCA_CODEX_HOME  set? : False
codexHome             = C:\Users\neil\.codex
standaloneRoot        = C:\Users\neil\.codex\packages\standalone

Same box under the shipped build: both variables are C:\Users\neil\AppData\Roaming\orca\codex-runtime-home\home.

B — the installer's own derivation (install.ps1 L901-909, fetched read-only, never executed)

$codexHome = if ([string]::IsNullOrWhiteSpace($env:CODEX_HOME)) {
    Join-Path $env:USERPROFILE ".codex"
} else { $env:CODEX_HOME }
$standaloneRoot = Join-Path $codexHome "packages\standalone"

C — the guard that threw (L659-664), run against a real NTFS junction whose Target is what a standalone install produces

FIXED    ownedTargetPrefix = C:\Users\neil\.codex\packages\standalone            StartsWith -> True
BASELINE ownedTargetPrefix = ...\orca\codex-runtime-home\home\packages\standalone StartsWith -> False

FIXED    : junction accepted -> installer proceeds
BASELINE : THROW not-managed-by-this-installer   <-- the reported bug

Same box, same junction, two derived roots, opposite outcomes. That isolates the variable.

orca-codex-installer-proof-wide.jpg

Limits, stated plainly

  • Derivation proof, not execution proof. The installer was never run — no iex, no install, no update on that machine. Its root-derivation and ownership-guard expressions were evaluated directly.
  • That box has Codex via npm-global, so the user's real bin junction does not exist there. The junction in step C is a real NTFS junction created in a C:\tmp sandbox with the same Target string, and removed afterwards. The guard is a pure StartsWith on Target and never inspects the link's own location, so the substitution is faithful.
  • Dev build only; no packaged-build check.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: bb7f3511-15c1-4506-9dc9-388989859cdc

📥 Commits

Reviewing files that changed from the base of the PR and between 83dae8d and cb21178.

📒 Files selected for processing (28)
  • src/main/__fixtures__/shell-wrapper-snapshots/local-bash-rcfile.txt
  • src/main/daemon/daemon-foreground-confirmation-protocol.test.ts
  • src/main/daemon/daemon-protocol-version.test.ts
  • src/main/daemon/daemon-protocol-version.ts
  • src/main/daemon/daemon-pty-router.test.ts
  • src/main/daemon/pty-subprocess-test-harness.ts
  • src/main/daemon/pty-subprocess-windows-shell-launch.test.ts
  • src/main/daemon/pty-subprocess/native-pty-spawn.ts
  • src/main/daemon/pty-subprocess/shell-launch-plan.ts
  • src/main/daemon/pty-subprocess/spawn-environment.ts
  • src/main/daemon/types.ts
  • src/main/ipc/pty-daemon-spawn-agent-home-env.test.ts
  • src/main/ipc/pty-spawn-env-terminal-basics.test.ts
  • src/main/ipc/pty/host-env/assembly.ts
  • src/main/ipc/pty/ipc/spawn-options.ts
  • src/main/powershell-osc133-bootstrap-windows-clm.test.ts
  • src/main/powershell-osc133-bootstrap.test.ts
  • src/main/powershell-osc133-bootstrap.ts
  • src/main/providers/local-pty-provider-windows-shell-launch.test.ts
  • src/main/providers/local-pty-shell-ready-bash-rcfile.ts
  • src/main/providers/local-pty-shell-ready-wrapper-generation.test.ts
  • src/main/providers/local-pty-utils-windows-fallback.test.ts
  • src/main/providers/local-pty-utils.ts
  • src/main/providers/local-pty-windows-spawn-environment.ts
  • src/main/providers/windows-shell-args.test.ts
  • src/main/providers/windows-shell-args.ts
  • src/main/pty/codex-default-home-shell-startup.test.ts
  • src/main/pty/codex-default-home-shell-startup.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 8 remain after this review.

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ No new issues found.

Reviewed changes

  • Post-profile reset marker — src/main/pty/codex-default-home-shell-startup.ts adds a one-shot ORCA_CODEX_DEFAULT_HOME_AFTER_PROFILE marker that the PowerShell OSC133 bootstrap and the Git Bash shell-ready rcfile consume after profile scripts ('1' → unset CODEX_HOME; a path → restore that explicit default home), closing the previously accepted PowerShell/Git-Bash profile blind spot.
  • Daemon env reconciliation — reconcileDaemonCodexDefaultHomeMarker and scrubCodexDefaultHomeMarkerForWindowsShell keep the marker coherent across a persistent daemon's inherited env and drop it before shells that cannot consume it (cmd.exe, wsl.exe, non-Git-Bash bash), at both the primary spawn and each fallback attempt.
  • Windows launch plumbing — buildPtyHostEnv sets the marker only for native Windows real-home launches (win32, non-WSL, no custom override); Git Bash keeps its shell-ready wrapper without a Codex preflight; the daemon protocol bumps to v37 so a stale daemon is replaced while its sessions stay attachable.
  • Tests — new pure-function, bash-rcfile, PowerShell CLM, IPC env-assembly, and daemon-router cases pin the marker's set/scrub/reconcile behavior and v36-legacy compatibility.

I traced the marker set/reconcile/scrub path end-to-end (including the persistent-daemon inherited-CODEX_HOME case, where the reset is deliberately dropped to avoid clobbering user-owned state) and confirmed the reset block runs after profile sourcing in the rcfile. The Linux-runnable suites pass locally (codex-default-home-shell-startup, shell-startup-env, local-pty-shell-ready-wrapper-generation, pty-spawn-env-terminal-basics, pty-daemon-spawn-agent-home-env — 140 tests). The Windows-gated PowerShell CLM cases still can't run on Linux CI, so the standing real-Windows ship gate from the PR description remains the right call.

Pullfrog  | View workflow run | Using DeepSeek Pro (free via Pullfrog for OSS) | 𝕏

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/main/pty/shell-startup-env.ts (1)

32-52: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Do not select the Windows real-home route when startup-file overrides are not visible. isHostSystemDefaultRealHomeSelected() treats win32 as authoritative, so a CODEX_HOME value assigned only by a PowerShell profile or Git Bash startup file is missed. The real-home route then sends the unset-after-profile marker, and both shell wrappers remove CODEX_HOME. Fix this shared visibility boundary for both shells. Keep Git Bash’s OSC 133 wrapper unchanged.


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: ed73eedd-e07e-41fc-9a45-7e7276d28950

📥 Commits

Reviewing files that changed from the base of the PR and between cb21178 and 13fce85.

📒 Files selected for processing (3)
  • src/main/daemon/pty-subprocess-windows-shell-launch.test.ts
  • src/main/pty/codex-default-home-shell-startup.test.ts
  • src/main/pty/codex-default-home-shell-startup.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 4 remain after this review.

@brennanb2025

Copy link
Copy Markdown
Contributor Author

Final review status — code clean; Windows Electron QA still required

Reviewed and pushed through same-model adversarial fix/re-review loops plus opening and final readiness checks. Final HEAD is dce80b1defe5bfa9a336ac7e806c39f644c0c50d.

Findings fixed

  • Windows profile-only CODEX_HOME could diverge from hook preparation and pane attribution.
  • Removing managed Codex preflight also removed unrelated Git Bash shell integration.
  • A surviving daemon could retain a stale custom CODEX_HOME after Electron prepared and recorded the real home.
  • The protocol v37 bump was not reflected in the packaged local-build compatibility contract on current main, causing the merge-ref contract test to fail.

The final design uses a trusted, one-shot post-profile instruction for PowerShell and Git Bash, keeps Git Bash integration independent of managed preflight, makes Electron's prepared home authoritative for that daemon child only, and keeps v36 attachable while fresh work uses v37. The TypeScript and JSON packaged compatibility artifacts now both declare v37.

Correction to my earlier status comment: profile-only CODEX_HOME behavior is no longer an accepted regression. The final implementation explicitly reconciles it after PowerShell/Git Bash profiles load, and the instruction removes itself afterward.

Review verdict

  • Same-model adversarial reviewer: CLEAN, no remaining P0–P2.
  • Final readiness checklist on exact HEAD: PASS / CLEAN.
  • Functional correctness: clean.
  • Architectural fit: the preparation/execution/attribution split is removed, not guarded around.
  • Performance/resources: clean; constant-time per-spawn environment mutation and static metadata only. No polling, timers, listeners, caches, scans, subprocess churn, startup awaits, or hot-output work.
  • Compatibility: managed/custom homes retain their routes; v36 retained sessions remain attachable; WSL, SSH/remote execution, folder workspaces, mobile, persisted state, and relay-wire behavior are unchanged.

Validation

  • 309 tests passed across 23 adversarial-review suites; 12 native PowerShell cases skipped on macOS.
  • Final readiness: 207 shell/IPC/daemon tests, 9 local-build contract tests, and 30 build-metadata/configuration tests passed.
  • Additional 18-case real-source probe passed.
  • pnpm tc:node, focused lint, formatting checks, commit hooks, and git diff --check passed.
  • Merge-tree against current origin/main is conflict-free.
  • Worktree is clean and origin matches final HEAD.
  • Exact-head Windows, Ubuntu, and macOS smoke checks are green. Full PR Checks are currently queued behind GitHub's cancellation of the superseded run.

Remaining gate

A new Grok-driven Windows Electron run could not start because the Grok account had zero credits. No new screenshots were produced; the existing Windows screenshots on this PR predate the final shell/daemon correction.

Recommendation: code review is clean, but land only after full exact-head CI completes and native-Windows Electron validation covers final HEAD with PowerShell and Git Bash profile/startup CODEX_HOME cases.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/main/codex-accounts/runtime-home-service-home-routing.ts (1)

147-152: 🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win

Treat Windows profile-defined CODEX_HOME as a custom-home override. isLaunchEnvOverrideVisible() returns true on Windows, while getCustomCodexHomeOverrideForLaunch() cannot inspect PowerShell profiles or Git Bash startup files. A profile-only override therefore selects the real-home lane. The PTY marker then clears or replaces CODEX_HOME after profile startup, so the pane can run with ~/.codex instead of its configured custom home. Change this selection boundary to retain the managed mirror when a Windows startup-file override can exist, or resolve the profile value before selecting the real-home lane.


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: 853373fc-d433-4e16-acd6-40e6f1870989

📥 Commits

Reviewing files that changed from the base of the PR and between 13fce85 and dce80b1.

📒 Files selected for processing (2)
  • src/shared/local-build-compatibility-contract.json
  • src/shared/local-build-compatibility-contract.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 5 remain after this review.

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ℹ️ No critical issues — one stale-comment nit inline.

Reviewed changes

  • Authoritative daemon reconciliation — reconcileDaemonCodexDefaultHomeMarker now applies main's prepared default-home selection over daemon-only inherited state (unset or set CODEX_HOME, clear ORCA_CODEX_HOME) instead of conservatively dropping the marker. This is what actually makes a real-home request take effect on a persistent daemon whose inherited process.env holds Orca's stale managed CODEX_HOME.
  • Packaged protocol contract alignment — local-build-compatibility-contract.json and .ts bumped daemonProtocolVersion 36→37 and appended 37 to attachableDaemonProtocolVersions, restoring the local-build-compatibility-contract.test.ts invariant against PROTOCOL_VERSION.
  • Tests — the reconcile and Windows-shell-launch cases are rewritten to pin the authoritative behavior (exact equality on env, including the unset and explicit-path cases), plus a new "no selection preserves daemon-only custom home" case.

The flip is correct: when main emits the marker it has already ruled out a visible custom override, so the daemon's inherited CODEX_HOME/ORCA_CODEX_HOME can only be Orca's own managed value, which is exactly what a real-home launch must override. The tests would fail under the previous conservative implementation, so they're meaningful coverage.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using DeepSeek Pro (free via Pullfrog for OSS) | 𝕏

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ No new issues found.

Reviewed changes

  • Marker scrub keyed off the resolved launch — scrubCodexDefaultHomeMarkerForLaunch(env, supportsCodexDefaultHomeAfterProfile) replaces the shell-path predicate, and the capability flag is threaded through WindowsShellLaunchArgs, WindowsShellSpawnAttempt, and LocalPtyLaunchPlan from the site where each shell's launch args are actually built (PowerShell true; Git Bash true only with a materialized wrapper; cmd/wsl/unknown absent).
  • Git Bash fallback now drops the marker — getGitBashLaunchCommand reports support only when the shell-ready wrapper exists, so a failed wrapper write launches --login -i with the one-shot marker scrubbed instead of leaking it unconsumed into the pane and its children.
  • Stale rationale removed — the retired "reconciliation may preserve a daemon-only custom home" comment in shell-launch-plan.ts is gone, which retires the one open prior-review thread.
  • Tests — new daemon and in-process cases pin the wrapper-materialization-failure path (plain login args, marker absent); scrubCodexDefaultHomeMarkerForLaunch is covered for true/false/undefined; and the Windows fallback test asserts the cmd.exe fallback removes the marker.

The refactor is behavior-preserving for every consuming shell and strictly narrows retention: the only case that changes is a Git Bash whose wrapper did not install, which previously kept a marker nothing could consume. Verified locally that the touched suites pass (codex-default-home-shell-startup, windows-shell-args, local-pty-utils-windows-fallback, pty-subprocess-windows-shell-launch, local-pty-provider-windows-shell-launch, local-pty-shell-ready-wrapper-generation — 105 tests).

Pullfrog  | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

@brennanb2025

brennanb2025 commented Sep 17, 2026 •

Copy link
Copy Markdown
Contributor Author

Review status: code clean; packaged update proof still blocked

Reviewed and validated exact head 3310201848c2e3d763481132246560bb1850dce8. The same-model clean review and final readiness pass found no remaining P0–P2 code issues. The PR is mergeable with a clean merge state, and all reported GitHub checks are green.

One material issue was found and fixed during review: Git Bash wrapper materialization could fail open while retaining a one-shot home marker that the launched shell could not consume. Marker retention now comes from the resolved launch's actual consumer capability. Successful PowerShell and wrapped Git Bash launches consume it; unsupported, unwrapped, and degraded paths remove it while still allowing the terminal to launch.

Validation completed:

  • 271 focused exact-head tests passed across shell, IPC, daemon, and Windows ownership paths; 12 native-Windows-only cases were skipped on macOS.
  • Native Windows high-spec validation passed 153 relevant tests.
  • Typecheck, changed-file code quality, formatting, diff checks, architecture/performance review, and merge-tree validation passed.
  • Performance review found only constant-size environment updates and bounded Git Bash wrapper-file checks at shell startup. No polling, timers, listeners, growing caches, new subprocesses, or renderer hot-path work were added.
  • Live hidden-Electron checks passed for the system-default real-home lane over both persistent-daemon and in-process local providers, a real codex --version child, Git Bash wrapper success and fail-open, cmd and WSL marker scrubbing, and an explicit custom home.

Windows evidence:

This review is not gap-free. A true packaged protocol-v36 → v37 NSIS update and daemon reattach remains blocked. Exact-head CI produces an unpacked Windows app rather than an NSIS installer, and the updater harness must run on disposable Windows because it replaces the registered installation and shortcuts. The available high-spec host has a live production Orca install and no usable Windows Sandbox or admin-accessible VM, so I did not risk that installation.

Closing the remaining material gap requires an exact-head v37 installer, a protocol-v36 baseline installer, and the repo's updater E2E on disposable Windows CI. An explicit managed-account pane was also not opened because no managed account was added; live custom-home routing and focused tests covered the same managed/custom selection boundary.

@brennanb2025

Copy link
Copy Markdown
Contributor Author

Closing as superseded: a merged PR already covers this change. Merged #24356 (bd6d7b9) 'run Windows Codex on the real ~/.codex' removed the isShellStartupEnvProbeSupported Windows guard from runtime-home-service-home-routing.ts and added powershell-profile-env.ts; same goal and

(Stale-PR cleanup 2026-10-20, approved by Brennan. Reopen if something here is still missing on main.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant