Skip to content

Show cache-read usage and quota pace in Capacity Dock - #1267

Merged
iamtoruk merged 4 commits into
getagentseal:mainfrom
ozymandiashh:feat/capacity-dock-cache-pace
Sep 12, 2026
Merged

iamtoruk merged 4 commits into
getagentseal:mainfrom
ozymandiashh:feat/capacity-dock-cache-pace

Conversation

@ozymandiashh

@ozymandiashh ozymandiashh commented Sep 7, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

  • Show provider-scoped cache-read tokens in the Capacity Dock’s Today section, alongside input, output, calls and the existing cost. Known zero displays as 0; missing or incomplete historical accounting stays unknown. Cache reads are already included in cost, so this adds visibility without changing pricing.
  • Add per-window quota pace and estimated exhaustion using the existing whole-window average calculation. Captions require valid durations and fresh data; short windows retain deficit/reserve guidance without an exhaustion ETA. Four quota windows use a two-column grid to keep scope labels, reset times and estimates readable.

The JSON field is optional for compatibility with older clients and histories. Status snapshot revision 7 invalidates older cached payloads without purging daily history. No additional polling is introduced.

Testing

  • Tested against a copied real Codex session in an isolated environment: CLI Today and the direct parser both reported 11,148,288 cache-read tokens, 84 calls and one session.
  • npm test: 3,748 passed, 5 skipped, versus 3,738 passed, 5 skipped on the base revision; zero failures. Covers durable/fresh history, provider/date/config filters, known zero, incomplete legacy data and snapshot invalidation.
  • npm run build and tsc --noEmit passed.
  • Native CapacityDockDetailView render harness: 62 checks passed across 0.9×, 1× and 1.25× scales and all four dock edges; rendered layouts inspected visually.
  • Swift Testing subset: 457 tests in 55 suites passed, versus 424 tests in 53 suites on the base. Includes fresh/stale quota samples, invalid windows, layout sizing, legacy payload decoding and overlapping/cancelled refreshes. swift build --jobs 2 passed.

Local Swift validation used an isolated copy of the Swift Testing suites because this machine has Command Line Tools without XCTest. macOS CI subsequently passed the full suite: 129 XCTest tests and 457 Swift Testing tests, plus release packaging.

All 18 CI checks passed on 98ad43fe, including Windows tests and packaging (the release-only asset check is skipped).

Main took render revision 6 for `sessionCountBasis` and changed the
provider-slice session fold from a sum to a per-day max. Both had to
survive the merge, so the resolutions are unions rather than sides:

- `addProviderSlice` keeps main's `Math.max` for `sessions` (per-day
  ticks are not distinct identities) and adds the cache-read sum beside
  it, with a comment saying why one is additive and the other is not.
- `ProviderSliceTotal`, `ProviderCost`, `providerDetails` and the Swift
  `ProviderDetail` carry both `sessionCountBasis` and `cacheReadTokens`.
- The snapshot revision stays 7, which is still the next free number
  above main's 6. Its doc comment said v6 was PR1265's per-model counts;
  it is main's `sessionCountBasis`, so the comment now says that.

The status-menubar suite hard-codes render revisions. Main's assertion
that a rejected v5 snapshot is rewritten as `:render-6:` auto-merged
cleanly while this branch moved the current revision to 7, which would
have failed silently on the next bump too. Those assertions now derive
the tag from `STATUS_SNAPSHOT_RENDER_VERSION`, so the current and
previous revisions follow the constant; the deliberately historical
`:render-5:` and `:render-2:` plants stay literal.
Ports the two parts of getagentseal#1287 the maintainer asked to keep, expressed
through this branch's `QuotaPacePresentation` rather than through
`QuotaPace.Verdict`:

- Placement: `QuotaDetailRow` in the agent-tab quota hover card becomes
  a VStack and draws the pace line under the bar, indented past the
  label column, with the three tones the dock already uses. The card is
  fitted, so a silent caption collapses there instead of reserving a
  slot the way the dock's computed frame must.
