Skip to content

Commit e889505

Browse files
committed
fix(files): scope the single-file picker, and restore the v2 route
Three fixes from the AI reviewers on #7377. The single-file picker kept its unscoped options when the folder changed: singleFileOptions read scopedWorkspaceFiles but listed workspaceFiles in its memo dependencies, so it never recomputed. That is the picker Append uses, so the folder narrowing I added for it did nothing after the first render. The v2 files-folders route called toWorkspaceFileFolderPathView while importing staging's toV2Folder — a conflict resolution I got half right, and a compile error I would have found by running the type-check I skipped. The file is back to staging's version, since keeping its projection was the decision anyway. fileFamilyInput took Record<string, any>, which the repo's TypeScript rules forbid. It now takes an interface naming the three fields it actually reads, so a shape change fails at the call site rather than at run time.
1 parent b5a77e3 commit e889505

3 files changed

Lines changed: 12 additions & 8 deletions

File tree

  • apps/sim
    • app
      • api/v2/files/folders
      • workspace/[workspaceId]/w/[workflowId]/components/panel/components/editor/components/sub-block/components/file-upload
    • blocks/blocks

‎apps/sim/app/api/v2/files/folders/route.ts‎

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,7 @@ export const GET = defineV2JsonRoute({
3232
sortOrder: query.sortOrder,
3333
}),
3434
useCase: listWorkspaceFileFoldersOperation,
35-
present: ({ folders }) => ({
36-
data: folders.map(toWorkspaceFileFolderPathView),
37-
nextCursor: null,
38-
}),
35+
present: ({ folders }) => ({ data: folders.map(toV2Folder), nextCursor: null }),
3936
})
4037

4138
export const POST = defineV2JsonRoute({
@@ -46,7 +43,7 @@ export const POST = defineV2JsonRoute({
4643
errorPolicy: v2FileErrorPolicies.default,
4744
mapInput: ({ body }) => ({ workspaceId: body.workspaceId, path: body.path }),
4845
useCase: createWorkspaceFileFolderOperation,
49-
present: ({ folder }) => ({ data: toWorkspaceFileFolderPathView(folder) }),
46+
present: ({ folder }) => ({ data: toV2Folder(folder) }),
5047
})
5148

5249
export const PATCH = defineV2JsonRoute({
@@ -61,7 +58,7 @@ export const PATCH = defineV2JsonRoute({
6158
destinationPath: body.destinationPath,
6259
}),
6360
useCase: updateWorkspaceFileFolderOperation,
64-
present: ({ folder }) => ({ data: toWorkspaceFileFolderPathView(folder) }),
61+
present: ({ folder }) => ({ data: toV2Folder(folder) }),
6562
})
6663

6764
export const DELETE = defineV2JsonRoute({

‎apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/editor/components/sub-block/components/file-upload/file-upload.tsx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -735,7 +735,7 @@ export function FileUpload({
735735
}
736736
}),
737737
],
738-
[workspaceFiles, acceptedTypes, cloudUploadBlocked]
738+
[scopedWorkspaceFiles, acceptedTypes, cloudUploadBlocked]
739739
)
740740

741741
// Find the selected file's workspace ID for highlighting in single file mode

‎apps/sim/blocks/blocks/file.ts‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,13 @@ function toFileIdList(value: string | string[] | null | undefined): string[] {
135135
return Array.isArray(value) ? value : [value]
136136
}
137137

138+
/** Only the fields {@link fileFamilyInput} reads, so a shape change fails here rather than at run time. */
139+
interface FileFamilyParams {
140+
folderScopeRef?: unknown
141+
folderIncludeSubfolders?: unknown
142+
_context?: { workspaceId?: string }
143+
}
144+
138145
/**
139146
* What read, get content, and compress send: the files picked, the folder they
140147
* were picked from, or the folder alone.
@@ -146,7 +153,7 @@ function toFileIdList(value: string | string[] | null | undefined): string[] {
146153
* the ids it covers today.
147154
*/
148155
function fileFamilyInput(
149-
params: Record<string, any>,
156+
params: FileFamilyParams,
150157
label: string,
151158
pickerValue: unknown
152159
): Record<string, unknown> {

0 commit comments

Comments
 (0)