Repository navigation
feat(scope-access): members, invitations, profiles, files and workspaces for any membership scope - #64
Conversation
App access now runs on a scope-parameterized core: given a membership scope (app, org, or an entity type such as data_room), it derives the scope's GraphQL names, limits an entity scope's reads to one entity, and writes the entity's id into every create. The Console Kit users adapter is the core on the app scope. The GraphQL helpers and pure value helpers no longer need Console Kit's runtime, so hosts without Console Kit can use them.
UsersFeaturePack takes a noun (application by default) so the same view serves an organization's or a data room's members.
A scope with storage capabilities offers presets built from the platform's capability names; a preset creates its profile with the combined mask.
… scope For apps without Console Kit: a provider that builds the runtime from the app's endpoints and session, a members panel on any scope, the user's pending invitations in every scope with in-app accept, a workspace switcher (personal plus the user's organizations, with organization create), and an entity's files with upload, download and delete through the storage plugin's per-scope mutations.
…cher constructive-graphql becomes its own lib item, so the scope blocks reuse the GraphQL helpers without Console Kit; console-module-users builds on scope-access. The files view ships with scope-panels, so App access still installs no storage pack.
…d lists RecordDetail renders its children under the related lists once the record has loaded, so an app can add an entity's members and files to its page.
…ds it has An app invitation's record names no entity, so a fixed selection with entityId failed the whole query on the app scope. The selection now comes from the scope's record type in the schema.
… per page The workspace switcher, on every page of an app that has one, now reads only rows. A members panel introspects the admin and auth schemas, a files panel the app's, and each schema is kept for the page per endpoint and user, so moving between pages doesn't introspect again.
…is unknown The footer added up every bucket's count and read a missing one as 0, so a host that knows only some counts showed "0 files in 1 bucket". When any count is unknown, the footer now names the buckets alone.
…entity add a bucket - Members: an organization is a users row too, so it holds an app membership. A member whose user type is the id of a membership type with hasUsersTableEntry is left off the list (membership-types.ts reads the admin API's membershipTypes; no type number is assumed). - Status: org and entity memberships have no verified flag, so `lifecycle.verified` is optional and absent there, and those members no longer read as "Unverified". - Files: the open bucket's count comes from its loaded files. An entity type made without buckets offers "New bucket" when the API has the scope's create mutation; RLS decides who may use it. - A new organization's users-row type comes from its scope's membership type, not a fixed number. Structure: the runtime, schema and target types live in scope-runtime.ts; supportsScopeObject/supportsScopePatch and scopeMutationDocument's payload selection in scope-names.ts serve every scope write; useScopeView loads both panels; loadScopeAccess reads rows, then maps them in a pure step; the users pack's noun helpers and profile presets have their own modules.
|
Review complete. 🟠 1 high · 🟡 2 medium 💬 Inline comments (3)
🧹 Nitpicks (2) — 🟢 2 low
The change introduces a generalized
Reviewed commit: 36a0adc |
There was a problem hiding this comment.
This PR refactors the Console Kit users adapter and adds a scope-access registry block with capability-mask authorization, a workspace switcher, and cross-scope pending-invite loading.
Key findings
- 🟠 Sender-name lookup downloads the entire users table — pending-invites-load.ts:83
- 🟡 Invite title hardcodes "an" before
noun.long— users-feature-pack.tsx:370 - 🟡 Create during initial load stores
falseasloaded— workspace.tsx:118
| flushSync(() => setLoaded((current) => current && { | ||
| ...current, | ||
| workspaces: orderedWorkspaces([...current.workspaces.filter((w) => w.id !== created.id), created]) | ||
| })); |
There was a problem hiding this comment.
🟡 bug · medium
Create during initial load stores false as loaded
The create action's flushSync updater setLoaded((current) => current && {...}) returns the boolean false — not null — when the initial list is still loading, corrupting the loaded state shape (apps/blocks/src/blocks/scope-access/workspace.tsx:118-121). Downstream, loading: loaded === null flips to false and workspaces falls back to NO_WORKSPACES, so the switcher renders an empty list until the setVersion reload re-fetches. The dialog is usable while the very first load is pending (slow backend, retry backoff), so the path is reachable in normal use.
📋 Prompt for AI Agents
In apps/blocks/src/blocks/scope-access/workspace.tsx lines 118-121, change the flushSync updater from setLoaded((current) => current && {...}) to a ternary that returns current unchanged when it is null: setLoaded((current) => current ? { ...current, workspaces: orderedWorkspaces([...current.workspaces.filter((w) => w.id !== created.id), created]) } : current), so creating an organization before the initial list loads does not store the boolean false in the loaded state.
An installed app type-checks the registry files under noImplicitAny, where a `.catch(() => [])` or `?? []` fallback reads as an implied any.
…scope can grant in full
- Pending invitations asked for every user to name a few senders; the
connection query now takes an `in` filter, and the lookup asks for the
senders' ids only.
- The invite dialog names the scope with the right article ("Invite a data
room member") and says what access it grants.
- A profile preset shows only when the scope has every capability it
names, so an Editor never lacks write_files.
- ScopeHost's doc names `data` as the files endpoint.
|
Both nitpicks from the Tenki review summary are fixed in f4adcfb:
|
Lets an app built on any blueprint manage members, invitations, profiles and files for every membership scope its database has: the app, an organization, and entity types such as a data room. Constructive Desktop opts an app into these screens from its AppSpec; nothing here names a blueprint or a scope.
scope-access):scopeNames(scope)derives each scope's GraphQL names, so the same code reads and writesappMemberships,orgMembershipsanddataRoomMemberships. Console Kit's app users adapter now delegates to it.scope-panels):ScopeAccessPanel(members, invitations, profiles, capabilities, defaults) andScopeFilesPanel(an entity's buckets and files: upload, download, delete, and "New bucket" when the entity has none) for any scope, withPendingInvitesfor the signed-in user across scopes (sender names read with aninfilter, a new option ofexecuteConstructiveConnectionQuery).workspace-switcher): the personal workspace and the user's organizations, kept per user in a store a data layer can read (activeWorkspaceId('org')), with "New organization". The new organization's users-row type comes from its scope's membership type.hasUsersTableEntrytypes.Registry items:
scope-access,scope-panels,workspace-switcher(new);feature-pack-usersgainsusers-scope-noun.tsandusers-profile-presets.tsx.🤖 Generated with Claude Code
https://claude.ai/code/session_017WbsGACCtSUb8SqXaydeYJ