diff --git a/frontend/src/lib/components/settings/RoleMcpAccessEditor.svelte b/frontend/src/lib/components/settings/RoleMcpAccessEditor.svelte index a351a0ab53..06d723e246 100644 --- a/frontend/src/lib/components/settings/RoleMcpAccessEditor.svelte +++ b/frontend/src/lib/components/settings/RoleMcpAccessEditor.svelte @@ -12,6 +12,8 @@ setting: McpRoleSetting | undefined /** The limit of the layer below, which an unset `setting` inherits. */ instanceLimit?: McpRoleSetting + /** The role is the instance's, overridden here: unset follows the instance's setting. */ + inherits?: boolean /** What the role allows; undefined while not known. */ caps?: RoleCapabilities /** The workspace overriding the role. Without one the role is the instance's, which cannot @@ -26,6 +28,7 @@ let { setting, instanceLimit, + inherits = false, caps, workspace, frozen = false, @@ -48,8 +51,9 @@ } const effective = $derived(setting?.access ?? instanceLimit?.access ?? ROLE) - // Without an instance limit, following the role is storing nothing. - const selected = $derived(setting?.access ?? (instanceLimit ? INHERIT : ROLE)) + // Unset follows the layer below: the instance's setting, or the role itself. + const unset = $derived(inherits ? INHERIT : ROLE) + const selected = $derived(setting?.access ?? unset) // Only what lowers the access: a role that cannot run already reads only, and gets nothing // from running tools. Read only stays, since workspace admins holding the role still run. A @@ -61,20 +65,21 @@ const items = $derived( [ - ...(instanceLimit ? [INHERIT] : []), + ...(inherits ? [INHERIT] : []), ROLE, ...(Object.keys(MCP_ROLE_LIMIT_LABELS) as Access[]).filter( (value) => value === setting?.access || (!frozen && lowers(value)) ) ] // Frozen, a stored setting can only be removed. - .filter( - (value) => !frozen || value === selected || value === (instanceLimit ? INHERIT : ROLE) - ) + .filter((value) => !frozen || value === selected || value === unset) .filter((value, i, all) => all.indexOf(value) === i) .map((value) => ({ value, - label: value === INHERIT ? inheritedLabel(instanceLimit!) : limitLabel(value as Access) + label: + value === INHERIT + ? inheritedLabel(instanceLimit ?? { access: ROLE }) + : limitLabel(value as Access) })) ) @@ -120,7 +125,8 @@ function setAccess(value: string) { if (value === selected) return if (value === INHERIT) return onchange(undefined) - if (value === ROLE) return onchange(instanceLimit ? { access: ROLE } : undefined) + // Over an instance role, following the role is stored: it holds whatever the instance sets. + if (value === ROLE) return onchange(inherits ? { access: ROLE } : undefined) onchange({ access: value as Access }) } diff --git a/frontend/src/lib/components/settings/WorkspaceRoleOverrides.svelte b/frontend/src/lib/components/settings/WorkspaceRoleOverrides.svelte index e5f2fdf24b..affe86879f 100644 --- a/frontend/src/lib/components/settings/WorkspaceRoleOverrides.svelte +++ b/frontend/src/lib/components/settings/WorkspaceRoleOverrides.svelte @@ -333,6 +333,7 @@ ? data.instance_mcp[name] : undefined} caps={runUnknown(name) ? undefined : caps} + inherits={!!role} {workspace} frozen={!data?.custom_roles_enabled} onchange={(mcp) => setMcp(name, mcp)}