Skip to content

improvement(billing): ux around on demand toggling and one-off credits#5307

Merged
icecrasher321 merged 108 commits into
stagingfrom
moab
Jul 1, 2026
Merged

improvement(billing): ux around on demand toggling and one-off credits#5307
icecrasher321 merged 108 commits into
stagingfrom
moab

Conversation

@icecrasher321

Copy link
Copy Markdown
Collaborator

Summary

Minor changes to demand toggling ux to not give odd errors.

Type of Change

  • Other: UX Improvement

Testing

Tested manually

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

waleedlatif1 and others added 30 commits April 3, 2026 23:30
…ership workflow edits via sockets, ui improvements
…ration, signup method feature flags, SSO improvements
* feat(posthog): Add tracking on mothership abort (#4023)

Co-authored-by: Theodore Li <theo@sim.ai>

* fix(login): fix captcha headers for manual login  (#4025)

* fix(signup): fix turnstile key loading

* fix(login): fix captcha header passing

* Catch user already exists, remove login form captcha
…nts, secrets performance, polling refactors, drag resources in mothership
…endar triggers, docs updates, integrations/models pages improvements
…mat, logs performance improvements

fix(csp): add missing analytics domains, remove unsafe-eval, fix workspace CSP gap (#4179)
fix(landing): return 404 for invalid dynamic route slugs (#4182)
improvement(seo): optimize sitemaps, robots.txt, and core web vitals across sim and docs (#4170)
fix(gemini): support structured output with tools on Gemini 3 models (#4184)
feat(brightdata): add Bright Data integration with 8 tools (#4183)
fix(mothership): fix superagent credentials (#4185)
fix(logs): close sidebar when selected log disappears from filtered list; cleanup (#4186)
v0.6.46: mothership streaming fixes, brightdata integration
waleedlatif1 and others added 18 commits June 10, 2026 13:20
…ration, smooth streaming, security hardening, db fixes
…x, db migrations from ci, docs updates, read replicas

v0.7.3: jira oauth scope fix, read-replica client, table wire data fix, db migrations from ci, docs updates, read replicas
…uting, trigger.dev, temporal, latex, quartr, brex, convex integrations
…richment providers, deepseek models, db performance
…nce, file sharing, scheduled tasks granularity
…t harness, sakana fugu provider

v0.7.13: pii redaction, react query frontend refactor, pi coding agent harness, sakana fugu provider
…ix, settings overhaul, thrive learning integration
…extension, workspace forking, slack trigger extension, new README
@vercel

vercel Bot commented Jul 1, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
docs Skipped Skipped Jul 1, 2026 1:59am

Request Review

@cursor

cursor Bot commented Jul 1, 2026

Copy link
Copy Markdown

PR Summary

Medium Risk
Changes how usage limits are computed when toggling on-demand and what users see for remaining credits; logic is well-tested but affects billing caps and display across org and personal paths.

Overview
Fixes billing UX bugs where goodwill credits were double-counted in the home credits chip and where a credit grant alone could make on-demand look enabled in settings.

Adds shared helpers in lib/billing/on-demand.ts (getPooledCreditsRemaining, getCoveredUsage, getIsOnDemandActive, getOnDemandOffLimit) so the chip and billing settings use the same rules as usage enforcement: remaining is limit - usage (credits already in the limit), on-demand is on only when the limit exceeds plan + credit balance, and turning off on-demand sets the limit to the covered ceiling without dropping below current usage—removing the prior toast that blocked disable when usage was above plan included only.

Vitest coverage documents the double-count and credit-grant regression cases.

Reviewed by Cursor Bugbot for commit c360daa. Configure here.

@greptile-apps

greptile-apps Bot commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR improves the billing UI around on-demand usage and credit display. The main changes are:

  • Shared billing math helpers for on-demand and pooled credits.
  • A disabled billing switch with tooltip copy when usage is above the covered amount.
  • Updated credits chip remaining-balance calculation.
  • Unit tests for the new helper behavior.

Confidence Score: 5/5

This looks safe to merge.

  • No blocking issues found in the changed code.

Important Files Changed

Filename Overview
apps/sim/app/workspace/[workspaceId]/settings/components/billing/billing.tsx Updates the on-demand toggle to use shared helper logic and show an explanatory tooltip when turn-off is unavailable.
apps/sim/app/workspace/[workspaceId]/home/components/credits-chip/credits-chip.tsx Uses the shared pooled-credit helper for the chip's remaining balance display.
apps/sim/lib/billing/on-demand.ts Adds shared helper functions for on-demand state, covered usage, off-limit calculation, and pooled remaining credits.
apps/sim/lib/billing/on-demand.test.ts Adds unit coverage for the new billing helper functions and edge cases.

Reviews (2): Last reviewed commit: "minor ux improvement" | Re-trigger Greptile

@icecrasher321

Copy link
Copy Markdown
Collaborator Author

@greptile

@icecrasher321 icecrasher321 merged commit 5055b31 into staging Jul 1, 2026
15 checks passed
@icecrasher321 icecrasher321 deleted the moab branch July 1, 2026 02:08
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.

4 participants