Skip to content

feat(factories): show hosted credit warning banner on the workspace board - #7242

Merged
mytmlt merged 6 commits into
mainfrom
feat/board-hosted-credit-warning-banner
Sep 9, 2026
Merged

mytmlt merged 6 commits into
mainfrom
feat/board-hosted-credit-warning-banner

Conversation

@superplanehq-integration

@superplanehq-integration superplanehq-integration Bot commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

SUPER-148

This change adds a hosted credit warning banner to the workspace board (the Lines / board view). The banner tells the user when the organization is out of hosted credit or is close to running out. It reuses and extends the existing HostedCreditEmptyBanner component instead of adding a new one.

UI

HostedCreditEmptyBanner now takes a level prop with two values. empty means remaining hosted credit is $0 or less. low means remaining hosted credit is above $0 and at or below $20 (2000 cents). The empty level uses red, severe styling. The low level uses amber, warning styling.

The banner action button now supports two shapes. When the caller passes spendingHref, the button is a link to Organization Spending, same as before. When the caller passes onGoToBilling instead, the button reads "Go to billing" and calls that handler. There is no billing page yet, so this button is a no-op for now.

web_src/src/pages/factories/lib/hostedCreditEmpty.ts has a new hostedCreditWarningLevel function. It reads remainingCreditCents, grantTotalCents, superplaneGrantCents, purchasedCreditCents, and billingEnabled, and returns "empty", "low", or null. It returns null when remaining credit is comfortably above the low-credit threshold, and also when the organization never had hosted credit (no grant, no purchase, billing off), so the banner does not warn about credit that was never expected to run out. shouldShowHostedCreditEmptyBanner stays in place as a boolean wrapper around this function, so it keeps working for any other caller.

web_src/src/pages/factories/lib/useHostedCreditEmptyBanner.tsx gets a new options argument with an action field. action: "spending" is the default and keeps the current behavior on the Tasks and Missions pages: the button links to Organization Spending. action: "billing" renders the new no-op "Go to billing" button. This keeps the Tasks and Missions pages working exactly as before, while the board opts into the new button.

web_src/src/pages/factories/pages/LinesPage.tsx calls the hook with action: "billing" and renders the banner above LineDetailHeader, at the top of the board. When remaining hosted credit is above $20, no banner shows. When it is $0 or less, a red banner shows. When it is between $0 and $20, an amber banner shows.

Tests and Storybook

Unit tests in hostedCreditEmpty.spec.ts and HostedCreditEmptyBanner.spec.tsx cover both warning levels, the boundary at $20, the red/amber styles, and the no-op billing button. A new integration test, LinesPage.hostedCreditBanner.spec.tsx, checks that the board shows no banner, a red banner, or an amber banner, based on the organization's remaining hosted credit. Storybook stories for HostedCreditEmptyBanner and for the Lines board cover the low-credit state and the board's billing button variant.

API, workers, database

No changes. This task only adds UI logic that reads the existing organization workspace usage data.


Created via SuperPlane.

RetriggerView in Greptile

The PR appears safe to merge.

superplaneagent and others added 2 commits September 7, 2026 16:04
Extend the banner and its lib/hostedCreditEmpty helpers to support a
new 'low' warning level in addition to the existing 'empty' one:

- 'empty' (remaining hosted credit <= $0): severe red styling.
- 'low' (0 < remaining <= $20 / 2000 cents): amber warning styling.

hostedCreditWarningLevel() replaces the old boolean-only threshold
check and now also triggers for the low-credit range.
shouldShowHostedCreditEmptyBanner() stays as a boolean wrapper around
it for compatibility.

The banner's action button now supports two shapes: a link to
Organization Spending (existing Work Orders / Missions behavior,
unchanged) or a plain 'Go to billing' button that takes an onClick
(no navigation wired yet — there is no billing page).

Signed-off-by: SuperPlane Agent <superplaneagent@superplane.com>
Co-authored-by: Miyat Miletic <mijat.miletic98@gmail.com>
…oard

Render the hosted credit warning banner (empty/low) at the top of the
workspace board (LinesPage), above the line header, using a new
'billing' action variant of useHostedCreditEmptyBanner: the button
does not link to Organization Spending like Tasks/Missions do, since
there is no billing page yet — it is a no-op 'Go to billing' button.

Add a LOW_CREDIT_USAGE_REPORT fixture and cover the empty/low/none
states with an integration spec and Storybook stories.

Signed-off-by: SuperPlane Agent <superplaneagent@superplane.com>
Co-authored-by: Miyat Miletic <mijat.miletic98@gmail.com>

@greptile-apps greptile-apps 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.

superplanehq-integration[bot] has reached the 50-credit limit for trial accounts. To continue receiving code reviews, upgrade your plan.

@superplanehq-integration

Copy link
Copy Markdown
Contributor Author

👋 Commands for maintainers:

  • /sp start - Start an ephemeral machine (takes ~30s)
  • /sp stop - Stop a running machine (auto-executed on pr close)

@superplanehq-integration

Copy link
Copy Markdown
Contributor Author

Maintainers: comment /deploy-storybook to get a Storybook link for this PR.

@mytmlt mytmlt self-assigned this Sep 8, 2026
Comment thread web_src/src/pages/factories/HostedCreditEmptyBanner.stories.tsx Outdated
superplaneagent and others added 2 commits September 8, 2026 06:54
Implement the BoardGoToBillingButton story onGoToBilling callback with
console logging so the interaction is observable in Storybook, matching
the project convention of logging interactive story callbacks.

Signed-off-by: SuperPlane Agent <superplaneagent@superplane.com>
Signed-off-by: Mijat Miletic <mijat.miletic98@gmail.com>
Co-authored-by: Cursor Agent <cursoragent@cursor.com>
Co-authored-by: Miyat Miletic <mytmlt@users.noreply.github.com>
@mytmlt
mytmlt merged commit a9fc9d2 into main Sep 9, 2026
5 of 6 checks passed
@mytmlt
mytmlt deleted the feat/board-hosted-credit-warning-banner branch September 9, 2026 11:30
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.

2 participants