Repository navigation
feat(codex): surface a stalled config sync instead of failing silently - #10449
Conversation
Why: the mirror keeps serving the last synced settings when ~/.codex/config.toml is missing, blank, or unreadable. That is the right call for data safety, but it is invisible — a downed WSL distro or an unhydrated cloud-synced home leaves "Orca ignores my config edits" with no log line and no UI to diagnose. Status is derived on demand from the same predicates the mirror uses, so the two cannot disagree. The stall is logged once per episode rather than on every launch and quota poll, and the Codex account section names the file and what to do.
|
Note Reviews pausedIt 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 Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughAdds Codex configuration sync status types and stall detection for missing, blank, or unreadable system configuration. The main process reports stall and recovery transitions during mirroring and exposes status through IPC and preload APIs. The web fallback returns a synced status. The settings UI fetches local Codex sync status and displays reason-specific localized warnings, with tests covering status transitions, logging behavior, API registration, and warning mapping. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 05026436-6e78-41c7-af7d-76a419e22c80
📒 Files selected for processing (14)
config/tsconfig.cli.jsonsrc/main/codex/codex-config-mirror.tssrc/main/codex/config-sync-stall.test.tssrc/main/codex/config-sync-stall.tssrc/main/ipc/codex-config-sync.tssrc/main/ipc/register-core-handlers.test.tssrc/main/ipc/register-core-handlers.tssrc/preload/api-types.tssrc/preload/index.tssrc/renderer/src/components/settings/AccountsPane.tsxsrc/renderer/src/components/settings/codex-config-sync-warning.test.tssrc/renderer/src/components/settings/codex-config-sync-warning.tssrc/renderer/src/web/web-preload-api.tssrc/shared/codex-config-sync-types.ts
…-stall-visibility
…-stall-visibility
An unreadable source throws out of the mirror, so reporting only on the success path left that stall latch-less: it logged the raw failure on every launch and quota poll while its reason never reached the surfaced status. Report from the catch path too. The clear message also claimed the source was "readable again", which is false when the stall ended because the runtime config was removed rather than because the source came back. Restoring console.warn now happens in afterEach — an inline mockRestore is skipped by a failing assertion, and the leaked spy made every later case in the block fail spuriously.
… host Review round 1 findings: - The unreadable-source latch still never fired in the steady state. Once a baseline exists, promotion reads the source before the mirror does, so it throws first and `!promotionPlan` returned before any reporting — logging a reasonless failure every launch and quota poll, which is exactly what the previous commit claimed to fix. Report from that branch too. The test only passed because its fixture had no baseline; it now seeds one first and fails without the fix. - The banner named the host's ~/.codex while a WSL or per-account runtime was selected, whose real source is a different file entirely. Gate it to the host scope, matching how the sign-in warning is already gated. - Three new translate keys were missing from the locale catalogs, failing the localization gate in `pnpm lint`. - The registrar mock was never asserted, so deleting the registration left the suite green. - `codexConfigSyncStatus` hung off the `agentHooks` namespace despite having nothing to do with agent hooks; moved to its own `codexConfigSync.status` while it is still a four-file change.
…rrors Review round 2: - The status resolved the shared runtime home, but the system default now runs Codex directly against ~/.codex and managed accounts get their own home. So a stalled per-account mirror showed no banner at all, while a stale shared home could warn about a config the active lane never reads. Resolve the mirrored home from the current selection, and report synced when the lane has no mirror to fall behind. - The round-1 report on the promotion failure path could clear the latch on a pass where no mirror ran, claiming a recovery that never happened and silencing every later pass. Only ever latch a stall there; leave clearing to the path that actually mirrored.
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 5c2d987f-c25c-4330-ab01-5376a85f7f27
📒 Files selected for processing (8)
src/main/codex-accounts/runtime-home-service.tssrc/main/codex-accounts/service.tssrc/main/codex/codex-config-mirror.tssrc/main/codex/config-sync-stall.test.tssrc/main/ipc/codex-config-sync.test.tssrc/main/ipc/codex-config-sync.tssrc/main/ipc/register-core-handlers.test.tssrc/main/ipc/register-core-handlers.ts
🚧 Files skipped from review as they are similar to previous changes (4)
- src/main/ipc/register-core-handlers.ts
- src/main/ipc/register-core-handlers.test.ts
- src/main/codex/config-sync-stall.test.ts
- src/main/codex/codex-config-mirror.ts
| it('re-registers cleanly so a reload cannot leak a duplicate handler', () => { | ||
| invokeHandler(null) | ||
| expect(removeHandlerMock).toHaveBeenCalledWith('codexConfigSync:status') | ||
| }) |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Exercise a second registration in this test.
This currently registers the handler only once, so it verifies that removeHandler was called but not that re-registration completes successfully. Invoke registerCodexConfigSyncHandlers twice and assert the second registration remains usable.
Proposed test adjustment
- invokeHandler(null)
+ expect(invokeHandler(null).state).toBe('synced')
+ expect(invokeHandler(null).state).toBe('synced')
expect(removeHandlerMock).toHaveBeenCalledWith('codexConfigSync:status')Review round 3: - Resolving the status per selection made the fetch account-dependent, but the effect was not keyed on the active account. Switching accounts left the banner describing the previous one — and switching INTO a stalled account showed nothing at all, which is the silence this change exists to remove. - Pin the home resolution itself: it had no direct test, and its shared-home path was a hand-copied literal that could drift from the real helper and silence the banner with every other test still green. - Narrow the handler's dependency to the one method it calls, which also drops an `as unknown as` cast from its test. - Skip the chmod-based test on Windows, where a read-only directory does not block writes so the scenario cannot be constructed; matches the convention already used in config-settings-promotion.test.ts.
…suite Round 4 returned clean; these are its two non-blocking nits. Narrowing the handler param left its JSDoc stranded above the new type, so the function had no hover doc. The resolver suite also read the developer's real CODEX_HOME and shell rc, so anyone exporting one would see it fail locally.
stablyai#10449) * feat(codex): surface a stalled config sync instead of failing silently Why: the mirror keeps serving the last synced settings when ~/.codex/config.toml is missing, blank, or unreadable. That is the right call for data safety, but it is invisible — a downed WSL distro or an unhydrated cloud-synced home leaves "Orca ignores my config edits" with no log line and no UI to diagnose. Status is derived on demand from the same predicates the mirror uses, so the two cannot disagree. The stall is logged once per episode rather than on every launch and quota poll, and the Codex account section names the file and what to do. * fix(codex): latch an unreadable source and stop over-claiming recovery An unreadable source throws out of the mirror, so reporting only on the success path left that stall latch-less: it logged the raw failure on every launch and quota poll while its reason never reached the surfaced status. Report from the catch path too. The clear message also claimed the source was "readable again", which is false when the stall ended because the runtime config was removed rather than because the source came back. Restoring console.warn now happens in afterEach — an inline mockRestore is skipped by a failing assertion, and the leaked spy made every later case in the block fail spuriously. * fix(codex): latch the stall promotion hits first, and scope it to the host Review round 1 findings: - The unreadable-source latch still never fired in the steady state. Once a baseline exists, promotion reads the source before the mirror does, so it throws first and `!promotionPlan` returned before any reporting — logging a reasonless failure every launch and quota poll, which is exactly what the previous commit claimed to fix. Report from that branch too. The test only passed because its fixture had no baseline; it now seeds one first and fails without the fix. - The banner named the host's ~/.codex while a WSL or per-account runtime was selected, whose real source is a different file entirely. Gate it to the host scope, matching how the sign-in warning is already gated. - Three new translate keys were missing from the locale catalogs, failing the localization gate in `pnpm lint`. - The registrar mock was never asserted, so deleting the registration left the suite green. - `codexConfigSyncStatus` hung off the `agentHooks` namespace despite having nothing to do with agent hooks; moved to its own `codexConfigSync.status` while it is still a four-file change. * fix(codex): report sync health for the home the selection actually mirrors Review round 2: - The status resolved the shared runtime home, but the system default now runs Codex directly against ~/.codex and managed accounts get their own home. So a stalled per-account mirror showed no banner at all, while a stale shared home could warn about a config the active lane never reads. Resolve the mirrored home from the current selection, and report synced when the lane has no mirror to fall behind. - The round-1 report on the promotion failure path could clear the latch on a pass where no mirror ran, claiming a recovery that never happened and silencing every later pass. Only ever latch a stall there; leave clearing to the path that actually mirrored. * fix(codex): refetch sync status when the active Codex account changes Review round 3: - Resolving the status per selection made the fetch account-dependent, but the effect was not keyed on the active account. Switching accounts left the banner describing the previous one — and switching INTO a stalled account showed nothing at all, which is the silence this change exists to remove. - Pin the home resolution itself: it had no direct test, and its shared-home path was a hand-copied literal that could drift from the real helper and silence the banner with every other test still green. - Narrow the handler's dependency to the one method it calls, which also drops an `as unknown as` cast from its test. - Skip the chmod-based test on Windows, where a read-only directory does not block writes so the scenario cannot be constructed; matches the convention already used in config-settings-promotion.test.ts. * chore(codex): restore the handler docstring and isolate the resolver suite Round 4 returned clean; these are its two non-blocking nits. Narrowing the handler param left its JSDoc stranded above the new type, so the function had no hover doc. The resolver suite also read the developer's real CODEX_HOME and shell rc, so anyone exporting one would see it fail locally.
Summary
When Orca can't read
~/.codex/config.toml, the mirror keeps serving the settings it last synced instead of wiping the managed runtime config (#9127). That is the right call for data safety, but it was completely invisible — no log line, no UI, no IPC. The user's symptom is "I edited my Codex config and Orca ignores it," with nothing to diagnose.This surfaces the stall.
ELI5
If Orca can't read your Codex settings file, it keeps using the last copy it understood — so nothing breaks. But it never told you that was happening, so your edits looked like they were being ignored for no reason. Now it says so, and names the file to fix.
What changed
missing-source,blank-source,unreadable-source.Status is derived on demand from the same predicates the mirror uses, so the two can't drift — there is no cached state to invalidate. The value crossing IPC stays machine-readable (
state+reason+ path); the sentence is localized at the edge viatranslate()like every other Accounts warning.Evidence
Captured against a real Codex setup (real
codex-cli 0.145.0, a real managed Codex account selected, real per-account home).The stall banner in the Codex section of AI Provider Accounts, naming the exact source config that is missing:
A real Codex terminal session in the same run, showing Orca injected the per-account home as
CODEX_HOME— the same home the status resolver reported on and the mirror logged, so all three agree:The stall clears as soon as the source returns; that transition is covered by the unit tests rather than a screenshot.
Diagnostic log line from that same run:
The banner is derived on demand so the UI clears instantly, while the log line follows the next mirror pass. That asymmetry is deliberate: the UI reflects truth now, the log records what the mirror actually did.
Validation
src/main/codex,src/main/ipc,src/renderer/.../settings,src/renderer/src/web.Deliberately out of scope
Each of these deserves its own change rather than riding along:
~/.codex/config.tomlused to clear runtime settings and no longer does, with nothing offered in its place.[projects.*]self-heal while stalled.Screenshots
Included above under Evidence — stall banner and the recovered (cleared) state, captured from a dev build.
Testing
pnpm typecheck— cleanpnpm lint— 0 errorsnpx vitest run --config config/vitest.config.ts src/main/codex src/main/ipc src/renderer/src/components/settings src/renderer/src/web— 3792 passedpnpm run check:max-lines-ratchet— no new bypassesKnown unrelated failure:
config/scripts/package-electron-runtime-contract.test.mjs > keeps release-cut version commits skill-independent and taggable on retriesfails identically on cleanorigin/main(verified in a detached worktree ate133d93b7b). This PR touches no release tooling.AI Review Report
Automated review raised two functional findings, both fixed in
6d0c85bb8b:unreadable-sourcenever reached the episode latch, because that case throws out of the mirror and reporting only happened on the success path. It logged the raw failure on every launch and quota poll while the reason never surfaced. Now reported from the catch path, with a regression test asserting one latchedunreadable-sourceline across three passes.While fixing those I also found the tests' inline
mockRestore()was skipped by a failing assertion, leaking aconsole.warnspy and cascading spurious failures into later cases; cleanup moved toafterEach.Security Audit
~/.codex/config.tomlandexistsSync-checks two paths.codexConfigSync:statusis read-only, takes no arguments, and returns a closed union plus that path.synced, so a browser client cannot infer anything about the host filesystem.Known gap
A promotion-blocked mirror is not surfaced in the UI. If
~/.codex/config.tomlis present and readable but the write-back cannot be performed (read-only~/.codex, or a symlink cycle), promotion throws, the mirror is skipped, and the stall is logged with a reason but the banner stays silent —getCodexConfigSyncStatusderives from disk and has no visibility into "promotion threw".Not a regression: that failure mode was equally silent before this PR, and the log line is new. Surfacing it needs a fourth stall reason plus coupling the IPC status to the module latch, which would give up the stateless "status and mirror cannot disagree" property this PR is built on. Tracked as a follow-up rather than bundled here.
Notes
Follow-ups deliberately not bundled here, each listed under Deliberately out of scope above: a "Re-sync now" button, a supported reset path, and the paused duplicate-
[projects.*]self-heal.