Skip to content

fix: has "view" permission for shared resource tools but cannot view details - #8169

Merged
peslyn merged 1 commit into
v3from
pr@v3@fix_has_view_permission_for_shared_resource_tools_but_cannot_view_details
Nov 26, 2026
Merged

peslyn merged 1 commit into
v3from
pr@v3@fix_has_view_permission_for_shared_resource_tools_but_cannot_view_details

Conversation

@shaohuzhang1

Copy link
Copy Markdown
Contributor

fix: has "view" permission for shared resource tools but cannot view details

if (!canOpenEditTool(tool)) return
return editToolFormRef.value?.open(tool)
}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking at this diff, here are my observations:

Correctness / Potential Issues

  1. Naming mismatch — viewableTypes vs. actual intent. The variable is named viewableTypes, implying "readable", but the function is canOpenEditTool and it gates opening an edit form. Using perm.tool.share.read() to gate an edit action is semantically questionable. If a user only has read permission, opening an edit form may allow them to attempt edits that will fail server-side, or worse, silently surface editable UI. Consider whether read genuinely grants "open edit form" semantics, or if the form is read-only in that case.

  2. ToolItem / TOOL_TYPE types not shown. Confirm tool.tool_type is always defined and matches ToolType. If tool_type can be undefined/null, includes will safely return false (fine), but worth confirming the type allows this.

  3. Early-return ordering. if (perm.tool.share.edit()) return true short-circuits before checking tool type. This means a user with edit permission can open the form for any tool type, including ones not in viewableTypes. Is that intended? If some tool types (e.g. a future type) should never be opened, the current logic bypasses that guard for editors. Likely fine, but worth documenting.

  4. Permission checks called repeatedly. perm.tool.share.edit() and perm.tool.share.read() are invoked on each call. If these are getters that recompute/traverse state, consider hoisting or memoizing — minor.

Optimization / Style Suggestions

  1. Hoist constant array. viewableTypes is allocated on every call. Move it to module scope:

    const EDITABLE_VIEW_TYPES: ReadonlySet<ToolType> = new Set([
      TOOL_TYPE.CUSTOM, TOOL_TYPE.MCP, TOOL_TYPE.SKILL, TOOL_TYPE.DATA_SOURCE,
    ])

    Then use EDITABLE_VIEW_TYPES.has(tool.tool_type) — clearer intent and avoids array re-creation + O(n) includes.

  2. Rename for clarity. Either rename to reflect intent (e.g. readableEditTypes or supportedTypes) or add a comment explaining why read permission suffices to open the edit form for these types.

  3. Type narrowing. If tool.tool_type could be a broader type, ensure Set<ToolType> membership check is type-safe; otherwise a narrowing helper/type-guard could improve safety.

  4. Return type annotation on canOpenEditTool (: boolean) would aid readability and catch accidental truthy returns.

  5. Test coverage. Since the gating logic changed from a single permission to a composite rule, add unit tests for the matrix: {edit: yes/no} × {type in set: yes/no} × {read: yes/no} to prevent regressions.

The change itself is small and safe; the main concern is the semantic coupling of a read permission to an "open edit form" action (#1), which you should confirm is truly intended behavior.

@peslyn
peslyn merged commit 9e9d832 into v3 Nov 26, 2026
3 of 4 checks passed
@peslyn
peslyn deleted the pr@v3@fix_has_view_permission_for_shared_resource_tools_but_cannot_view_details branch November 26, 2026 02:45
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.

2 participants