Skip to content

Commit bbf7a55

Browse files
committed
fix(files): return materialized file names
1 parent 4bdb02b commit bbf7a55

2 files changed

Lines changed: 8 additions & 1 deletion

File tree

apps/sim/lib/copilot/tools/handlers/materialize-file.test.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -331,6 +331,7 @@ describe('executeMaterializeFile - save storage transition', () => {
331331
displayName: 'image (1).png',
332332
})
333333
)
334+
expect(result.output).toEqual({ succeeded: ['image (1).png'], failed: [] })
334335
expect(result.resources).toEqual([{ type: 'file', id: 'file-1', title: 'image (1).png' }])
335336
})
336337

@@ -380,6 +381,7 @@ describe('executeMaterializeFile - save storage transition', () => {
380381
expect.objectContaining({ originalName: 'image (2).png' })
381382
)
382383
expect(mockIncrementStorageUsageForBillingContextInTx).toHaveBeenCalledTimes(1)
384+
expect(result.output).toEqual({ succeeded: ['image (2).png'], failed: [] })
383385
expect(result.resources).toEqual([{ type: 'file', id: 'file-1', title: 'image (2).png' }])
384386
})
385387

@@ -433,6 +435,7 @@ describe('executeMaterializeFile - save storage transition', () => {
433435
expect(mockGetWorkspaceFile).toHaveBeenCalledWith(context.workspaceId, 'file-1', {
434436
throwOnError: true,
435437
})
438+
expect(result.output).toEqual({ succeeded: ['report (1).txt'], failed: [] })
436439
expect(result.resources).toEqual([{ type: 'file', id: 'file-1', title: 'report (1).txt' }])
437440
expect(mockIncrementStorageUsageForBillingContextInTx).not.toHaveBeenCalled()
438441
expect(mockMaybeNotifyStorageLimitForBillingContext).not.toHaveBeenCalled()

apps/sim/lib/copilot/tools/handlers/materialize-file.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -571,7 +571,11 @@ export async function executeMaterializeFile(
571571
}
572572

573573
if (result.success) {
574-
succeeded.push(fileName)
574+
const materializedName =
575+
operation === 'save'
576+
? result.resources?.find((resource) => resource.type === 'file')?.title
577+
: undefined
578+
succeeded.push(materializedName ?? fileName)
575579
if (result.resources) resources.push(...result.resources)
576580
} else {
577581
failed.push({ fileName, error: result.error ?? 'Failed to materialize file' })

0 commit comments

Comments
 (0)