feat(ui): migrate the stats poll to React Query (W5.2b) - #432
Merged
Conversation
Stage 2b of the App.tsx decomposition. Replaces the manual 1s setInterval stats poll (statsIntervalRef + fetchStats useCallback + the connected-gated polling effect) with a useQuery: - enabled: connected, refetchInterval: 1000, refetchIntervalInBackground: true (matches the old setInterval running regardless of tab visibility), staleTime: 0, retry: false. - The test-status state machine (handleStatusTransition → fetchTestResult / clear-on-start) now runs as a useEffect keyed on the query data, firing once per poll exactly as before. - statsIntervalRef removed (incl. its expireSession cleanup); the stats query disables when connected flips false. handleLogout's explicit stats reset is gone — queryClient.clear() (added for the cross-session fix) leaves the query dataless, so stats falls back to initialStats. - useTestProgress/expectedDuration moved below the query (they read stats). App.tsx useState 26 → 24 across W5.1/2a/2b. tsc + biome clean; build green; 183/183 unit tests pass. Live polling/test-status behavior is covered by the fullstack E2E on the PR.
krisarmstrong
enabled auto-merge (squash)
June 15, 2026 15:46
Contributor
License Compliance ReportAll dependencies pass license compliance checksGo Dependencies
npm DependenciesSee full report in workflow artifacts Allowed Licenses: MIT, Apache-2.0, BSD-*, ISC, CC0-1.0, MPL-2.0 |
This was referenced Jul 8, 2026
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.
What
Stage 2b of the App.tsx decomposition (follows #431). Replaces the manual 1s setInterval stats poll with
useQuery.Removed:
statsIntervalRef, thefetchStatsuseCallback, and theconnected-gated polling effect (incl. theexpireSessioninterval cleanup).Behavior-preserving
refetchInterval: 1000+refetchIntervalInBackground: truematches the oldsetInterval(which polled regardless of tab visibility);enabled: connectedreplicates start/stop on connection;staleTime: 0keeps every tick fresh.handleStatusTransition(→ fetch result on completion / clear on start) now runs as auseEffectkeyed on the query data — fires once per poll, exactly asfetchStatsdid.queryClient.clear()(added in feat(ui): add React Query + migrate the interfaces read (W5.2a) #431) leaves the query dataless, sostatsfalls back toinitialStats— the explicit reset is gone.useTestProgress/expectedDurationmoved below the query (they readstats).Impact
App.tsx
useState26 → 24 (stats + interfaces now query-owned); −38 net lines this slice.Verification
tsc+biomeclean ·npm run buildgreen · 183/183 unit tests. The live polling + test-status transitions are exercised by the fullstack E2E on this PR.