Skip to content

fix(tui): keep Copilot totals after background refresh - #1784

Merged
iamtoruk merged 4 commits into
getagentseal:mainfrom
ozymandiashh:codex/fix-1769-copilot-summary
Oct 27, 2026
Merged

iamtoruk merged 4 commits into
getagentseal:mainfrom
ozymandiashh:codex/fix-1769-copilot-summary

Conversation

@ozymandiashh

Copy link
Copy Markdown
Collaborator

The provider-filtered TUI could show the correct spend at first paint, then drop its headline to zero after background indexing while the project and model panels retained the usage. The shared daily cache was non-empty and complete but lacked the sessions' entire date; the indexed headline refused to fill that date.

Allow provider-scoped projections to fill missing historical dates from their normalized sessions even when the shared cache is complete. Existing cached days keep their precedence, period and project filters still apply, and the projection leaves the shared cache unchanged. No parser or cache-format change.

Closes #1769.

Behavior proof

Two controlled Copilot VS Code journals contain 40 + 60 credits ($1.00), 2,000 input tokens and 1,000 output tokens, three days before the run. A complete shared cache contains only an unrelated older Claude day.

Phase Main 1a3ce74a This branch
First paint $1.00 / 2 calls $1.00 / 2 calls
Cached background index $0.00 / 0 calls $1.00 / 2 calls
Source refresh $0.00 / 0 calls $1.00 / 2 calls
Shared daily cache changed No No

The new integration test mounts the production Ink dashboard and waits for its actual background refresh. It also covers 5,000 cache-read tokens, project inclusion/exclusion, repeated refreshes and byte-for-byte cache preservation. Two additional regression cases cover Copilot and Codex period bounds and retention of richer cached history. All three added cases fail against the unchanged production code and pass with the fix.

These are controlled fixtures on macOS, not the reporter's logs or a live Windows Copilot installation. The images render captured, ANSI-stripped Ink output; capture details.

Before refresh fix After refresh fix
Before After

Validation

Node 26.8.1, unchanged dependencies, normal root test scope (npm test -- --maxWorkers=2):

Run Passed Failed Skipped
Main 1a3ce74a 5,211 0 8
Branch 2029c3dd, first full run 5,213 1 8
Same branch, full rerun 5,214 0 8

The first branch run failed the existing raw Ctrl-C hydration-lock removal assertion in tests/dashboard-process-exit.test.ts. Its original two-test suite then passed separately on main and branch; the full branch rerun passed without changing code, assertions or timeouts. The initial failure is retained above.

  • Full main/branch suites compared; final branch run adds three passing cases and has no failures.
  • All 35 focused dashboard/project-filter tests passed.
  • All 37 serial refresh-lock tests passed.
  • npx tsc --noEmit, npm run build, and git diff --check passed.
  • UI change: before/after captured renderings and fixture provenance attached.
  • Live Copilot / native Windows validation: not available on this machine.

@ozymandiashh ozymandiashh added area: cli The codeburn CLI and its core parsing/reporting engine area: windows The Windows tray app and Windows-specific behaviour bug Something isn't working needs-real-data-proof PR needs screenshot or output proving it works against real data needs-validation PR requires validation against real-world usage before review labels Oct 21, 2026
@JaylyDev

Copy link
Copy Markdown
Contributor

Did some very basic tests on this branch - parsing new format (stats from the last 28 days) seems to be fixed on my machine, however it's currently excluding cost preserved from expired session logs despite the ui says "includes preserved from expired session logs".

Screenshot of live copilot usage:

image image

£68.68 + £0.93 = £69.91 which aligns up with data retrieved from cache & running codeburn models command.

The provider-scoped background index kept the cached slice whenever the
live parse had the same call count, while report and the first paint
(buildDurablePeriod) take the live slice there. A shared cache derived
under older numbers, which a provider-only run never re-derives, still
moved the headline after refresh: on the getagentseal#1769 reporter's machine
Lifetime went from 69.91 to 68.68 with the same calls and less output.

The index now uses overlayProviderDaySlices like buildDurablePeriod. It
also fills the dates and slices the cache lacks, so the date fill above
goes back to main. Two test values that pinned the cached slice move to
what report shows for the same data.
@iamtoruk
iamtoruk merged commit 07c0ee6 into getagentseal:main Oct 27, 2026
23 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: cli The codeburn CLI and its core parsing/reporting engine area: windows The Windows tray app and Windows-specific behaviour bug Something isn't working needs-real-data-proof PR needs screenshot or output proving it works against real data needs-validation PR requires validation against real-world usage before review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Copilot: TUI usage cost reduced after refreshing changed source files and codeburn cache

3 participants