Skip to content

Commit 0ac1e45

Browse files
authored
fix(web): preserve preview session during builds (#136)
## Summary - keep the hidden preview-session exchange mounted while the branded build loader covers the starter scaffold - exchange the one-minute preview URL handoff for the renewable host cookie before long-running app builds finish - document the loader/session boundary ## Decision The preview iframe must stay unmounted until generated content is ready, but authorization cannot wait that long because URL handoffs expire after 60 seconds. The existing hidden session-refresh iframe now runs behind the loader, preserving the security boundary without exposing starter content. ## Verification - `pnpm turbo skills:build` - `pnpm turbo typecheck lint build` (55/55 tasks) - production reproduction confirmed the branded loader stayed visible while the original handoff expired, which this change directly prevents by performing the documented cookie exchange during that state
1 parent 085961b commit 0ac1e45

2 files changed

Lines changed: 16 additions & 11 deletions

File tree

apps/web/README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,10 @@ live iframe mounted so application state is preserved during ordinary use.
2727
Fresh app-builder projects keep the animated Cheatcode mark visible while the internal starter
2828
scaffold boots and the model generates the requested app. The persisted `app-preview-status`
2929
stream part reveals the iframe only when generated content is ready, and an iframe-load guard keeps
30-
the same mark in place until the final document has loaded. Existing project edits remain visible
31-
and continue hot-reloading normally.
30+
the same mark in place until the final document has loaded. While that mark is visible, the hidden
31+
session exchange remains mounted so the one-minute URL handoff becomes a renewable ten-minute
32+
host cookie before long-running builds finish. Existing project edits remain visible and continue
33+
hot-reloading normally.
3234

3335
## Public exports
3436

apps/web/src/components/preview/preview-side-panel.tsx

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -402,15 +402,18 @@ function AppTabContent({
402402
}) {
403403
if (previewPhase === "booting" || isGeneratedPreviewPending) {
404404
return (
405-
<PreviewDeviceFrame
406-
device={frameDevice}
407-
content={
408-
<CheatcodeLoader
409-
className="h-full min-h-[420px] min-w-0 flex-1 bg-bg-secondary"
410-
label={isGeneratedPreviewPending ? "Building preview…" : "Starting preview…"}
411-
/>
412-
}
413-
/>
405+
<>
406+
<PreviewSessionRefresh previewUrl={requestedIframeUrl} />
407+
<PreviewDeviceFrame
408+
device={frameDevice}
409+
content={
410+
<CheatcodeLoader
411+
className="h-full min-h-[420px] min-w-0 flex-1 bg-bg-secondary"
412+
label={isGeneratedPreviewPending ? "Building preview…" : "Starting preview…"}
413+
/>
414+
}
415+
/>
416+
</>
414417
);
415418
}
416419
if (previewPhase === "error") {

0 commit comments

Comments
 (0)