Repository navigation
perf(client): reuse usage queries within the hour and ask only selected environments - #36
Conversation
The hourly window ended at the current minute, so nearly every open of the usage page asked for a new window and missed both the client query cache and the server's shared scan. The window is now 24 hour buckets ending with the hour in progress, so it stays identical for the whole hour on web and mobile. It stays at 24 hours because servers reject longer hourly windows, and older servers must keep answering new clients. untilDay now names the day of the last covered instant rather than the exclusive end. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
The usage page subscribed every connected environment's summary query, so a deselected environment still ran its transcript scan and held the page's attention with a "Scanning" status. The usage query atom is now keyed by window and selection. Deselected environments stay listed in the filter, without a summary and without a query, and their menu rows show no status. Web and mobile share the change. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
|
Verdict: FAIL Head: 96aa1b3 (independent verifier, own worktree) Ran
Blocking finding (regression) Verified OK
|
…stant The hour-aligned window ends at the next hour, which is already tomorrow during the last hour of the day, so every bar read as yesterday. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
|
Verdict: FAIL Head: 2995b31 The LA case is fixed, but the fix breaks in half-hour-offset zones. Probes (
Other checks:
Notes: |
The window's end is a UTC hour, so in half-hour zones the instant before it can already be tomorrow. Labels read relative to the render time, as they did before the window was hour-aligned, and the range reads 'to now' rather than the bucket end. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
|
Verdict: PASS+NOTES Head: 1069343 Both earlier FAILs are closed. The chart labels hours relative to render-time now.
Notes (non-blocking):
|
Thread transfer impact✅ Thread transfer remains within every enforced ceiling.
Baseline: Scenario and decoded snapshot size10 historical turns, 5 command tools per turn, 878.9 KiB retained MCP result per historical turn, and a 1.05 MiB retained result in the measured turn.
Updated in place by a trusted workflow. PR artifacts are strictly validated and never executed. |
Opening the Usage page almost always missed every cache. The past-24h window was built from the current minute, so the query key changed every minute, missing both the client's 60s cache and the server's in-flight dedupe. The page also asked every connected environment for usage, including ones deselected in its environment filter, and then waited for the slowest. A paused or slow cloud box took 2.5–8.5s.
How it's fixed:
makeWindow(shared by web and mobile) requests 24 hourly buckets ending at the end of the current hour. Reopening the page within the hour reuses the query. The server rejects hourly windows longer than 24h, so the window starts between 23 and 24 hours back, and the range label shows the exact times.Tests: window computation with literal values (UTC, reuse across a whole hour, a Los Angeles late-evening day boundary). A query test asserts only the selected environment is asked and checks the merged cost.
🤖 Generated with Claude Code