Skip to content

fix(menubar): show a Total row under the Trend tooltip's model breakdown - #1434

Open
ozymandiashh wants to merge 1 commit into
getagentseal:mainfrom
ozymandiashh:fix/1433-trend-tooltip-total
Open

ozymandiashh wants to merge 1 commit into
getagentseal:mainfrom
ozymandiashh:fix/1433-trend-tooltip-total

Conversation

@ozymandiashh

Copy link
Copy Markdown
Collaborator

Summary

  • If only Claude is selected, hovering a Trend bar in the menubar popover used to show the day's cost in the tooltip header. Since 0.9.24 it shows a model breakdown and a token count instead, and the day's cost is gone from the tooltip. The web dashboard tooltip still ends with a Total row.
  • The model rows are not new. What changed is the data behind the Claude-only view:
    • Up to 0.9.23, provider-filtered history.daily rows in src/usage-aggregator.ts set inputTokens/outputTokens to 0 and topModels to empty.
    • 38e6e19 (harden provider period and cache contracts, first shipped in 0.9.24) replaced that with overlayProviderDaySlices, which reads the real per-provider slices, so those rows now carry tokens and models.
    • TrendInsight switches the chart to tokens whenever any bar has tokens. With Claude selected, the chart switched from $ to tokens, and so did the BarTooltipCard header. The card never had a Total row, so the cost disappeared.
    • The model rows can't stand in for a total either: the payload carries up to 5 topModels and the card renders 4.
  • What changed, in BarTooltipCard only:
    • When a day has a model breakdown, the rows now end with a 0.5pt separator and a Total row laid out like a model row: Total, the day's cost (bar.cost, shown when above 0, like the model rows) and N tok (bar.tokens, always shown, like the model rows).
    • The figures are the payload's day totals, not a sum of the visible rows.
    • The header figure now shows only on days without a breakdown, so no number appears twice. In the All view it moves from the header down to the Total row.
    • New "Total" key in en and zh-Hans (总计), plus a CHANGELOG entry under Unreleased > Fixed (menubar).
  • What did not change:
    • The CLI and the payload. Carrying real per-provider tokens is correct; this only changes how the tooltip shows them.
    • How the chart picks its metric. The Claude-only chart still plots tokens.
    • Days without a model breakdown, which render exactly as before.
    • The web dashboard, desktop app and Windows tray. The hourly buckets and session breakdown mentioned in the issue exist only in the web dashboard; the menubar Trend chart is daily.

Fixes #1433

Testing

  • I have tested this locally against real data (not just unit tests)
  • npm test passes
  • npm run build succeeds

This is a Swift-only change, so I didn't run the npm checks. I also haven't run the patched app against my own data. What I did run:

  • swift build in mac/ passes, both incremental and from a clean build dir, with no warnings from HeatmapSection.swift.
  • swift test can't run on this host (Command Line Tools only, no Testing module), so CI is the gate for the Swift tests.
  • Localization: I wrote a script that copies the rules from LocalizationCatalogTests, LocalizationCoverageTests and LocalizationSourceScanner. It passes on main (619 keys) and on this branch (620 keys). I also compiled the repo's own LocalizationSourceScanner.swift against both trees. It finds 0 unrouted literals and picks up Total as a requested key. The new N tok text is covered by the scanner's tok exemption.
  • Payload shape: I ran codeburn status --format menubar-json --period week with and without --provider claude. The Claude daily rows now have nonzero input/output tokens and a topModels list; the All rows have 3 to 5 topModels.
  • Render harness: I copied BarTooltipCard verbatim from main and from this branch and rendered both with ImageRenderer at 332pt wide (popover width minus padding), at 2x, in light and dark:
    • All view with 5 models: the Total row shows the day's cost and tokens, and Total lines up with the model names.
    • Claude only: the day's cost is back in the tooltip, in the Total row.
    • Day with tokens but no cost: the Total row shows only tokens.
    • Day with no breakdown: the image is byte-identical to main in both light and dark.
    • Long model names, a 5-digit cost, a 1B+ token count and the zh-Hans label: nothing clips.
    • I can attach the before/after images.
  • The card is about 19.5pt taller (one row plus the separator). Its bottom edge is pinned, so it now reaches further up into the chart and can cover a short hovered bar. I left the offset alone to keep the diff small.

Provider-filtered daily history now carries input and output tokens, so
the Trend chart picks tokens as its metric even with a single provider
selected. The tooltip header followed it and showed "N tok", which left
the day's cost nowhere in the tooltip. The model rows could not stand in
for a total either: only the first four of up to five topModels render.

When a day has a model breakdown, the tooltip now ends it with a
separator and a Total row carrying the day's cost and tokens from the
payload (not a sum of the visible rows), matching the web dashboard's
tooltip. The header figure is kept only for days without a breakdown.

Fixes getagentseal#1433
@github-actions

Copy link
Copy Markdown

Closing for now: you already have 5 pull requests open (#1339, #1347, #1352, #1364, #1370), and we review at most 5 per contributor at a time. Reopen this one when one of them is merged or closed. Issues are always welcome.

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.

Menubar popover: hover tooltip missing Total row since model breakdown (v0.9.24)

1 participant