Skip to content

fix: prevent stale AI Usage day details across ranges (B19) - #1210

Merged
wibus-wee merged 2 commits into
mainfrom
lody/f1cfac5f-261
Oct 2, 2026
Merged

wibus-wee merged 2 commits into
mainfrom
lody/f1cfac5f-261

Conversation

@wibus-wee

Copy link
Copy Markdown
Member

Related issue

B19. Same-repository maintainer branch; no separate GitHub Issue.

Problem / pressure

Selecting a day in AI Usage and changing the range already clears the selection,
but an old resize/scroll callback can select it again. The active timeline can
then report “No usage” while the independent day query renders the old day's
full totals. Controlled callback delivery reproduces this on the starting main
source; the exact production bundle and native callback sequence remain unverified.

Summary

Separate explicit day selection from caret positioning in the hourly panel and
year calendar. Accept position updates only for the current selected date, using
the existing synchronous date ref. Retain the day cache, animations and 30d ↔ All
selection behavior. Extend the owning mounted regression suite, add an interactive
range-switching Story, and document the contract and ablation in the bilingual
timeline Spec and 2026-10-02-usage-range-selection Agent Note.

Visual explanation

sequenceDiagram
    participant View as Usage view
    participant State as Selection owner
    participant Query as Day query owner
    View->>State: Click day A
    State->>Query: Select A
    View->>State: Switch hourly range
    State->>Query: Clear selected date
    View->>State: Old resize/scroll measures A
    Note over State: Current date differs: discard position update
Loading

Before / after

Before After
A retained cell's position callback can reopen the old day after reset. Position callbacks only move the currently selected day's caret.
An old date callback can replace a newer selection. Date matching preserves the new selection.

Test plan

  • NODE_OPTIONS=--no-experimental-webstorage NODE_ENV=test pnpm check passed, including 4,657 components tests and 199 Electron tests. The RPC suite retains three existing skipped tests.
  • Final four usage/cache suites: 45 passed; components typecheck and scoped type-aware lint passed (warnings only).
  • pnpm build passed for the local desktop; pnpm format and pnpm run docs check passed. Existing build/docs warnings remain; no SHA-protected topics.
  • Actual ablation: restoring hourly/heatmap selection callbacks fails 4/3 regressions; removing the date guard fails 7; weakening it to a non-null check fails the rendered-date regression. All 11 timeline tests pass with the final protections.
  • Browser: synthetic RangeSwitching Story reproduces the inconsistent readout/detail with an explicitly delivered captured callback, then stays closed with the fix; 30d ↔ All retains selection and return to 24h closes it. No page errors. Screenshots are local artifacts, not repository fixtures.
  • Production/native mobile acceptance and hosted usage accounting were not run.

Context handoff

Same-repository maintainer contribution. No captured user/agent transcripts or account data included.

@wibus-wee
wibus-wee marked this pull request as ready for review October 2, 2026 17:19
@wibus-wee
wibus-wee merged commit 85c0a11 into main Oct 2, 2026
13 checks passed
@wibus-wee
wibus-wee deleted the lody/f1cfac5f-261 branch October 2, 2026 17:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant