Skip to content

feat(billing): show the AI usage meter on the detail pages too (AI usage display, part 4) - #1434

Merged
gkhngyk merged 5 commits into
ansvisor:mainfrom
cihan-gyk:feature/ai-usage-detail-pages
Oct 24, 2026
Merged

gkhngyk merged 5 commits into
ansvisor:mainfrom
cihan-gyk:feature/ai-usage-detail-pages

Conversation

@cihan-gyk

Copy link
Copy Markdown
Collaborator

Summary

AI usage display, part 4: the month's AI usage meter (and its 80% / 100% banner) on the detail pages too, so it is in the same place on every page (Drive › AI Usage › AI-USAGE-spec.md §3.1).

Stacked on #1431 (banners, on #1430). Web only, no migration.

Each detail page's header block — its Back link and its title — is wrapped in HeaderWithAiUsage (#1430), so the meter sits at the block's top right and the banner follows it:

  • a prompt (prompts/[id]) and an answer (insights/[id]): their Back button and title block now share one block;
  • an audit (audit/[id]): the Back link row with Re-audit and Delete;
  • a cited page (citations/url), a topic (prompts/topics/[id]) and Similar topics;
  • a brand's Settings, Prompts and Topics (brands/[id]/layout.tsx): after Workspace Settings;
  • an opportunity (content/[id], OpportunityDetail):
    • its Back + title row only, with HeaderWithAiUsage banner={false}, a new option, so its badges stay under the title and the banner follows the whole block;
    • also in its drawer on the Content page, because the drawer covers that page's header.

Pages in a centred column (a prompt, an answer, Similar topics) have the meter at the column's right, level with Back. That's 24 px further in than on the other pages, from those pages' own padding. Moving it out of the column would take it off the Back row's line.

On a phone the meter goes under the header block, on the right, as on every page.

Most of the diff is re-indentation: "Hide whitespace" shows about 40 added lines.

Pre-push review: no high findings. Fixed:

  • on a phone, the opportunity's meter squeezed its title (it was inline in the row);
  • the drawer showed no usage while it covered the page's meter;
  • the commit title was shortened.

Left as is: the 24 px offset on centred pages (above), and the Back link row being shorter than the meter on an audit and a cited page.

Not here:

Related issue

Drive spec AI Usage (approved 2026-10-23). No GitHub issue.

Type of change

  • Bug fix
  • New feature
  • Breaking change
  • Documentation

How to test

  1. As in feat(billing): show the month's AI usage at the top right of the main pages (AI usage display, part 1) #1430, run Cloud mode with a workspace on a cloud plan.
  2. Open a prompt, an answer, an audit, a cited page, a topic, Similar topics, an opportunity, and a brand's settings. "AI n%" sits at the top right of each header block.
  3. Open an opportunity from the Content page's drawer: the drawer shows the meter at its title's right.
  4. At 84%, the amber banner follows each header block.
  5. Check light and dark, 1024 px and a phone width.

Checked locally on the demo workspace, temporarily on Growth at 100% (restored afterwards). The demo workspace has no audit, so the audit page was checked in code and tests only.

  • At 1024 px:
    • a topic, an opportunity and a brand's settings have the meter at 24 px from the top and the right;
    • the brand's meter sits 12 px after Workspace Settings;
    • a prompt, an answer and Similar topics have it level with Back, at 48 px (their own padding);
    • the red banner follows each header block;
    • there is no horizontal overflow.
  • At the pane's phone width: the meter sits under each header block, with no overflow.

Checklist

  • web/: yarn format:check, yarn lint (0 errors; 6 existing warnings elsewhere), yarn typecheck, yarn test (366 files, 3,313 tests) and yarn build pass
  • The pages' existing tests pass with the wrapper; ai-usage-meter.test.tsx covers banner={false}
  • No new UI text

🤖 Generated with Claude Code

cihan-gyk and others added 3 commits October 24, 2026 01:06
… pages (AI usage display, part 1)

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…AI usage, and once it's used up (AI usage display, part 2)

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…age display, part 4)

A prompt, an answer, an audit, a cited page, a topic, Similar topics, an opportunity, and a brand's settings, prompts and topics.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

@gkhngyk gkhngyk left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

One fix before merge:

  1. The meter sits under the drawer's close button. Files: web/src/components/content/opportunity-detail.tsx:486, with web/src/app/[locale]/(dashboard)/dashboard/content/page.tsx:1759-1761 and web/src/components/ui/sheet.tsx:65.
    • On the Content page's drawer, SheetContent keeps its built-in close button: 28 px, absolute top-3 right-3, so it spans 12–40 px from the top and from the right.
    • The drawer's body is p-6. From 640 px up, the meter now sits at 24 px from the top and the right, 32 px tall.
    • The two share a 16×16 px corner. The X is drawn over the meter's right end, the "%" side, and a click there closes the drawer instead of opening the popover.
    • Fix: leave room for the close button in the drawer. For example, wrap the header in <div className={cn(inDrawer && 'pr-8')}>, or give HeaderWithAiUsage a className and pass pr-8 when inDrawer. Alternatively, pass showCloseButton={false} to this SheetContent and put a close button in the header row next to the meter.
    • The standalone content/[id] page has no close button and is fine as is.

cihan-gyk and others added 2 commits October 24, 2026 11:33
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]>
…usage meter

On the Content page's drawer the opportunity's header row ends under the
sheet's close button (28 px at top-3 right-3), so the X covered the
meter's "%" end and a click there closed the drawer. HeaderWithAiUsage
takes a className for its row, and the drawer passes pr-8.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@cihan-gyk

cihan-gyk commented Oct 24, 2026 •

Copy link
Copy Markdown
Collaborator Author

@gkhngyk Fixed, and main merged in.

Checks: web format, lint (0 errors), typecheck, yarn test (367 files / 3342 tests) and yarn build with CI's placeholder env.

@gkhngyk gkhngyk left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

All items done.

  • Close button: the drawer passes pr-8 to HeaderWithAiUsage (web/src/components/content/opportunity-detail.tsx:487). From 640 px up the meter now ends 56 px from the drawer's edge, clear of the X (12–40 px). Below 640 px the title row gets the same room. The standalone page is unchanged, and the new meter test pins the class.
  • Merge of main (eba1c38): no hidden changes. What it adds on top of main is exactly part 4 as reviewed; only one test hunk's line offset differs, because #1436 added tests above it.

@gkhngyk
gkhngyk merged commit 1a5dc0e into ansvisor:main Oct 24, 2026
5 checks passed
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