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]);