fix: prevent raw app iframe reload on userStore refresh (#8455)

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Ruben Fiszel
2026-03-19 14:17:06 +00:00
committed by GitHub
parent 278c8fe416
commit 4e59a1a166
2 changed files with 10 additions and 3 deletions

View File

@@ -3,7 +3,7 @@
import RawAppBackgroundRunner from './RawAppBackgroundRunner.svelte'
import type { Runnable } from './rawAppPolicy'
import { htmlContent } from './utils'
import { onMount } from 'svelte'
import { onMount, untrack } from 'svelte'
interface Props {
workspace: string
@@ -26,10 +26,14 @@
// Use blob URL instead of srcDoc to give the iframe a proper origin.
// srcDoc iframes have "null" origin which breaks URL constructor in routers.
// untrack(user) so that userStore refreshes don't regenerate the blob URL
// and cause the iframe to fully reload (losing all state).
// The user context is only needed for initial render.
let blobUrl = $derived.by(() => {
if (!secret) return undefined
const u = untrack(() => user)
const baseUrl = typeof window !== 'undefined' ? window.location.origin : ''
const html = htmlContent(workspace, secret, { ctx: user, workspace }, baseUrl, initialHash)
const html = htmlContent(workspace, secret, { ctx: u, workspace }, baseUrl, initialHash)
const blob = new Blob([html], { type: 'text/html' })
return URL.createObjectURL(blob)
})

View File

@@ -50,6 +50,7 @@
import { syncTutorialsTodos } from '$lib/tutorialUtils'
import { ArrowLeft, Search, WandSparkles } from 'lucide-svelte'
import { getUserExt } from '$lib/user'
import { deepEqual } from 'fast-equals'
import { twMerge } from 'tailwind-merge'
import OperatorMenu from '$lib/components/sidebar/OperatorMenu.svelte'
import GlobalSearchModal from '$lib/components/search/GlobalSearchModal.svelte'
@@ -125,7 +126,9 @@
console.error('Could not persist workspace to local storage', e)
}
const user = await getUserExt(workspace)
userStore.set(user)
if (!deepEqual(user, $userStore)) {
userStore.set(user)
}
if (isCloudHosted() && user?.is_admin) {
isPremiumStore.set(await WorkspaceService.getIsPremium({ workspace }))
}