Skip to content

fix(billing): show the AI usage breakdown by what was used: quality checks under the Content Editor, no empty rows, "<0.1%" for a small share - #1629

Merged
gkhngyk merged 2 commits into
ansvisor:mainfrom
cihan-gyk:fix/ai-usage-meter-rows
Oct 28, 2026
Merged

gkhngyk merged 2 commits into
ansvisor:mainfrom
cihan-gyk:fix/ai-usage-meter-rows

Conversation

@cihan-gyk

Copy link
Copy Markdown
Collaborator

Summary

What changes:

  • getAiUsage folds the quality checks into the Content Editor row, now "Content Editor (briefs, Content Agent, quality checks)". The separate quality row is gone.
  • It returns only the features that spent something this period, in a fixed order: improve, content, action_center, other. percentUsed is unchanged.
  • A listed feature whose share rounds to 0 reads "<0.1%" (featurePercentLabel) instead of "0%". The server keeps the true rounded value, so the rows never add up to more than the total.
  • With no AI spend yet, the Billing card and the header meter's popover say so in one line.

Related issue

None. Ansvisor's decision (2026-10-28): the breakdown read as "you hardly use it". The Action Center's task writing is off on the cloud (ACTION_TASKS_AI), and quality checks cost a fraction of a cent, so most rows sat at 0%.

Type of change

  • feat — New feature
  • fix — Bug fix
  • chore — Maintenance / dependencies
  • docs — Documentation only
  • refactor — Code change that neither fixes a bug nor adds a feature
  • test — Adding or updating tests

How to test

  1. cd server && npx vitest run src/lib/plan-guard-ai-usage.test.js
  2. cd web && yarn vitest run src/components/settings/ai-usage-card.test.tsx src/components/ai-usage/ai-usage-meter.test.tsx

Checklist

  • Branch follows the naming convention (feature/, fix/, chore/, docs/) — see CONTRIBUTING.md
  • Commits follow Conventional Commits
  • yarn lint passes (run from web/)
  • yarn typecheck passes (run from web/)
  • yarn format:check passes (run from web/)
  • Changes are focused — one concern per PR

Checked together with the other PRs from the same test (one integration tree of all eleven on main 3f6a4d4):

  • server/: npm run format, npm run lint and npm test (3,349 tests).
  • web/: yarn format, yarn lint (0 errors, the 7 earlier warnings), yarn typecheck, yarn test (4,385 tests) and yarn build.
  • This branch's own tests were also run on it alone.

Checked in the browser at 1024 px, light and dark, against the dev DB with the API and web in cloud mode.

  • The demo organization was set to an active Growth plan, then put back.
  • With no spend, the card said "No AI usage yet this period."
  • With three temporary usage rows (content $0.50, quality $0.004, improve $0.001, deleted afterwards), it showed "Improve suggestions <0.1%" and "Content Editor (briefs, Content Agent, quality checks) 2%", and no Action Center row.

For you, @gkhngyk: "Other" is rows from before 00242 whose prompt, draft or action was deleted, so it fades out as periods pass. The total "0% used" line is unchanged, as asked.

🤖 Generated with Claude Code

cihan-gyk and others added 2 commits October 28, 2026 01:15
…hecks under the Content Editor, no empty rows, "<0.1%" for a small share

The AI usage breakdown listed every feature at 0% (the Action Center's
task writing is off on the cloud, quality checks cost a fraction of a
cent), which read as hardly using the product. getAiUsage folds quality
checks into the Content Editor row and returns only features that spent
something; a listed feature whose share rounds to 0 shows "<0.1%". With
no spend yet, the card and the header meter say so in one line.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…nge the new way

An older API lists every feature, unused ones at 0, and the quality checks in a row of their own. The web now adds that row into the Content Editor's and drops the unused rows, so no unused feature reads as "<0.1%" and a workspace that used nothing reads "No AI usage yet" until the API is deployed.
@gkhngyk

gkhngyk commented Oct 28, 2026

Copy link
Copy Markdown
Contributor

I took the review's before-merge item over (50fd906): aiUsageFromApi folds an older API's quality row into content and drops 0 rows, for both the Billing card and the header meter, so nothing reads "<0.1%" before the API deploy. Tests with the old answer's shape.

@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.

Looks good with 50fd906: the web reads an older API's answer (a separate quality row, unused features at 0) the way the new one reads, for the Billing card and the header meter, so it can ship before the API. The remaining follow-ups from the review stay open.

@gkhngyk
gkhngyk merged commit 6bbe099 into ansvisor:main Oct 28, 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