Skip to content

feat(bestie): show the last 7 days of cost in the Bestie tab - #3499

Merged
rileycrane merged 6 commits into
mainfrom
rileycrane/bestie-cost-row
Nov 18, 2026
Merged

rileycrane merged 6 commits into
mainfrom
rileycrane/bestie-cost-row

Conversation

@rileycrane

@rileycrane rileycrane commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

What it shows

A Cost, last 7 days row in the Bestie tab (and the Former Bestie tab): a seven-bar daily sparkline (oldest first, today last), the week's total, and Open Usage, which opens Settings → Usage.

  • It is an estimate, not a bill: the cost the agent's harness recorded, or else its token counts at published prices (genai-prices), exactly as the Usage plugin computes it. A partly unknown total says so ("partial").
  • An agent whose type reports no usage, or that runs on another device or is hosted, shows the row as not available, with the reason.
  • A failed read shows a quiet message with Retry; the rest of the tab never waits on it.

Where the numbers come from

On open, the row calls the agent type's existing usage({ since, signal }) for the last seven days, then reuses Usage's own stats() and price loader (src/bundled/usage/) to total it. bestie/cost.ts is a thin wrapper; there is no new pricing or aggregation code. Other bundled plugins already import across plugin folders (Bestie imports from ../agents and ../channels), and no lint or boundary rule forbids it, so nothing was moved.

No new state

No persisted state, no sync, no new storage. The read is aborted when the tab closes.

Not done

Open Usage is not filtered to this agent. Usage keeps its filters in its own saved view state and its settings card takes no route parameter, so filtering would mean writing Usage's saved choice from Bestie or changing Usage. I did neither, and left UsagePage.tsx alone. If the Usage plugin is turned off, the link opens Settings without that section.

Evidence

  • pnpm check exits 0 (biome, tsc, design typecheck, design check; biome reports only schema-version infos).
  • New tests: bestie/CostRow.test.tsx (7-day totals and exclusion of older requests, the since bound, sparkline label and Open Usage target, type without usage, agent not on this device reads nothing, rejected read gives a quiet state and Retry reads again, abort on unmount) and one case in BestieTab.test.tsx (a rejected read leaves the tab intact). The existing tab tests only gained the navigation argument.
  • vitest run over the whole repo: 21522 passed, 1 failed, 25 skipped. The failure is browser-host/media-preparation.integration.test.mjs (tiled HEIC), which also fails on main. pnpm test's other stages (node integration tests, cargo, browser) were not run; the change is frontend only.
  • Pre-push hooks passed.

Not verified in the running app. I did not run the desktop app, so the row's layout, the sparkline in both themes, narrow widths and enlarged text, and the Open Usage navigation have not been looked at. The design guide's rendered checks are deferred to a human try.

🤖 Generated with Claude Code

Screenshots

Recorded at 6efc4f284 in Chromium, using this PR's Bestie tab fixture (tests/fixtures/bestie-tab.tsx) with example data. The usage read is a stub returning three example requests, and Usage on/off is the settings-card registration the row subscribes to.

Usage on Usage off
Bestie tab Bestie tab with Usage on: Cost, last 7 days, $3.75, Open Usage Bestie tab with Usage off: no Cost row
Former Bestie tab Former Bestie tab with Usage on: Cost row shown Former Bestie tab with Usage off: no Cost row

Usage turned off and back on while each tab is open (21 s):

cost-row-usage-on-off.mp4

@rileycrane
rileycrane force-pushed the rileycrane/bestie-cost-row branch from d068199 to 8bb70f7 Compare November 13, 2026 23:12

@rileycrane rileycrane left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

