Skip to content

Commit 3607910

Browse files
PR Batch Testerclaude
andcommitted
fix(web): media preview URLs change whenever the file revision does
Two mints in the same millisecond sign the same URL, so an edited file could keep its old source. The revision now goes in the URL too. Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent fe3b224 commit 3607910

1 file changed

Lines changed: 10 additions & 7 deletions

File tree

‎apps/web/src/components/files/FilePreviewPanel.tsx‎

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -290,12 +290,14 @@ function WorkspaceVideoPreview(props: {
290290
},
291291
});
292292
// Servers that report the file's revision let an unchanged file stay loaded; older ones
293-
// only offer the workspace mutation, which changes after every command.
293+
// only offer the workspace mutation, which changes after every command. The revision also
294+
// goes in the URL, since two mints in the same millisecond sign identical URLs.
294295
const fileRevision = assetUrl._tag === "Success" ? assetUrl.fileRevision : undefined;
296+
const revision = fileRevision ?? props.workspaceMutationId;
295297
const revisionSuffix =
296-
fileRevision !== undefined || props.workspaceMutationId === null
298+
revision === null
297299
? ""
298-
: `${assetUrl._tag === "Success" && assetUrl.url.includes("?") ? "&" : "?"}workspace-revision=${encodeURIComponent(props.workspaceMutationId)}`;
300+
: `${assetUrl._tag === "Success" && assetUrl.url.includes("?") ? "&" : "?"}${fileRevision !== undefined ? "file" : "workspace"}-revision=${encodeURIComponent(revision)}`;
299301
const latestUrl = assetUrl._tag === "Success" ? `${assetUrl.url}${revisionSuffix}` : null;
300302

301303
return (
@@ -304,7 +306,7 @@ function WorkspaceVideoPreview(props: {
304306
src={latestUrl}
305307
sourceFailed={assetUrl._tag === "Failure"}
306308
label={props.name}
307-
revision={fileRevision ?? props.workspaceMutationId}
309+
revision={revision}
308310
preload="metadata"
309311
className="flex h-full min-h-0 w-full max-w-5xl items-center justify-center"
310312
onRetry={refreshAssetUrl}
@@ -347,10 +349,11 @@ function WorkspaceAudioPreview(props: {
347349
},
348350
});
349351
const fileRevision = assetUrl._tag === "Success" ? assetUrl.fileRevision : undefined;
352+
const revision = fileRevision ?? props.workspaceMutationId;
350353
const revisionSuffix =
351-
fileRevision !== undefined || props.workspaceMutationId === null
354+
revision === null
352355
? ""
353-
: `${assetUrl._tag === "Success" && assetUrl.url.includes("?") ? "&" : "?"}workspace-revision=${encodeURIComponent(props.workspaceMutationId)}`;
356+
: `${assetUrl._tag === "Success" && assetUrl.url.includes("?") ? "&" : "?"}${fileRevision !== undefined ? "file" : "workspace"}-revision=${encodeURIComponent(revision)}`;
354357
const url = assetUrl._tag === "Success" ? `${assetUrl.url}${revisionSuffix}` : null;
355358
if (assetUrl._tag === "Failure" || (url !== null && failedUrl === url)) {
356359
return (
@@ -368,7 +371,7 @@ function WorkspaceAudioPreview(props: {
368371
<AudioPreview
369372
src={url}
370373
name={props.name}
371-
revision={fileRevision ?? props.workspaceMutationId}
374+
revision={revision}
372375
onError={() => setFailedUrl(url)}
373376
/>
374377
);

0 commit comments

Comments
 (0)