fix(usage): wait for a refresh to answer before settling the page - #23
Merged
Conversation
Two community PRs landed the same day solving the same problem: one added per-environment scope with unavailable-machine handling, the other made a refresh wait for new numbers. Only the first kept its wiring — the second's module ended up orphaned, imported by nothing but its own test. The behavior that went missing: SWR keeps the previous summary on screen while a refresh runs, and the surviving code counted that retained value as an answer. Pressing Refresh settled instantly and showed the old totals as if they were current. An environment with a pending request is now still reporting even when it has a retained summary, and only a settled summary counts as answered. Folded into the wired module with the orphan's test ported; the duplicate module and its test are gone. Model: Claude Opus 5, harness: Claude Code
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.
Problem
Two community PRs were merged into the fork on the same day, both reworking usage coverage:
fix(usage): handle unavailable environments→ addedstate/usageEnvironmentScope.tsfix(web): wait for usage refresh completion→ addedstate/usageStatus.tsOnly the first kept its wiring.
usageStatus.tsended up imported by nothing but its own test, so the behavior it added was silently lost: SWR keeps the previous summary on screen while a refresh is in flight, and the surviving code counted that retained value as an answer. Pressing Refresh settled the page immediately and presented the previous request's totals as current.Fix
Folded the missing rule into the module that is actually wired:
answered.Ported the orphan's refresh-settling test onto the wired module and deleted the duplicate module and its test.
Verification
vp test run src/state/usage.test.ts— 11 passing (10 existing + the ported refresh case). The pre-existing offline/reconnecting cases still pass unchanged: they all describe settled environments, so the stricter pending rule does not hold the page open for a machine that is down. Web typecheck clean.Found by auditing the 89 modules that fork merges added for ones with no non-test importer — the same signature as the dropped
/goalwiring in #22.Model: Claude Opus 5, harness: Claude Code