Skip to content

feat(ai-hud): scaffold status bar AI cost + cache HUD#28

Merged
kanywst merged 8 commits into
mainfrom
feat/prompt-cache-hud
May 25, 2026
Merged

feat(ai-hud): scaffold status bar AI cost + cache HUD#28
kanywst merged 8 commits into
mainfrom
feat/prompt-cache-hud

Conversation

@kanywst
Copy link
Copy Markdown
Member

@kanywst kanywst commented May 24, 2026

Goal

Reserve the workbench slot for the status bar HUD that surfaces AI cost and prompt-cache hit ratio in real time. This is the counter-positioning vs Cursor's credit model: show the raw numbers, never enforce a hard cap.

Design: `docs/zeus-prompt-cache-hud.md`

Counter-positioning

Cursor's credit pricing is what most heavy users complain about. Hard caps create anxiety. Zeus shows: live agent count, rolling cache-hit ratio, last-call cost, today's cumulative cost. Click to drill in; ignore if you don't care; configurable off entirely.

Depends on

#26 feat/agent-sdk — runtime event stream with `usage` data

Summary by CodeRabbit

  • Documentation
    • Added docs describing a new status-bar HUD that shows real-time AI cost and prompt-cache state (agents count, cache hit ratio, per-call cost, and daily cumulative totals), hover breakdowns, persistence across restarts, and configurable enable/detail/today-limit settings.
  • Tests
    • Stabilized a shutdown-path test by increasing timing allowances and test timeout to reduce CI flakiness.

Review Change Stack

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 24, 2026

Warning

Review limit reached

@kanywst, we couldn't start this review because you've used your available PR reviews for now.

Your plan includes 1 review of capacity. Refill in 37 minutes and 12 seconds.

Your organization has run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After more review capacity refills, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than trial, open-source, and free plans. In all cases, review capacity refills continuously over time.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 91470535-c9fb-4e92-b8a8-aa7cbce7d38f

📥 Commits

Reviewing files that changed from the base of the PR and between 9c5daf4 and de188c4.

📒 Files selected for processing (3)
  • docs/zeus-prompt-cache-hud.md
  • src/vs/workbench/contrib/aiHud/README.md
  • src/vs/workbench/contrib/mcp/test/node/mcpStdioStateHandler.test.ts
📝 Walkthrough

Walkthrough

Adds documentation for a Prompt cache HUD status bar and a small test timing adjustment. The docs define HUD segments, data sources, daily total persistence, configuration flags, implementation notes, and acceptance criteria; the test increases GRACE_TIME and suite timeout to reduce flakiness.

Changes

AI HUD Status Bar

Layer / File(s) Summary
Prompt cache HUD specification and contribution documentation
src/vs/workbench/contrib/aiHud/README.md, docs/zeus-prompt-cache-hud.md
Contribution README introduces the status bar HUD that reads AI cost and prompt-cache state from IAgentRuntime. Detailed design document specifies status bar segments (agents count, cache hit ratio, recent call cost, daily total), hover/tooltip breakdown, data sources (agent runtime event stream and SDK usage mapping), persistence via IStorageService (zeus.ai.cost), configuration flags (zeus.ai.hud.enabled, zeus.ai.hud.detail, zeus.ai.hud.todayLimit), implementation approach using multiple adjacent StatusBarItems, and acceptance criteria for real-time updates and persistence.
McpStdioStateHandler test timing adjustment
src/vs/workbench/contrib/mcp/test/node/mcpStdioStateHandler.test.ts
Increases GRACE_TIME from 100 to 1000, converts the Mocha suite callback to a function to call this.timeout(10_000), and updates timing comments to reduce CI flakiness in the SIGTERM→SIGKILL shutdown path.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐰 I hopped through docs at break of day,
A HUD to show what costs us play by play,
Prompts and caches shining in a row,
Tests slowed their ticks so flakiness won't grow,
Hooray for clear totals on display!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: scaffolding a status bar HUD for displaying AI costs and prompt cache state, which aligns with the documentation added and the overall PR objective.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/prompt-cache-hud

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces documentation and a placeholder for a new AI cost and prompt-cache status bar HUD. The feedback highlights a path error in the README, potential storage growth issues with the proposed per-day key strategy, and technical limitations regarding per-segment coloring in the VS Code StatusBarItem API.

Comment thread src/vs/workbench/contrib/aiHud/README.md Outdated
Comment thread docs/zeus-prompt-cache-hud.md Outdated
Comment thread docs/zeus-prompt-cache-hud.md Outdated
@kanywst kanywst marked this pull request as ready for review May 24, 2026 11:56
@kanywst
Copy link
Copy Markdown
Member Author

kanywst commented May 24, 2026

/gemini review

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces documentation and a placeholder for a new 'Prompt cache HUD' feature, which provides real-time visibility into AI costs and prompt-cache usage. It also updates a test to skip execution on CI environments due to flakiness. Feedback suggests using global storage scope for cost tracking to ensure aggregate transparency across workspaces and recommends simplifying the CI environment check while linking a tracking issue for the skipped test.

