Skip to content

feat(site/src): map the spend reporting period to selectable days within retention - #29631

Merged
ibetitsmike merged 4 commits into
mainfrom
mike/ai-spend/page-period
Sep 22, 2026
Merged

ibetitsmike merged 4 commits into
mainfrom
mike/ai-spend/page-period

Conversation

@ibetitsmike

@ibetitsmike ibetitsmike commented Sep 20, 2026 •

Copy link
Copy Markdown
Collaborator

Without URL dates the server applies the current budget period narrowed to retention; this PR maps that echoed window (period_start, period_end, retention_start) onto local picker days so the picker shows the applied range, bounds it below by the first whole day within retention, and stays off when less than a day of retention leaves nothing selectable. Exports toBoundary from the picker for that mapping and adds the page's stories.

Why

Usage before the retention cutoff has been purged, so the picker must not offer those days or presets; the cutoff moves, so it is read from each real report rather than computed client side. Because retention is deployment-wide, the page keeps the last reported cutoff while a new report loads. Only the initial load replaces the picker with a skeleton, preserving keyboard focus on later requests.

What to scrutinize

  • appliedWindowToDateRange returns undefined when the first selectable day is after today; SpendPage.period.test.ts covers UTC/local day mapping, a clamped start, and sub-day retention, and pins a positive-offset zone so it cannot pass vacuously on UTC hosts.
  • SpendPage.stories.tsx is new in this split at this layer; the 12-user fixture is generated with Array.from (same values as feat: route and link the User spend page for its viewers #28964's hand-written list).

Validation

pnpm test src/pages/AISettingsPage/SpendPage/SpendPage.period.test.ts src/pages/AISettingsPage/SpendPage/SpendPage.test.tsx, pnpm test:storybook on SpendPage.stories.tsx, repository pre-commit.

Delivery record

Published head 78d974d61f1 passed per-layer integration checks and commit hooks. The composed head d899228f798 passed format, check, full frontend lint, 125 unit tests, and 86 story tests. Pre-push hooks were skipped as requested. See #28964 for audit findings, their disposition, and historical UAT limits. No exact-head live UAT or new independent re-review is claimed.

Stack context

PR 7 of 9. The stack adds a User spend page under Admin settings > AI > User spend: total and per-user AI Gateway spend for one organization over a reporting period, read from GET /api/v2/organizations/{organization}/ai/spend/users (#29129, merged). It is #28964 split into one-concern PRs. Historical UAT covers earlier heads only; live UAT has not been rerun after these review fixes. Bottom to top: DateRangePicker limits, shared dimension badge, API client method, spend table, page view, page container, reporting period, dimension filters, route and navigation (#28964).

Xum prepared this PR on behalf of @ibetitsmike.

@ibetitsmike
ibetitsmike marked this pull request as ready for review September 21, 2026 08:49
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 21, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-09-21T12:02:40.195120Z 4da7608 Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c3a7f21540

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@ibetitsmike
ibetitsmike force-pushed the mike/ai-spend/page-period branch from c3a7f21 to 820f4da Compare September 21, 2026 10:06
@ibetitsmike

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 820f4da363

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@ibetitsmike
ibetitsmike force-pushed the mike/ai-spend/page-period branch from 820f4da to 7ea2a39 Compare September 21, 2026 10:31
@ibetitsmike

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Breezy!

Reviewed commit: 7ea2a3915d

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@ibetitsmike
ibetitsmike force-pushed the mike/ai-spend/page-period branch from 7ea2a39 to 497e104 Compare September 21, 2026 10:51
@ibetitsmike

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 👍

Reviewed commit: 497e104e82

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@ibetitsmike
ibetitsmike force-pushed the mike/ai-spend/page-period branch from 497e104 to e6e988b Compare September 21, 2026 11:13
@ibetitsmike

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. What shall we delve into next?

Reviewed commit: e6e988b44a

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@ibetitsmike
ibetitsmike force-pushed the mike/ai-spend/page-period branch from e6e988b to f85ee87 Compare September 21, 2026 11:27
@ibetitsmike

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Bravo.

Reviewed commit: f85ee878b5

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@ibetitsmike
ibetitsmike force-pushed the mike/ai-spend/page-period branch from f85ee87 to 4da7608 Compare September 21, 2026 11:56
@ibetitsmike

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. You're on a roll.

Reviewed commit: 4da7608979

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@ibetitsmike
ibetitsmike force-pushed the mike/ai-spend/page-period branch from 4da7608 to 79dc59d Compare September 22, 2026 08:43
@ibetitsmike
ibetitsmike force-pushed the mike/ai-spend/page-period branch from 79dc59d to 78d974d Compare September 22, 2026 10:59
@ibetitsmike
ibetitsmike removed this pull request from stack #29634 September 22, 2026 11:13
@ibetitsmike
ibetitsmike force-pushed the mike/ai-spend/page-period branch 4 times, most recently from c45512b to f294bb8 Compare September 22, 2026 12:54
ibetitsmike added a commit that referenced this pull request Sep 22, 2026
… view (#29629)

Adds `SpendPageView`, the presentational page: paywall and not-enabled
states, the organizations loading, error, and empty states, a warning
when the requested organization is unavailable, and the filters row
(`SpendFilters`: organization picker hidden with a single organization,
optional provider, model, and client menus, and the date range picker or
a non-interactive **Current budget period** label when no explicit range
is applied).

## Why

Keeping the view stateless lets its stories cover every page-level state
without network mocks; the container PR above wires the data.

## What to scrutinize

- `SpendFilters` passes `MaxAISpendPeriodDays` and `minDate` to the
picker. This layer shows a skeleton while the report is loading; #29631
separates the initial retention-bound load from subsequent report loads
so the picker stays mounted. The container decides when `dateRange` is
undefined.
- `SpendPageView.stories.tsx` holds only page-level states; table states
moved to the table PR below.

## Validation

`pnpm test:storybook` on `SpendPageView.stories.tsx`, repository
pre-commit.

## Delivery record

Published head `c462e135906` passed per-layer integration checks and
commit hooks. The composed head `d899228f798` passed format, check, full
frontend lint, 125 unit tests, and 86 story tests. Pre-push hooks were
skipped as requested. See #28964 for audit findings, their disposition,
and historical UAT limits. No exact-head live UAT or new independent
re-review is claimed.

## Stack context

PR 5 of 9. The stack adds a **User spend** page under **Admin settings**
> **AI** > **User spend**: total and per-user AI Gateway spend for one
organization over a reporting period, read from `GET
/api/v2/organizations/{organization}/ai/spend/users` (#29129, merged).
It is #28964 split into one-concern PRs. Historical UAT covers earlier
heads only; live UAT has not been rerun after these review fixes. Bottom
to top: DateRangePicker limits, shared dimension badge, API client
method, spend table, page view, page container, reporting period,
dimension filters, route and navigation (#28964).

> Xum prepared this PR on behalf of @ibetitsmike.
@ibetitsmike
ibetitsmike force-pushed the mike/ai-spend/page-period branch from f294bb8 to 951bbe6 Compare September 22, 2026 13:03
Base automatically changed from mike/ai-spend/page to main September 22, 2026 13:11
@ibetitsmike
ibetitsmike force-pushed the mike/ai-spend/page-period branch from 951bbe6 to 539b6c6 Compare September 22, 2026 13:11
@ibetitsmike
ibetitsmike merged commit d532b40 into main Sep 22, 2026
25 of 26 checks passed
@ibetitsmike
ibetitsmike deleted the mike/ai-spend/page-period branch September 22, 2026 13:24
@github-actions github-actions Bot locked and limited conversation to collaborators Sep 22, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants