From 7337e2c5b09488c986cf89df416b5a799b893ed9 Mon Sep 17 00:00:00 2001 From: mawkone Date: Thu, 11 Jun 2026 12:07:39 -0700 Subject: [PATCH] fix(preview): re-trigger dev server ensure check when user clicks refresh button --- .../project/[projectId]/(home)/preview/page.tsx | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/vibn-frontend/app/[workspace]/project/[projectId]/(home)/preview/page.tsx b/vibn-frontend/app/[workspace]/project/[projectId]/(home)/preview/page.tsx index 44209798..04c55d88 100644 --- a/vibn-frontend/app/[workspace]/project/[projectId]/(home)/preview/page.tsx +++ b/vibn-frontend/app/[workspace]/project/[projectId]/(home)/preview/page.tsx @@ -153,6 +153,18 @@ export default function PreviewTab() { const deviceMode = usePreviewToolbarStore((s) => s.deviceMode); const refreshKey = usePreviewToolbarStore((s) => s.refreshKey); + // When the user clicks the manual refresh button in the toolbar, we don't + // just want to reload the iframe — we also want to trigger the same ghost/zombie + // check as the initial mount, in case the server died while they were looking at it. + const prevRefreshKeyRef = useRef(refreshKey); + useEffect(() => { + if (refreshKey === prevRefreshKeyRef.current) return; + prevRefreshKeyRef.current = refreshKey; + + // Reset the ensure called flag so the ensure effect (below) fires again. + ensureCalledRef.current = false; + }, [refreshKey]); + useLayoutEffect(() => { setIframeSrc(primaryRunning?.url ?? null); }, [primaryRunning?.url]);