Skip to content

[4/n] Add billing cycle usage section scaffold to v2 page#11119

Open
IsaiahWitzke wants to merge 8 commits into
iw/billing-dispatcherfrom
iw/billing-cycle-usage-section
Open

[4/n] Add billing cycle usage section scaffold to v2 page#11119
IsaiahWitzke wants to merge 8 commits into
iw/billing-dispatcherfrom
iw/billing-cycle-usage-section

Conversation

@IsaiahWitzke
Copy link
Copy Markdown
Contributor

@IsaiahWitzke IsaiahWitzke commented May 16, 2026

adds a usage section (with legend that depends on the types of usage COST_TYPEs that the gql api returns)

image

enterprise users can see stuff here

image

but enterprise admins are kicked to the admin panel for this info (idea here is that admins will have more ability to set usage limits etc in there... although i guess i should show all the data for them here too just at the end or in a separate CTA... 🤷 )

image

@cla-bot cla-bot Bot added the cla-signed label May 16, 2026
@IsaiahWitzke IsaiahWitzke force-pushed the iw/billing-dispatcher branch from 61b51c6 to 6a51a86 Compare May 16, 2026 23:33
@IsaiahWitzke IsaiahWitzke force-pushed the iw/billing-cycle-usage-section branch 4 times, most recently from e8498f7 to 508b382 Compare May 17, 2026 00:41
@IsaiahWitzke IsaiahWitzke changed the title Add billing cycle usage section scaffold to v2 page [4/n] Add billing cycle usage section scaffold to v2 page May 17, 2026
@IsaiahWitzke IsaiahWitzke force-pushed the iw/billing-dispatcher branch from 9c8027b to 622b73d Compare May 17, 2026 01:36
IsaiahWitzke and others added 6 commits May 16, 2026 21:44
Introduces BillingCycleUsageSectionView, a sub-view rendered at the
bottom of the BillingAndUsagePageV2 Overview tab. This PR lands the
surrounding scaffolding only; per-row body rendering for OwnOnly /
TeamAggregate / PerUserTotals lands in a follow-up.

What's in this PR:
* Header row with 'Usage' title plus a 'Resets <date>' / period range
  on the right and a refresh icon that triggers
  TeamUpdateManager::refresh_workspace_metadata.
* Period selector dropdown, only rendered when the resolved
  visibility's max_prior_cycles allows historical periods AND we have
  at least two summaries to choose from.
* Dynamic legend that surfaces a colored dot for each cost_type
  (BaseLimit / BonusGrant / Payg) actually present in the selected
  period's entries. BaseLimit and BonusGrant reuse the parent's
  existing dot colors; PAYG gets a new dedicated color.
* FullBreakdown viewers (Enterprise admins) see a 'View detailed
  usage in the admin panel' CTA card that calls
  AdminActions::open_admin_panel — Enterprise per-user/per-bucket
  drill-down lives in the web admin panel, not in-product.
* Empty states for 'no billing_cycle_usage at all', 'no summaries
  yet this cycle', and 'no entries in the selected period'. A
  'Usage rows coming soon' placeholder stands in for the row body
  that the follow-up PR fills in.
* Drops the #[allow(dead_code)] on resolve_usage_visibility and
  UsageVisibility now that both have a real caller.

Co-Authored-By: Oz <oz-agent@warp.dev>
Without an explicit ConstrainedBox the bare Icon::Refresh SVG has no
intrinsic size, so Flex layout produces an infinite Y origin and the
scene asserts. Wrap the icon in a 16x16 ConstrainedBox to match how
every other icon in the billing & usage page is rendered.

Co-Authored-By: Oz <oz-agent@warp.dev>
Both the Buy credits card and the empty-state in the billing cycle usage
section have a surface_1 background and rounded corners; the only outline
the Buy credits panel had was an internal top-border divider between the
description+denominations row and the price/auto-reload row. Drop it so
the only outlined card on the page is the empty-state placeholder.

Co-Authored-By: Oz <oz-agent@warp.dev>
Same fix as the Refresh icon: SVG icons have no intrinsic size, so wrapping
in ConstrainedBox prevents an infinite-x layout panic in the period selector
when a workspace has multiple billing cycle summaries.

