Skip to content

feat(webapp): billing limits — pause, reject, recovery, and settings UI#3996

Open
kathiekiwi wants to merge 7 commits into
mainfrom
feature/billing-limits
Open

feat(webapp): billing limits — pause, reject, recovery, and settings UI#3996
kathiekiwi wants to merge 7 commits into
mainfrom
feature/billing-limits

Conversation

@kathiekiwi

@kathiekiwi kathiekiwi commented Jun 19, 2026

Copy link
Copy Markdown
Collaborator

Summary

Adds Billing Limits to the webapp.

Customers can set a monthly spend cap. When usage crosses the limit, billable environments enter a grace period. If the limit is not resolved before grace expires, new triggers are rejected until the organization increases or removes the limit.

The webapp consumes billing-limit state from the billing platform and enforces it across environments, queues, and trigger creation.

Depends on the matching cloud billing PR.

User-facing changes

Billing Limits settings

  • New /settings/billing-limits page replaces the standalone billing-alerts page.

  • Configure:

    • plan limit
    • custom limit
    • no limit
  • Configure billing alerts and notification emails.

  • Resolve active billing limits by increasing or removing the limit.

Org-wide banners

Adds banners for:

  • grace period
  • rejected state
  • billing limits not configured
  • upgrade prompts

Usage page

Shows the configured billing limit on the spend chart.

Enforcement

  • Billable environments are paused when an org enters grace.

  • New triggers are rejected once grace expires.

  • Billing-limit pauses cannot be manually resumed.

  • New environments created during grace/rejected inherit the correct paused state.

  • Recovery supports:

    • resuming queued runs
    • cancelling queued runs and starting fresh
    • optional cancellation of in-progress runs when a limit is reached

Infrastructure

  • Adds billing-limit workers and reconciliation.
  • Adds admin endpoints used by the billing platform.
  • Adds BILLING_LIMIT as an environment pause source.

Test plan

  • Configure limits, alerts, and emails.
  • Verify grace and rejected flows.
  • Verify trigger rejection after grace expiry.
  • Verify recovery flows (queue and new_only).
  • Verify new environments created during grace start paused.
  • Verify billing-limit pauses cannot be manually resumed.
  • Verify billing limit marker on the usage chart.

Notes

  • isConfigured: false means no billing limit has been configured yet.
  • mode: "none" means the customer explicitly opted out.
  • Grace pauses execution but still accepts triggers.
  • Rejected blocks new triggers.

@changeset-bot

changeset-bot Bot commented Jun 19, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 2a89262

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@coderabbitai

coderabbitai Bot commented Jun 19, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: c8e9d511-ede3-4edc-b323-2232e7ea7f5e

📥 Commits

Reviewing files that changed from the base of the PR and between cc28bfd and 2a89262.