Comment thread docs/zeus-prompt-cache-hud.md Outdated
Comment thread src/vs/workbench/contrib/mcp/test/node/mcpStdioStateHandler.test.ts Outdated
@kanywst
Copy link
Copy Markdown
Member Author

kanywst commented May 24, 2026

/gemini review

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces the design and documentation for a Prompt cache HUD, a status bar feature for real-time AI cost and cache tracking. It also modifies a test in the MCP state handler to skip execution on CI due to flakiness. Feedback suggests improving the HUD design by persisting cache hit ratios across sessions, clarifying currency units in configuration, and adopting a more maintainable approach for pricing data. Regarding the test changes, it is recommended to use the test runner's built-in skip mechanism or address the underlying race condition rather than manually checking environment variables.

Comment thread docs/zeus-prompt-cache-hud.md Outdated
Comment thread docs/zeus-prompt-cache-hud.md Outdated
Comment thread docs/zeus-prompt-cache-hud.md Outdated
Comment thread src/vs/workbench/contrib/mcp/test/node/mcpStdioStateHandler.test.ts Outdated
@kanywst
Copy link
Copy Markdown
Member Author

kanywst commented May 24, 2026

/gemini review

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces documentation and a placeholder for the 'Prompt cache HUD,' a status bar feature designed to provide real-time transparency into AI costs and prompt-cache performance. It also increases the grace time in mcpStdioStateHandler.test.ts to mitigate test flakiness on CI. Feedback includes suggestions for internationalization support, addressing potential race conditions in storage persistence, improving user visibility for stale pricing data, and further increasing the test grace period to ensure stability.

Comment thread docs/zeus-prompt-cache-hud.md
Comment thread docs/zeus-prompt-cache-hud.md Outdated
Comment thread docs/zeus-prompt-cache-hud.md Outdated
Comment thread src/vs/workbench/contrib/mcp/test/node/mcpStdioStateHandler.test.ts Outdated
@kanywst
Copy link
Copy Markdown
Member Author

kanywst commented May 25, 2026

/gemini review

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces documentation for a new 'Prompt cache HUD' feature, which provides real-time AI cost and cache transparency in the status bar. It also includes stability improvements for MCP tests by increasing grace periods and timeouts to mitigate flakiness on slow CI runners. Feedback focuses on optimizing the persistence frequency of the cost tracking service to reduce disk I/O and improving the user experience for the stale pricing warning by making it configurable or dismissible.

Comment thread docs/zeus-prompt-cache-hud.md Outdated
Comment thread docs/zeus-prompt-cache-hud.md Outdated
kanywst added 8 commits May 25, 2026 23:11
Reserves 'src/vs/workbench/contrib/aiHud/' for the status bar item
that surfaces AI cost and prompt-cache state. Design at
'docs/zeus-prompt-cache-hud.md'.

This is the counter-positioning vs Cursor's credit model: show the
raw numbers, never enforce a hard cap. Users decide whether to
stop.
…note

- src/vs/workbench/contrib/aiHud/README.md: relative path is 5 levels
  to docs/, not 6
- docs/zeus-prompt-cache-hud.md: replace per-day storage key
  ('zeus.ai.cost.today.<date>') with a single key holding
  {date, total} that resets at local midnight, so the store doesn't
  grow over time
- docs/zeus-prompt-cache-hud.md: note that the HUD is implemented as
  multiple adjacent StatusBarItems because VS Code's API doesn't
  support per-segment coloring in one item
- IStorageService scope: WORKSPACE -> APPLICATION (per-user). The
  user's daily spend shouldn't reset when they switch workspaces,
  since the goal is total-cost transparency. Future setting
  'zeus.ai.hud.scope' can flip it per-project for users who want
  that.
- Flaky test (mcpStdioStateHandler 'sigterm after grace'):
  drop the redundant GITHUB_ACTIONS check (CI is set by every
  major CI provider, so the second condition was always true when
  the first was). Add a 'FLAKY-ON-CI(zeus#28)' marker so the skip
  is traceable and removable later.
…ce, nls.localize plan, UI stale-pricing warning, bump GRACE_TIME to 1000ms
…lity-only

Address reviewer concerns:
- Add zeus.ai.hud.stalePricingDays (default 30, null disables) so users
  on locked editor versions can suppress the stale-pricing glyph
- Reword the 1s persistence cadence note: renderer windows stay in sync
  via IPC subscriptions, not by re-reading storage, so write frequency
  is purely a hard-kill durability bound
@kanywst kanywst force-pushed the feat/prompt-cache-hud branch from 6b7501a to de188c4 Compare May 25, 2026 14:14
@kanywst kanywst merged commit 677a81d into main May 25, 2026
4 checks passed
@kanywst kanywst deleted the feat/prompt-cache-hud branch May 25, 2026 14:44
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