Skip to content

Commit 7c843d9

Browse files
fix(web): a failed page in the floating browser preview shows the error instead of a blank panel
The floating preview kept showing the desktop WebContents after a LoadFailed navigation, leaving a blank white panel. It now hides the surface and shows the same PreviewUnreachable view the Browser panel uses, with Reload. Fixes #7212 AI-assisted; verified with the tests and tools listed above.
1 parent b68aedf commit 7c843d9

1 file changed

Lines changed: 13 additions & 2 deletions

File tree

‎apps/web/src/components/preview/ThreadPreviewMiniPlayer.tsx‎

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ import { Atom } from "effect/reactivity";
5656
import { deviceScreenKey, deviceStreamScreenAtom } from "../device/deviceStreamSession";
5757
import type { PreviewStreamViewport } from "@t3tools/client-runtime/preview/server-browser-stream";
5858
import { previewBridge } from "./previewBridge";
59+
import { PreviewUnreachable } from "./PreviewUnreachable";
5960
import { showPreviewPopup } from "./showPreviewPopup";
6061
import {
6162
clampPreviewMiniPlayerPosition,
@@ -262,6 +263,7 @@ function BrowserMiniPlayer({ threadRef, tabId, miniPlayer }: Props & { readonly
262263
snapshot.navStatus._tag === "Success"
263264
? previewPdfAssetUrl(snapshot.navStatus.url, httpBaseUrl)
264265
: null;
266+
const loadFailed = snapshot.navStatus._tag === "LoadFailed" ? snapshot.navStatus : null;
265267
const poppedOut = serverTab ? serverPictureInPicture : Boolean(desktopOverlay?.pictureInPicture);
266268
const canPopOut = serverTab
267269
? poppedOut || (pdfUrl === null && supportsServerPictureInPicture())
@@ -335,14 +337,23 @@ function BrowserMiniPlayer({ threadRef, tabId, miniPlayer }: Props & { readonly
335337
<>
336338
<BrowserSurfaceSlot
337339
tabId={runtimeTabId}
338-
visible={Boolean(desktopOverlay?.hasWebContents)}
340+
visible={Boolean(desktopOverlay?.hasWebContents) && !loadFailed}
339341
cornerRadius={PREVIEW_MINI_PLAYER_CORNER_RADIUS}
340342
zIndex={PREVIEW_MINI_PLAYER_WEBVIEW_Z_INDEX}
341343
fitSourceContent
342344
layoutVersion={`${frame.x}:${frame.y}`}
343345
className="absolute inset-0"
344346
/>
345-
{!desktopOverlay?.hasWebContents ? (
347+
{loadFailed ? (
348+
<div className="pointer-events-auto absolute inset-0 z-[48] overflow-hidden rounded-[inherit]">
349+
<PreviewUnreachable
350+
url={loadFailed.url}
351+
code={loadFailed.code}
352+
description={loadFailed.description}
353+
onReload={() => void previewBridge?.refresh(runtimeTabId)}
354+
/>
355+
</div>
356+
) : !desktopOverlay?.hasWebContents ? (
346357
<div className="pointer-events-none absolute inset-0 z-[49] flex items-center justify-center rounded-[inherit] bg-muted text-xs text-muted-foreground">
347358
Reconnecting preview…
348359
</div>

0 commit comments

Comments
 (0)