📒 Files selected for processing (41)
  • .server-changes/billing-limits.md
  • apps/webapp/app/components/billing/BillingAlertsSection.tsx
  • apps/webapp/app/components/billing/OrgBanner.tsx
  • apps/webapp/app/components/billing/billingAlertsFormat.ts
  • apps/webapp/app/components/billing/selectOrgBanner.ts
  • apps/webapp/app/components/layout/AppLayout.tsx
  • apps/webapp/app/entry.server.tsx
  • apps/webapp/app/hooks/useOrganizations.ts
  • apps/webapp/app/hooks/useScrollContainerToTop.ts
  • apps/webapp/app/routes/_app.orgs.$organizationSlug.projects.$projectParam.env.$envParam.queues/route.tsx
  • apps/webapp/app/routes/_app.orgs.$organizationSlug.settings.billing-limits/route.tsx
  • apps/webapp/app/routes/_app.orgs.$organizationSlug.settings.usage/route.tsx
  • apps/webapp/app/routes/_app.orgs.$organizationSlug/route.tsx
  • apps/webapp/app/routes/admin.api.v1.orgs.$organizationId.billing-limit.hit.ts
  • apps/webapp/app/routes/admin.api.v1.orgs.$organizationId.billing-limit.resolve.ts
  • apps/webapp/app/routes/admin.api.v1.orgs.$organizationId.runs.enable.ts
  • apps/webapp/app/runEngine/validators/validateProductionEntitlement.server.ts
  • apps/webapp/app/services/billingLimit.schemas.ts
  • apps/webapp/app/services/platform.v3.server.ts
  • apps/webapp/app/services/routeBuilders/permissions.server.ts
  • apps/webapp/app/services/upsertBranch.server.ts
  • apps/webapp/app/v3/billingLimitWorker.server.ts
  • apps/webapp/app/v3/services/billingLimit/BillingLimitBulkCancelService.server.ts
  • apps/webapp/app/v3/services/billingLimit/billingLimitConstants.ts
  • apps/webapp/app/v3/services/billingLimit/billingLimitConvergeEnvironments.server.ts
  • apps/webapp/app/v3/services/billingLimit/billingLimitPendingResolveCoordinator.server.ts
  • apps/webapp/app/v3/services/billingLimit/billingLimitResolve.server.ts
  • apps/webapp/app/v3/services/billingLimit/getInitialEnvPauseStateForBillingLimit.server.ts
  • apps/webapp/app/v3/services/billingLimit/manualPauseEnvironmentGuard.server.ts
  • apps/webapp/app/v3/services/billingLimit/runBillingLimitReconcileTick.server.ts
  • apps/webapp/app/v3/services/pauseEnvironment.server.ts
  • apps/webapp/server.ts
  • apps/webapp/test/billingAlertsFormat.test.ts
  • apps/webapp/test/billingLimitBulkCancelInProgress.test.ts
  • apps/webapp/test/billingLimitConvergeEnvironments.test.ts
  • apps/webapp/test/billingLimitConvergeResolve.test.ts
  • apps/webapp/test/billingLimitEnvCreatePause.test.ts
  • apps/webapp/test/billingLimitReconcileTick.test.ts
  • apps/webapp/test/billingLimitResolve.test.ts
  • apps/webapp/test/billingLimitsRoute.test.ts
  • apps/webapp/test/orgBanner.test.ts
✅ Files skipped from review due to trivial changes (2)
  • .server-changes/billing-limits.md
  • apps/webapp/test/orgBanner.test.ts
🚧 Files skipped from review as they are similar to previous changes (39)
  • apps/webapp/app/hooks/useScrollContainerToTop.ts
  • apps/webapp/app/components/billing/selectOrgBanner.ts
  • apps/webapp/app/v3/services/billingLimit/billingLimitPendingResolveCoordinator.server.ts
  • apps/webapp/server.ts
  • apps/webapp/test/billingLimitConvergeResolve.test.ts
  • apps/webapp/app/v3/services/billingLimit/billingLimitResolve.server.ts
  • apps/webapp/app/hooks/useOrganizations.ts
  • apps/webapp/app/routes/admin.api.v1.orgs.$organizationId.billing-limit.hit.ts
  • apps/webapp/app/routes/admin.api.v1.orgs.$organizationId.billing-limit.resolve.ts
  • apps/webapp/test/billingLimitResolve.test.ts
  • apps/webapp/app/v3/services/billingLimit/billingLimitConstants.ts
  • apps/webapp/test/billingLimitReconcileTick.test.ts
  • apps/webapp/test/billingLimitsRoute.test.ts
  • apps/webapp/app/entry.server.tsx
  • apps/webapp/app/v3/services/billingLimit/getInitialEnvPauseStateForBillingLimit.server.ts
  • apps/webapp/app/routes/_app.orgs.$organizationSlug.projects.$projectParam.env.$envParam.queues/route.tsx
  • apps/webapp/app/v3/billingLimitWorker.server.ts
  • apps/webapp/app/services/routeBuilders/permissions.server.ts
  • apps/webapp/test/billingLimitEnvCreatePause.test.ts
  • apps/webapp/app/components/layout/AppLayout.tsx
  • apps/webapp/app/routes/admin.api.v1.orgs.$organizationId.runs.enable.ts
  • apps/webapp/app/routes/_app.orgs.$organizationSlug/route.tsx
  • apps/webapp/app/routes/_app.orgs.$organizationSlug.settings.usage/route.tsx
  • apps/webapp/app/v3/services/billingLimit/manualPauseEnvironmentGuard.server.ts
  • apps/webapp/test/billingLimitConvergeEnvironments.test.ts
  • apps/webapp/app/services/upsertBranch.server.ts
  • apps/webapp/test/billingAlertsFormat.test.ts
  • apps/webapp/app/v3/services/pauseEnvironment.server.ts
  • apps/webapp/app/runEngine/validators/validateProductionEntitlement.server.ts
  • apps/webapp/test/billingLimitBulkCancelInProgress.test.ts
  • apps/webapp/app/v3/services/billingLimit/BillingLimitBulkCancelService.server.ts
  • apps/webapp/app/components/billing/OrgBanner.tsx
  • apps/webapp/app/services/billingLimit.schemas.ts
  • apps/webapp/app/v3/services/billingLimit/runBillingLimitReconcileTick.server.ts
  • apps/webapp/app/v3/services/billingLimit/billingLimitConvergeEnvironments.server.ts
  • apps/webapp/app/services/platform.v3.server.ts
  • apps/webapp/app/components/billing/billingAlertsFormat.ts
  • apps/webapp/app/components/billing/BillingAlertsSection.tsx
  • apps/webapp/app/routes/_app.orgs.$organizationSlug.settings.billing-limits/route.tsx
