Skip to content

feat(platform): settings permissions, admin, billing attribution#5545

Merged
icecrasher321 merged 16 commits into
stagingfrom
fix/invite-bug
Jul 13, 2026
Merged

feat(platform): settings permissions, admin, billing attribution#5545
icecrasher321 merged 16 commits into
stagingfrom
fix/invite-bug

Conversation

@icecrasher321

@icecrasher321 icecrasher321 commented Jul 9, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Split account, organization, and workspace settings (did not change UI organization for now)
  • Fixed workspace-scoped billing and entitlements.
  • Hardened invites, memberships, and external access.
  • Added durable storage and execution accounting.
  • Introduced backward-compatible Copilot billing attribution.

Type of Change

  • Bug fix

Testing

N/A

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)

Keep organization activation server-owned so failed membership checks cannot clear a valid session context.
@vercel

vercel Bot commented Jul 9, 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 13, 2026 7:48am

Request Review

@cursor

cursor Bot commented Jul 9, 2026

Copy link
Copy Markdown

PR Summary

High Risk
Changes payment routing, admission, and settlement across copilot validate/update-cost, unified billing, and execution paths—incorrect attribution or org gates could mis-bill or block usage; large surface area with extensive tests but production billing impact is critical.

Overview
Introduces account settings as a first-class route (/account/settings with shell, section pages, and personal credit usage) and tightens who can see or change billing: unified GET /api/billing separates personal vs organization payers, requires org admin for team billing, exposes subscription state (active/free/lapsed), payer block flags, and upgrade workspace hints; plan switches can be scoped to a workspace payer with billing-admin checks.

Copilot and hosted usage move to versioned billing protocols on validate/update-cost (legacy markerless Go, explicit legacy-v0, attribution-v1, direct-v1), routing charges to the workspace organization payer with member-cap checks, immutable attribution envelopes where required, payer-level overage settlement, and retryable 503s on threshold failures. Chat, guardrails, and execution paths pass billing attribution and avoid charging on preprocess/upload failures (skipCost). The standalone member-credits API is removed in favor of attributed limits.

Session and org context: upgrade recovery only auto-sets active org when there is exactly one membership; intentional “no active organization” and external-only users are not forced into an org. Audit log list/export validate access against organizationId in the query. Storage quotas use workspace billing context; mothership chat attachments stay quota-exempt. Invitations accept forwards actor/provenance into core acceptance (audit handling adjusted). Docs and resume UI copy reflect workspace payer billing, org billing authority, and automatic resume waiting reasons.

Reviewed by Cursor Bugbot for commit e598c51. Configure here.

@greptile-apps

greptile-apps Bot commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR keeps invite acceptance from changing the active organization on the client. The main changes are:

  • Removed the client-side organization.setActive call after invite acceptance.
  • Left query invalidation and redirect handling in the invite accept flow.
  • Added a jsdom regression test for external workspace invites.

Confidence Score: 4/5

The changed flow looks mergeable after checking the external workspace redirect context.

  • Server-owned activation still covers organization-joining invite paths.
  • External workspace invites now preserve the previous active organization.
  • The redirect can still depend on workspace pages not using stale session organization state.

apps/sim/app/invite/[id]/invite.tsx

Important Files Changed

Filename Overview
apps/sim/app/invite/[id]/invite.tsx Removes client-owned organization activation after accepting an invite.
apps/sim/app/invite/[id]/invite.test.tsx Adds a regression test that asserts external workspace invites do not call client-side organization activation.

Reviews (1): Last reviewed commit: "fix(invites): preserve active organizati..." | Re-trigger Greptile

Comment thread apps/sim/app/invite/[id]/invite.tsx
Remove locally generated migrations so they can be regenerated against the latest staging schema without preserving stale snapshots or numbering.
Resolve storage, webhook, Jupyter, workspace-layout, and API-validation conflicts while preserving both staging updates and billing durability changes.
Remove this branch's generated migrations so they can be regenerated against the latest staging schema with fresh numbering.
Resolve mothership executor, upload-test mocks, and regenerate tool schemas from the copilot staging catalog.
@icecrasher321 icecrasher321 changed the title fix(invites): preserve active organization for external access feat(platform): settings permissions, admin, billing attribution Jul 11, 2026
@icecrasher321

Copy link
Copy Markdown
Collaborator Author

@greptile

@icecrasher321

Copy link
Copy Markdown
Collaborator Author

bugbot run

@greptile-apps

greptile-apps Bot commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

Too many files changed for review. (522 files found, 500 file limit)

Comment thread apps/sim/app/api/chat/[identifier]/route.ts
Comment thread apps/sim/app/api/billing/switch-plan/route.ts Outdated
@icecrasher321

Copy link
Copy Markdown
Collaborator Author

@greptile

@icecrasher321

Copy link
Copy Markdown
Collaborator Author

bugbot run

Comment thread apps/sim/app/api/billing/update-cost/route.ts
Comment thread apps/sim/lib/billing/core/billing.ts
@icecrasher321

Copy link
Copy Markdown
Collaborator Author

bugbot run

Comment thread apps/sim/app/account/settings/billing/credit-usage/page.tsx
@icecrasher321

Copy link
Copy Markdown
Collaborator Author

bugbot run

Comment thread apps/sim/app/api/billing/update-cost/route.ts
@icecrasher321

Copy link
Copy Markdown
Collaborator Author

bugbot run

Comment thread apps/sim/app/api/guardrails/validate/route.ts Outdated
Comment thread apps/sim/app/api/files/multipart/route.ts
@icecrasher321

Copy link
Copy Markdown
Collaborator Author

bugbot run

@cursor cursor 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.

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit e598c51. Configure here.

@icecrasher321 icecrasher321 merged commit ef7c8e2 into staging Jul 13, 2026
17 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