Skip to content

fix(files): only show Share in context menu for files, not folders#5147

Merged
TheodoreSpeaks merged 1 commit into
stagingfrom
fix/remove-share-on-folder
Jun 20, 2026
Merged

fix(files): only show Share in context menu for files, not folders#5147
TheodoreSpeaks merged 1 commit into
stagingfrom
fix/remove-share-on-folder

Conversation

@TheodoreSpeaks

Copy link
Copy Markdown
Collaborator

Summary

  • Gate the Share action in the file-row right-click menu so it only renders for files, not folders
  • Previously Share showed for folders too and silently no-op'd, since the handler only acts on files

Type of Change

  • Bug fix

Testing

Tested manually. Lint and check:api-validation:strict pass.

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

@vercel

vercel Bot commented Jun 20, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
docs Skipped Skipped Jun 20, 2026 2:29am

Request Review

@TheodoreSpeaks

Copy link
Copy Markdown
Collaborator Author

@greptile review

@cursor

cursor Bot commented Jun 20, 2026

Copy link
Copy Markdown

PR Summary

Low Risk
Single conditional around an optional menu callback in the files UI; no API or permission model changes.

Overview
Share in the file list row context menu is now offered only when the right-clicked row is a file, not a folder.

FileRowContextMenu already hides Share when onShare is omitted; files.tsx now passes handleContextMenuShare only when the user can edit and contextMenuItemRef points at a file. Folder rows no longer show a Share action that did nothing because the share handler only opens sharing for files.

Reviewed by Cursor Bugbot for commit 5b29199. Bugbot is set up for automated code reviews on this repo. Configure here.

@greptile-apps

greptile-apps Bot commented Jun 20, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR gates the "Share" option in the file-row right-click context menu so it only appears for files, not folders. Previously the option was shown for both but silently no-op'd on folders because handleContextMenuShare only acts when contextMenuItemRef.current?.kind === 'file'.

  • Guard added: onShare is now passed as handleContextMenuShare only when canEdit is true AND contextMenuItemRef.current?.kind === 'file'; otherwise it is undefined, which the existing {!isMultiSelect && onShare && (...)} guard in FileRowContextMenu uses to suppress the menu item entirely.
  • No side-effects: contextMenuItemRef is written synchronously in handleRowContextMenu before openContextMenu triggers the re-render, so the kind check is always up-to-date when the menu renders.

Confidence Score: 5/5

Safe to merge — one-line change that adds a missing guard with no risk of regressions.

The change is minimal and targeted: it adds contextMenuItemRef.current?.kind === 'file' to an existing canEdit guard, relying on a discriminated union type that is already used throughout the file. The ref is written synchronously before the state update that causes the re-render, so the kind value is always current. The receiving component already handles onShare === undefined by suppressing the menu item, so no downstream changes are needed.

No files require special attention.

Important Files Changed

Filename Overview
apps/sim/app/workspace/[workspaceId]/files/files.tsx Single-prop change to FileRowContextMenu: gates onShare to file rows only using the existing contextMenuItemRef discriminated union. Logic is correct and consistent with how the ref is populated.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[User right-clicks a row] --> B[handleRowContextMenu]
    B --> C{parseRowId}
    C -->|kind = 'folder'| D[contextMenuItemRef.current = folder item]
    C -->|kind = 'file'| E[contextMenuItemRef.current = file item]
    D --> F[openContextMenu triggers re-render]
    E --> F
    F --> G{canEdit AND kind === 'file'?}
    G -->|No — folder or no edit permission| H[onShare = undefined - Share item hidden]
    G -->|Yes — file with edit permission| I[onShare = handleContextMenuShare - Share item visible]
    I --> J[User clicks Share → setShareFileId]
Loading
%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%%
flowchart TD
    A[User right-clicks a row] --> B[handleRowContextMenu]
    B --> C{parseRowId}
    C -->|kind = 'folder'| D[contextMenuItemRef.current = folder item]
    C -->|kind = 'file'| E[contextMenuItemRef.current = file item]
    D --> F[openContextMenu triggers re-render]
    E --> F
    F --> G{canEdit AND kind === 'file'?}
    G -->|No — folder or no edit permission| H[onShare = undefined - Share item hidden]
    G -->|Yes — file with edit permission| I[onShare = handleContextMenuShare - Share item visible]
    I --> J[User clicks Share → setShareFileId]
Loading

Reviews (1): Last reviewed commit: "fix(files): only show Share in context m..." | Re-trigger Greptile

@greptile-apps

greptile-apps Bot commented Jun 20, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR fixes a UX bug where the "Share" context menu item was incorrectly displayed for folders in the file browser, even though the share handler only operates on files. The fix gates the onShare prop on contextMenuItemRef.current?.kind === 'file', so the menu item is omitted entirely for folders rather than silently no-op'ing.

  • The ref is set synchronously in handleRowContextMenu before openContextMenu triggers the re-render, so the kind check evaluates correctly at render time.
  • FileRowContextMenu already conditionally renders Share only when onShare is defined ({!isMultiSelect && onShare && ...}), so the new guard aligns the data layer with what the component already expected.

Confidence Score: 5/5

Safe to merge — the change is a one-line conditional that correctly suppresses a no-op menu item for folders.

The fix is minimal and the logic is sound: contextMenuItemRef.current is always written synchronously before openContextMenu fires the re-render, so the kind check is never stale. The downstream component (FileRowContextMenu) already conditionally renders the Share item only when onShare is defined, so no secondary changes were needed. No new state, no new code paths, no regressions visible.

No files require special attention.

Important Files Changed

Filename Overview
apps/sim/app/workspace/[workspaceId]/files/files.tsx Gates onShare prop behind contextMenuItemRef.current?.kind === 'file'; the ref is written synchronously before the state-driven re-render so the check is always fresh when the menu renders.

Reviews (2): Last reviewed commit: "fix(files): only show Share in context m..." | Re-trigger Greptile

@TheodoreSpeaks TheodoreSpeaks merged commit 1248f8e into staging Jun 20, 2026
16 checks passed
@TheodoreSpeaks TheodoreSpeaks deleted the fix/remove-share-on-folder branch June 20, 2026 02:35
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