🤖 Review scoped to 9fcfe80..8bb70f7 (#3499 only). Two reproduced correctness findings below. Unchanged Bestie/Usage Vitest suites: 211 passed. Existing Bestie layout journey: 6 passed across Chromium/WebKit; inspected the narrow 20rem/20px screenshot. No native-app or dark-theme validation was performed.

Comment thread src/bundled/bestie/CostRow.tsx Resolved
Comment thread src/bundled/bestie/CostRow.test.tsx Resolved

@rileycrane rileycrane left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

🤖 Carl review scoped to 9fcfe80ae6f2d496519ee5075932bbe3bfa583ba..8bb70f725ba5118b7606f6b9ec6108da2578e2fb (#3499's two commits only): no additional findings beyond the two existing P2 errors, both recommended must-fix: unreachable Open Usage destination and uncontrolled test clock.

I independently found the navigation issue before reading existing feedback. Source tracing confirms Usage is disabled by default, its card is absent, and the settings target fails as unavailable without the page/plugin Enable recovery. The Settings sidebar still permits manual recovery. After comparing reviews, I also confirmed the clock defect: the same fixture observations yield $1.75 at the November 13 fixture clock and $0.00 on November 21 through the real weekCost helper; mounted CostRow reads the uncontrolled current time.

Calendar boundaries, shared pricing/partial totals, caller updates, and read-on-open cancellation produced no additional blocker. Read-only review; checkout remained clean and diff check passed. Reused the reported exact-head CI and Bestie/Usage/browser evidence instead of rerunning those suites. No running-app validation performed.

@rileycrane rileycrane left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

🤖 Re-check scoped to 8bb70f7..4af716e: both earlier must-fix findings are resolved. CostRow subscribes to actual Usage settings-card registration, hides Open Usage while absent, and retains the figures/sparkline; enable/disable transitions and the enabled navigation target are covered. The tests now control Date and restore real timers. Checked production tab registration plus Bestie/Former Bestie/test-fixture callers. Exact archived-head Bestie/Usage suites: 212 passed; diff check passed. Ready from this code review, with no new must-fixes. Prior Chromium/WebKit layout evidence consumed; native-app and dark-theme validation remain outstanding.

@rileycrane rileycrane left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

🤖 Carl re-check scoped to 8bb70f725..4af716e14: both prior must-fixes are resolved. Open Usage now follows the active settings-card registration through a live subscription, while cost and sparkline remain visible with Usage off. The enabled target and off/on/off transitions are covered, and both tab factories plus the layout fixture receive the settings-card service. The tests pin Date to the observations' sample day and restore it after unmounting; async timers remain real.

Ready from code review: no additional must-fix found in the fix. Exact HEAD and clean checkout verified, diff check passed, and current CI is 63 pass / 1 skipped. Consumed existing exact-head 212-test Bestie/Usage and 6/6 Chromium/WebKit layout evidence rather than repeating those suites. No native-app or dark-theme validation performed by this re-check.

@rileycrane rileycrane left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

🤖 READY from the merge-resolution re-check at d20fe59; no must-fixes. Verified both 4af716e and 21b8a5b are ancestors. Remerge-diff shows only the intended help-text placement and the new base test passing navigation/settingsCards. All eight other feature-file patch IDs match the last reviewed version. In a fresh detached worktree at this exact head, Bestie/Usage Vitest passed 213/213 tests; TypeScript and base-to-head diff check passed; checkout remains clean. Existing browser/video evidence consumed, no new native-app exercise. CI is still pending (22 successful, 1 skipped, 40 running at this check); this verdict covers source resolution, not completed CI or human validation.

@rileycrane rileycrane left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

🤖 READY from the bounded merge re-check at d20fe590d. No new must-fixes.

Reviewed the merge of 21b8a5b74 into previously reviewed 4af716e14 in a fresh detached worktree. The remerge diff contains only the documented help-text placement and the new BestieTab regression's four-argument factory call. The remaining feature patches match the previously reviewed version; production navigation/settings-card forwarding, the live Open Usage gate and controlled test clock are preserved.

Exact-head Bestie/Usage suites: 15 files, 213 tests passed. Diff/ancestry checks passed; checkout remains clean. Existing full-suite comparison and browser evidence consumed, without another broad rerun. CI is still pending (35 successful, 1 skipped, 27 running at the last check); this is code-review readiness. Live-account/native acceptance remains outstanding.

Base automatically changed from rileycrane/bestie-memory-v2 to main November 16, 2026 22:58
rileycrane and others added 3 commits November 16, 2026 15:47
Add a Cost row to the Bestie tab: a daily sparkline, the week's total and
Open Usage, which opens Settings -> Usage. The numbers are estimates from the
agent type's own `usage` read, priced as the Usage plugin prices them, and are
computed when the tab opens. Nothing is stored or synced.

An agent whose type reports no usage, or that runs elsewhere, shows the row as
not available. A read that fails shows a quiet message with Retry.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Riley Crane <rileycrane@squareup.com>
The Bestie tab now takes the host's navigation for its Cost row, and the
layout fixture still built it without one, so the tab threw before it
rendered. The fixture now passes a navigation and gives its agent type a
`usage` read with recorded costs, so the row shows its sparkline, total and
Open Usage. The layout journey waits for that row before measuring, so the
widest new row is part of the fit check at every width and text size.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Riley Crane <rileycrane@squareup.com>
The Cost row's Open Usage opened the Usage plugin's settings card, and
Usage is off by default, so on a fresh install the button led to a page
that isn't available. The row now shows the button only while that card
is registered, following the settings cards as Usage is turned on or
off. The cost and sparkline still show either way: they come from the
agent type's own usage read.

The row's rendered tests also read their week from the real clock
against fixed sample dates, so they would fail a week after those
dates. They now hold Date at the sample day.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Riley Crane <rileycrane@squareup.com>
@rileycrane
rileycrane force-pushed the rileycrane/bestie-cost-row branch from d20fe59 to 6ce3a12 Compare November 17, 2026 00:03
@rileycrane
rileycrane marked this pull request as ready for review November 17, 2026 00:36
@rileycrane
rileycrane requested a review from a team as a code owner November 17, 2026 00:36

@wesbillman wesbillman left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

🤖 Star Lord: changes needed at 6ce3a12; two P2 defects and a product-scope decision are detailed inline. Source review only; the single CI snapshot has a failed required aggregate and a cancelled Chromium shard.

Comment thread src/bundled/bestie/cost.ts Resolved
Comment thread src/bundled/bestie/CostRow.tsx Resolved
Comment thread src/bundled/bestie/BestieTab.tsx Resolved
rileycrane and others added 3 commits November 16, 2026 17:54
goose shares one workspace read between concurrent callers and keeps only
the sessions the first caller's window covers. When the Bestie tab's
seven-day read started first, Usage's 30-day read joined it and lost every
session last active 8-30 days ago. Read Usage's window and add up the week.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Riley Crane <rileycrane@squareup.com>
Retry cleared the failed read, so the loading row replaced the focused
button and a keyboard user lost their place. Keep the failed row, with
Retry busy, until the read settles; on recovery, hand focus to Open Usage,
or to the daily sparkline while Usage is off.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Riley Crane <rileycrane@squareup.com>
With Usage off, neither the Bestie nor the Former Bestie tab mounts the
row, so nothing is read, and turning Usage off stops a read under way.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Riley Crane <rileycrane@squareup.com>

@wesbillman wesbillman left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

🤖 Carl, an automated reviewer, commenting via Wes's GitHub account.

Verdict: no blockers at 6efc4f2. Reviewed across plugin boundary, cost computation and data flow, and CostRow behavior/a11y.

  • Plugin encapsulation is correct. Reusing usage/stats and usage/pricing from Bestie is allowed by docs/plugin-architecture.md (bundled source stays importable). Gating on settingsCards.has("buzz.usage/usage") and linking with settingsTarget({ section }) follow existing precedents (Builderlab login, GitHub authors). Disabling Usage removes the card, which removes the row and aborts any read in progress. No new host contract, storage or sync.
  • Numbers match Usage. Same prices, local calendar-day buckets and partial totals. The 30-day since is needed: goose shares one refresh using the first caller's window, so a 7-day read could cut short a concurrent Usage read.
  • Navigation: calling navigation.open directly instead of the tab's open/canOpen is consistent with the host. ProfilePanel's own openSettings does the same, and on the Agents page the tab's canOpenLink accepts only profile links.

Remaining gaps (not blocking):

  • Rendered checks are still to do, as the PR says: both themes, narrow width, enlarged text, keyboard, and Open Usage in the Agents page and the profile panel.
  • Cold-read cost is unmeasured. Each time the tab opens it re-reads history; for goose that exports every agent's sessions in the workspace for 30 days, then filters. Worth one timing check on a real history.

@rileycrane
rileycrane merged commit 802e5bd into main Nov 18, 2026
66 checks passed
@rileycrane
rileycrane deleted the rileycrane/bestie-cost-row branch November 18, 2026 03:29
joahg added a commit to joahg/buzz-app that referenced this pull request Nov 18, 2026
…utomatic

* origin/main: (27 commits)
  feat(bestie): show the last 7 days of cost in the Bestie tab (block#3499)
  test(perf): measure the cost of background channel traffic (block#3727)
  fix(channels): make renaming and access changes easy to find in Channel settings (block#3679)
  fix(channels): move unarchive into the archived pill (block#3763)
  Retry the protected Claude fixture download (block#3086)
  test(search): fix main typecheck in scoped search tests (block#3780)
  fix(messages): copy a message's author and time as one line above its text (block#3598)
  fix(agents): copy the npub from the card menu's "Copy public key" (block#3666)
  fix(presence): call the online state "Online" in the profile to be consistent (block#3677)
  fix(shell): say availability, not status, when availability is unknown (block#3688)
  test(browser): warm up the window-chrome fixture before navigating (block#3690)
  AIDA-2282: Reject legacy CLI calls to the desktop app (block#2014)
  fix(messages): highlight only selected text inside Markdown boxes (block#3734)
  Add committed artifact change notifications (block#3759)
  test(reactions): measure the action bar only after it opens (block#3281)
  fix(dm): create a DM only when its first message is sent (block#3682)
  feat(solo): grant chat admin access to owned agents (block#3647)
  feat(messages): copy forwards into composers (block#3632)
  feat(media): add image and video context actions (block#3740)
  feat(solo): archive a workspace's inactive chats (block#3717)
  ...

Signed-off-by: Joah Gerstenberg <joah@squareup.com>
joahg added a commit to joahg/buzz-app that referenced this pull request Nov 18, 2026
…place

* origin/main: (200 commits)
  feat(builderlab): list stored conversations above the live activity feed (block#3607)
  feat(bestie): show the last 7 days of cost in the Bestie tab (block#3499)
  test(perf): measure the cost of background channel traffic (block#3727)
  fix(channels): make renaming and access changes easy to find in Channel settings (block#3679)
  fix(channels): move unarchive into the archived pill (block#3763)
  Retry the protected Claude fixture download (block#3086)
  test(search): fix main typecheck in scoped search tests (block#3780)
  fix(messages): copy a message's author and time as one line above its text (block#3598)
  fix(agents): copy the npub from the card menu's "Copy public key" (block#3666)
  fix(presence): call the online state "Online" in the profile to be consistent (block#3677)
  fix(shell): say availability, not status, when availability is unknown (block#3688)
  test(browser): warm up the window-chrome fixture before navigating (block#3690)
  AIDA-2282: Reject legacy CLI calls to the desktop app (block#2014)
  fix(messages): highlight only selected text inside Markdown boxes (block#3734)
  Add committed artifact change notifications (block#3759)
  test(reactions): measure the action bar only after it opens (block#3281)
  fix(dm): create a DM only when its first message is sent (block#3682)
  feat(solo): grant chat admin access to owned agents (block#3647)
  feat(messages): copy forwards into composers (block#3632)
  feat(media): add image and video context actions (block#3740)
  ...

Signed-off-by: Joah Gerstenberg <joah@squareup.com>

# Conflicts:
#	.github/workflows/desktop-build.yml
#	browser-host/vite-config.test.mjs
dr0uleau added a commit that referenced this pull request Nov 18, 2026
Co-authored-by: Zerk <c35e7cc95f6fdbfb7e861dccc02bdca567b6d6b20f16b5115c3c6ae082bbeede@buzz.block.builderlab.xyz>

* origin/main: (28 commits)
  fix(emoji): stop a universal sibling selector restyling every list (#3821)
  perf(messages): cut floating action bar work per scroll frame (#3835)
  fix(timeline): keep jump to latest hidden when returning to the latest message (#3832)
  perf(agents): reuse activity record parses while an agent streams (#3830)
  perf(sidebar): keep sidebar context values stable across renders (#3829)
  fix(emoji): preserve time-like numeric text (#3747)
  chore(goose): bump bundled goose-acp to v1.60.1 (#3843)
  Toggle channel mute with /mute (#3731)
  fix(activity): make the unread dot the Mark as read action (#3751)
  fix(unread): describe attachment-only messages in activity and Inbox previews (#3742)
  perf(sidebar): re-render one row, not the sidebar, per live message (#3746)
  feat(builderlab): list stored conversations above the live activity feed (#3607)
  feat(bestie): show the last 7 days of cost in the Bestie tab (#3499)
  test(perf): measure the cost of background channel traffic (#3727)
  fix(channels): make renaming and access changes easy to find in Channel settings (#3679)
  fix(channels): move unarchive into the archived pill (#3763)
  Retry the protected Claude fixture download (#3086)
  test(search): fix main typecheck in scoped search tests (#3780)
  fix(messages): copy a message's author and time as one line above its text (#3598)
  fix(agents): copy the npub from the card menu's "Copy public key" (#3666)
  ...

Signed-off-by: Daniel Rouleau <drouleau@squareup.com>
joshfriend added a commit that referenced this pull request Nov 18, 2026
* origin/main: (164 commits)
  fix(composer): let arrow keys leave a code block at the draft edge (#3754)
  fix(composer): let arrow keys leave a code block at the draft edge (#3754)
  feat(codex): assign voices per agent (#3564)
  fix: center section emoji artwork (#3795)
  test(panels): wait for the closing dock before reopening the header menu (#3343)
  Route local agents in listed communities through an agent gateway (#2632)
  fix(emoji): stop a universal sibling selector restyling every list (#3821)
  perf(messages): cut floating action bar work per scroll frame (#3835)
  fix(timeline): keep jump to latest hidden when returning to the latest message (#3832)
  perf(agents): reuse activity record parses while an agent streams (#3830)
  perf(sidebar): keep sidebar context values stable across renders (#3829)
  fix(emoji): preserve time-like numeric text (#3747)
  chore(goose): bump bundled goose-acp to v1.60.1 (#3843)
  Toggle channel mute with /mute (#3731)
  fix(activity): make the unread dot the Mark as read action (#3751)
  fix(unread): describe attachment-only messages in activity and Inbox previews (#3742)
  perf(sidebar): re-render one row, not the sidebar, per live message (#3746)
  feat(builderlab): list stored conversations above the live activity feed (#3607)
  feat(bestie): show the last 7 days of cost in the Bestie tab (#3499)
  test(perf): measure the cost of background channel traffic (#3727)
  ...

# Conflicts:
#	docs/buzz-help.md
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