[4/n] Add billing cycle usage section scaffold to v2 page#11119
[4/n] Add billing cycle usage section scaffold to v2 page#11119IsaiahWitzke wants to merge 8 commits into
Conversation
61b51c6 to
6a51a86
Compare
e8498f7 to
508b382
Compare
9c8027b to
622b73d
Compare
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>
189c294 to
34be7a8
Compare
|
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 Powered by Oz |
There was a problem hiding this comment.
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
- 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>
|
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 Powered by Oz |
There was a problem hiding this comment.
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
| .with_vertical_padding(40.) | ||
| .with_uniform_padding(16.) |
There was a problem hiding this comment.
💡 [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.
| .with_vertical_padding(40.) | |
| .with_uniform_padding(16.) | |
| .with_uniform_padding(16.) | |
| .with_vertical_padding(40.) |
| .with_vertical_padding(40.) | ||
| .with_uniform_padding(16.) |
There was a problem hiding this comment.
💡 [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.
| .with_vertical_padding(40.) | |
| .with_uniform_padding(16.) | |
| .with_uniform_padding(16.) | |
| .with_vertical_padding(40.) |
adds a usage section (with legend that depends on the types of usage COST_TYPEs that the gql api returns)
enterprise users can see stuff here
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... 🤷 )