Skip to content

Commit b5dc4ce

Browse files
committed
fix: handle Storybook iframe.html URL for workspace restoration
In Storybook, the pathname is /iframe.html with query params for story selection. This should still restore the selected workspace from localStorage.
1 parent c1a5827 commit b5dc4ce

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/browser/hooks/useRouterUrlSync.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,17 @@ export function parseInitialUrl(): string {
2323
return `/project?path=${encodeURIComponent(projectPath)}`;
2424
}
2525

26-
// If URL is at root (dev server), about:blank (tests), or file:// path (packaged Electron),
27-
// check localStorage for saved workspace from previous session
26+
// If URL is at root (dev server), about:blank (tests), file:// path (packaged Electron),
27+
// or iframe.html (Storybook), check localStorage for saved workspace from previous session
2828
const isRootOrFileUrl =
2929
pathname === "/" ||
3030
pathname === "" ||
3131
pathname === "blank" ||
3232
pathname.endsWith("index.html") ||
33-
pathname.endsWith(".html");
34-
if (isRootOrFileUrl && !search) {
33+
pathname.endsWith("iframe.html");
34+
// For iframe.html (Storybook), ignore search params when checking for root URL
35+
const effectiveSearch = pathname.endsWith("iframe.html") ? "" : search;
36+
if (isRootOrFileUrl && !effectiveSearch) {
3537
const savedWorkspace = readPersistedState<WorkspaceSelection | null>(
3638
SELECTED_WORKSPACE_KEY,
3739
null

0 commit comments

Comments
 (0)