🌐 US-Proxy
class="logged-out env-production page-responsive" style="word-wrap: break-word;" >
Skip to content

feat(site): polish AI budget members table - #26805

Merged
EhabY merged 9 commits into
mainfrom
feat/ai-budget-members-table-polish
Jul 13, 2026
Merged

feat(site): polish AI budget members table#26805
EhabY merged 9 commits into
mainfrom
feat/ai-budget-members-table-polish

Conversation

@EhabY

@EhabY EhabY commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

Finishing touches for the AI cost control group members table.

  • Spend uses the primary color until 85% of budget (matching the limit color) instead of secondary, via a new AIBudgetAmount component that owns the spend-amount coloring. The severity class maps moved out of utils/budget.ts into the components that use them.
  • The AI budget column tooltip shows the reset date from the current usage period and the group's default limit, when configured (including a $0 default, which means no allowance).
  • An "AI budget period" label next to the tab bar shows the current spend window (e.g. "June 1 - July 1, 2026"). The window is rendered in the viewer's local time, matching the spend page.
  • "Budget type" is renamed to "Budget group", showing a badge for the group (or individual override) currently responsible for the member's spend. Admins can reassign this at any time, so spend history may span multiple sources.
  • A group budget of exactly $0 shows "None" (no spending allowance), distinct from no budget configured ("Unlimited"). A member with no governing group at all also shows "Unlimited", since no budget applies.
  • When another named group governs a member's budget, the cell shows that spend with a "Not attributed to this group" note and names the governing group in a tooltip. It shows a dash instead when the governing group can't be resolved (e.g. it's in another org).
  • "Manage AI budget" is disabled only when a different, named group governs the member's spend, since an override there wouldn't apply. It stays enabled when the org-wide Everyone default governs, since that just means no group budget is set yet.
  • The hand-written UserAISpend type is replaced with the generated UserAISpendStatus, which also fixes limit_source (previously sent as override instead of user_override).
  • The aibridge visibility gates coerce to boolean before feeding react-query's enabled, so unlicensed deployments no longer poll the enterprise spend endpoint.

Skipped for now: the per-group spend breakdown ("Group breakdown" button and popover). The backend contract isn't defined yet, so it'll land in a follow-up.

Closes #26401

@EhabY
EhabY force-pushed the feat/ai-budget-members-table-polish branch from dd18046 to 749d184 Compare July 1, 2026 12:39
@EhabY EhabY changed the title feat(site/src/pages/GroupsPage): polish AI budget members table feat(site): polish AI budget members table Jul 1, 2026
@EhabY
EhabY force-pushed the feat/ai-budget-members-table-polish branch 4 times, most recently from f2d3cfb to a097f7d Compare July 7, 2026 13:12
@EhabY
EhabY marked this pull request as ready for review July 8, 2026 13:56
@EhabY
EhabY requested a review from ssncferreira July 8, 2026 14:31
@EhabY
EhabY force-pushed the feat/ai-budget-members-table-polish branch 3 times, most recently from 3fa59a7 to daabe1b Compare July 8, 2026 21:49
@EhabY
EhabY requested a review from DanielleMaywood July 9, 2026 07:57
Comment thread site/src/utils/budget.ts Outdated
Comment thread site/src/modules/dashboard/Navbar/UserDropdown/UserDropdown.tsx Outdated
Comment thread site/src/pages/GroupsPage/AIBudgetPeriod.tsx Outdated
Comment thread site/src/pages/GroupsPage/GroupMemberBudgetCells.stories.tsx Outdated
Comment thread site/src/pages/GroupsPage/GroupMemberBudgetCells.test.ts Outdated
Comment thread site/src/pages/GroupsPage/GroupMemberBudgetCells.tsx Outdated
Comment thread site/src/pages/GroupsPage/GroupPage.stories.tsx Outdated
Comment thread site/src/pages/GroupsPage/GroupPage.stories.tsx Outdated
Comment thread site/src/pages/GroupsPage/GroupPage.stories.tsx Outdated
@EhabY
EhabY requested a review from DanielleMaywood July 9, 2026 10:56
@EhabY

EhabY commented Jul 9, 2026

Copy link
Copy Markdown
Contributor Author

@ssncferreira quick contract question on the members payload (AIGOV-291): when no budget applies to a member, is effective_group_id null, like /users/me/ai/spend (it only sets a group together with a concrete limit), or do we attribute unbudgeted spend to Everyone with a null limit?

The frontend renders both today, but differently:

  • effective_group_id: null → "Unlimited", no badge
  • Everyone + null limit → "Unlimited" with an "Everyone (not allocated)" badge

If the me-endpoint semantics carry over, the second state can't happen and I'll drop it from the stories.

@EhabY
EhabY force-pushed the feat/ai-budget-members-table-polish branch from 8cc5b28 to b206d9d Compare July 9, 2026 11:21
@linear-code

linear-code Bot commented Jul 9, 2026

Copy link
Copy Markdown

AIGOV-468

@ssncferreira

ssncferreira commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

@ssncferreira quick contract question on the members payload (AIGOV-291): when no budget applies to a member, is effective_group_id null, like /users/me/ai/spend (it only sets a group together with a concrete limit), or do we attribute unbudgeted spend to Everyone with a null limit?

The frontend renders both today, but differently:

  • effective_group_id: null → "Unlimited", no badge
  • Everyone + null limit → "Unlimited" with an "Everyone (not allocated)" badge

If the me-endpoint semantics carry over, the second state can't happen and I'll drop it from the stories.

@EhabY this is related to the discussion around always having an effective group, i.e, defaulting to the Everyone group with an unlimited spend. Linear issue: AIGOV-509. Currently, effective_group_id is still nullable, but once AIGOV-509 lands, it will no longer be nullable, and only the Everyone group can have unlimited spend.

EhabY added 7 commits July 13, 2026 14:24
Emphasize spend in the primary color until it nears the limit, add the
reset date to the AI budget column tooltip (derived from the monthly
AIBudgetPeriod rather than the unrelated chat usage-limit subsystem,
and noted as rendering in local time), rename Budget type to Budget
Source with a new tooltip, and show a dash in both columns when
another group governs the member's budget.
Show the AI budget period on the group members tab, derive the reset
date from the spend period, badge the budget source, and disable the
override action when a member's budget is governed by another group.

Escape the empty-cell dash placeholder so it doesn't trip
make lint/emdash.
Render each member's AI spend against the viewed group, or
unlimited/not-attributed when another group governs the budget, plus
the governing budget group. Rename the limit_source override value
from "override" to "user_override", clarify the governance tooltips
to state plainly what's governing the budget, distinguish a group
budget of exactly $0 from no budget configured (unlimited), and stop
showing a dollar figure for spend governed by a group the viewer can't
resolve.

Adds per-state Storybook coverage, including an AIBudgetShowcase story
covering every AI budget state in one table, and shares the spend
severity color with AIBudgetUsage.
…e-governed members

The dropdown disabled "Manage AI budget" whenever another group governed
a member's spend, including the org-wide Everyone default. Since Everyone
means the budget is simply unset, that blocked setting up a first override
for any group without its own configured budget.

Also dedupe the aibridge-visibility gate into a shared useAIBudgetVisible
hook, fix a flash of the "unresolvable group" fallback while the governing
group's name is still loading, and inline a couple of single-use locals.
…le-use AI spend hook

useAISpend was only consumed by UserDropdown, so fold it into a plain
toAISpend helper there instead of a dedicated hook module, and add a
test covering its visibility and severity branching.
…bility check

useAIBudgetVisible bundled a feature/experiment check together with a
useQuery call. Since the experiment gate is temporary (AIGOV-443), just
inline the check and call useQuery directly in each of its two
consumers instead of maintaining a shared hook for it.
Derive notAttributed by composing isBudgetFromOtherGroup instead of
reimplementing its comparisons, flatten a nested ternary for the
budget group badge label, and inline a single-use class name in
AIBudgetUsage.

Also drop comments that just restated the story's exported name, its
play()/step() assertions, or the line directly below them, keeping
only the ones that explain non-obvious behavior.
@EhabY
EhabY force-pushed the feat/ai-budget-members-table-polish branch from b206d9d to bf11493 Compare July 13, 2026 11:24

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

LGTM 👍 just a few notes regarding consistency mainly around the budget period and period reset

Comment thread site/src/pages/GroupsPage/AIBudgetPeriod.tsx Outdated
Comment thread site/src/pages/GroupsPage/GroupMemberBudgetCells.stories.tsx
Comment thread site/src/pages/GroupsPage/GroupMemberBudgetCells.tsx Outdated
Comment thread site/src/pages/GroupsPage/GroupMemberBudgetCells.stories.tsx
@EhabY
EhabY force-pushed the feat/ai-budget-members-table-polish branch from 14e8062 to 0136986 Compare July 13, 2026 11:52
Also flattens the member budget cells, unifies the em-dash placeholder,
and trims restating comments.
@EhabY
EhabY force-pushed the feat/ai-budget-members-table-polish branch from 0136986 to 72933cd Compare July 13, 2026 12:21
Comment thread site/src/modules/dashboard/Navbar/UserDropdown/UserDropdown.stories.tsx Outdated
Comment thread site/src/modules/dashboard/Navbar/UserDropdown/UserDropdown.stories.tsx Outdated
Comment thread site/src/modules/dashboard/Navbar/UserDropdown/UserDropdown.tsx Outdated
Comment thread site/src/modules/dashboard/Navbar/UserDropdown/UserDropdown.tsx Outdated
Comment thread site/src/pages/GroupsPage/GroupPage.stories.tsx Outdated
Follow the codebase's spread-based mock pattern instead of factory
helpers, and inline single-use style/border logic at their call sites.
@EhabY
EhabY merged commit d5e5b10 into main Jul 13, 2026
30 of 31 checks passed
@EhabY
EhabY deleted the feat/ai-budget-members-table-polish branch July 13, 2026 14:33
@github-actions github-actions Bot locked and limited conversation to collaborators Jul 13, 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.

Polish small UX items for group AI budget management

3 participants