fix(dashboard): route scheduled refresh through the quota cache - #142
Merged
Conversation
added 2 commits
August 2, 2026 18:18
The hook change in a142542 added `revalidate` but nothing called it: auto-refresh still went `handleAutoRefresh` -> `refreshAll` -> `refreshUsageLimits()`, the forced path that appends `refresh=1`, resets the CLI's two-minute cache (src/lib/usage-limits.js:28, :1922 via src/lib/local-api.js:1720-1722) and fans out to every configured provider — every 30 seconds, per visible tab. `refreshAll` now takes `{ forceUsageLimits }`. Manual refresh passes true; both scheduled passes pass false — the interval tick and the post-sync follow-up that runs when the background sync queued new buckets. The follow-up matters: with `isLocalMode` false it never runs at all, so a single-tick test cannot tell whether it was fixed. Also renames use-usage-limits.test.tsx to .ts. It contains no JSX, and validate:ui-hardcode was reading its TS generics (`deferred<T>()`) as JSX text nodes and failing ci:local on the previous commit. Closes #140
7 tasks
Owner
Author
Final merge reviewVerdict: PASS — no merge-blocking correctness, security, performance, or test-quality findings. Verified in this session:
The pre-existing manual-refresh cancellation found during review is deliberately out of scope and is now tracked as #146. Proceeding with squash merge under the user's explicit authorization. |
5 tasks
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
refreshAllnow takes{ forceUsageLimits }: manual refresh passestrue, both scheduled passes passfalseand go through the hook's cache-awarerevalidate.a142542) addedrevalidateto the hook but nothing called it —git grep revalidate -- dashboard/srchit only a comment inuse-pulse.ts. Merging it alone would have closed nothing. This commit is the wiring plus the behavioural tests.use-usage-limits.test.tsx→.ts: the file has no JSX, andvalidate:ui-hardcodewas reading its TS generics (deferred<T>()) as JSX text and failingci:localon the previous commit. Renaming fixes it at the source rather than widening the baseline.The call site that hides from a naive test
handleAutoRefreshcallsrefreshAlltwice — the interval tick (DashboardPage.jsx:809) and the post-sync follow-up when the background sync queued buckets (:813). WithisLocalModefalse,startAutoSync()returnsnulland:813never executes, so a one-tick test passes whether or not that line was fixed. The suite mockstriggerLocalSyncto report queued buckets so the branch actually runs.Test plan
npm run ci:local— exit 0 (dashboard 42 files / 320 tests)DashboardPage.limits-refresh.test.jsx— 7 tests, renders the page withDashboardViewstubbedhandleWaketo a direct forcedrefreshAll()→ exactly the 2 wake tests fail. All restored → 7/7bin/tracker.js serveagainst the built bundle: manual click → exactly one?refresh=1; auto at 30s → two scheduled requests, neither forced. (Read viaperformance.getEntriesByType("resource")— the network panel listing hides query strings. The smoke establishes "no scheduled request carriesrefresh=1"; which of the two was the tick and which the follow-up is not established by it, and does not need to be — the mutation above carries that.)LimitsPage.test.jsx:91-98and:110-113— no new test added, cited insteadNotes for the reviewer
focus/visibilitychangealso run throughhandleAutoRefresh(:857-859), so they became cache-aware too. That is a deliberate call — they are scheduled work, not a user asking for fresh numbers — and it is inside the two-minute contract. Covered by two tests.revalidatepublishes withsource: "page-load", which reads oddly for a scheduled tick. It is inert today:DashboardPage'suseUsageLimits()leavespublishToPreloadCachefalsy, anduse-usage-limits.ts:52early-returns. Left alone rather than widening the union type.handleManualRefresh(:771-780) awaitstriggerLocalSync()inside the sametryasrefreshAll, so a failed local sync cancels the entire manual refresh — nothing refetches. Reproducible on the Vite dev server, where/api/local-auth404s. Unrelated to limits: stop scheduled dashboard refresh from bypassing quota cache #140; worth its own issue.src/lib/usage-limits.js.Closes #140
Review trail
/code-reviewclean (claim-verb audit and false-success grep both no-match). Codex QA atxhighreturned 5 Pass / 2 Fix: Edge Case (wake path untested, with a concrete mutation that would slip past every other test) and Handoff (nothing committed). Both closed — the wake tests exist because that pass asked for them.