Skip to content

refactor(codex): remove WSL runtime mirror machinery - #16505

Merged
brennanb2025 merged 4 commits into
mainfrom
brennanb2025/sta-4606-wsl-mirror-removal-stage-4
Aug 27, 2026
Merged

brennanb2025 merged 4 commits into
mainfrom
brennanb2025/sta-4606-wsl-mirror-removal-stage-4

Conversation

@brennanb2025

@brennanb2025 brennanb2025 commented Aug 25, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 6 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​93 $\color{#cf222e}{\Huge{\mathbf{−}}}$​281 $\color{#cf222e}{\Huge{\mathbf{−}}}$​188
Prod 4 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​63 $\color{#cf222e}{\Huge{\mathbf{−}}}$​390 $\color{#cf222e}{\Huge{\mathbf{−}}}$​327

Summary

  • delete the retired WSL runtime-home copy, read-back, seed, and active-pointer paths
  • remove obsolete per-distro mirror state and restart preservation plumbing
  • retain direct-home routing and legacy drain coverage while deleting mirror-only tests

Verification

  • 1,859 tests passed across src/main/codex, src/main/codex-accounts, and src/main/agent-hooks (12 skipped)
  • pnpm typecheck
  • node config/scripts/check-changed-code-quality.mjs
  • mutation checks for direct-home account selection and freshness-gated legacy promotion

@brennanb2025

Copy link
Copy Markdown
Contributor Author

Electron visible-behavior check (macOS, this PR app)

Launched brennanb2025/sta-4606-wsl-mirror-removal-stage-4 via CDP (identity.devRepoRoot = this worktree). Exercised Settings → AI Provider Accounts, Agents (default = Codex), and the status-bar Usage popover. No source edits.

Visible: Codex System default is Active ([email protected]); empty managed roster; accounts scoped to this device. Account Location / WSL distro picker is not shown (expected on macOS; wsl.isAvailable() === false). Usage popover shows Codex wk 13%; Manage Accounts… returns to the accounts pane.

Gaps: Windows/WSL live UI, managed-account add/switch/remove, and a Codex pane launch were not available on this host.

Landing

01-initial-window.png

AI Provider Accounts (Claude + Codex)

03-accounts-pane.png

Codex accounts (search-focused)

07-settings-search-codex-account.png

Settings search “WSL” (no Account Location control)

06-settings-search-wsl.png

Agents: default = Codex

09-agents-codex-default.png

Status-bar Usage (Codex wk 13%)

11-status-bar-usage.png

Manage Accounts… → accounts pane

12-manage-accounts-from-usage.png

@brennanb2025

Copy link
Copy Markdown
Contributor Author

Review status: land after fixes

Reviewed the final PR state at cbfbd44652.

  • Fixed a real restart regression: retained legacy WSL panes now drain refreshed auth before restart/update store flushing, while the retired mirror machinery remains removed.
  • pnpm exec tsc --noEmit -p config/tsconfig.node.json passes.
  • Focused restart/drain/WSL/account tests pass (38/38).
  • Full src/main/codex-accounts suite passes (280/280).
  • Changed-code quality, type-aware quality, React Doctor, and git diff --check pass.
  • Final readiness checklist found no proven P0/P1/P2 issues.
  • Grok Electron validation passed on macOS with the visible account/settings/usage flows; screenshots and detailed evidence are in the preceding PR comment.

Remaining validation gap: live Windows/WSL managed-account flows and a Codex pane launch were not available on this macOS host. SSH and mobile surfaces are not touched by this diff.

@brennanb2025

Copy link
Copy Markdown
Contributor Author

Remote Windows high-spec validation follow-up:

  • Created a disposable Orca-managed worktree at C:\Users\neil\orca\workspaces\orca\pr16505-windows-grok on head cbfbd44652.
  • The paired environment was reachable, but its terminal/runtime reported Linux awin ... WSL2 (hostPlatform: linux), not a native Windows runtime.
  • No usable Linux node/Grok command was available there, and invoking the mounted Windows Node binary did not produce a runnable Electron surface.
  • Native Windows Electron validation therefore could not be honestly completed from this session; no screenshots are being claimed for that platform.
  • The disposable worktree was removed successfully and verified absent from the remote worktree registry.

The existing local/macOS Electron screenshots and functional review remain valid; this is a platform-environment blocker, not a code finding.

@brennanb2025

Copy link
Copy Markdown
Contributor Author

High-spec retry result (2026-08-26):

I retried via the corrected remote-host and supervised orchestration paths, both against PR head cbfbd44652. The remote worktrees were created successfully, but every terminal receipt identified executionHostId: local, hostPlatform: linux, and the shell title neil@awin with WSL2 kernel 6.18.33.2-microsoft-standard-WSL2; Grok then failed because the remote shell has no grok executable. A bounded invocation of the mounted Windows Node binary (/mnt/c/Program Files/nodejs/node.exe --version) exited 124 after 12 seconds, while cmd.exe /c ver also hung, so there was no native Windows process or Electron CDP endpoint to validate.

The orchestration dispatch is recorded as failed (agent_prompt_stalled), no Windows screenshots are claimed, and both disposable worktrees/terminals have been stopped and removed. This remains an environment/runtime blocker, not a code finding.

@brennanb2025
brennanb2025 force-pushed the brennanb2025/sta-4606-wsl-mirror-removal-stage-3 branch from 740bef3 to dc57877 Compare August 26, 2026 21:48
@brennanb2025
brennanb2025 force-pushed the brennanb2025/sta-4606-wsl-mirror-removal-stage-4 branch from cbfbd44 to da2046a Compare August 26, 2026 21:48
@brennanb2025
brennanb2025 force-pushed the brennanb2025/sta-4606-wsl-mirror-removal-stage-3 branch from dc57877 to a327198 Compare August 27, 2026 00:03
@brennanb2025
brennanb2025 force-pushed the brennanb2025/sta-4606-wsl-mirror-removal-stage-4 branch from da2046a to f1a1bbb Compare August 27, 2026 00:03
runtime-home-service.ts no longer spawns wsl.exe or imports child_process;
both boundary guards fail closed on a stale entry so the goalpost keeps moving.
@brennanb2025
brennanb2025 force-pushed the brennanb2025/sta-4606-wsl-mirror-removal-stage-4 branch from f1a1bbb to 42cbc0e Compare August 27, 2026 04:29
@brennanb2025
brennanb2025 changed the base branch from brennanb2025/sta-4606-wsl-mirror-removal-stage-3 to main August 27, 2026 04:29
@coderabbitai

coderabbitai Bot commented Aug 27, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: f50ca4bf-d076-424d-80f9-ced1abbf3f82

📥 Commits

Reviewing files that changed from the base of the PR and between 42cbc0e and 830b736.

📒 Files selected for processing (2)
  • src/main/agent-auth-restart-preservation.test.ts
  • src/main/agent-auth-restart-preservation.ts

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


📝 Walkthrough

Walkthrough

WSL runtime authentication drains now return promises and coalesce callers onto in-flight drains. CodexRuntimeHomeService awaits drains for selected WSL accounts during restart synchronization. Legacy WSL runtime-home migration, shell execution, seed configuration, and read-back state were removed. Runtime-auth comparison now distinguishes unreadable files from missing files. Restart preservation runs optional WSL synchronization and store persistence with separate timeout budgets. Tests cover asynchronous draining, failure logging, ordering, and direct-account behavior.

Merge Risk: 🟡 Moderate · up to 830b7

The refactor removes WSL mirror machinery but still leaves restart preservation skipping supported UNC-backed WSL accounts, which can leave refreshed authentication undrained after restart; the associated async test also may pass without confirming completion. Merge should wait for explicit owner follow-up on these bounded issues.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description summarizes the implementation and reports verification results, but it omits most required template sections, including ELI5, What Changed, Why, Linked Issue, Visual Proof, Testing che… Complete the required template sections. Add the linked issue, explain the change and rationale, state N/A with a reason for Visual Proof if applicable, document manual and automated testing, complete the Agent skill upstream boundary secti…
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 6 functions across 7 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely identifies the main change: removing retired WSL runtime mirror machinery.
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.
Full details: Description check

Explanation

The description summarizes the implementation and reports verification results, but it omits most required template sections, including ELI5, What Changed, Why, Linked Issue, Visual Proof, Testing checkboxes, AI Disclosure, Review, boundary confirmation, Notes, and the Checklist.

Resolution

Complete the required template sections. Add the linked issue, explain the change and rationale, state N/A with a reason for Visual Proof if applicable, document manual and automated testing, complete the Agent skill upstream boundary section, address compatibility and platform impact, and complete the checklist.

  • 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.

@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: Pro Plus

Run ID: d3e2cc74-f33a-4421-9348-23ca7f4487b4

📥 Commits

Reviewing files that changed from the base of the PR and between ebcd637 and 42cbc0e.

📒 Files selected for processing (10)
  • src/main/agent-auth-restart-preservation.test.ts
  • src/main/agent-auth-restart-preservation.ts
  • src/main/codex-accounts/legacy-wsl-runtime-auth-drain.ts
  • src/main/codex-accounts/runtime-home-service.ts
  • src/main/codex-accounts/runtime-home-wsl-managed-accounts.test.ts
  • src/main/codex-accounts/runtime-home-wsl-session-bridge.test.ts
  • src/main/codex-accounts/runtime-home-wsl-system-default.test.ts
  • src/main/pty/codex-home-wsl-env.ts
  • src/main/wsl/__fixtures__/wsl-invocation-allowlist.txt
  • src/shared/child-process/__fixtures__/child-process-import-allowlist.txt
💤 Files with no reviewable changes (3)
  • src/main/wsl/fixtures/wsl-invocation-allowlist.txt
  • src/shared/child-process/fixtures/child-process-import-allowlist.txt
  • src/main/codex-accounts/runtime-home-wsl-system-default.test.ts

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

Comment on lines +67 to +78
syncActiveWslSelectionsBeforeRestart: vi.fn(async () => {
calls.push('codex-wsl')
})
},
store: {
flushPendingOrThrowAsync
flushPendingOrThrowAsync: vi.fn(async () => {
calls.push('flush')
})
}
})

