Repository navigation
feat(billing): show the month's AI usage at the top right of the main pages (AI usage display, part 1) - #1430
Merged
Conversation
… pages (AI usage display, part 1) Co-Authored-By: Claude Opus 5.5 <[email protected]>
This was referenced Oct 23, 2026
Merged
gkhngyk
approved these changes
Oct 24, 2026
gkhngyk
left a comment
Contributor
There was a problem hiding this comment.
Looks good. One small follow-up, fine to do later:
web/src/components/providers/ai-usage-provider.tsx:53-56: a failed read doesn't movereadAt. While the API is unreachable, every page change and every tab focus starts another read, and each one can wait the full 15 s.readingkeeps it to one read at a time, so this isn't a storm, but a short back-off in thecatchwould keep an outage quiet. For example, setreadAt.current = Date.now() - AI_USAGE_STALE_MS + 15_000there, so the next try waits about 15 s instead of firing on the next navigation.
cihan-gyk
added a commit
to cihan-gyk/ansvisor
that referenced
this pull request
Oct 24, 2026
ansvisor#1430 and ansvisor#1431 are on main (squash-merged), with ansvisor#1433 and ansvisor#1436; this branch's own change (part 4) is applied on top of them. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
AI usage display, part 1: the month's AI usage at the top right of the main pages (Drive › AI Usage ›
AI-USAGE-spec.md§3.1 and §4).Web only, no migration. It reads the server routes that are already on
main:GET /api/billing/ai-usage(#1386),/api/audits/quotaand/api/prompts/usage.The meter
dark:variants. Its name says it too: "AI 84% used this month, close to the limit".The popover (on click)
settings.aiUsageMeter.features).id="ai-usage"). The card scrolls itself into view once it has loaded, since Billing shows it only after reading the plan.Reads
AiUsageProvidersits in the dashboard layout./api/aeoproxy, not a server action, because Next runs server actions one at a time and the meter would otherwise wait behind a page's own work, such as the Content Agent's. Each read gives up after 15 s.AiUsageProvideris incomponents/providers/, beside the plan and role providers.Pages: each header row is wrapped in
HeaderWithAiUsage, so the meter is in the same place on every page: 24 px from the top and from the right at 1280, 1024 and 375 px.Next PRs (same spec):
max-w-5xlcolumn with a Back row, so they need their own placement.Chat has no header row yet. The meter goes there with the Chat work, and it is the only meter there (spec §3.1).
From the spec, changed here:
Pre-push review: no high findings. Fixed:
@/lib/formatinstead of new ones;components/providers/.Related issue
Drive spec AI Usage (approved 2026-10-23). No GitHub issue.
Type of change
How to test
NEXT_PUBLIC_IS_CLOUD=truefor the web andIS_CLOUD=truefor the server, and give the workspace a cloud plan (e.g. Growth) with an active subscription.prompt_improve_usage):Checked locally on the demo workspace, temporarily on Growth with test usage rows (restored and removed afterwards):
Checklist
web/:yarn format:check,yarn lint(0 errors; 6 existing warnings elsewhere),yarn typecheck,yarn test(364 files, 3,300 tests) andyarn buildpassai-usage-client.test.ts: the reads go through the proxy. A missing plan reads as null and an error throws. Site Audit pages count the running ones, and prompt locations are the account's. A limit with no cap, one that can't be read, and prompts without a brand are left out.ai-usage-meter.test.tsx:ai-usage-card.test.tsx: the card scrolls itself into view for#ai-usage.action-center/{actions,kpis}/page.test.tsxstub the wrapper, as they stub the tabs.messages/en.json🤖 Generated with Claude Code