Skip to content

fix(usage): wait for a refresh to answer before settling the page - #23

Merged
sheehanmunim merged 1 commit into
mainfrom
fix/usage-refresh-settling
Aug 19, 2026
Merged

fix(usage): wait for a refresh to answer before settling the page#23
sheehanmunim merged 1 commit into
mainfrom
fix/usage-refresh-settling

Conversation

@sheehanmunim

Copy link
Copy Markdown
Member

Problem

Two community PRs were merged into the fork on the same day, both reworking usage coverage:

  • fix(usage): handle unavailable environments → added state/usageEnvironmentScope.ts
  • fix(web): wait for usage refresh completion → added state/usageStatus.ts

Only the first kept its wiring. usageStatus.ts ended 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:

  • an environment with a pending request is still reporting, even when it has a retained summary to display;
  • only a settled summary counts toward 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 /goal wiring in #22.

Model: Claude Opus 5, harness: Claude Code

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
@sheehanmunim
sheehanmunim merged commit 0721e01 into main Aug 19, 2026
3 of 7 checks passed
@sheehanmunim
sheehanmunim deleted the fix/usage-refresh-settling branch August 19, 2026 21:49
@github-actions github-actions Bot added vouch:trusted PR author is trusted by repo permissions or the VOUCHED list. size:M labels Aug 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:M vouch:trusted PR author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant