Skip to content

feat(ai-cost): read the billed months on the AI & Cost screen - #2943

Open
Gregory91G wants to merge 2 commits into
mainfrom
feat/ai-cost-billed-months-screen
Open

Gregory91G wants to merge 2 commits into
mainfrom
feat/ai-cost-billed-months-screen

Conversation

@Gregory91G

@Gregory91G Gregory91G commented Aug 28, 2026

Copy link
Copy Markdown
Contributor

Refs #2942.

Do not merge as an answer to #2942 — that issue has been reframed. The need there is monthly statistics in general: the same parameters with a monthly cut in place of the daily one, available for every metric. This branch builds a section for two cost keys, which is the narrow reading it was written against.

Open rather than closed. It stands as a worked reference for the monthly reading of these two metrics while the general shape is decided. What ships against #2942 is the product owner's call.

Why. ai.seat_cost has been served since #2671 and shown on no screen; the monthly ai.extra_usage_cost was shown on none either. So what a seat costs could not be read anywhere in the product.

What changed. A new "Billed by month" section on the AI & Cost screenBilling month | Seat cost | Extra usage billed, one row per billing month, both figures read at month buckets.

No total column, deliberately. The seat fee and the usage billed on top of it answer different questions; adding them reports a figure the vendor never charged. One line to add if a reader asks for a sum.

A section of its own rather than the existing rows. Both metrics are anchored to the first day of the month they bill for, so a row that totals a window drops any month whose first day it misses — which is why the surrounding sections take only the per-day distribution. The new section carries that caveat in place, and a window holding no month start says so.

Split out of #2928. No frontend consumer asked for this, so it waits on its own rather than riding the data-path checks that shipped there.

Verified. tsc -b clean, eslint . --max-warnings 0 clean, and 16/16 in ai-cost-view.test.tsx — four of them new: a month's two figures side by side with no sum of them anywhere, a month with no seat fee reading as absent rather than $0, a window inside one month showing the empty state a reader meets when the portal opens, and a failed monthly request saying so instead of calling the period uninvoiced.

The suite takes two metric collections through one hook, so its mock now dispatches on the requested keys — without that a failing per-tool request stands in for a failing monthly one and the new section asserts nothing.

Not run. tests/stand/ui — no browser journey covers this section, and no screenshot of it exists yet. Someone should look at it before this merges.

The invoiced seat fee reached the metrics API and no surface at all, and the
monthly billed extra usage reached none either: the screen carried only the
per-day distribution, because a row that totals a window cannot take a figure
anchored to the first day of the month it bills for.

A section of its own reads both at month buckets, one row per billing month.
There is deliberately no total column — the seat fee and the usage billed on top
of it answer different questions, and adding them reports a figure the vendor
never charged. A tier the invoice does not price reads as absent rather than
zero, and a failed request says so instead of calling the period uninvoiced.

The view takes two collections through one hook, so the suite's mock now
dispatches on the requested keys. Without that a failing per-tool request stands
in for a failing monthly one and the new section asserts nothing.

Signed-off-by: Gregory Gogin <grigoriy.gogin@constructor.tech>
The suite pinned a week inside July while the monthly result carried points on
two month firsts — a pairing the API cannot produce, since both month-grain
metrics are anchored to the first day of the month they bill for and a window
missing that day returns nothing. The rendering was right and the premise was
impossible, which also left the section's real default state untested.

The period is now a fixture the tests set: a two-month window for the rows, and
a week inside a month for the state a reader meets when the portal opens. The
collection hook is mocked and filters nothing, so the empty case says so with an
empty monthly result rather than by narrowing the window alone.

Signed-off-by: Gregory Gogin <grigoriy.gogin@constructor.tech>
@Gregory91G
Gregory91G requested a review from a team as a code owner August 28, 2026 09:30
@Gregory91G Gregory91G self-assigned this Aug 28, 2026
@coderabbitai

coderabbitai Bot commented Aug 28, 2026

Copy link
Copy Markdown

Warning

Review limit reached

Next included review available in 45 minutes.

View limit details

Limit details: You’ve used the included review currently available.

This review ran on the open-source allowance, not this organization's plan, because the pull request author doesn't have an assigned seat. Waiting won't change this — ask an organization admin to assign them a seat, or add seats in Billing if every seat is already assigned, then retry.

Learn how review limits work.

Review configuration:

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 5637cb1f-2c43-4721-9e05-82cabb8efc83

📥 Commits

Reviewing files that changed from the base of the PR and between 50bf0bc and 07383e3.

📒 Files selected for processing (2)
  • src/frontend/src/components/portal/ai-cost-view.test.tsx
  • src/frontend/src/components/portal/ai-cost-view.tsx

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants