fix: bust browser cache for workspace file downloads

The downloadFile function was using a plain fetch() that honored the
aggressive cache headers, causing newly created files to download empty.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
waleed
2026-03-09 20:07:27 -07:00
parent 8fc75a6e9d
commit 94914b848e

View File

@@ -115,8 +115,8 @@ function formatFileType(mimeType: string | null, filename: string): string {
}
async function downloadFile(file: WorkspaceFileRecord) {
const serveUrl = `/api/files/serve/${encodeURIComponent(file.key)}?context=workspace`
const response = await fetch(serveUrl)
const serveUrl = `/api/files/serve/${encodeURIComponent(file.key)}?context=workspace&t=${Date.now()}`
const response = await fetch(serveUrl, { cache: 'no-store' })
if (!response.ok) {
throw new Error(`Failed to download file: ${response.statusText}`)
}