Skip to content

improvement(billing): wire up billing, org, teammates tabs + remove deprecated subscription tab#4887

Merged
icecrasher321 merged 6 commits into
improvement/platformfrom
improvement/billing-ux-wire
Jun 4, 2026
Merged

improvement(billing): wire up billing, org, teammates tabs + remove deprecated subscription tab#4887
icecrasher321 merged 6 commits into
improvement/platformfrom
improvement/billing-ux-wire

Conversation

@icecrasher321
Copy link
Copy Markdown
Collaborator

Summary

Wire up billing, org, teammates tabs in settings with new ui/ux

Type of Change

  • Other: UX

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)

@vercel
Copy link
Copy Markdown

vercel Bot commented Jun 4, 2026

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

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
docs Skipped Skipped Jun 4, 2026 9:55pm

Request Review

@cursor
Copy link
Copy Markdown

cursor Bot commented Jun 4, 2026

PR Summary

Medium Risk
New billing invoices API and expanded org billing UI touch payment data and permissions; raising API route maxDuration increases resource exposure on long media jobs but matches existing execution limits.

Overview
Replaces the Subscription settings tab with a full Billing experience and redirects legacy subscription URLs to billing across settings, inbox, usage-limit CTAs, and team upgrade flows.

The Billing page now consolidates plan summary, org-aware usage limits, on-demand toggles, 80% usage email notifications, Stripe portal / cancel / restore, and invoice history backed by a new GET /api/billing/invoices route (user or org context, admin-gated for orgs, empty list when Stripe is absent). UsageLimitField takes props for user vs org saves and read-only non-admins, with a ref guard so on-demand toggles are not overwritten by stale debounced saves.

Long-running media tool routes (image, video, STT, Textract) raise maxDuration to 5400s and align polling with getMaxExecutionTimeout() instead of the default execution cap.

Organization / teammates UX drops the old table roster and inline invite card in favor of shared MemberRow / MemberSection chrome, OrganizationMemberLists (searchable org + per-workspace sections), and OrganizationInviteModal. Team seats use settings-section layout with clearer team vs enterprise seat display. The large Subscription UI (plan cards, credit purchase, modals) is removed; upgrade paths point at Billing / Explore plans.

Reviewed by Cursor Bugbot for commit 2c638dc. Configure here.

Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 2c638dc. Configure here.

Comment thread apps/sim/app/api/billing/invoices/route.ts Outdated
@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented Jun 4, 2026

Greptile Summary

This PR wires up the Billing, Organization, and Teammates settings tabs with real data and new UI, and removes the deprecated Subscription tab (redirecting legacy /subscription URLs to /billing).

  • Billing tab: Now fetches live Stripe invoices via a new /api/billing/invoices endpoint, supports on-demand usage toggling, cancel/restore subscription, and Stripe portal navigation — all with correct org-admin permission gating.
  • Organization tab: Replaces the old inline invite card + roster with OrganizationInviteModal (defaults to write role) and OrganizationMemberLists (per-workspace sections, search, inline role editing); seat counting is split into accepted-member vs. pending-invite counts.
  • Tools execution: Propagates executionContext.abortSignal as a fallback through the entire tool fetch chain so plan-level timeouts and cancellations are honored when no explicit signal is passed.

Confidence Score: 4/5

Safe to merge after fixing the missing disabled guard on the "View all in Stripe" button — a one-line change.

The billing tab expansion is well-structured and permission checks are applied consistently across every control — except the "View all in Stripe" overflow button, which omits the !canManageBilling guard that every other portal-access control in the same file carries. A non-admin team member who has more than 12 invoices will see an active-looking button and get an error toast on click. Everything else — the new invoices API route, org invite modal, member lists, seat-count split, and abort-signal propagation — looks correct.

apps/sim/app/workspace/[workspaceId]/settings/components/billing/billing.tsx — the "View all in Stripe" button at line 624.

Important Files Changed

Filename Overview
apps/sim/app/workspace/[workspaceId]/settings/components/billing/billing.tsx Major expansion: wires up real invoice fetching, on-demand toggle, cancel/restore, and Stripe portal — "View all in Stripe" button lacks the !canManageBilling disabled guard that all other portal-access controls have.
apps/sim/app/api/billing/invoices/route.ts New GET endpoint that lists finalized Stripe invoices; correctly requires auth, enforces org-admin check for org-scoped context, and returns empty list when Stripe is unconfigured.
apps/sim/app/workspace/[workspaceId]/settings/components/team-management/team-management.tsx Replaces inline invite/roster components with OrganizationInviteModal + OrganizationMemberLists; seat counting now uses accepted-member count separately from reserved-seat count.
apps/sim/app/workspace/[workspaceId]/settings/components/team-management/components/organization-member-lists/organization-member-lists.tsx New component: renders org roster with per-workspace sections, search filtering, and inline role/permission dropdowns; well-structured.
apps/sim/app/workspace/[workspaceId]/settings/components/team-management/components/organization-invite-modal/organization-invite-modal.tsx New invite modal with email input, workspace multi-select, and role picker; defaults to 'write' role (safer than the previous 'admin' default).
apps/sim/app/workspace/[workspaceId]/settings/components/member-list/member-list.tsx New shared MemberRow/MemberSection/MemberAvatar primitives extracted for reuse across Teammates and Organization pages.
apps/sim/tools/index.ts Propagates executionContext.abortSignal as fallback through the entire tool execution chain (direct, retried, and reacquired paths), ensuring cancellation signals reach tool fetches.
apps/sim/app/workspace/[workspaceId]/settings/[section]/settings.tsx Removes deprecated Subscription section; adds normalizedSection redirect so legacy /subscription URLs are redirected to /billing.
apps/sim/hooks/queries/subscription.ts Adds useInvoices hook with proper query-key structure, 5-minute stale time, and enabled guard for org context requiring organizationId.
apps/sim/lib/api/contracts/subscription.ts Adds Zod schemas and route contract for the new invoices endpoint; types are exported correctly.

Sequence Diagram

sequenceDiagram
    participant UI as Billing UI
    participant IQ as useInvoices hook
    participant IR as /api/billing/invoices
    participant Stripe as Stripe API
    participant BP as /api/billing/portal

    UI->>IQ: fetch invoices (context, orgId)
    IQ->>IR: "GET /api/billing/invoices?context=..."
    IR->>IR: auth + org-admin check
    IR->>Stripe: "invoices.list(customerId, limit=12)"
    Stripe-->>IR: invoice list + hasMore
    IR-->>IQ: "{ invoices, hasMore }"
    IQ-->>UI: render invoice rows

    alt "hasMore && canManageBilling"
        UI->>BP: POST /api/billing/portal
        BP->>Stripe: billingPortal.sessions.create
        Stripe-->>BP: "{ url }"
        BP-->>UI: redirect to Stripe portal
    end
Loading

Reviews (2): Last reviewed commit: "address comments" | Re-trigger Greptile

@icecrasher321
Copy link
Copy Markdown
Collaborator Author

@greptile

@icecrasher321 icecrasher321 merged commit 7c455ce into improvement/platform Jun 4, 2026
3 checks passed
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