📜 Recent review details
⏰ Context from checks skipped due to timeout. (25)
  • GitHub Check: internal / 🧪 Unit Tests: Internal (6, 12)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (2, 10)
  • GitHub Check: internal / 🧪 Unit Tests: Internal (1, 12)
  • GitHub Check: internal / 🧪 Unit Tests: Internal (3, 12)
  • GitHub Check: internal / 🧪 Unit Tests: Internal (9, 12)
  • GitHub Check: internal / 🧪 Unit Tests: Internal (11, 12)
  • GitHub Check: internal / 🧪 Unit Tests: Internal (5, 12)
  • GitHub Check: internal / 🧪 Unit Tests: Internal (12, 12)
  • GitHub Check: internal / 🧪 Unit Tests: Internal (7, 12)
  • GitHub Check: internal / 🧪 Unit Tests: Internal (4, 12)
  • GitHub Check: internal / 🧪 Unit Tests: Internal (10, 12)
  • GitHub Check: internal / 🧪 Unit Tests: Internal (8, 12)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (9, 10)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (7, 10)
  • GitHub Check: internal / 🧪 Unit Tests: Internal (2, 12)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (6, 10)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (4, 10)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (8, 10)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (1, 10)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (3, 10)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (5, 10)
  • GitHub Check: webapp / 🧪 Unit Tests: Webapp (10, 10)
  • GitHub Check: typecheck / typecheck
  • GitHub Check: e2e-webapp / 🧪 E2E Tests: Webapp
  • GitHub Check: 🛡️ E2E Auth Tests (full)

Walkthrough

This PR implements a billing limits feature that lets organizations configure a monthly compute spend cap. When the cap is reached, a billing platform webhook triggers a grace period during which billable environments are paused; new task triggers are rejected once the grace period ends. A recovery flow lets users increase or remove the limit and choose to resume queued runs or accept cancellation. A Redis-backed worker periodically reconciles environment pause state against billing platform data. The feature adds a new /settings/billing-limits settings page that consolidates limit configuration, alert thresholds, and the recovery panel, replacing the old /settings/billing-alerts route (which now redirects). The unified OrgBanner component replaces the prior UpgradePrompt and EnvironmentBanner components with a selector-driven switch over all banner states. Environment pause-source tracking now distinguishes billing-limit-enforced pauses from manual pauses, gating pause/resume operations accordingly.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 21.53% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title 'feat(webapp): billing limits — pause, reject, recovery, and settings UI' clearly describes the main feature added: billing limits functionality with pause/reject/recovery mechanisms and UI changes.
Description check ✅ Passed The pull request description comprehensively covers all required sections: summary of changes, user-facing features, enforcement mechanisms, infrastructure additions, test plan, and important implementation notes.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/billing-limits

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

coderabbitai[bot]

This comment was marked as resolved.

