feat(web): render HTML and PDF files in the file viewer #9143
Mergedjuliusmarmingemerged 2 commits into
t3code/open-outside-workspace-files fromrefs/pull/9143/headmerged by juliusmarminge View on GitHubgithub-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:trusted
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:L
- @@ -198,0 +238,21 @@238+ }239+ if (assetUrl._tag !== "Success") {240+ return (241+ <div className="flex min-h-0 flex-1 items-center justify-center text-muted-foreground">242+ <LoaderCircle className="size-5 animate-spin" />243+ </div>244+ );245+ }246+ const src = `${assetUrl.url}${revisionSuffix}`;247+ const className = "min-h-0 flex-1 border-0 bg-white";248+ // The built-in PDF viewer needs an unsandboxed frame; a PDF runs no scripts.249+ return isPdfPreviewFile(props.absolutePath) ? (250+ // oxlint-disable-next-line react/iframe-missing-sandbox251+ <iframe key={src} src={src} title={props.title} className={className} />252+ ) : (253+ <iframe254+ key={src}255+ src={src}256+ title={props.title}257+ className={className}258+ sandbox="allow-scripts allow-forms allow-popups allow-modals"
- apps/web/src/components/files/FilePreviewPanel.tsx line 200OutdatedResolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -196,3 +197,4 @@196197 );197198 }198199200+const isPdfPreviewFile = (path: string): boolean => /\.pdf$/i.test(path);
- apps/web/src/components/files/FilePreviewPanel.tsx lines 200 to 200Resolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -196,3 +197,4 @@196197 );197198 }198199200+const isPdfPreviewFile = (path: string): boolean => /\.pdf$/i.test(path.split(/[?#]/, 1)[0] ?? "");
- @@ -198,0 +241,21 @@241+ <div className="flex min-h-0 flex-1 items-center justify-center text-muted-foreground">242+ <LoaderCircle className="size-5 animate-spin" />243+ </div>244+ );245+ }246+ const src = `${assetUrl.url}${revisionSuffix}`;247+ const className = "min-h-0 flex-1 border-0 bg-white";248+ // The built-in PDF viewer needs an unsandboxed frame; a PDF runs no scripts.249+ return isPdfPreviewFile(props.absolutePath) ? (250+ // oxlint-disable-next-line react/iframe-missing-sandbox251+ <iframe key={src} src={src} title={props.title} className={className} />252+ ) : (253+ <iframe254+ key={src}255+ src={src}256+ title={props.title}257+ className={className}258+ sandbox="allow-scripts allow-forms allow-popups allow-modals"259+ />260+ );261+}@@ -198,0 +210,21 @@210+ readonly threadRef: ScopedThreadRef;211+ readonly absolutePath: string;212+ readonly workspaceRoot: string;213+ readonly title: string;214+ readonly workspaceMutationId: string | null;215+}) {216+ const insideWorkspace =217+ mediaFileReference(props.absolutePath, props.workspaceRoot).relativePath !== undefined;218+ const resource = useMemo(219+ () => ({220+ _tag: insideWorkspace ? ("workspace-file" as const) : ("media-file" as const),221+ threadId: props.threadRef.threadId,222+ path: props.absolutePath,223+ }),224+ [insideWorkspace, props.threadRef.threadId, props.absolutePath],225+ );226+ const assetUrl = useAssetUrlState(props.environmentId, resource);227+ const revisionSuffix =228+ props.workspaceMutationId === null229+ ? ""230+ : `${assetUrl._tag === "Success" && assetUrl.url.includes("?") ? "&" : "?"}workspace-revision=${encodeURIComponent(props.workspaceMutationId)}`;
juliusmarminge merged thisd937e30
juliusmarminge closed this
Sign in to join this conversation.


Thread transfer impact#
✅ Thread transfer remains within every enforced ceiling.
Baseline: unavailable · PR result:
4f990b7· Source CI: successScenario and decoded snapshot size
10 historical turns, 5 command tools per turn, 878.9 KiB retained MCP result per historical turn, and a 1.05 MiB retained result in the measured turn.
Updated in place by a trusted workflow. PR artifacts are strictly validated and never executed.