Skip to content

fix(roles): reflect & preserve wildcard tool grants in the role editor - #6157

Open
AriOliv wants to merge 1 commit into
decocms:mainfrom
AriOliv:fix/role-editor-tool-grants
Open

fix(roles): reflect & preserve wildcard tool grants in the role editor#6157
AriOliv wants to merge 1 commit into
decocms:mainfrom
AriOliv:fix/role-editor-tool-grants

Conversation

@AriOliv

@AriOliv AriOliv commented Aug 17, 2026

Copy link
Copy Markdown
Contributor

Problem

The organization role editor (Settings → Roles → MCP Permissions) renders a connection's tools as unchecked even when the role already grants them, and re-saving destroys the grant.

convertRoleToFormData expands a stored ["*"] (all-tools) grant into concrete names via conn.tools:

toolSet[key] = tools.includes("*") ? (conn.tools?.map((t) => t.name) ?? []) : tools;

But the connection list endpoint (COLLECTION_CONNECTIONS_LIST) omits tools — the editor fetches them lazily per selected connection. So conn.tools is undefined, the grant expands to [], and:

  • every tool renders unchecked (0/N) even though the role grants them, and
  • saving writes [] back → buildPermission drops the entry → the grant is destroyed.

Grants for connections not present in the current (paginated) list were likewise dropped on load.

Fix

  • convertRoleToFormData preserves the raw grant, including the "*" sentinel, and no longer drops grants for connections missing from the current page.
  • ToolSetSelector understands "*" as "all tools" for checked state, the N/N count, and both per-tool and per-connection toggles (toggling a single tool off first expands "*" to concrete names so the rest stay selected).
  • buildPermission already collapses a fully-selected connection back to ["*"], so grants round-trip cleanly.

Testing

  • tsc --noEmit on apps/web passes.
  • A role that grants all of a connection's tools (stored ["*"]) now reopens fully checked instead of 0/N, and survives a re-save instead of being wiped.

🤖 Generated with Claude Code

The org role editor rendered a connection's tools as unchecked even when the
role already granted them, and re-saving destroyed the grant:

convertRoleToFormData expanded a stored ["*"] (all-tools) grant via
conn.tools, but COLLECTION_CONNECTIONS_LIST omits tools (fetched lazily per
selected connection) -> the grant expanded to [] -> every tool showed unchecked
and buildPermission dropped the entry on the next save. Grants for connections
absent from the current (paginated) page were likewise dropped.

Now the raw grant (including the "*" sentinel) is preserved, and
ToolSetSelector understands "*" as all-tools for checked state, counts, and
per-tool + per-connection toggles (toggling one tool off first expands "*" to
concrete names). buildPermission already collapses a fully-selected connection
back to ["*"], so grants round-trip.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@AriOliv
AriOliv force-pushed the fix/role-editor-tool-grants branch from 54ed0b6 to 8913537 Compare August 17, 2026 23:31
@AriOliv AriOliv changed the title fix(roles): reflect & preserve wildcard tool grants; stop built-in role editor from dropping edits fix(roles): reflect & preserve wildcard tool grants in the role editor Aug 17, 2026
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