fix(preview): failed tabs no longer sit as a blank floating panel #7236
Closedgb1095(GitHub profile, opens in a new tab)wants to merge 17 commits into
main fromrefs/pull/7236/headopened 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
- apps/web/src/components/preview/PreviewAutomationHosts.tsx line 264Resolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -219,4 +220,7 @@219220 };220221 if (runtimeTabId && tabId && previewBridge && state.desktopByTabId[tabId]) {221222 const status = await previewBridge.automation.status(runtimeTabId);222- return { ...status, tabId, visible, ...viewportStatus };223+ return applyPreviewLoadFailureToAutomationStatus(224+ { ...status, tabId, visible, ...viewportStatus },225+ snapshot?.navStatus,226+ );apps/web/src/components/preview/ThreadPreviewMiniPlayer.tsx line 323Resolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -300,4 +306,3 @@300306 <div className="absolute inset-0 z-[29] rounded-xl bg-muted shadow-2xl/35" />301307 <BrowserSurfaceSlot302308 tabId={runtimeTabId}303- visible={Boolean(desktopOverlay?.hasWebContents)}
- apps/web/src/components/preview/ThreadPreviewMiniPlayer.tsx line 286OutdatedResolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -277,4 +283,4 @@277283 ? "Close separate window"278284 : "Pop into separate window"279285 }280- disabled={!desktopOverlay?.hasWebContents}286+ disabled={!desktopOverlay?.hasWebContents || isUnreachable}
- apps/desktop/src/preview/Manager.ts line 3499Resolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -2862,0 +2852,21 @@2852+ return {2853+ available: false,2854+ visible: true,2855+ tabId,2856+ url: tab.navStatus.kind === "Idle" ? null : tab.navStatus.url,2857+ title:2858+ tab.navStatus.kind === "LoadFailed"2859+ ? tab.navStatus.description || tab.navStatus.title2860+ : null,2861+ loading: false,2862+ };2863+ }2864+ if (tab.navStatus.kind === "LoadFailed") {2865+ return {2866+ available: false,2867+ visible: true,2868+ tabId,2869+ url: tab.navStatus.url,2870+ title: tab.navStatus.description || wc.getTitle() || tab.navStatus.title,2871+ loading: false,2872+ };
- @@ -3063,0 +3053,21 @@3053+ return {3054+ available: false,3055+ visible: true,3056+ tabId,3057+ url: tab.navStatus.kind === "Idle" ? null : tab.navStatus.url,3058+ title:3059+ tab.navStatus.kind === "LoadFailed"3060+ ? tab.navStatus.description || tab.navStatus.title3061+ : null,3062+ loading: false,3063+ };3064+ }3065+ if (tab.navStatus.kind === "LoadFailed") {3066+ return {3067+ available: false,3068+ visible: true,3069+ tabId,3070+ url: tab.navStatus.url,3071+ title: tab.navStatus.description || wc.getTitle() || tab.navStatus.title,3072+ loading: false,3073+ };
- apps/web/src/components/preview/previewNavigationReadiness.ts line 65Resolvedby gb1095(GitHub profile, opens in a new tab)@@ -59,4 +59,4 @@5959 if (readyState === "interactive" || readyState === "complete") return;6060 } else {6161 const status = await previewBridge.automation.status(runtimeTabId);62- if (status.available && !status.loading) return;62+ if (!status.loading) {
- apps/web/src/components/preview/previewNavigationReadiness.ts line 82Resolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -56,7 +59,20 @@5659 const readyState = await previewBridge.automation.evaluate(runtimeTabId, {5760 expression: "document.readyState",5861 });5962 if (readyState === "interactive" || readyState === "complete") return;6063 } else {6164 const status = await previewBridge.automation.status(runtimeTabId);62- if (status.available && !status.loading) return;65+ if (!status.loading) {66+ if (status.available) return;67+ // LoadFailed reports available:false with a live guest. A detached68+ // webContents is not a finished load.69+ if (state.desktopByTabId[tabId]?.hasWebContents) return;70+ throw new PreviewAutomationTargetUnavailableError({71+ requestId,72+ operation,73+ environmentId: threadRef.environmentId,74+ threadId: threadRef.threadId,75+ tabId,76+ bridgeAvailable: Boolean(previewBridge),77+ });78+ }apps/web/src/components/preview/previewAutomationStatus.ts line 24Resolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -0,0 +4,21 @@4+ * preview_status must not report a failed guest as a healthy automation target.5+ * Keep the requested URL so Retry/navigate still have something useful; the6+ * chrome-error interstitial is not a navigable address.7+ *8+ * When a live desktop status already says the guest is available, keep it.9+ * A stale LoadFailed snapshot can lag a successful retry.10+ */11+export function applyPreviewLoadFailureToAutomationStatus(12+ status: PreviewAutomationStatus,13+ navStatus: PreviewNavStatus | undefined,14+ options?: { readonly preferLiveAvailability?: boolean },15+): PreviewAutomationStatus {16+ if (navStatus?._tag !== "LoadFailed") return status;17+ if (options?.preferLiveAvailability && status.available) return status;18+ return {19+ ...status,20+ available: false,21+ loading: false,22+ url: navStatus.url,23+ title: navStatus.description || status.title,24+ };
- apps/desktop/src/preview/Manager.ts line 3499Resolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -3413,0 +3406,21 @@3406+ visible: true,3407+ tabId,3408+ url: tab.navStatus.kind === "Idle" ? null : tab.navStatus.url,3409+ title:3410+ tab.navStatus.kind === "LoadFailed"3411+ ? tab.navStatus.description || tab.navStatus.title3412+ : null,3413+ loading: false,3414+ attached: false,3415+ };3416+ }3417+ if (tab.navStatus.kind === "LoadFailed") {3418+ return {3419+ available: false,3420+ visible: true,3421+ tabId,3422+ url: tab.navStatus.url,3423+ title: tab.navStatus.description || wc.getTitle() || tab.navStatus.title,3424+ loading: false,3425+ attached: true,3426+ };
- apps/web/src/components/preview/PreviewAutomationHosts.tsx line 109OutdatedResolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -101,6 +102,8 @@101102 operation,102103 requestId,103104 });104- if (state.desktopByTabId[tabId] && previewBridge && isPreviewWebviewRendering(runtimeTabId)) {105- const status = await previewBridge.automation.status(runtimeTabId);106- if (status.available) return;105+ // Attachment only. LoadFailed still has a live guest and must stay106+ // reachable so navigate/retry can recover. Page health is reported by107+ // preview_status, not this wait.108+ if (state.desktopByTabId[tabId]?.hasWebContents && previewBridge) {109+ return;
- apps/web/src/components/preview/ThreadPreviewMiniPlayer.tsx lines 72 to 81Resolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -62,6 +63,11 @@6263 miniPlayer?.tabId === tabId && miniPlayer.size6364 ? miniPlayer.size6465 : PREVIEW_MINI_PLAYER_DEFAULT_SIZE;66+ const navStatus = snapshot?.navStatus ?? { _tag: "Idle" as const };67+ const isUnreachable = navStatus._tag === "LoadFailed";6568 const close = () => {6669 usePreviewMiniPlayerStore.getState().close(threadRef);6770 };71+ const retry = () => {72+ if (previewBridge && runtimeTabId) void previewBridge.refresh(runtimeTabId);73+ };
- apps/web/src/components/preview/ThreadPreviewMiniPlayer.tsx line 351OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -332,4 +348,4 @@332348 className="absolute inset-0"333349 />334350 <div className="pointer-events-none absolute inset-0 z-[49] rounded-xl ring-1 ring-inset ring-border/80" />335- {!desktopOverlay?.hasWebContents ? (351+ {isUnreachable && navStatus._tag === "LoadFailed" ? (
- apps/web/src/components/preview/ThreadPreviewMiniPlayer.tsx line 359Resolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -332,4 +348,10 @@332348 className="absolute inset-0"333349 />334350 <div className="pointer-events-none absolute inset-0 z-[49] rounded-xl ring-1 ring-inset ring-border/80" />335- {!desktopOverlay?.hasWebContents ? (351+ {isUnreachable && navStatus._tag === "LoadFailed" ? (352+ <PreviewMiniPlayerUnreachable353+ url={navStatus.url}354+ description={navStatus.description}355+ onRetry={retry}356+ onClose={close}357+ />apps/web/src/components/preview/ThreadPreviewMiniPlayer.tsx line 302OutdatedResolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -283,4 +296,7 @@283296 ? "Close popped-out preview"284297 : "Pop preview into separate window"285298 }286- disabled={!desktopOverlay?.hasWebContents}299+ disabled={300+ !desktopOverlay?.hasWebContents ||301+ (isUnreachable && !desktopOverlay.pictureInPicture)302+ }apps/web/src/components/preview/previewAutomationStatus.ts line 24Resolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -0,0 +5,21 @@5+ * Keep the requested URL so Retry/navigate still have something useful; the6+ * chrome-error interstitial is not a navigable address.7+ *8+ * When a live desktop status already says the guest is available or still9+ * loading, keep it. A stale LoadFailed snapshot can lag a retry that is10+ * attaching or already in flight.11+ */12+export function applyPreviewLoadFailureToAutomationStatus(13+ status: PreviewAutomationStatus,14+ navStatus: PreviewNavStatus | undefined,15+ options?: { readonly preferLiveAvailability?: boolean },16+): PreviewAutomationStatus {17+ if (navStatus?._tag !== "LoadFailed") return status;18+ if (options?.preferLiveAvailability && (status.available || status.loading)) return status;19+ return {20+ ...status,21+ available: false,22+ loading: false,23+ url: navStatus.url,24+ title: navStatus.description || status.title,25+ };
juliusmarminge closed this
Sign in to join this conversation.


Important
Review skipped#
Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the
.coderabbit.yamlfile in this repository. To trigger a single review, invoke the@coderabbitai reviewcommand.⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Team
Run ID:
895e3cbd-6d8b-463d-8bdd-9959f0ad3c29You can disable this status message by setting the
reviews.review_statustofalsein the CodeRabbit configuration file.Use the checkbox below for a quick retry:
Warning
Your free Security trial is over. An organization admin can upgrade to Advanced for continuous pull request security review or dismiss this notice.
Comment `@coderabbitai help` to get the list of available commands.