fix(preview): re-trigger dev server ensure check when user clicks refresh button

This commit is contained in:
2026-06-11 12:07:39 -07:00
parent 2036df6c2b
commit 7337e2c5b0

View File

@@ -153,6 +153,18 @@ export default function PreviewTab() {
const deviceMode = usePreviewToolbarStore((s) => s.deviceMode); const deviceMode = usePreviewToolbarStore((s) => s.deviceMode);
const refreshKey = usePreviewToolbarStore((s) => s.refreshKey); 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(() => { useLayoutEffect(() => {
setIframeSrc(primaryRunning?.url ?? null); setIframeSrc(primaryRunning?.url ?? null);
}, [primaryRunning?.url]); }, [primaryRunning?.url]);