Skip to content

fix: harden live usage sync realtime and spend accuracy - #9

Merged
pj-workspace merged 1 commit into
mainfrom
fix/max-realtime-usage-sync
Aug 12, 2026
Merged

pj-workspace merged 1 commit into
mainfrom
fix/max-realtime-usage-sync

Conversation

@pj-workspace

Copy link
Copy Markdown
Owner

Summary

  • Panel-open live polling: events head ~3s, metrics ~8s; background sync uses one wait per wave then burst (no per-request 10–20s queue)
  • Today stats and menu today% derive from merged live events, not the frozen full-chart snapshot
  • Auto + Composer spend prefers aggregated first-party models; bonusSpend is only a last resort (it is total−included, not Auto pool)
  • Live merge treats page-1 as authoritative for its time window, uses stable event ids without chargedCents, and collapses in-progress progressive snapshots so totals stop oscillating

Test plan

  • ./scripts/build-app.sh release succeeds
  • Open panel → Events: new usage appears within ~3s
  • Overview Today request/spend moves with live head (not only after full chart sync)
  • Auto card shows first-party sum (hundreds), not bonusSpend ($253)
  • During a long streaming request, details do not flood with rising/falling ladder rows; today total does not spike then crash

Production risk

Medium-low — changes sync cadence and event merge semantics; wrong collapse heuristics could undercount rapid same-model tool calls (growth threshold ≥15% / 2 min). Watch Events + Today after merge.

Poll events head while the panel is open, burst within each sync wave,
derive today/Auto spend from live merged events and first-party aggregates,
and stop accumulating in-progress billing snapshots during live merge.
Copilot AI lite review requested due to automatic review settings August 12, 2026 06:07
@pj-workspace
pj-workspace merged commit 454a953 into main Aug 12, 2026

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants