Repository navigation
fix(workspace): restore member management for Enterprise workspace owners - #20401
christian-byrne wants to merge 4 commits into
Conversation
canManageMembers gated on the can_change_seats capability, which the server zeroes for every sales-managed tier (hideLifecycleCapabilities). An Enterprise owner therefore lost the row menu entirely: no Change role, no Remove member, no Set credit limit. Member writes are membership authorization, not billing lifecycle -- ingest registers PATCH/DELETE /workspace/members/:userId behind RequireWorkspaceOwner alone, with no tier check -- so gate them on the owner role instead. Fixes FE-3268
can_change_seats carried the ended freeze implicitly -- both lapsedSelfServeCapabilities and hideLifecycleCapabilities zero it -- so dropping that read has to restate it. hasMemberSeats cannot stand in: max_seats 0 means uncapped, not seatless, and a stale terminal payload can still report its old seat count. Also corrects the single-seat test comment, which claimed ended-plan coverage the test did not provide.
isPlanEnded also requires the team/sales-managed classifier that selects the ended banner, so it under-covers the freeze. The capability this replaced was withheld by lapsedSelfServeCapabilities for every terminal subscription, banner-eligible or not, so gate on isPlanTerminal. Also aligns the e2e workspace tier with its billing-status tier.
…d term BE-1530 ANDs a dunning failure into is_active, so usePlanEnded's isPlanTerminal (and isPlanEnded with it) reads a cancel-scheduled term whose card is failing as dead. Freezing on either took the row menu away for a term the customer has paid for and the server still honours member writes on -- and removing members is exactly what a team winding down needs. Mirror the backend's IsTerminalSubscription instead: ended, or canceled with no future cancel_at. cancel_at is only sent while it is still ahead, so no clock comparison is needed. The shared isPlanTerminal is left alone: the banner and invite gating misread this state too, but correcting that is a separate change.
🎨 Storybook: ✅ Built — View Storybook🌾 Fallow: ✅ PassedFallow audits the diff for duplication, complexity and dead code. It gates on new findings only, so when the audit completes, a red is something this PR introduced or moved — never inherited backlog. A red can also mean the audit itself did not finish; the details below say which happened. No new findings in the changed files. Reproduce locally# the base the gate compared against
npx fallow audit --root . --quiet --format json \
--changed-since 850d562e93a4e2ed7920d1302a9ca2415378f7e5
Full docs: ADR-DEVEX-LINT-0015 📦 Bundle: 9.3 MB gzip 🟢 -957 kBDetailsSummary
Category Glance App Entry Points — 4.17 kB (baseline 4.1 kB) • 🔴 +63 BMain entry bundles and manifests
Status: 1 added / 1 removed Graph Workspace — 1.46 MB (baseline 1.45 MB) • 🔴 +5.54 kBGraph editor runtime, canvas, workflow orchestration
Status: 2 added / 2 removed / 1 unchanged Views & Navigation — 143 kB (baseline 136 kB) • 🔴 +7.92 kBTop-level views, pages, and routed surfaces
Status: 16 added / 16 removed / 2 unchanged Panels & Settings — 678 kB (baseline 672 kB) • 🔴 +5.71 kBConfiguration panels, inspectors, and settings screens
Status: 11 added / 11 removed / 18 unchanged User & Accounts — 54.4 kB (baseline 53.9 kB) • 🔴 +531 BAuthentication, profile, and account management bundles
Status: 11 added / 11 removed / 4 unchanged Editors & Dialogs — 133 kB (baseline 133 kB) • ⚪ 0 BModals, dialogs, drawers, and in-app editors
Status: 9 added / 9 removed UI Components — 203 kB (baseline 205 kB) • 🟢 -2.03 kBReusable component library chunks
Status: 20 added / 20 removed Data & Services — 4.2 MB (baseline 4.17 MB) • 🔴 +24 kBStores, services, APIs, and repositories
Status: 14 added / 14 removed / 3 unchanged Utilities & Hooks — 584 kB (baseline 580 kB) • 🔴 +4.1 kBHelpers, composables, and utility bundles
Status: 27 added / 25 removed / 13 unchanged Vendor & Third-Party — 14.2 MB (baseline 17.3 MB) • 🟢 -3.04 MBExternal libraries and shared vendor chunks
Status: 5 added / 5 removed / 13 unchanged Other — 18.6 MB (baseline 18.5 MB) • 🔴 +47.4 kBBundles that do not match a named category
Status: 134 added / 128 removed / 184 unchanged ⚡ Performance
🎭 Playwright: ✅ 2240 passed, 0 failed📊 Browser Reports
🧩 Custom Nodes Ecosystem Matrix: ✅ PassedExecutes the frontend JS of every registry pack that ships any, against this change, in both renderers. The eight
On a pin-bump PR, a red gate means the ecosystem moved — not that your diff broke something. That is what the bump PR is for. Outside a pin bump or a cold rebuild of the unpinned tail, a red means the diff. Note the corpus size and the executed count are different numbers, and the verdict is against the executed count: roughly 3,100 of ~5,100 packs ship no extension-shaped JS and are skipped. Reproduce locally# build one shard's fixture, then run it
python3 scripts/registry-census/build_matrix.py --shard 1/4
MATRIX_RENDERER=vue MATRIX_VUE=1 \
npx vitest run --config vitest.matrix.config.mts
Full docs: scripts/registry-census/README.md |
|
Note Currently processing new changes in this PR. This may take a few minutes, please wait... ⚙️ Run configuration
📒 Files selected for processing (3)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
Codecov Report✅ All modified and coverable lines are covered by tests. @@ Coverage Diff @@
## main #20401 +/- ##
==========================================
+ Coverage 85.62% 86.42% +0.80%
==========================================
Files 3537 2492 -1045
Lines 169616 141982 -27634
Branches 44528 36677 -7851
==========================================
- Hits 145232 122713 -22519
+ Misses 22386 18888 -3498
+ Partials 1998 381 -1617
Flags with carried forward coverage won't be shown. Click here to find out more.
... and 1058 files with indirect coverage changes 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
🔍 Cursor Review — Consolidated panel
Triggered by @christian-byrne.
Found 4 finding(s).
| Severity | Count |
|---|---|
| 🟡 Medium | 2 |
| 🟢 Low | 1 |
| ⚪ Nit | 1 |
Panel: 8/8 reviewers contributed findings.
| () => | ||
| subscriptionStatus.value === 'ended' || | ||
| (subscriptionStatus.value === 'canceled' && | ||
| subscription.value?.endDate == null) |
There was a problem hiding this comment.
🟡 Medium — isSubscriptionTerminal treats the mere presence of endDate (cancel_at) as proof the term is still ahead and never compares it to the current time, so an elapsed cancellation that still carries a past cancel_at — the stale pre-reconcile shape usePlanEnded's own comment documents as reachable — reads as non-terminal and leaves change-role, remove-member, and credit-limit actions enabled on a dead plan while the panel renders the ended banner. There is also no timed refresh of billing status, so a tab loaded before cancel_at keeps those actions enabled after the term expires, unlike the capability snapshot this replaced which refetched on expires_at. Gating on Date.parse(endDate) > Date.now() rather than presence separates the dunning wind-down from the elapsed case; presence alone cannot.
Raised by 7 of 8 reviewers (claude-opus-5-thinking-max adversarial, gpt-5.6-sol-max adversarial, kimi-k3-max adversarial, claude-opus-5-thinking-max edge-case, gemini-3.1-pro edge-case, gpt-5.6-sol-max edge-case, kimi-k3-max edge-case).
| hasMemberSeats.value && | ||
| (isCloud ? canChangeSeats.value : workspaceRole.value === 'owner') | ||
| !isSubscriptionTerminal.value && | ||
| workspaceRole.value === 'owner' |
There was a problem hiding this comment.
🟡 Medium — On cloud, member-management authorization now rests entirely on the client-cached workspaceRole, which useWorkspaceUI derives as store.activeWorkspace?.role ?? 'owner' — fail-open when the active workspace or its role is absent, where the replaced canChangeSeats was capabilities.value?.can_change_seats ?? false and was revalidated on expiry, on revision bumps, and forced false on an explicit 401/403. A non-owner on a partial or list-derived workspace payload, or an owner demoted in another session, therefore keeps the full row menu until /api/workspaces is refetched, and every click 403s against RequireWorkspaceOwner. Treat an unknown role as non-owner, and consider ANDing a server-authoritative signal so the gate fails closed in those windows.
Raised by 4 of 8 reviewers (gpt-5.6-sol-max adversarial, claude-opus-5-thinking-max adversarial, kimi-k3-max adversarial, claude-opus-5-thinking-max edge-case).
| }) | ||
|
|
||
| it('freezes member management once a cancellation has elapsed', async () => { | ||
| mockSubscription.value = { tier: 'TEAM', isCancelled: true } |
There was a problem hiding this comment.
🟢 Low — This test is the regression guard for the elapsed-cancellation freeze, but it builds the elapsed state with endDate omitted, which is the one elapsed shape the new presence check happens to catch. The payload usePlanEnded documents for an elapsed cancellation retains cancel_at with a past timestamp; setting endDate to a past ISO string here would fail against the current implementation, which is exactly the hole the test should be pinning.
Raised by 1 of 8 reviewers (claude-opus-5-thinking-max edge-case).
| // also clears on a failed payment, so a wind-down in dunning reads as dead | ||
| // while its paid-for term still runs. cancel_at is only ever sent while it | ||
| // is still ahead, so its presence alone separates the two. | ||
| const isSubscriptionTerminal = computed( |
There was a problem hiding this comment.
⚪ Nit — isSubscriptionTerminal is a third client-side copy of "is this plan dead", alongside usePlanEnded.isPlanTerminal (already consumed in this same file via isPlanEnded for isInviteDisabled and uiConfig) and the backend's IsTerminalSubscription. The two local predicates now disagree by design on the dunning case, so a future change to either silently desyncs the invite gate from the member-write gate; exporting both shapes from usePlanEnded would keep the definitions co-located with the backend contract they mirror.
Raised by 1 of 8 reviewers (claude-opus-5-thinking-max adversarial).
|
Fair challenge. One point lands and has changed the shape of this work; the other is about something this branch doesn't actually do — but the instinct behind it was right and I've acted on it. You're right that the backend owns this — Comfy-Org/cloud#12313I said "no backend bug, no backend change needed." That was wrong. The capability set had no field answering "may this actor manage members", so the frontend had nothing correct to read and substituted the nearest-looking thing. That's a gap in the contract, and it belongs server-side. Comfy-Org/cloud#12313 adds But the server isn't "lying" about
|
PR Created by the Glary-Bot Agent
Enterprise workspace owners cannot grant another member the Owner role — the per-row action menu is absent on every member, so Change role, Remove member and Set credit limit are all unreachable.
It is a capability-API issue, but on the client side: the frontend reads the wrong capability. There is no backend bug and no backend change here.
Root cause
canManageMembersgated on thecan_change_seatscapability:can_change_seatsis seat quantity — a billing-lifecycle capability. The server zeroes it for every sales-managed tier, because those seat counts are set by contract rather than self-serve:SelfServeLifecycleTierexcludesENTERPRISE, soResolveBillingCapabilitiesreturnshideLifecycleCapabilities, which setsCanChangeSeats = falseunconditionally (cloud/common/billing/policy/capabilities.go).memberMenuItems()returns[]whencanManageMembersis false, so the entire menu disappears.Member writes are membership authorization, not billing lifecycle.
PATCH/DELETE /api/workspace/members/:userIdare registered on theapiWorkspaceOwnergroup, whose only predicate isRequireWorkspaceOwner()— a role equality check with no tier, plan or seat condition. The API would have accepted these writes all along; only the UI was hiding them.The asymmetry is the tell:
hideLifecycleCapabilitiesdeliberately leavesCanInviteMembersalone, which is why inviting still worked for Enterprise owners while role changes did not.Regression from #15675 (Aug 26), which migrated this surface from
workspaceRole === 'owner'tocanChangeSeats. The sibling implementation in theplatformrepo gates the same action onisOwnerand never had the bug.The fix
Gate on the owner role — the predicate the server actually enforces — and state the dead-plan freeze explicitly, since
can_change_seatshad been carrying it implicitly.That freeze needs the backend's own
IsTerminalSubscription, notusePlanEnded. Two near-misses, both caught in review and both now pinned by tests:hasMemberSeatscannot carry it:max_seats: 0means uncapped, not seatless.isPlanTerminal/isPlanEndedcannot carry it either: BE-1530 ANDs a dunning failure intois_active, so a cancel-scheduled term whose card is failing reads as dead while the paid-for term is still running. Freezing there would strip the menu from a team mid-wind-down — exactly when removing members matters.cancel_atis only ever sent while still ahead, so its presence alone separates the two and no clock comparison is needed.Also unfrozen (all still owner-gated)
Relative to
mainthe swap additionally restores the menu for owners with no subscription row but a surviving seat override, with ascheduled/unrecognised status, and during a capability-fetch failure (where it previously blinked out on a refresh error). Every one still requiresrole === 'owner', which is what the server enforces — nothing is granted that the backend would refuse.Verification
87/87
useMembersPanel.test.ts; 2423/2423 acrosssrc/platform/workspace21/21
@cloudE2E across the members, Enterprise-billing and ended-subscription suitesoxfmt,oxlint --type-aware,eslint,typecheck:app,typecheck:browsercleanMutation-tested. Every conjunct is independently pinned, and the suite distinguishes all three candidate predicates:
main's predicate!isSubscriptionTerminalisPlanTerminalinsteadisPlanEndedinsteadrole === 'owner'hasMemberSeatsDriven in a real browser against the production sales-managed payload (
can_change_seats: false,can_invite_members: true). Pre-fix the E2E fails at exactlyexpect(members.menuButton(janeRow)).toBeVisible()— element not found — reproducing the reported screenshot.The new E2E carries that payload permanently; the existing member specs all ran under the default fixture where
can_change_seatsistrue, which is the gap that let this ship.Follow-up (not in this PR)
UpdateWorkspaceMemberRolereturns403 DIRECTORY_MANAGEDfor IdP-managed members andListWorkspaceMembersexposesmanaged_by_directory, butmapApiMemberToWorkspaceMemberdrops the field, so Change role on an SSO-managed row fails with a generic toast. Pre-existing and not Enterprise-specific, but restoring the menu aims it at the cohort most likely to run SCIM/WorkOS. Worth its own ticket.Fixes FE-3268
Screenshots