Skip to content

feat(desktop): agent usage dashboard with cache breakdown - #6694

Open
malkovitc wants to merge 3 commits into
block:mainfrom
malkovitc:duncan/agent-usage-ui
Open

malkovitc wants to merge 3 commits into
block:mainfrom
malkovitc:duncan/agent-usage-ui

Conversation

@malkovitc

Copy link
Copy Markdown

Supersedes #4001 with the same dashboard restacked onto current main.

Summary

  • 7/30/custom-range agent usage dashboard and focused per-agent/model views
  • exact input/output/cost totals with unknown/partial/invalid coverage semantics
  • cache-read, cache-write, and fresh-input breakdown without fabricating absent values
  • current profile panel and E2E bridge integration

Validation on current main

  • 36 focused hook/usage tests passed
  • pnpm typecheck
  • Biome check on all changed dashboard/integration files
  • pnpm build:e2e
  • 21/21 agent-usage Playwright smoke E2E tests passed
  • git diff --check origin/main...HEAD

The branch was rebased onto current main at 0720f5380ce8a6c050afac159f8462c06cd51ab5; the only rebase conflict was additive E2E bridge command registration, resolved by retaining both current archive/unread commands and get_agent_usage_series.

Duncan and others added 3 commits August 24, 2026 18:25
Adds the agent-usage UI feature on top of the merged NIP-AM backend.

- `desktop/src/features/agent-usage/`: daily bars chart, 7/30-day range
  tabs, focused agent view with caveats, hooks, and lib utilities. All
  state is driven by the `get_agent_usage_series` Tauri command.
- Profile panel: usage ingress row + focused view wired into agent
  profiles; gated on owner-scoped visibility (`viewerIsOwner && isBot`).
- `AgentsView`: agent-usage overview section.
- `AgentsScreen`/`ProfilePanelContext`: usage navigation state.
- `e2eBridge.ts` + `tests/helpers/bridge.ts`: `get_agent_usage_series`
  mock handler + fixture types, including the M2 cache fields
  (`cacheReadTokens`, `cacheWriteTokens`, `freshInputTokens`) the wire
  type carries. The UI absorbs but does not display these fields.
- `tests/e2e/agent-usage.spec.ts` + `agent-usage-screenshots.spec.ts`:
  Playwright coverage for loading, empty state, bars, range switching,
  error/retry, focused view, caveats, and cache invalidation.
- `desktop/playwright.config.ts`: agent-usage specs added to suite.
- `desktop/package.json`: recharts dependency.

Co-authored-by: Will Pfleger <pfleger.will@gmail.com>
Signed-off-by: Will Pfleger <pfleger.will@gmail.com>
(cherry picked from commit 3d723a7)
Signed-off-by: evgeniy.chernomortsev <j.malkovitc@gmail.com>
…t-usage focused view

The plumbing already returned cacheReadTokens/cacheWriteTokens/freshInputTokens
at every scope of AgentUsageSeries, but the focused view rendered only the four
top-level stats and never surfaced them. Add an Input-breakdown subsection to the
totals card (Cache read / Cache write / Fresh input) gated on any known cache
value, and a compact per-model breakdown line. Fields follow the existing
unknown-not-zero semantics: absent subsets are omitted, a known-but-incomplete
value shows its lower bound with a Partial marker, and a scope with no cache data
renders no subsection at all.

Co-authored-by: Will Pfleger <pfleger.will@gmail.com>
Signed-off-by: Will Pfleger <pfleger.will@gmail.com>
(cherry picked from commit b01a381)
Signed-off-by: evgeniy.chernomortsev <j.malkovitc@gmail.com>
Signed-off-by: evgeniy.chernomortsev <j.malkovitc@gmail.com>

@chatgpt-codex-connector chatgpt-codex-connector Bot 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: abf93e3b94

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +59 to +61
React.useEffect(() => {
if (canViewUsage || !query.data) return;
if (query.data.hasArchivedEvidence !== true) onIneligible();

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Wait for ownership resolution before redirecting usage views

When an owned agent's Usage view is opened directly, the local SQLite usage query can resolve before the asynchronous profile/relay-agent queries establish ownership. During that window canViewUsage is false; if the agent has no archived evidence, this effect redirects to the summary and never restores the requested view after ownership resolves. Treat unresolved ownership separately from confirmed ineligibility before calling onIneligible.

Useful? React with 👍 / 👎.

@malkovitc

Copy link
Copy Markdown
Author

Packaging evidence: the restacked dashboard was combined with #6692 and successfully bundled into Buzz Linza Patched 0.5.18 after 21/21 focused Playwright E2E tests, 36 focused unit tests, typecheck, Biome, and build:e2e. The installed bundle passes strict deep codesign verification; the prior 0.5.17 app remains as a rollback backup.

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.

1 participant