Repository navigation
Conversation
|
@coderabbitai review |
✅ Action performedReview finished.
|
|
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:
📝 WalkthroughWalkthroughCodex persistence now supports temporary settings previews and atomic settings updates with reset-credit ledger changes. Account removal synchronizes runtime targets, rolls back on persistence failure, and remains retryable. Corrupt ledgers no longer block credential removal. Background quota refresh handles startup failures. Durable file publication now uses synchronous renames after generation checks, with regression coverage for competing writers. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
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: 1
🧹 Nitpick comments (2)
src/main/codex-accounts/service.ts (1)
719-727: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueOptional: collapse the duplicated failure log.
Both the synchronous
catchand the promisecatchlog the same message. A small helper removes the duplication and keeps a single log site.♻️ Proposed refactor
+ const logFailure = (error: unknown): void => { + console.error('[codex-accounts] Quota refresh after account change failed:', error) + } try { void this.rateLimits .refreshForCodexAccountChange(outgoingAccountId, target) - .catch((error) => { - console.error('[codex-accounts] Quota refresh after account change failed:', error) - }) + .catch(logFailure) } catch (error) { - console.error('[codex-accounts] Quota refresh after account change failed:', error) + logFailure(error) }src/main/codex-accounts/service.test.ts (1)
208-216: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winMirror the synchronous-callback contract in the test double.
The real
withCodexAccountSettingsPreviewthrows when the callback returns a thenable. This double accepts any callback. A regression that passes an asynchronous callback fromdoRemoveAccountwould still pass these tests, because the double would restore settings before the callback settled.Add the same thenable rejection to keep the double aligned with the store contract.
♻️ Proposed change
const withSettingsPreview = <T>(updates: Partial<GlobalSettings>, action: () => T): T => { const previousSettings = settings applySettings(updates) try { - return action() + const result = action() + if (typeof (result as { then?: unknown })?.then === 'function') { + void Promise.resolve(result).catch(() => {}) + throw new Error('Codex account settings preview callback must be synchronous') + } + return result } finally { settings = previousSettings } }
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 58467c48-bea3-42b2-b8d7-825d025336b5
📥 Commits
Reviewing files that changed from the base of the PR and between 33b6d4d and 5178def37aeaca212b66313ce0c1513d757dfad7.
📒 Files selected for processing (6)
src/main/codex-accounts/service.test.tssrc/main/codex-accounts/service.tssrc/main/durable-file-write.test.tssrc/main/durable-file-write.tssrc/main/persistence.test.tssrc/main/persistence.ts
|
5178def to
95e5c39
Compare
|
@coderabbitai review |
✅ Action performedReview finished.
|
There was a problem hiding this comment.
🧹 Nitpick comments (3)
src/main/codex-accounts/service.test.ts (3)
2869-2875: 🗄️ Data Integrity & Integration | 🔵 Trivial | ⚡ Quick winAssert that the corrupt ledger is never rewritten.
The test proves the settings-only flush runs. It does not prove the combined settings-and-ledger flush is skipped. Add a negative assertion so a future change that rewrites a corrupt ledger fails this test.
♻️ Proposed additional assertion
expect(store.updateCodexAccountSettingsAndFlush).toHaveBeenCalledOnce() + expect(store.updateCodexAccountSettingsAndResetLedgerAndFlush).not.toHaveBeenCalled() expect(() => store.getCodexResetCreditAttemptLedger()).toThrow( 'Codex reset-credit attempt ledger is corrupt' )
3382-3382: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueAlign the test name with the assertions.
The assertions at Lines 3415-3416 check
activeCodexManagedAccountId, which is the selected account, not the runtime target. Rename the test to describe the restored account selection.✏️ Proposed rename
- it('restores the selected runtime when account removal persistence fails', async () => { + it('restores the selected account when account removal persistence fails', async () => {
239-254: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winType the fixture against
Storeto catch method drift.
createStore()return type is inferred and passed throughstore as neverat construction, so renamed or changedupdateCodexAccountSettingsAndFlush,withCodexAccountSettingsPreview, orupdateCodexAccountSettingsAndResetLedgerAndFlushcalls can keep the tests passing. Annotate the fixture assatisfies Partial<Store>orPick<Store, ...>where those Codex persistence methods are needed.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 2a2f0020-3bdd-42e8-a1a1-27448e14dabf
📥 Commits
Reviewing files that changed from the base of the PR and between 5178def37aeaca212b66313ce0c1513d757dfad7 and 95e5c393b20a526c3fff7466de6791a049aeb3bf.
📒 Files selected for processing (6)
src/main/codex-accounts/service.test.tssrc/main/codex-accounts/service.tssrc/main/durable-file-write.test.tssrc/main/durable-file-write.tssrc/main/persistence.test.tssrc/main/persistence.ts
🚧 Files skipped from review as they are similar to previous changes (5)
- src/main/durable-file-write.ts
- src/main/durable-file-write.test.ts
- src/main/codex-accounts/service.ts
- src/main/persistence.test.ts
- src/main/persistence.ts
|
Addressed the three follow-up CodeRabbit nitpicks in
Verification on the current head: |
53f2de3 to
f283b6b
Compare
|
Rebased onto current Post-rebase verification:
|
|
@coderabbitai review |
✅ Action performedReview finished.
|
|
Taking a look! |
|
Exact-head readiness evidence for
Brennan action: approve final-head PR Checks, then rerun/approve Windows Crash-Survival E2E at this SHA. |
|
Thanks for this — the crash-safety approach is right, and committing the account settings and the reset-credit ledger through a single durability barrier before the managed home is deleted is exactly what this path needed. Nothing has been pushed to your branch. I reviewed it closely and have five fixes ready, but they can't land cleanly yet — more on that at the bottom. The important one: removal is currently impossible in a real case. The new read-only settings preview throws on any The other four:
One request. Could you move The PR is showing conflicts against main right now, so a rebase is needed regardless — dropping that commit during the same rebase would be the easiest moment to do it. That commit is also why the fixes above are still sitting here rather than on your branch: the superset fix and that commit's gating are genuine alternatives rather than things that stack, so the perf change wants to sit on top of these fixes rather than beside them. Once the rebase lands I'll push the five fixes and their tests; equally happy for you to take them yourself if you'd prefer. Two things seen and deliberately left alone, so they aren't lost: if the durable flush fails, the rollback re-runs reconciliation outside the preview, so a self-heal write can persist — meaning a failed removal can also clear an invalid host selection. That seems acceptable (the cleared selection is genuinely invalid and would be cleared at next launch anyway, and there was no rollback at all before). And deleting the managed home still follows the durable commit, so a crash in that window can orphan |
5b2ea47 to
81461be
Compare
|
Rebase/split request completed.
Exact-head verification:
I have not folded the five fixes from your review into the rebase, so the branch is ready for the prepared fixes and tests you offered to push. |
81461be to
e3b0254
Compare
|
Adversarial review fixes pushed through Fixed four defects:
The three initial cleanup regressions and the selectable-roster regression failed before their fixes. Seven cleanup regressions pass, including concurrent file creation and unavailable shares. The generated WSL ownership script ran with real Bash against empty, credential-bearing, wrong-owner, and failed-enumeration fixtures. Added Settings snapshot coverage and a WSL switcher regression. Validation on the current head:
All current-head CI workflows completed successfully, including the full unit-test shards, relay integration, static analysis/typecheck, Linux/Windows packaging, six persistence platforms, Linux compatibility, and mobile verification. Native Windows file locks, a real WSL distro, and a paired SSH mutation were not exercised locally; those differ from the portable fault tests and rendered macOS checks above. Before: an active account and a pending cleanup row, with pending selection and reauthentication disabled. After confirmed removal and cleanup retry, then restarting: both managed homes and rows remain removed; the system default is active. |
nwparker
left a comment
There was a problem hiding this comment.
Reviewed final head b538252bbe7094db63da736b48ef2340cc3cc6ab. The crash-safe removal approach is valid; the four cleanup and snapshot compatibility defects found during review are fixed and covered by regressions.
Local verification passed 493 tests across 64 suites, full Node/Web/CLI typecheck, and changed-code quality. Actual hidden Electron Settings checks exercised removal, guarded pending cleanup, retry, and restart persistence. All applicable current-head CI checks passed, including the full unit-test shards, Linux/Windows packaging, and six persistence platforms.
No remaining blocking findings. Detailed review and visual proof: #11655 (comment)
nwparker
left a comment
There was a problem hiding this comment.
Request changes on the overall design and maintenance cost. This supersedes my earlier approval, which established correctness of the covered failure cases but did not adequately assess whether the full implementation was proportionate.
The PR adds 461 net production-code lines across 17 production files. The cost is more than a retry record: ProfilePreferences.updateSettings gains a Codex-specific temporary mode, withCodexAccountSettingsPreview swaps live settings, and the shared persistence entry points gain preview guards. reconcileCodexAccountRemoval adds a worklist that repeatedly repairs runtime selections until they stabilize, followed by restoration of touched runtimes on failure. These mechanisms add coupled state and failure behavior to the shared Store and account-removal flow.
The acknowledged account/reset-ledger commit before credential deletion is justified. Retaining ownership checks and a durable cleanup record is also justified. Please simplify the removal flow around the existing durable-mutation queue and distinguish failure before the commit from cleanup failure after it. Evaluate synchronizing runtime state after the acknowledged commit, with cleanup kept pending if synchronization cannot finish, rather than introducing a reversible Store preview. Preserve host/WSL lifecycle behavior and the existing safeguards; any changed failure semantics need explicit tests.
The linked issue identifies a reproducible code-review finding, but it does not establish an affected customer or frequency. That does not invalidate the bug. It does mean the broader architecture needs a clearer justification or a smaller implementation before I recommend shipping this PR. Existing tests and green CI remain valid evidence for the current implementation; they do not resolve the scope concern.
|
Opened #25308 as a smaller replacement built from main. It commits account removal, reset-credit cleanup and the retry target together through the existing durable writer, then synchronizes the runtime and deletes credentials after acknowledgement. Failed cleanup stays visible and retries at startup. The replacement is +330/-98 production lines (net 232), versus net 461 here; the entire diff is +1128/-119 across 28 files. It retains ownership recovery safeguards, credits kazu-42 in the commit, and includes actual before/after UI proof. All 785 focused tests and type/quality checks passed locally. Leaving this PR open with the replacement linked. |
|
I agree with the requested simplification and am closing this PR in favor of #25308. I independently reviewed its exact head Local verification passed 1,445 tests across 160 distinct files, with four platform/opt-in skips, plus Node/Web/CLI typechecks, changed-code quality and whitespace checks. Current-head hosted checks on #25308 were 27 success and 13 skipped. The detailed approval review is on that replacement PR. #24944 remains a separate Draft. Its dependency is now #25308, and the prepared Closing this PR records the replacement decision; #25308 is still open and has not been merged. The original branch and implementation history are retained. |
… an inactive account is removed Removing an inactive managed Codex account unconditionally ran syncForCurrentSelection() and the quota refresh, which blanks the active account's usage bars and forces a cold probe even though the selection never changed (stablyai#24942) — the focused follow-up requested in stablyai#11655's review. The refresh is now gated on the removal having changed nothing that the views depend on: the active account id is unchanged, every runtime lane's selection is unchanged, and the selected host account's home still passes Orca's existing read-only ownership probe. Any other outcome — selected account removed, stale persisted selection, system-default host, or an ownership probe that cannot prove the home — keeps today's refresh behavior, so the change is fail-safe toward refreshing. Generated-by: GLM-5.3-Flash (ZCode)
… an inactive account is removed Removing an inactive managed Codex account unconditionally ran syncForCurrentSelection() and the quota refresh, which blanks the active account's usage bars and forces a cold probe even though the selection never changed (stablyai#24942) — the focused follow-up requested in stablyai#11655's review. The refresh is now gated on the removal having changed nothing that the views depend on: the active account id is unchanged, every runtime lane's selection is unchanged, and the selected host account's home still passes Orca's existing read-only ownership probe. Any other outcome — selected account removed, stale persisted selection, system-default host, or an ownership probe that cannot prove the home — keeps today's refresh behavior, so the change is fail-safe toward refreshing. Generated-by: GLM-5.3-Flash (ZCode)





ELI5
Removing a saved Codex account now saves the account change and credit-reset safety records together before deleting its credentials. If a crash or cleanup failure interrupts removal, Orca retains a recoverable record and shows a pending account that can be retried.
What Changed
pendingRemovals, keeping the existing selectable account roster compatible with older clients, remote switchers, and mobile. Settings shows retry guidance and disables selection and reauthentication. Preserve confirmation, busy-state, runtime availability, remote ownership, and host lifecycle behavior.Why
Deleting credentials before storage acknowledges removal can leave contradictory state after a crash. Deleting the ownership marker before a locked credential file also made cleanup impossible to retry. The existing durable mutation queue and ownership checks cover these failures without introducing another writer or trusting an inaccessible filesystem. The inactive-account performance change requested in the maintainer review remains separate.
Linked Issue
Related: #11653. This provides durable recovery metadata and explicit retry; automatic startup/background cleanup remains outside this PR.
Maintainer requirements: #11655 (comment)
Visual Proof
Current-head rendered Electron screenshots and acceptance details: #11655 (comment)
The hidden macOS app exercised active-account removal, pending-row guards, refusal of untrusted cleanup, retry, and restart persistence using disposable credentials and an isolated profile.
Testing
Validated against main at
b407d06c1ecd, with final headb538252bbe70:ORCA_BACKGROUND_LAUNCH=1; no window was shown or focused.All applicable current-head CI checks passed: full unit-test shards, relay integration, static analysis/typecheck, Linux and Windows packaging, six persistence platforms, Linux compatibility, and mobile verification. Native Windows file locks, a real WSL distro, and a real paired SSH mutation were not exercised locally. Packaging and the full repository test/lint matrix are covered by CI rather than claimed as local results.
AI Disclosure
Implemented with OpenAI Codex (GPT-6), with automated and rendered-app verification.
Review
The review traced persistence ordering, known and indeterminate write failures, reset-credit guards, selection self-healing, runtime restoration, cleanup ownership, restart recovery, and pending-row actions. The asynchronous rename behavior remains unchanged. Cleanup retry fixes and their evidence are documented in the linked review comment.
Agent skill upstream boundary
Notes
Removal uses the execution host's store and filesystem. A disconnect or unavailable home never proves deletion. A corrupt reset ledger remains fail-closed for provider resets. No new RPC commands or dependencies are added; the pending-removal snapshot field is optional and the existing selectable roster keeps its semantics. Folder workspaces use the same account service.
Contributor: https://x.com/DevKazu42
Checklist