The best way to control Claude Code, Codex and more from any computer or phone
fix(web): edited HTML previews outside the workspace no longer turn white (#34569)
Co-authored-by: Julius Marminge <julius0216@outlook.com>
Timo S. committed
Nov 14, 2026 at 07:11 UTC
31d9b3bcd60cd113ad8df50c9819f59c8b769ce9
2 files changed
+49
-6
apps/web/src/components/files/AttachmentFilePreview.browser.test.tsx
+36
@@ -1494,6 +1494,42 @@ it("keeps a workspace PDF open across URL renewals and reloads it when the file
1494
URL.revokeObjectURL(edited);
1495
}
1496
});
1497
+
1498
+it("loads an edited HTML file outside the workspace from a renewed URL", async () => {
1499
+ const { WorkspaceBrowserPreview } = await import("./FilePreviewPanel");
1500
+ const preview = (mutation: string) => (
1501
+ <WorkspaceBrowserPreview
1502
+ environmentId={EnvironmentId.make("test")}
1503
+ threadRef={{ environmentId: EnvironmentId.make("test"), threadId: ThreadId.make("test") }}
1504
+ draft={false}
1505
+ workspaceRoot="/repo"
1506
+ absolutePath="/tmp/report.html"
1507
+ title="Report"
1508
+ workspaceMutationId={mutation}
1509
+ />
1510
+ );
1511
+ assetUrlState.mockReturnValue({ _tag: "Success", url: "data:text/html,original", expiresAt: 0 });
1512
+ await using screen = await render(preview("first"));
1513
+ const opened = screen.container.querySelector("iframe");
1514
+ expect(opened?.getAttribute("src")).toMatch(/^data:text\/html,original/);
1515
+
1516
+ assetUrlState.mockReturnValue({
1517
+ _tag: "Success",
1518
+ url: "data:text/html,original",
1519
+ expiresAt: 0,
1520
+ waiting: true,
1521
+ });
1522
+ await screen.rerender(preview("second"));
1523
+ expect(assetUrlState).toHaveBeenLastCalledWith(expect.anything(), expect.anything(), "second");
1524
+ expect(screen.container.querySelector("iframe")).toBe(opened);
1525
+
1526
+ assetUrlState.mockReturnValue({ _tag: "Success", url: "data:text/html,edited", expiresAt: 0 });
1527
+ await screen.rerender(preview("second"));
1528
+ expect(screen.container.querySelector("iframe")?.getAttribute("src")).toMatch(
1529
+ /^data:text\/html,edited/,
1530
+ );
1531
+});
1532
+
1533
function planningPdf(
1534
titles = ["Quarterly outlook", "Delivery milestones", "Budget and risks"],
1535
firstHeight = 140,
apps/web/src/components/files/FilePreviewPanel.tsx
+13
-6
@@ -249,13 +249,20 @@ export function WorkspaceBrowserPreview(props: {
249
workspaceRoot: props.workspaceRoot,
250
absolutePath: props.absolutePath,
251
});
252
- const assetUrl = useAssetUrlState(
253
- props.environmentId,
254
- resource,
255
- pdf ? props.workspaceMutationId : undefined,
256
- );
252
+ // Each workspace mutation re-mints the URL: a file outside the workspace is signed by its
253
+ // inode, which an atomic replace changes.
254
+ const assetUrl = useAssetUrlState(props.environmentId, resource, props.workspaceMutationId);
255
+ // The HTML frame keeps its first URL per key, so the key moves only once the re-minted URL arrives.
256
+ const [settledMutationId, setSettledMutationId] = useState(props.workspaceMutationId);
257
+ if (
258
+ assetUrl._tag === "Success" &&
259
+ !assetUrl.waiting &&
260
+ settledMutationId !== props.workspaceMutationId
261
+ ) {
262
+ setSettledMutationId(props.workspaceMutationId);
263
+ }
264
const fileRevision = pdf && assetUrl._tag === "Success" ? assetUrl.fileRevision : undefined;
258
- const revision = fileRevision ?? props.workspaceMutationId;
265
+ const revision = fileRevision ?? (pdf ? props.workspaceMutationId : settledMutationId);
266
const revisionSuffix =
267
revision === null
268
? ""