You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Restore automatic usage tracking for default accounts - #6240
Register the renderer rate-limit push listener before the initial startup snapshot request.
Treat the initial rateLimits.get() response as a fallback so a live startup push for system-default Claude/Codex accounts cannot be overwritten by an older empty snapshot.
Add a deterministic regression test for the startup race where a fresh push lands before the stale get() promise resolves.
Design and Review
Design approach: preserve IPC/store contracts and change only renderer event ordering/guarding in useIpcEvents. No UI, schema, provider, SSH/runtime target, or copy changes.
Design review: clean after adding alternatives, interaction states, architecture/data-flow coverage, and internal consistency notes to the ignored scratch design doc.
Implementation deviations: none.
Completeness verification: COMPLETE; implementation matches the design and edge cases.
Perf Audit
Result: PERF CLEAN.
Hot paths checked: renderer startup IPC hydration, main rate-limit service polling/push path, store subscriber/render churn, startup latency, and listener cleanup.
Evidence: no new polling, subprocesses, timers, IPC calls, or long-lived listeners; the raced path now avoids a redundant stale store write. Existing deterministic hook coverage is sufficient for this race.
Accepted gap: the regression asserts final behavior, not explicit call count; non-blocking because perf audit found no actionable churn.
Code Review
Review round 1: two independent reviewers reported no issues found.
Additional reviewer checks included focused Vitest, touched-file oxlint, and git diff --check.
Validation
Reproduction before fix: GITHUB_TOKEN=${GITHUB_TOKEN:-dummy} pnpm exec vitest run --config config/vitest.config.ts src/renderer/src/hooks/useIpcEvents.test.ts -t "rate-limit hydration" failed with claude: null / codex: null overwriting fresh snapshots.
Focused test after fix: GITHUB_TOKEN=${GITHUB_TOKEN:-dummy} pnpm exec vitest run --config config/vitest.config.ts src/renderer/src/hooks/useIpcEvents.test.ts -t "rate-limit hydration" passed.
Full touched hook suite: pnpm vitest run --config config/vitest.config.ts src/renderer/src/hooks/useIpcEvents.test.ts passed, 64 tests.
Static checks: pnpm run typecheck passed; pnpm run lint passed; git diff --check passed.
Electron validation: launched this exact worktree on CDP port 9337, verified window.api.app.getIdentity() branch/root, inspected window.api.rateLimits.get() and window.__store.getState().rateLimits, and confirmed renderer console had 0 errors.
Screenshot evidence: captured locally at .playwright-cli/page-2026-06-24T06-17-00-350Z.png; live Claude/Codex default accounts were unavailable in this profile, so visible usage chips could not be captured.
demo-project: not exercised because the change is global renderer startup hydration with no workspace-specific user action.
Post-PR Stabilization
Completed initial 8-minute wait and stabilization sweep.
Live provider-account UI could not be observed in this local profile because rate-limit providers were all null; deterministic race coverage and live API/store inspection cover the startup hydration behavior.
useIpcEvents previously subscribed to rateLimits.onUpdate after awaiting rateLimits.get(), creating a window where a pushed update could be missed and overwritten by the stale initial snapshot. The fix reorders the operations: onUpdate is subscribed first, a boolean flag records whether any push arrived before get() resolves, and the get() result is discarded if the flag is set. A new test suite reproduces the race by immediately invoking the captured listener with fresh state while get() returns stale state, asserting that setRateLimitsFromPush ends up called with the fresh value.
The title accurately summarizes the main change: fixing startup usage tracking hydration for default accounts.
Linked Issues check
✅ Passed
The hook change and regression test address #5690 by preferring fresh startup pushes over stale initial snapshots.
Out of Scope Changes check
✅ Passed
Changes stay within renderer IPC hydration and test coverage; no unrelated functionality appears to be added.
Docstring Coverage
✅ Passed
No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Description check
✅ Passed
The description covers summary, testing, review, validation, and risks, but it does not follow the template exactly with explicit Screenshots and Security Audit sections.
✏️ Tip: You can configure your own custom pre-merge checks in the settings.
✨ 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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #5690
Summary
rateLimits.get()response as a fallback so a live startup push for system-default Claude/Codex accounts cannot be overwritten by an older empty snapshot.get()promise resolves.Design and Review
useIpcEvents. No UI, schema, provider, SSH/runtime target, or copy changes.Perf Audit
Code Review
git diff --check.Validation
GITHUB_TOKEN=${GITHUB_TOKEN:-dummy} pnpm exec vitest run --config config/vitest.config.ts src/renderer/src/hooks/useIpcEvents.test.ts -t "rate-limit hydration"failed withclaude: null/codex: nulloverwriting fresh snapshots.GITHUB_TOKEN=${GITHUB_TOKEN:-dummy} pnpm exec vitest run --config config/vitest.config.ts src/renderer/src/hooks/useIpcEvents.test.ts -t "rate-limit hydration"passed.pnpm vitest run --config config/vitest.config.ts src/renderer/src/hooks/useIpcEvents.test.tspassed, 64 tests.pnpm run typecheckpassed;pnpm run lintpassed;git diff --checkpassed.window.api.app.getIdentity()branch/root, inspectedwindow.api.rateLimits.get()andwindow.__store.getState().rateLimits, and confirmed renderer console had 0 errors..playwright-cli/page-2026-06-24T06-17-00-350Z.png; live Claude/Codex default accounts were unavailable in this profile, so visible usage chips could not be captured.demo-project: not exercised because the change is global renderer startup hydration with no workspace-specific user action.Post-PR Stabilization
track-community-prpassed;verifypassed (lint, typecheck, tests, build, packaged CLI smoke).Risks