Co-Authored-By: Oz <oz-agent@warp.dev>
Visual / cost-type changes:
- Correct PAYG_CREDITS_DOT_COLOR to #5EB1EF to match admin panel
- Add AMBIENT_CREDITS_DOT_COLOR (#6366f1) for the ambient-only cost type
- Include AmbientBonusGrant in the legend iteration
- Rename legend labels to 'Base', 'Add-ons', 'Pay-as-you-go', 'Ambient-only'
  for consistency with COST_TYPE_LABELS in the admin UI

Plumbing changes:
- Migrate call sites to the new Workspace::resolve_usage_visibility(is_admin)
  method now that the helper lives on Workspace
- Compute is_admin / visibility once in View::render and thread visibility
  down to render_header / render_body instead of recomputing per child

Co-Authored-By: Oz <oz-agent@warp.dev>
@IsaiahWitzke IsaiahWitzke force-pushed the iw/billing-cycle-usage-section branch from 189c294 to 34be7a8 Compare May 17, 2026 01:49
@IsaiahWitzke IsaiahWitzke marked this pull request as ready for review May 17, 2026 01:54
@IsaiahWitzke IsaiahWitzke requested a review from jefflloyd May 17, 2026 01:54
@oz-for-oss
Copy link
Copy Markdown
Contributor

oz-for-oss Bot commented May 17, 2026

@IsaiahWitzke

I'm starting a first review of this pull request.

You can view the conversation on Warp.

I completed the review and no human review was requested for this pull request.

Comment /oz-review on this pull request to retrigger a review (up to 3 times on the same pull request).

Powered by Oz

Copy link
Copy Markdown
Contributor

@oz-for-oss oz-for-oss Bot left a comment

Choose a reason for hiding this comment

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

Overview

This PR adds a billing-cycle usage section scaffold to the v2 billing page, including a period selector, dynamic legend, refresh affordance, and enterprise-admin CTA.

Concerns

  • The selected period can become stale after workspace or billing data changes, causing the new section to render blank labels/legend instead of falling back to the current period.
  • The section-level refresh action only refreshes workspace metadata, but the section also renders AI request usage model data, so the reset label can remain stale after clicking refresh.

Verdict

Found: 0 critical, 2 important, 0 suggestions

Request changes

Comment /oz-review on this pull request to retrigger a review (up to 3 times on the same pull request).

Powered by Oz

@IsaiahWitzke IsaiahWitzke marked this pull request as draft May 17, 2026 02:23
@IsaiahWitzke IsaiahWitzke removed the request for review from jefflloyd May 17, 2026 02:23
IsaiahWitzke and others added 2 commits May 16, 2026 22:47
- Reset selected_period_end when the workspace's billing data no longer
  contains the previously selected period (workspace switch or pruned
  refresh data). New trailing periods (e.g. next billing cycle) are
  preserved.
- Refresh button now also refreshes AIRequestUsageModel so the resets
  label (next_refresh_time_local) stays in sync with workspace metadata.
- Replace std::mem::drop with let _ for the Receiver returned by
  refresh_workspace_metadata.

Co-Authored-By: Oz <oz-agent@warp.dev>
Co-Authored-By: Oz <oz-agent@warp.dev>
@IsaiahWitzke IsaiahWitzke marked this pull request as ready for review May 17, 2026 03:19
@oz-for-oss
Copy link
Copy Markdown
Contributor

oz-for-oss Bot commented May 17, 2026

@IsaiahWitzke

I'm starting a first review of this pull request.

You can view the conversation on Warp.

I completed the review and no human review was requested for this pull request.

Comment /oz-review on this pull request to retrigger a review (up to 3 times on the same pull request).

Powered by Oz

Copy link
Copy Markdown
Contributor

@oz-for-oss oz-for-oss Bot left a comment

Choose a reason for hiding this comment

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

Overview

This PR adds the billing cycle usage section scaffold to the v2 billing page, including period selection, dynamic legend entries, refresh handling, and an enterprise-admin admin-panel CTA. The PR includes screenshots for the user-facing changes, and I did not find security concerns in the changed code.

Concerns

  • Two new card containers set 40px vertical padding and then immediately overwrite it with 16px uniform padding, so the intended vertical spacing is not applied.

Verdict

Found: 0 critical, 0 important, 2 suggestions

Approve with nits

Comment /oz-review on this pull request to retrigger a review (up to 3 times on the same pull request).

Powered by Oz

Comment on lines +545 to +546
.with_vertical_padding(40.)
.with_uniform_padding(16.)
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.

💡 [SUGGESTION] with_uniform_padding(16.) resets all padding after the 40px vertical padding is set, so this CTA loses the intended vertical spacing. Apply the uniform padding first, then override the vertical edges.

Suggested change
.with_vertical_padding(40.)
.with_uniform_padding(16.)
.with_uniform_padding(16.)
.with_vertical_padding(40.)

Comment on lines +584 to +585
.with_vertical_padding(40.)
.with_uniform_padding(16.)
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.

💡 [SUGGESTION] This has the same padding-order issue: the uniform padding call overwrites the 40px vertical padding. Reverse these calls so the empty state keeps the intended height.

Suggested change
.with_vertical_padding(40.)
.with_uniform_padding(16.)
.with_uniform_padding(16.)
.with_vertical_padding(40.)

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant