feat(file): include public share status in File read output#5191
Conversation
The read operation now attaches each workspace file's public share status as a "share" field (the share record, or null when not shared), batch-fetched via getSharesForResources to avoid N+1. Picker/upload input files have no canonical id and carry share: null.
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
PR SummaryMedium Risk Overview After loading files by ID, the route batch-loads public shares via The File block Reviewed by Cursor Bugbot for commit cdddec3. Bugbot is set up for automated code reviews on this repo. Configure here. |
|
@greptile review |
Greptile SummaryThis PR enriches the File block's Read operation so each returned workspace file carries a
Confidence Score: 4/5The change is narrow and well-contained; the batched share fetch is correct and avoids N+1. One behavioral difference from the rest of the file: inactive share tokens and URLs are returned in the read response even though The logic is correct and the apps/sim/app/api/tools/file/manage/route.ts — specifically the inactive-share URL treatment in the Important Files Changed
Sequence Diagram%%{init: {'theme': 'neutral'}}%%
sequenceDiagram
participant Client
participant FileManageAPI as /api/tools/file/manage
participant WorkspaceFileManager
participant ShareManager as share-manager (getSharesForResources)
Client->>FileManageAPI: "POST { operation: "read", fileId: [...] }"
FileManageAPI->>FileManageAPI: assertActiveWorkspaceAccess
FileManageAPI->>WorkspaceFileManager: getWorkspaceFile(workspaceId, id) x N
WorkspaceFileManager-->>FileManageAPI: workspaceFile[]
FileManageAPI->>ShareManager: getSharesForResources("file", selectedFileIds)
ShareManager-->>FileManageAPI: "Map<fileId, ShareRecord>"
FileManageAPI->>FileManageAPI: map files to userFiles with share field
FileManageAPI->>FileManageAPI: concat picker/upload files with share: null
FileManageAPI-->>Client: "{ files: [{ ...userFile, share: ShareRecord | null }] }"
%%{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"}}}%%
sequenceDiagram
participant Client
participant FileManageAPI as /api/tools/file/manage
participant WorkspaceFileManager
participant ShareManager as share-manager (getSharesForResources)
Client->>FileManageAPI: "POST { operation: "read", fileId: [...] }"
FileManageAPI->>FileManageAPI: assertActiveWorkspaceAccess
FileManageAPI->>WorkspaceFileManager: getWorkspaceFile(workspaceId, id) x N
WorkspaceFileManager-->>FileManageAPI: workspaceFile[]
FileManageAPI->>ShareManager: getSharesForResources("file", selectedFileIds)
ShareManager-->>FileManageAPI: "Map<fileId, ShareRecord>"
FileManageAPI->>FileManageAPI: map files to userFiles with share field
FileManageAPI->>FileManageAPI: concat picker/upload files with share: null
FileManageAPI-->>Client: "{ files: [{ ...userFile, share: ShareRecord | null }] }"
Reviews (2): Last reviewed commit: "feat(file): include public share status ..." | Re-trigger Greptile |
…internals
Read's per-file "share" is now { visibility, url, allowedEmails } using the
same visibility vocabulary as Manage Sharing: 'private' when not shared (url
null, no config) instead of null, otherwise public/password/email/sso with the
link. Drops row internals (id, token, resourceType, resourceId, isActive,
hasPassword).
|
@greptile review |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 2d3707c. Configure here.
Input (picker/upload) files only have a synthetic id (storage key/URL), so looking them up in the shares map could collide with a canonical file id and attach the wrong share. Give them an explicit private share instead.
|
@greptile review |
|
@greptile review |

Summary
sharefield — the public-safe share record (isActive,url,authType,hasPassword,allowedEmails, …) ornullwhen the file isn't shared.getSharesForResources(one query for all files, no N+1).share: null.Follow-up to #5177 (Manage Sharing operation).
Type of Change
Testing
tsc --noEmit,bun run lint,bun run check:api-validation:strict, and the File block test suite all pass.Checklist