Add the EnvironmentPauseSource enum and migration, plus the billing-limit platform client wrappers and schemas.
Configure a spend limit, manage billing alerts, and surface org-wide banners.
Converge billable environments to paused via webhook and a reconciliation worker; block manual resume.
Reject triggers with a 422 once entitlement reports no access, and bust the entitlement cache on state changes.
Recovery UI and durable resolve: cancel queued runs before unpausing, with reconciliation as a safety net.
Optionally cancel in-progress runs on limit hit via a deduplicated bulk-cancel job.
@kathiekiwi kathiekiwi force-pushed the feature/billing-limits branch from 5c1a4bf to ac87dcd Compare June 22, 2026 09:05
@pkg-pr-new

pkg-pr-new Bot commented Jun 22, 2026

Copy link
Copy Markdown

Open in StackBlitz

@trigger.dev/build

npm i https://pkg.pr.new/@trigger.dev/build@ac87dcd

trigger.dev

npm i https://pkg.pr.new/trigger.dev@ac87dcd

@trigger.dev/core

npm i https://pkg.pr.new/@trigger.dev/core@ac87dcd

@trigger.dev/python

npm i https://pkg.pr.new/@trigger.dev/python@ac87dcd

@trigger.dev/react-hooks

npm i https://pkg.pr.new/@trigger.dev/react-hooks@ac87dcd

@trigger.dev/redis-worker

npm i https://pkg.pr.new/@trigger.dev/redis-worker@ac87dcd

@trigger.dev/rsc

npm i https://pkg.pr.new/@trigger.dev/rsc@ac87dcd

@trigger.dev/schema-to-json

npm i https://pkg.pr.new/@trigger.dev/schema-to-json@ac87dcd

@trigger.dev/sdk

npm i https://pkg.pr.new/@trigger.dev/sdk@ac87dcd

commit: ac87dcd

coderabbitai[bot]

This comment was marked as resolved.

@kathiekiwi kathiekiwi force-pushed the feature/billing-limits branch from ac87dcd to 80b0a02 Compare June 22, 2026 09:52
@kathiekiwi kathiekiwi changed the title Billing limits feat(webapp): billing limits — pause, reject, recovery, and settings UI Jun 22, 2026
devin-ai-integration[bot]

This comment was marked as resolved.

@kathiekiwi kathiekiwi force-pushed the feature/billing-limits branch from 80b0a02 to 18bce2f Compare June 22, 2026 16:12
devin-ai-integration[bot]

This comment was marked as resolved.

@kathiekiwi kathiekiwi force-pushed the feature/billing-limits branch from 18bce2f to c338591 Compare June 22, 2026 19:17
devin-ai-integration[bot]

This comment was marked as resolved.

@kathiekiwi kathiekiwi force-pushed the feature/billing-limits branch from c338591 to 31b6df9 Compare June 22, 2026 20:13
devin-ai-integration[bot]

This comment was marked as resolved.

@kathiekiwi kathiekiwi force-pushed the feature/billing-limits branch from 31b6df9 to 3200c8a Compare June 22, 2026 22:06
devin-ai-integration[bot]

This comment was marked as resolved.

@kathiekiwi kathiekiwi force-pushed the feature/billing-limits branch from 3200c8a to 7763a7a Compare June 22, 2026 22:56
coderabbitai[bot]

This comment was marked as resolved.

devin-ai-integration[bot]

This comment was marked as resolved.

@kathiekiwi kathiekiwi force-pushed the feature/billing-limits branch from 7763a7a to 6d9aa23 Compare June 23, 2026 08:27
devin-ai-integration[bot]

This comment was marked as resolved.

@kathiekiwi kathiekiwi force-pushed the feature/billing-limits branch from 6d9aa23 to cc28bfd Compare June 23, 2026 16:28
@kathiekiwi kathiekiwi marked this pull request as ready for review June 23, 2026 16:28

@devin-ai-integration devin-ai-integration Bot 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.

Devin Review found 1 new potential issue.

Open in Devin Review

Comment thread apps/webapp/app/routes/_app.orgs.$organizationSlug/route.tsx
… tests

Add the usage-bar marker, documentation, and test coverage.
@kathiekiwi kathiekiwi force-pushed the feature/billing-limits branch from cc28bfd to 2a89262 Compare June 23, 2026 17:50
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