expect(flushPendingOrThrowAsync).toHaveBeenCalledTimes(1)
expect(JSON.stringify(warn.mock.calls)).not.toContain('token-secret')
expect(calls).toEqual(['codex-host', 'codex-wsl', 'flush'])

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 | 🟡 Minor | ⚡ Quick win

Make the test wait for WSL drain completion.

The mock records codex-wsl before its promise settles. A non-awaited drain would still pass this assertion. Use a deferred promise and assert that flush does not run before the drain resolves.

Comment on lines +1042 to +1051
const account = this.getActiveAccount(settings.codexManagedAccounts, accountId)
if (!account || account.managedHomeRuntime !== 'wsl') {
continue
}
const distro =
selectedDistroKey === getWslSelectionKey(null)
? account.wslDistro?.trim() || null
: selectedDistroKey.trim() || null
if (distro) {
drains.push(this.startLegacyWslAuthDrain({ runtime: 'wsl', wslDistro: distro }))

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

Drain UNC-backed WSL accounts too. Line 1043 skips accounts that getWslManagedHomePath(account) accepts without managedHomeRuntime === 'wsl'. Their direct-home launch works, but restart does not drain refreshed auth from a retained legacy pane. Classify these accounts with the same UNC-aware predicate and derive the default-lane distro from the UNC path when metadata is absent.

@brennanb2025

Copy link
Copy Markdown
Contributor Author

Electron QA (macOS, Playwright CDP)

Fresh Orca dev instance launched from this worktree (sta-4606-stage-4-pr16505 @ brennanb2025/sta-4606-wsl-mirror-removal-stage-4), attached via CDP on 127.0.0.1:9335 / renderer 5174. Identity from window.api.app.getIdentity():

  • name: Orca: brennanb2025/sta-4606-wsl-mirror-removal-stage-4
  • isDev: true
  • devRepoRoot: this worktree

This PR is a WSL/backend change (remove Codex WSL runtime-home mirror machinery). No meaningful changed UI surface is reachable on macOS — window.api.wsl.isAvailable() returned false, distros [], and Settings does not show an Account location / WSL runtime picker. I did not invent Windows/WSL UI.

What was exercised

  • App launched and rendered the empty-workspace home.
  • Settings → AI Provider Accounts: Claude + Codex system-default accounts load; Codex shows [email protected] as Active. Copy is host-local (Account auth stays on this device). No mirror / runtime-home / Account location controls.
  • Settings → Terminal: macOS terminal settings only; no Windows/WSL runtime controls.

The only visible “WSL” string on Accounts is unrelated OpenCode Go helper copy (“shared across Windows and WSL terminals”).

Remaining gaps

  • Windows + real WSL distro path (direct-home vs retired mirror copy/read-back/seed/active-pointer) was not exercised here.
  • No Codex account add/switch/reauth was performed (would not validate this PR’s backend deletion).

Screenshots (full uncropped app window)

Empty home (fresh profile):

01-empty-app-home.png

AI Provider Accounts (Claude + Codex; strongest relevant surface):

02-settings-accounts.png

Codex accounts section after scroll:

03-settings-codex-accounts.png

Terminal settings (no WSL runtime UI on macOS):

04-settings-terminal.png

@brennanb2025

Copy link
Copy Markdown
Contributor Author

Electron QA (macOS, isolated dev instance)

Launched a fresh electron-vite Orca from brennanb2025/sta-4606-wsl-mirror-removal-stage-4 with CDP (9335 / renderer 5174, dedicated user-data dir) and attached Playwright. Identity confirmed: sta-4606-stage-4-pr16505 @ brennanb2025/sta-4606-wsl-mirror-removal-stage-4.

This PR is WSL/backend (runtime-home mirror removal). There is no dedicated changed UI. Closest reachable surface: Settings → AI Provider Accounts → Codex. On this macOS host the pane shows host System default / Active ([email protected]), “accounts for this device,” and no managed Codex accounts. codexAccounts.list() reports activeAccountIdsByRuntime.wsl: {} and wsl.listDistros() is empty. Settings search for WSL does not surface a WSL distro, runtime-home, or mirror pane.

Not exercised: actual WSL launch/routing, mirror copy/read-back/seed, or restart preservation — those require Windows+WSL.

Visible proof

Isolated instance home (empty profile, app alive on this branch):

02-main-empty-worktree-launch.png

Codex accounts / direct-home system default (closest related UI):

03-settings-codex-accounts-direct-home.png

Settings search WSL — no WSL-specific settings pane on macOS:

04-settings-search-wsl-no-mirror-ui.png

@brennanb2025

Copy link
Copy Markdown
Contributor Author

Electron QA retry 2 (macOS, Grok + Playwright CDP)

Launched a fresh Orca dev instance for brennanb2025/sta-4606-wsl-mirror-removal-stage-4 (identity.devRepoRoot = this worktree, Dock tile Orca/ brennanb2025-sta-4606-wsl-mirror-removal-stage-4, CDP http://127.0.0.1:9337, isolated user-data profile). Exercised landing, Settings → AI Provider Accounts, settings search “WSL”, Agents (default = Codex), and the status-bar Usage popover including Manage Accounts…. No source edits.

Visible (this PR app):

  • Empty landing (fresh profile, no workspaces).
  • Codex System default is Active ([email protected]); Claude System default Active; empty managed roster; accounts scoped to this device.
  • Account Location / WSL distro picker is not shown (expected on macOS; wsl.isAvailable() === false).
  • Settings search “WSL” still lists AI Provider Accounts and does not surface an Account Location control.
  • Agents: default = Codex.
  • Usage popover: Codex wk 24%, Grok wk 63%, Claude Limited; Manage Accounts… returns to the accounts pane.

Gaps (unchanged, platform): Windows/WSL live UI (Account Location, per-distro managed accounts, mirror-removal behavior) is not exercisable on this macOS host. A Codex pane launch was not run. An earlier concurrent launch of this worktree hit ENOSPC on Chromium disk-cache and wedged CDP; that process was stopped. The screenshots below are from the subsequent healthy fresh instance.

Landing (fresh instance)

05-fresh-landing.png

AI Provider Accounts (Claude + Codex, this device)

06-fresh-accounts-pane.png

Settings search “WSL” (no Account Location control)

07-fresh-search-wsl.png

Agents: default = Codex

04-agents-codex-default.png

Status-bar Usage (Codex wk 24%)

08-usage-popover.png

Manage Accounts… → accounts pane

09-manage-accounts-from-usage.png

@brennanb2025

Copy link
Copy Markdown
Contributor Author

Codex review loop — status

  • Final head: 830b736cb499d1bc4106ce279480ea5ae2e57271 (pushed to PR refactor(codex): remove WSL runtime mirror machinery #16505).
  • Same-model adversarial review: 2 rounds completed with gpt-5.6-sol / high effort. Round 1 found one proven in-scope P2 in restart preservation: a shared timeout could allow restart before the bounded WSL auth drain completed and leave no independent store-flush wait. The fix now awaits the WSL drain independently and gives store persistence its own timeout, with deterministic regression coverage. Round 2 was clean; no scope-expanding or additional proven issues were found.
  • Readiness checklist: start pass identified that same P2; final pass found no proven P0/P1/P2 issues. Residual risk is limited to the intended bounded WSL drain behavior and the lack of live Windows/WSL/Windows-SSH execution in this macOS environment.
  • Verification: focused suites passed (39 tests), broader Codex/account/hook coverage passed (1,954 tests, 12 skipped), post-fix regression subset passed (24 tests), pnpm tc / pnpm tc:node, direct oxlint, formatting, and diff checks passed. The changed-code quality wrapper is locally blocked by Node 26 warning text corrupting its JSON parser; this is tooling/environmental. GitHub checks are complete and green; the unrelated E2E job is skipped.
  • Electron QA screenshots were captured and attached in comment 5434569143 and comment 5434601790. The visible macOS settings/account surfaces were verified; live Windows/WSL routing remains unverified.

PR is reviewed and ready for maintainer decision. Do not merge automatically.

@brennanb2025
brennanb2025 merged commit 673842d into main Aug 27, 2026
48 checks passed
brennanb2025 pushed a commit that referenced this pull request Aug 27, 2026
…tor(codex): remove WSL runtime mirror machinery" (#16722)

This reverts commit ebcd637 (#16504) and dependent commit 673842d (#16505).

Launch-blocker rationale (findings-counsel validated):
- P0 Data Loss (F06-1): The WSL legacy auth drain deleteSource=1 path deletes intact source auth without re-validating the destination after concurrent destination rewrites, permanently corrupting auth credentials on upgrade.
- P1 Workflow Regression (FC-01): Pre-upgrade sessions under ~/.local/share/orca/codex-runtime-home/home are not linked into direct homes, breaking /resume in the Codex CLI for upgrading WSL users.
paidaxingyo666 pushed a commit to paidaxingyo666/Manta that referenced this pull request Aug 30, 2026
* refactor(codex): remove WSL runtime mirror machinery

* test(codex): drop allowlist entries the mirror removal made stale

runtime-home-service.ts no longer spawns wsl.exe or imports child_process;
both boundary guards fail closed on a stale entry so the goalpost keeps moving.

* fix(codex): drain legacy WSL auth before restart

* fix(codex): await WSL auth drain before restart

(cherry picked from commit 673842d)
paidaxingyo666 pushed a commit to paidaxingyo666/Manta that referenced this pull request Aug 30, 2026
…tor(codex): remove WSL runtime mirror machinery" (stablyai#16722)

This reverts commit ebcd637 (stablyai#16504) and dependent commit 673842d (stablyai#16505).

Launch-blocker rationale (findings-counsel validated):
- P0 Data Loss (F06-1): The WSL legacy auth drain deleteSource=1 path deletes intact source auth without re-validating the destination after concurrent destination rewrites, permanently corrupting auth credentials on upgrade.
- P1 Workflow Regression (FC-01): Pre-upgrade sessions under ~/.local/share/orca/codex-runtime-home/home are not linked into direct homes, breaking /resume in the Codex CLI for upgrading WSL users.

(cherry picked from commit 9c01e09)
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
* refactor(codex): remove WSL runtime mirror machinery

* test(codex): drop allowlist entries the mirror removal made stale

runtime-home-service.ts no longer spawns wsl.exe or imports child_process;
both boundary guards fail closed on a stale entry so the goalpost keeps moving.

* fix(codex): drain legacy WSL auth before restart

* fix(codex): await WSL auth drain before restart
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
…tor(codex): remove WSL runtime mirror machinery" (stablyai#16722)

This reverts commit 35c6098 (stablyai#16504) and dependent commit bf956ae (stablyai#16505).

Launch-blocker rationale (findings-counsel validated):
- P0 Data Loss (F06-1): The WSL legacy auth drain deleteSource=1 path deletes intact source auth without re-validating the destination after concurrent destination rewrites, permanently corrupting auth credentials on upgrade.
- P1 Workflow Regression (FC-01): Pre-upgrade sessions under ~/.local/share/orca/codex-runtime-home/home are not linked into direct homes, breaking /resume in the Codex CLI for upgrading WSL users.
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