Skip to content

feat(codex): surface a stalled config sync instead of failing silently - #10449

Merged
brennanb2025 merged 8 commits into
mainfrom
fix/codex-config-sync-stall-visibility
Jul 25, 2026
Merged

brennanb2025 merged 8 commits into
mainfrom
fix/codex-config-sync-stall-visibility

Conversation

@brennanb2025

@brennanb2025 brennanb2025 commented Jul 24, 2026 •

Copy link
Copy Markdown
Contributor

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

  • Codex account settings shows a banner naming the exact file and what to do. The copy is reason-specific: a blank file reads as "expected while a synced folder finishes downloading", not as an error.
  • One log line per stall episode, not one per launch and quota poll, plus a recovery line when it clears.
  • Three distinct causes are kept apart rather than collapsed: 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 via translate() 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:

real-02-banner.png

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:

real-03-codex-session.png

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:

[codex-config] Config sync stalled (missing-source): /tmp/.../.codex/config.toml is unusable,
so .../codex-runtime-home/home keeps its last synced settings. Edits to the source will not
apply until it is readable.

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

  • 3761 tests pass across src/main/codex, src/main/ipc, src/renderer/.../settings, src/renderer/src/web.
  • Typecheck clean, lint 0 errors, max-lines ratchet clean (no new bypasses).
  • Each new test fails when its own fix is reverted — verified by reverting the blank-source detection and the episode latch independently.

Deliberately out of scope

Each of these deserves its own change rather than riding along:

  • A "Re-sync now" button. The mirror already runs every launch and on the quota poll, so it saves little time; its real value is confirmation feedback.
  • A supported reset path. Emptying ~/.codex/config.toml used to clear runtime settings and no longer does, with nothing offered in its place.
  • The mirror also pauses the runtime config's duplicate-[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 — clean
  • pnpm lint — 0 errors
  • npx vitest run --config config/vitest.config.ts src/main/codex src/main/ipc src/renderer/src/components/settings src/renderer/src/web — 3792 passed
  • pnpm run check:max-lines-ratchet — no new bypasses
  • Manual: dev build with an unreadable source, banner verified in Settings -> AI Provider Accounts, then verified it clears on recovery
  • Revert-proofed: each new test fails when its own fix is reverted

Known unrelated failure: config/scripts/package-electron-runtime-contract.test.mjs > keeps release-cut version commits skill-independent and taggable on retries fails identically on clean origin/main (verified in a detached worktree at e133d93b7b). This PR touches no release tooling.

AI Review Report

Automated review raised two functional findings, both fixed in 6d0c85bb8b:

  1. Major — unreadable-source never 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 latched unreadable-source line across three passes.
  2. Minor — the clear message claimed the source was "readable again", which is false when the stall ended because the runtime config was removed. Reworded to "stall cleared", with a test asserting the phrase is absent.

While fixing those I also found the tests' inline mockRestore() was skipped by a failing assertion, leaking a console.warn spy and cascading spurious failures into later cases; cleanup moved to afterEach.

Security Audit

  • No new network calls, subprocesses, or filesystem writes. The added code only reads ~/.codex/config.toml and existsSync-checks two paths.
  • The absolute config path is shown in the user's own settings UI and written to the app log. It is a path, not file contents — no config values, tokens, or credentials are read into the status or logged.
  • New IPC channel codexConfigSync:status is read-only, takes no arguments, and returns a closed union plus that path.
  • The web fallback returns 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.toml is 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 — getCodexConfigSyncStatus derives 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.

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.
@coderabbitai

coderabbitai Bot commented Jul 24, 2026 •

Copy link
Copy Markdown
Contributor

Review 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 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)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 40.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 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 matches the PR’s main change: surfacing Codex config sync stalls instead of failing silently.
Description check ✅ Passed All required sections are present and the PR description is detailed; the AI review report is the only part that could be more explicit about cross-platform coverage.
✨ Finishing Touches
📝 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: 05026436-6e78-41c7-af7d-76a419e22c80

📥 Commits

Reviewing files that changed from the base of the PR and between 4dcb68f and d54c0c3.

📒 Files selected for processing (14)
  • config/tsconfig.cli.json
  • src/main/codex/codex-config-mirror.ts
  • src/main/codex/config-sync-stall.test.ts
  • src/main/codex/config-sync-stall.ts
  • src/main/ipc/codex-config-sync.ts
  • src/main/ipc/register-core-handlers.test.ts
  • src/main/ipc/register-core-handlers.ts
  • src/preload/api-types.ts
  • src/preload/index.ts
  • src/renderer/src/components/settings/AccountsPane.tsx
  • src/renderer/src/components/settings/codex-config-sync-warning.test.ts
  • src/renderer/src/components/settings/codex-config-sync-warning.ts
  • src/renderer/src/web/web-preload-api.ts
  • src/shared/codex-config-sync-types.ts

Comment thread src/main/codex/codex-config-mirror.ts Resolved
Comment thread src/main/codex/config-sync-stall.ts Resolved
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.

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

Run ID: 5c2d987f-c25c-4330-ab01-5376a85f7f27

📥 Commits

Reviewing files that changed from the base of the PR and between 722f541 and 126b474.

📒 Files selected for processing (8)
  • src/main/codex-accounts/runtime-home-service.ts
  • src/main/codex-accounts/service.ts
  • src/main/codex/codex-config-mirror.ts
  • src/main/codex/config-sync-stall.test.ts
  • src/main/ipc/codex-config-sync.test.ts
  • src/main/ipc/codex-config-sync.ts
  • src/main/ipc/register-core-handlers.test.ts
  • src/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

Comment on lines +78 to +81
it('re-registers cleanly so a reload cannot leak a duplicate handler', () => {
invokeHandler(null)
expect(removeHandlerMock).toHaveBeenCalledWith('codexConfigSync:status')
})

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

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.
@brennanb2025
brennanb2025 merged commit c3526cc into main Jul 25, 2026
4 checks passed
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
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.
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