Skip to content

Switch workspace and preselect the fitting plan on the trial wall - #1475

Merged
helpcodeai merged 11 commits into
mainfrom
helpcodeai/subscription-multi-workspace
Nov 3, 2026
Merged

helpcodeai merged 11 commits into
mainfrom
helpcodeai/subscription-multi-workspace

Conversation

@helpcodeai

Copy link
Copy Markdown
Contributor

Summary

Three problems on the Cloud trial-ended wall for people with more than one workspace.

No way to switch workspace. The wall covers the whole app, and the sidebar's workspace switcher sits behind it. Someone whose second workspace's trial ended could not get back to their paid one.

Wrong plan preselected. Starter was always preselected, even for a workspace already past Starter's limits.

Wrong user count. GET /api/license/usage counted users by User.organizationId, i.e. the user's primary workspace. Members invited from another workspace were left out, and deactivated members were counted.

The Stripe side (a second workspace sent to the first one's billing portal) is fixed on the site: HelpCode-ai/anythingmcp-website#488.

Changes

  • Workspace switch (license-wall.tsx): with more than one workspace, the wall names the current workspace and lists the others under "Switch to another workspace". It is shown for every role and uses the existing switchOrg.
  • Plan preselection (card-trial.ts, plan-picker.tsx, license-wall.tsx):
    • CloudPlan.limits gives Starter 5 connectors / 3 MCP servers / 1 user and Team 15 / 10 / 3.
    • New helpers: limitsExceeded, smallestFittingPlan, selectionForUsage, describeUsage.
    • The wall reads /api/license/usage and preselects the smallest plan that fits, Team when nothing does. It keeps the billing period, and a plan the admin clicks is never moved afterwards.
    • Under a plan the workspace has outgrown, the picker says "This workspace has 7 connectors, 2 users". Past Team, the Enterprise line says so.
  • User count (license-guard.service.ts): getUsage counts users as active organizationMember rows of the workspace (deactivatedAt: null).

Type

  • Bug fix
  • New feature

Cloud and self-hosted

  • Cloud: as above. The wall is Cloud-only.
  • Self-hosted: the wall never shows. getUsage now counts active members of the workspace, which on a single-tenant instance matches the seat count used elsewhere (countActiveSeats).

Testing

  • Added/updated unit tests

Commands and results:

  • packages/backend: npx jest --maxWorkers=4 src/license src/adapters: 710 suites passed, 1 skipped (new getUsage spec)
  • packages/backend: npx tsc --noEmit -p tsconfig.json: clean (after npx prisma generate)
  • packages/frontend: npx tsc --noEmit -p tsconfig.json: clean
  • packages/frontend: eslint on the changed files: 0 errors, 2 set-state-in-effect warnings that were already there before this change
  • packages/frontend: npx playwright test --workers=4: 330 passed. New tests cover the helpers, Team preselected with the "This workspace has…" note, the workspace switch posting /organizations/switch, and no switch with a single workspace.

Checklist

  • My code follows the existing code style
  • I have tested my changes locally
  • All existing tests pass
  • This PR has a descriptive title

The trial-ended wall now lists the user's other workspaces, so someone in
several workspaces can leave an ended one for a paid one. The plan picker
preselects the smallest plan the workspace fits in (Team past Starter's
limits) and says which counts a plan does not cover. Licence usage counts
users by active membership, not by primary workspace.
@helpcodeai
helpcodeai enabled auto-merge (squash) November 3, 2026 09:08
@helpcodeai
helpcodeai merged commit 013d6b1 into main Nov 3, 2026
14 checks passed
@helpcodeai
helpcodeai deleted the helpcodeai/subscription-multi-workspace branch November 3, 2026 12:14
@github-actions github-actions Bot locked and limited conversation to collaborators Nov 3, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant