Skip to content

refactor(frontend): bring back the billing gauge#5091

Merged
jog1t merged 1 commit into
mainfrom
05-21-refactor_frontend_bring_back_the_billing_gauge
May 21, 2026
Merged

refactor(frontend): bring back the billing gauge#5091
jog1t merged 1 commit into
mainfrom
05-21-refactor_frontend_bring_back_the_billing_gauge

Conversation

@jog1t
Copy link
Copy Markdown
Contributor

@jog1t jog1t commented May 21, 2026

Description

Please include a summary of the changes and the related issue. Please also include relevant motivation and context.

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

Please describe the tests that you ran to verify your changes.

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

Copy link
Copy Markdown
Contributor Author

jog1t commented May 21, 2026

Merge activity

  • May 21, 8:51 PM UTC: A user started a stack merge that includes this pull request via Graphite.
  • May 21, 9:11 PM UTC: Graphite rebased this pull request as part of a merge.
  • May 21, 9:11 PM UTC: @jog1t merged this pull request with Graphite.

@claude
Copy link
Copy Markdown
Contributor

claude Bot commented May 21, 2026

PR Review: refactor(frontend): bring back the billing gauge

PR #5091 restores BillingUsageGauge (and BillingPlanBadge) to two navigation surfaces in the frontend:

  1. settings-drawer.tsx — Adds a trailing prop to NavItem and a new NavBillingGauge wrapper component next to the "Billing" nav item.
  2. user-dropdown.tsx — Adds BillingUsageGauge and BillingPlanBadge to the "Billing" dropdown menu item when on a project route.

Findings

Medium — Missing features.billing guard in user-dropdown.tsx

BillingUsageGauge and BillingPlanBadge are rendered when isMatchingProjectRoute is true, but there is no features.billing flag check. The equivalent billing UI in layout.tsx explicitly checks features.billing && matchRoute(...). Neither BillingUsageGauge nor BillingPlanBadge internally guard on the flag, so on OSS/non-billing deployment flavors the billing queries will fire and the components will attempt to render.

Suggested fix:

{isMatchingProjectRoute && features.billing ? (
  <>
    <BillingUsageGauge />
    <BillingPlanBadge />
  </>
) : null}

Per project conventions (frontend/src/lib/features.ts): consume flags via import { features } from "@/lib/features", never read VITE_FEATURE_FLAGS directly.

Low — NavBillingGauge in settings-drawer.tsx also lacks a features.billing guard

Same issue at lower severity — BillingUsageGauge will return null visually when usage is below the 80% threshold, but the queries still fire. If billing endpoints don't exist in non-billing deployments this could produce 404s in the background.

Info — Dead code in goToBilling (pre-existing)

Both branches of the if (isMatchingProjectRoute) / else in goToBilling call the identical navigate(...). Since the Billing menu item is only rendered when isMatchingProjectRoute is true, the else branch is unreachable. Not introduced by this PR but worth noting.

Info — No test/story for NavBillingGauge's null-loaderData guard

The NavBillingGauge component has a non-obvious contract: it guards against mid-transition null loaderData to prevent crashes. This follows the established pattern for NamespaceSettingsTitle etc., which is good — but a Ladle story simulating the null-loaderData transition state would make this guard contract explicit.


Summary

Severity Issue
Medium user-dropdown.tsx renders billing components without features.billing guard
Low settings-drawer.tsx NavBillingGauge also lacks features.billing guard
Info Dead code in goToBilling (pre-existing)
Info No Ladle story for the null-loaderData guard in NavBillingGauge

The routing-guard pattern in NavBillingGauge is consistent with existing code. The main actionable item is adding the features.billing check before rendering billing components in both files.

@jog1t jog1t changed the base branch from 05-21-fix_frontend_remove_create_actor_from_context_switcher to graphite-base/5091 May 21, 2026 21:08
@jog1t jog1t changed the base branch from graphite-base/5091 to main May 21, 2026 21:09
@jog1t jog1t force-pushed the 05-21-refactor_frontend_bring_back_the_billing_gauge branch from 844737f to 3a89690 Compare May 21, 2026 21:10
@jog1t jog1t merged commit 1cad778 into main May 21, 2026
8 of 11 checks passed
@jog1t jog1t deleted the 05-21-refactor_frontend_bring_back_the_billing_gauge branch May 21, 2026 21:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant