diff --git a/src/routes/+layout.svelte b/src/routes/+layout.svelte index 97bdc76dcc..fa96bf8e5a 100644 --- a/src/routes/+layout.svelte +++ b/src/routes/+layout.svelte @@ -38,8 +38,28 @@ } } + async function syncStudioPrompt() { + if (!browser || resolvedProfile.id !== ProfileMode.STUDIO) return; + + const currentUrl = new URL(window.location.href); + const promptParam = currentUrl.searchParams.get('prompt'); + + if (promptParam) { + sessionStorage.setItem('studioPrompt', promptParam); + return; + } + + const storedPrompt = sessionStorage.getItem('studioPrompt'); + if (!storedPrompt) return; + + currentUrl.searchParams.set('prompt', storedPrompt); + await goto(currentUrl.toString(), { replaceState: true, noScroll: true }); + sessionStorage.removeItem('studioPrompt'); + } + onMount(async () => { updateViewport(); + await syncStudioPrompt(); // handle sources if (isCloud) { const urlParams = page.url.searchParams; @@ -116,6 +136,7 @@ }); afterNavigate((navigation) => { + syncStudioPrompt(); if (navigation.type !== 'enter' && navigation.from?.route?.id !== navigation.to.route.id) { trackPageView(navigation.to.route.id); }