- Wording: the long-window caption drops "est. N% at reset" /
  "est. out in X" for the plain "Lasts until reset" / "Runs out in X",
  and the exhausted state becomes "Limit reached". The projected
  percentage it came from stays in the hover text, which has room for
  the reasoning. Short windows keep the on-pace / deficit / reserve
  stage (getagentseal#726), and the freshness, connection and duration gates are
  untouched.

`QuotaPace.inferredWindowSeconds(label:)` is deliberately NOT ported.
Grok Build chooses its window label from the distance to the reset, so
a monthly cycle passing through the 4-12 day band is labeled "Weekly"
and a label round trip paces a month's budget against seven days. The
adapter's real `windowSeconds` is the only source here, and a new test
pins that shape: 72% used with six days to a monthly reset reads
"Lasts until reset", while the same sample against an inferred 7-day
window overflows and would have printed "Runs out in 9h 20m". The same
test asserts a window with no duration metadata stays silent rather
than falling back to its label.

Verified with a standalone swiftc harness over QuotaPace,
QuotaPacePresentation and QuotaSummary: this host has Command Line
Tools only, so `swift test` cannot load the Testing module.

Closes getagentseal#1267
ozymandiashh added a commit to ozymandiashh/codeburn that referenced this pull request Sep 12, 2026
getagentseal#1267 lands first, so rebuild this branch on top of it rather than on
origin/main. The remaining diff is then only this branch's own
contribution: per-model input/output/cache-read counts in the desktop
Overview and the macOS menubar Models rows.

Conflict resolutions:

* src/status-snapshot-semantic.ts — this branch bumped the snapshot render
  revision from 5 to 6, but main had already taken 6 for sessionCountBasis
  and getagentseal#1267 has taken 7 for per-provider cacheReadTokens. Move to 8, and
  bump the single shared constant getagentseal#1267 extracted instead of making a third
  inline edit in src/main.ts. A revision must be distinct from every other
  branch's or a snapshot written elsewhere would be accepted here while
  lacking this change's fields.

* src/main.ts — take getagentseal#1267's side: the revision and semantic key now come
  from statusSnapshotSemanticKey() rather than local constants.

* src/usage-aggregator.ts — import-only conflicts, superset of both sides.
  addProviderSlice keeps main's Math.max session folding and getagentseal#1267's
  summed cacheReadTokens; neither is reverted.

* tests/cli-status-menubar.test.ts — both branches appended a test at the
  same insertion point and git interleaved them. Reassembled so both
  blocks survive intact.

This branch's own snapshot-invalidation test planted a literal :render-5:.
Against a tree that already ships 7, that plant proves nothing — main alone
rejects it, so the case passed without this change. Plant the immediately
previous revision via getagentseal#1267's derived PREVIOUS_RENDER_TAG instead, and
assert the rewritten record carries CURRENT_RENDER_TAG. The deliberately
historical :render-5: / :render-2: plants elsewhere stay literal: those
name specific pre-field contracts rather than "one revision back".
@ozymandiashh

Copy link
Copy Markdown
Collaborator Author

Rebased onto current main (after #1304, #1305, #1308, #1309) and absorbed the worthwhile parts of #1287, which I am closing in favour of this.

Ported: the agent-tab hover card's verdict placement and the plainer wording (Lasts until reset / Runs out in 1d 20h / Limit reached), both expressed through this PR's QuotaPacePresentation and its real windowSeconds. Deliberately NOT ported: inferredWindowSeconds(label:), which is the Grok Build bug you found. New regression test grokBuildMonthlyCycleLabeledWeekly pins it: a monthly cycle at 72% with six days to reset, labelled Weekly, now reads Lasts until reset against its real 30-day window, where the label-inferred 7-day window would have printed Runs out in 9h 20m. A nil windowSeconds with the same label stays silent, which is what catches a re-introduced fallback.

Merge notes: render revision 7, and main's rejects a pre-count-basis render-5 snapshot test asserted :render-6:, which auto-merged clean and was wrong once this moved to 7. The suite now derives the tags from STATUS_SNAPSHOT_RENDER_VERSION so this cannot recur; the deliberately historical plants stay literal. addProviderSlice keeps your Math.max on sessions and sums cacheReadTokens beside it, with a comment on why one is additive and the other is not.

tsc clean, full suite 3986 passed / 0 failed, swift build complete. The gates are untouched: connection, ten-minute freshness, validated duration, percent-range and clock-skew rejection, 3% elapsed silence.

@iamtoruk
iamtoruk merged commit 610cae4 into getagentseal:main Sep 12, 2026
21 checks passed
iamtoruk added a commit that referenced this pull request Sep 12, 2026
Every caption and help sentence #1267 added rendered English in a zh-Hans
build: they are composed in a presentation type, not at a view call site, so
neither the catalog diff nor the source scan could see them. Each sentence is
now one key with placeholders. The two stage captions reuse the Plan tab's
existing keys, and the countdown reuses the popover's. English output is
unchanged: the 329 existing pace expectations pass untouched.
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