AI-native design editor. Open-source Figma alternative.
fix(cloud): show a link's document only once it is ready (#1460)
Danila Poyarkovd61f8516fb83
diff --git a/changes/1460/added.md b/changes/1460/added.mdnew file mode 100644index 000000000..b78cda894--- /dev/null+++ b/changes/1460/added.md@@ -0,0 +1 @@+- `useCanvas` in `@open-pencil/vue` takes an `onFailed` callback for a canvas that cannot start, as when CanvasKit fails to load.diff --git a/changes/1460/fixed.md b/changes/1460/fixed.mdnew file mode 100644index 000000000..5c3fc7d1f--- /dev/null+++ b/changes/1460/fixed.md@@ -0,0 +1,5 @@+- A document that fails to open from Home leaves Home in place instead of an empty tab.+- The startup splash uses the app's theme, so it no longer changes colour as the app starts on a light system.+- A document opened on a slow connection waits for the canvas to load instead of failing with “The operation was timed out”.+- Storage downloads that take longer than 20 seconds finish instead of failing; only a transfer that stops for 20 seconds fails.+- The startup splash stops animating when the system asks for reduced motion.diff --git a/changes/1460/performance.md b/changes/1460/performance.mdnew file mode 100644index 000000000..524fcf262--- /dev/null+++ b/changes/1460/performance.md@@ -0,0 +1 @@+- The canvas engine starts loading as the app starts, so a document opened on a slow connection shows sooner.diff --git a/cloud.html b/cloud.htmlindex 3b96ff503..6cc3d8a75 100644--- a/cloud.html+++ b/cloud.html@@ -8,16 +8,74 @@<link rel="icon" type="image/svg+xml" href="/brand/favicon.svg" /><link rel="icon" type="image/png" sizes="96x96" href="/brand/favicon-96x96.png" /><style>- html, body, #app { height: 100%; margin: 0; }- body { background: #1e1e1e; }+ :root {+ --loader-bg: #1e1e1e;+ --loader-fg: 255, 255, 255;+ }@media (prefers-color-scheme: light) {- body { background: #f3f4f6; }+ :root {+ --loader-bg: #f3f4f6;+ --loader-fg: 32, 33, 36;+ }+ }+ html[data-theme='dark'] {+ --loader-bg: #1e1e1e;+ --loader-fg: 255, 255, 255;+ }+ html[data-theme='light'] {+ --loader-bg: #f3f4f6;+ --loader-fg: 32, 33, 36;+ }+ html, body, #app { height: 100%; margin: 0; }+ body { background: var(--loader-bg); }+ #boot-splash {+ position: fixed;+ inset: 0;+ display: flex;+ align-items: center;+ justify-content: center;+ z-index: 9999;+ color: rgb(var(--loader-fg));+ background: var(--loader-bg);+ }+ #boot-splash img { width: 40px; height: 40px; }+ #boot-splash .bar {+ position: absolute;+ bottom: 50%;+ left: 50%;+ transform: translate(-50%, 40px);+ width: 100px;+ height: 2px;+ background: rgba(var(--loader-fg), 0.08);+ border-radius: 1px;+ overflow: hidden;+ }+ #boot-splash .bar::after {+ content: '';+ display: block;+ height: 100%;+ width: 40%;+ background: rgba(var(--loader-fg), 0.25);+ border-radius: 1px;+ animation: slide 1s ease-in-out infinite;+ }+ @keyframes slide {+ 0% { transform: translateX(-100%); }+ 100% { transform: translateX(350%); }+ }+ @media (prefers-reduced-motion: reduce) {+ #boot-splash .bar::after { animation: none; }}</style></head><body>- <div id="app"></div>+ <div id="app">+ <div id="boot-splash">+ <img src="/brand/app-icon.svg" width="40" height="40" alt="OpenPencil" />+ <div class="bar"></div>+ </div>+ </div><script type="module" src="/src/cloud/main.ts"></script></body></html>diff --git a/index.html b/index.htmlindex 3eca6d31a..2ee3c4809 100644--- a/index.html+++ b/index.html@@ -64,6 +64,9 @@0% { transform: translateX(-100%); }100% { transform: translateX(350%); }}+ @media (prefers-reduced-motion: reduce) {+ #boot-splash .bar::after { animation: none; }+ }/* Pre-boot support notice; the app CSS never loads when it shows. */#boot-notice {box-sizing: border-box;@@ -103,6 +106,14 @@-webkit-user-select: text;}</style>+ <script>+ // The splash takes the app's theme, dark unless chosen otherwise (`src/app/shell/theme.ts`),+ // so the page does not change colour when the app starts.+ try {+ const theme = localStorage.getItem('open-pencil:theme')+ if (theme !== 'auto') document.documentElement.dataset.theme = theme === 'light' ? 'light' : 'dark'+ } catch {}+ </script></head><body>diff --git a/packages/docs/development/cloud.md b/packages/docs/development/cloud.mdindex 502cb9237..f69a89574 100644--- a/packages/docs/development/cloud.md+++ b/packages/docs/development/cloud.md@@ -490,6 +490,14 @@ send them to. Peer-to-peer rooms move to `/rooms/:id` so "share" names a sharedcost is that a browser editor at any other address cannot keep a Cloud document in its addressbar; every server serves its own editor, and the desktop app gets links through `openpencil://`.+**2026-10 · A link shows nothing until its document does.** A document link asks someone signed+out to sign in on the server's page before the editor loads, and comes back to the document. A+link that opens, or a sign-in the tab comes back from, keeps the boot splash's look over the+window until the document is drawn, over Home rather than an empty document, so a link that+fails or waits for a sign-in leaves the person on Home. A tab that holds its document never shows+the room's joining screen, since the room's state can arrive in parts. The cost is a longer+splash on a slow connection in place of an editor that fills in.+**2026-10 · Workspaces are deleted at once, not after a grace period.** GitLab keeps a deleted groupfor 30 days so it can be restored; a Cloud workspace can only be deleted once it holds nodocuments, and deleted documents already have their own retention, so a delay would protectdiff --git a/packages/vue/src/canvas/surface/kit-loader.ts b/packages/vue/src/canvas/surface/kit-loader.tsindex e145b2374..fae2d7560 100644--- a/packages/vue/src/canvas/surface/kit-loader.ts+++ b/packages/vue/src/canvas/surface/kit-loader.ts@@ -9,10 +9,12 @@ type CanvasKitLoaderOptions = {canvasRef: Ref<HTMLCanvasElement | null>lifecycle: { destroyed: boolean }setCanvasKit: (ck: CanvasKit | null) => void- createSurface: (canvas: HTMLCanvasElement) => void+ /** Whether a surface the canvas can draw on was made. */+ createSurface: (canvas: HTMLCanvasElement) => booleanloadFonts: () => Promise<unknown> | undefinedrenderNow: () => voidonReady?: () => void+ onFailed?: (error: unknown) => void}export function useCanvasKitLoader({@@ -22,7 +24,8 @@ export function useCanvasKitLoader({createSurface,loadFonts,renderNow,- onReady+ onReady,+ onFailed}: CanvasKitLoaderOptions) {const isDestroyed = () => lifecycle.destroyed@@ -36,7 +39,7 @@ export function useCanvasKitLoader({await new Promise((resolve) => {requestAnimationFrame(resolve)})- createSurface(canvas)+ if (!createSurface(canvas)) throw new Error('WebGL is unavailable, so the canvas cannot draw')await loadFonts()if (isDestroyed()) returnrenderNow()@@ -45,7 +48,15 @@ export function useCanvasKitLoader({// Start once there is a canvas: a CanvasSurface child hands its element over after the// root has mounted, so waiting for mount alone would find none.- whenever(canvasRef, () => void init(), { once: true, flush: 'post', immediate: true })+ whenever(+ canvasRef,+ () =>+ void init().catch((error: unknown) => {+ if (!onFailed) throw error+ if (!isDestroyed()) onFailed(error)+ }),+ { once: true, flush: 'post', immediate: true }+ )onScopeDispose(() => {lifecycle.destroyed = truediff --git a/packages/vue/src/canvas/surface/lifecycle.ts b/packages/vue/src/canvas/surface/lifecycle.tsindex 20559c4da..e450d54c0 100644--- a/packages/vue/src/canvas/surface/lifecycle.ts+++ b/packages/vue/src/canvas/surface/lifecycle.ts@@ -100,9 +100,9 @@ export function createCanvasSurfaceManager({function createSurface(canvas: HTMLCanvasElement,{ reloadFonts = false }: { reloadFonts?: boolean } = {}- ) {+ ): boolean {const ck = getCanvasKit()- if (!ck) return+ if (!ck) return falseif (state.renderer) editor.removeCanvasRenderer(state.renderer)state.renderer?.destroy()@@ -126,7 +126,7 @@ export function createCanvasSurfaceManager({const surface = result.surfaceif (!surface) {canvas.dataset.surfaceError = 'webgl'- return+ return false}const glCtx = canvas.getContext('webgl2') ?? null@@ -152,6 +152,7 @@ export function createCanvasSurfaceManager({return undefined})}+ return true}function acknowledgePresentation() {@@ -276,7 +277,8 @@ export function useCanvasSurfaceLifecycle({setCanvasKit,getCanvasKitValue,lifecycle,- onReady+ onReady,+ onFailed}: {canvasRef: Ref<HTMLCanvasElement | null>surface: ReturnType<typeof createCanvasSurfaceManager>@@ -284,6 +286,7 @@ export function useCanvasSurfaceLifecycle({getCanvasKitValue: () => CanvasKit | nulllifecycle: { destroyed: boolean }onReady?: () => void+ onFailed?: (error: unknown) => void}) {useCanvasKitLoader({canvasRef,@@ -292,7 +295,8 @@ export function useCanvasSurfaceLifecycle({createSurface: surface.createSurface,loadFonts: () => surface.getRenderer()?.loadFonts(surface.renderNow),renderNow: surface.renderNow,- onReady+ onReady,+ onFailed})const { cancelResize } = useCanvasResizeObserver({diff --git a/packages/vue/src/canvas/surface/types.ts b/packages/vue/src/canvas/surface/types.tsindex 8f3df3ad2..8e5c2ce1b 100644--- a/packages/vue/src/canvas/surface/types.ts+++ b/packages/vue/src/canvas/surface/types.ts@@ -42,6 +42,11 @@ export interface UseCanvasOptions {* Called once the rendering surface is ready.*/onReady?: () => void+ /**+ * Called instead of `onReady` when the surface cannot start, as when CanvasKit fails to+ * load. Without it the failure is left unhandled.+ */+ onFailed?: (error: unknown) => void/*** Reports the color space the canvas actually presents, including fallbacks, or null* when no surface could be configured.diff --git a/packages/vue/src/canvas/surface/use.ts b/packages/vue/src/canvas/surface/use.tsindex db5e1272d..b4d15d2cc 100644--- a/packages/vue/src/canvas/surface/use.ts+++ b/packages/vue/src/canvas/surface/use.ts@@ -48,7 +48,8 @@ export function useCanvas(setCanvasKit: (value) => {ck = value},- onReady: options?.onReady+ onReady: options?.onReady,+ onFailed: options?.onFailed})// The scene surface plays shaders in preview; an overlay surface draws none.diff --git a/src/app/cloud-portal/site.ts b/src/app/cloud-portal/site.tsindex 7bbf7015f..0409b2be6 100644--- a/src/app/cloud-portal/site.ts+++ b/src/app/cloud-portal/site.ts@@ -15,14 +15,16 @@ import { parseCloudLinkPath, type CloudAccountStatus } from '@open-pencil/cloud/*/export const WELCOME_PATH = '/welcome'+/** The server's sign-in page, which goes on to its `redirect` afterwards. */+const SIGN_IN_PATH = '/auth/sign-in'+/**- * Whether an address is a link to a document, a shared file, or an invitation, which sign in on- * their own; a shared file or invitation carries its secret.+ * Whether an address is a link to a shared file or an invitation, which carries its secret and+ * opens on its own, signed in or not.*/-export function isCloudLink(url: URL): boolean {+export function isSecretCloudLink(url: URL): boolean {const path = parseCloudLinkPath(url.pathname)- if (!path) return false- return path.kind === 'documents' || url.hash.length > 1+ return path !== null && path.kind !== 'documents' && url.hash.length > 1}/** Whether this browser chose to use the server's editor without an account. */@@ -45,17 +47,25 @@ export type SiteAccount = CloudAccountStatus | null | 'unreachable'* Where a visit to an editor page belongs: null for the editor, or the welcome page, which sends* an account waiting for review on to its standing page. An account that may use the server* gets the editor, and so does an unreachable server, since the editor works without it.+ * A document's link needs an account: signed out, it goes to sign in and comes back after.* Without an account, the root asks first unless this browser chose the local editor, and every* page does where the server does not allow it.*/export function siteDestination(visit: {path: string+ /** The address's query, which a document link keeps through signing in. */+ search?: stringaccount: SiteAccountlocalEditor: booleanchoseLocalEditor: boolean}): string | null {const { path, account } = visitif (account === 'unreachable' || account?.state === 'active') return null+ if (parseCloudLinkPath(path)?.kind === 'documents') {+ if (account) return WELCOME_PATH+ const redirect = path + (visit.search ?? '')+ return `${SIGN_IN_PATH}?${new URLSearchParams({ redirect })}`+ }if (visit.localEditor && (path !== '/' || visit.choseLocalEditor)) return nullreturn WELCOME_PATH}@@ -95,13 +105,14 @@ async function signedInAccount(api: CloudPortalClient): Promise<SiteAccount> {* unreachable, and the editor opens.*/export async function enterCloudSite(location: Location = globalThis.location): Promise<boolean> {- if (isCloudLink(new URL(location.href))) return true+ if (isSecretCloudLink(new URL(location.href))) return trueconst [discovery, account] = await Promise.all([discoverCloud(location.origin).catch(() => null),signedInAccount(createCloudPortalClient({ baseURL: location.origin }))])const destination = siteDestination({path: location.pathname,+ search: location.search,account,localEditor: discovery?.localEditor ?? false,choseLocalEditor: localEditor.valuediff --git a/src/app/cloud/connect/flow.ts b/src/app/cloud/connect/flow.tsindex 6253fa5aa..c15fa3b4d 100644--- a/src/app/cloud/connect/flow.ts+++ b/src/app/cloud/connect/flow.ts@@ -134,6 +134,21 @@ export function openCloudConnect(options: { kind?: CloudServer['kind']; serverIdcloudConnectStep.value = 'server'}+/**+ * Signs in to a known server to open something only an account may: on the server's own editor,+ * its sign-in page, in place of this one and coming back to it, so no dialog stands in front of an+ * editor with nothing in it; anywhere else the connect dialog.+ */+export async function signInToOpen(serverId: string): Promise<void> {+ const server = findCloudServer(serverId)+ const discovery = server ? await discoverCloudServer(server.url).catch(() => null) : null+ if (discovery && cloudSignInRoute(discovery) === 'redirect') {+ redirectToCloudSignIn(serverId, discovery, { replace: true })+ return+ }+ openCloudConnect({ serverId })+}+/** Checks the chosen server answers as OpenPencil Cloud before asking anyone to sign in. */export function continueCloudConnect(): void {const url =@@ -194,7 +209,7 @@ export async function signInToCloudServer(method: CloudSignInMethod): Promise<voconst server = await addCloudServer({ kind: target.kind, url: target.url })if (attempt !== generation) returnif (cloudSignInRoute(target.discovery) === 'redirect') {- redirectToCloudSignIn(server.id, target.discovery, method)+ redirectToCloudSignIn(server.id, target.discovery, { method })return}cloudConnectStep.value = 'device'diff --git a/src/app/cloud/documents/link.ts b/src/app/cloud/documents/link.tsindex c88e6a314..8cc9b09cc 100644--- a/src/app/cloud/documents/link.ts+++ b/src/app/cloud/documents/link.ts@@ -14,10 +14,10 @@ import { toast } from '@/app/shell/ui'import { openStorageDocumentInNewTab } from '@/app/tabs'import { IS_BROWSER } from '@/constants'-import { cloudSignedIn, openCloudConnect } from '../connect/flow'+import { cloudSignedIn, signInToOpen } from '../connect/flow'import { cloudServerHost, normalizeCloudServerURL } from '../servers/address'import { cloudServerForLink, findCloudServer, isCloudSiteServer } from '../servers/store'-import { cloudAPIClient, cloudConnection } from '../sessions/connection'+import { cloudAPIClient, recheckedCloudConnection } from '../sessions/connection'import { CLOUD_STORAGE_PROVIDER_ID } from '../sessions/token'import { openVersionHistory, previewVersion, versionHistoryOf } from '../versions/history'import { isCloudBinding } from './status'@@ -99,10 +99,14 @@ export async function openCloudDocumentLink(link: CloudDocumentLink): Promise<votoast.error(messages.documentLinkUnknownServer({ host: cloudServerHost(url) }))return}- const connection = cloudConnection(server.id)+ const connection = await recheckedCloudConnection(server)+ if (connection.state === 'unreachable') {+ toast.error(messages.errorUnreachableHeading)+ return+ }if (connection.state !== 'signed-in' || !connection.discovery) {stored.value = JSON.stringify(link satisfies CloudDocumentLink)- openCloudConnect({ serverId: server.id })+ await signInToOpen(server.id)return}stored.value = null@@ -141,13 +145,18 @@ export function forgetCloudDocumentLink(): void {stored.value = null}+/** Opens the document link kept while signing in to `serverId`, if one was. */+export async function reopenCloudDocumentLink(serverId: string): Promise<void> {+ const parsed = v.safeParse(v.pipe(v.string(), v.parseJson(), linkSchema), stored.value ?? '')+ if (!parsed.success) return+ const url = normalizeCloudServerURL(parsed.output.server)+ if (url !== findCloudServer(serverId)?.url) return+ await openCloudDocumentLink(parsed.output)+}+/** Picks a document link back up once signing in for it finished. */export function resumeCloudDocumentLink(): () => void {return watch(cloudSignedIn, (signedIn) => {- const parsed = v.safeParse(v.pipe(v.string(), v.parseJson(), linkSchema), stored.value ?? '')- if (!signedIn || !parsed.success) return- const url = normalizeCloudServerURL(parsed.output.server)- if (url !== findCloudServer(signedIn.serverId)?.url) return- void openCloudDocumentLink(parsed.output)+ if (signedIn) void reopenCloudDocumentLink(signedIn.serverId)})}diff --git a/src/app/cloud/documents/save.ts b/src/app/cloud/documents/save.tsindex 4d7ae435d..267576916 100644--- a/src/app/cloud/documents/save.ts+++ b/src/app/cloud/documents/save.ts@@ -8,7 +8,7 @@ import {import { openCloudConnect } from '../connect/flow'import { cloudServerHost } from '../servers/address'import { cloudServers, findCloudServer } from '../servers/store'-import { cloudAPIClient, cloudConnection, refreshCloudConnection } from '../sessions/connection'+import { cloudAPIClient, checkedCloudConnection, cloudConnection } from '../sessions/connection'import { CLOUD_STORAGE_PROVIDER_ID } from '../sessions/token'/**@@ -16,10 +16,7 @@ import { CLOUD_STORAGE_PROVIDER_ID } from '../sessions/token'* being checked are waited for, so a fresh start does not look signed out.*/export async function cloudSaveDestinations(): Promise<SaveDestination[]> {- const checking = cloudServers.value.filter(- (server) => cloudConnection(server.id).state === 'checking'- )- await Promise.all(checking.map((server) => refreshCloudConnection(server)))+ await Promise.all(cloudServers.value.map((server) => checkedCloudConnection(server)))return cloudServers.value.flatMap((server) => {const connection = cloudConnection(server.id)if (connection.state !== 'signed-in') return []diff --git a/src/app/cloud/integration/index.ts b/src/app/cloud/integration/index.tsindex 3f8a644e7..a265838eb 100644--- a/src/app/cloud/integration/index.ts+++ b/src/app/cloud/integration/index.ts@@ -19,6 +19,7 @@ export { isCloudBinding } from '../documents/status'export { openCloudShare } from '../sharing/dialog'export { cloudSaveDestinations, cloudUploadFailure, signInToSaveTo } from '../documents/save'export { useHomeCloud } from '../home'+export { openingCloudLink } from '../sessions/startup'export { CLOUD_STORAGE_PROVIDER_ID } from '../sessions/token'export {isVersionHistoryOpen,diff --git a/src/app/cloud/integration/off/index.ts b/src/app/cloud/integration/off/index.tsindex fe7cd75f8..4c37db46b 100644--- a/src/app/cloud/integration/off/index.ts+++ b/src/app/cloud/integration/off/index.ts@@ -18,6 +18,9 @@ export const CLOUD_INCLUDED: boolean = false// Still the identifier Home and Save to compare locations with; no provider registers it.export { CLOUD_STORAGE_PROVIDER_ID } from '@/app/cloud/sessions/token'+/** Nothing opens from a Cloud link without Cloud. */+export const openingCloudLink = computed(() => false)+export type { CloudAIWorkspace } from '@/app/cloud/ai/access'export const cloudAIAvailable = computed(() => false)diff --git a/src/app/cloud/links.ts b/src/app/cloud/links.tsindex b266397d3..5f9cbfa2a 100644--- a/src/app/cloud/links.ts+++ b/src/app/cloud/links.ts@@ -15,7 +15,7 @@ import { isTauri } from '@/app/tauri/env'import { bindDesktopLinkQueue } from '@/app/tauri/link-queue'import { IS_BROWSER } from '@/constants'-import { cloudSignedIn, openCloudConnect } from './connect/flow'+import { cloudSignedIn, signInToOpen } from './connect/flow'import { beginCloudInvitation } from './invitations/flow'import { cloudServerHost, normalizeCloudServerURL } from './servers/address'import { cloudServerForLink, findCloudServer } from './servers/store'@@ -80,7 +80,7 @@ async function signInForLink(link: CloudLink): Promise<void> {return}signingIn.value = JSON.stringify(link satisfies CloudLink)- openCloudConnect({ serverId: server.id })+ await signInToOpen(server.id)}/** Opens an invitation's dialog, or a shared document. */@@ -114,17 +114,22 @@ export async function openCloudLink(link: CloudLink): Promise<void> {}}+/** Opens the shared link kept while signing in to `serverId`, if one was. */+export async function reopenCloudLink(serverId: string): Promise<void> {+ const parsed = v.safeParse(+ v.pipe(v.string(), v.parseJson(), cloudLinkSchema),+ signingIn.value ?? ''+ )+ if (!parsed.success) return+ const url = normalizeCloudServerURL(parsed.output.server)+ if (url !== findCloudServer(serverId)?.url) return+ await openCloudLink(parsed.output)+}+/** Opens a shared link again once signing in for it finished. */export function resumeCloudLink(): () => void {return watch(cloudSignedIn, (signedIn) => {- const parsed = v.safeParse(- v.pipe(v.string(), v.parseJson(), cloudLinkSchema),- signingIn.value ?? ''- )- if (!signedIn || !parsed.success) return- const url = normalizeCloudServerURL(parsed.output.server)- if (url !== findCloudServer(signedIn.serverId)?.url) return- void openCloudLink(parsed.output)+ if (signedIn) void reopenCloudLink(signedIn.serverId)})}diff --git a/src/app/cloud/sessions/connection.ts b/src/app/cloud/sessions/connection.tsindex 3cf639356..99424b975 100644--- a/src/app/cloud/sessions/connection.ts+++ b/src/app/cloud/sessions/connection.ts@@ -52,6 +52,8 @@ const INITIAL: CloudConnection = {export const cloudConnections = shallowRef<Readonly<Record<string, CloudConnection>>>({})const discoveries = new Map<string, Promise<CloudDiscovery>>()const generations = new Map<string, number>()+/** Each server's latest check while it runs. */+const checks = new Map<string, Promise<CloudConnection>>()export function cloudConnection(serverId: string): CloudConnection {return cloudConnections.value[serverId] ?? INITIAL@@ -125,9 +127,43 @@ async function signedInConnection(}/** Asks the server where this app stands and publishes the answer. */-export async function refreshCloudConnection(server: CloudServer): Promise<CloudConnection> {+export function refreshCloudConnection(server: CloudServer): Promise<CloudConnection> {const generation = (generations.get(server.id) ?? 0) + 1generations.set(server.id, generation)+ const check = askServer(server, generation)+ checks.set(server.id, check)+ void check.finally(() => {+ if (checks.get(server.id) === check) checks.delete(server.id)+ })+ return check+}++/**+ * Where this app stands with a server once the check under way, if any, finishes. Something that+ * only needs the answer waits for that check rather than starting another, which would throw the+ * first one's answer away and leave whoever waits on it reading `checking`.+ */+export function checkedCloudConnection(server: CloudServer): Promise<CloudConnection> {+ const running = checks.get(server.id)+ if (running) return running+ const connection = cloudConnection(server.id)+ return connection.state === 'checking'+ ? refreshCloudConnection(server)+ : Promise.resolve(connection)+}++/**+ * Where this app stands with a server now: signed in as last checked, or else the answer of the+ * check under way or of a new one, since a server out of reach or a session that ended may have+ * come back since the last answer.+ */+export function recheckedCloudConnection(server: CloudServer): Promise<CloudConnection> {+ const connection = cloudConnection(server.id)+ if (connection.state === 'signed-in') return Promise.resolve(connection)+ return checks.get(server.id) ?? refreshCloudConnection(server)+}++async function askServer(server: CloudServer, generation: number): Promise<CloudConnection> {const previous = cloudConnection(server.id)publish(server.id, { ...previous, state: 'checking', failure: null })let next: CloudConnection@@ -149,6 +185,7 @@ export async function refreshCloudConnection(server: CloudServer): Promise<Cloud/** Drops what the app knows about a server's session, after signing out or removing it. */export function forgetCloudConnection(serverId: string): void {generations.set(serverId, (generations.get(serverId) ?? 0) + 1)+ checks.delete(serverId)const { [serverId]: _removed, ...rest } = cloudConnections.valuecloudConnections.value = rest}diff --git a/src/app/cloud/sessions/sign-in.ts b/src/app/cloud/sessions/sign-in.tsindex 5cd91ace9..7db4380b1 100644--- a/src/app/cloud/sessions/sign-in.ts+++ b/src/app/cloud/sessions/sign-in.ts@@ -35,11 +35,23 @@ function returnURL(): string {export function redirectToCloudSignIn(serverId: string,discovery: CloudDiscovery,- method: CloudSignInMethod+ options: {+ /** How to sign in; the pages offer every way when none is chosen. */+ method?: CloudSignInMethod+ /** Leaves this page out of history, as one that showed nothing yet. */+ replace?: boolean+ } = {}): void {pendingSignIn.value = serverId- const provider = method === 'email' ? undefined : method- globalThis.location.assign(cloudSignInURL(discovery, returnURL(), provider))+ const provider = options.method === 'email' ? undefined : options.method+ const url = cloudSignInURL(discovery, returnURL(), provider)+ if (options.replace) globalThis.location.replace(url)+ else globalThis.location.assign(url)+}++/** Whether this tab left, or is leaving, to sign in, and has yet to pick the server up again. */+export function leftForCloudSignIn(): boolean {+ return pendingSignIn.value !== null}/** The server this tab left to sign in to, once, after coming back. */diff --git a/src/app/cloud/sessions/startup.ts b/src/app/cloud/sessions/startup.tsindex 0f07574f6..671d19d1a 100644--- a/src/app/cloud/sessions/startup.ts+++ b/src/app/cloud/sessions/startup.ts@@ -1,4 +1,6 @@-import { IS_CLOUD_SITE } from '@/constants'+import { ref } from 'vue'++import { IS_BROWSER, IS_CLOUD_SITE } from '@/constants'import { checkCloudAvailability } from '../availability'import { cloudSignedIn } from '../connect/flow'@@ -6,6 +8,7 @@ import {forgetCloudDocumentLink,openCloudDocumentLink,readCloudDocumentLink,+ reopenCloudDocumentLink,resumeCloudDocumentLink} from '../documents/link'import { resumeCloudInvitation } from '../invitations/flow'@@ -14,11 +17,29 @@ import {forgetCloudLink,openCloudLink,readCloudLink,+ reopenCloudLink,resumeCloudLink} from '../links'import { addCloudSiteServer, cloudServers, findCloudServer } from '../servers/store'-import { refreshCloudConnection } from './connection'-import { takePendingCloudSignIn } from './sign-in'+import { cloudConnection, refreshCloudConnection } from './connection'+import { leftForCloudSignIn, takePendingCloudSignIn } from './sign-in'++/**+ * Whether the tab is still opening what it started with: a document or shared file its address+ * links to, or whatever a sign-in it comes back from was for. The window shows only that it is+ * opening until the document shows or nothing is left to open, so no empty editor or Home comes+ * first.+ */+export const openingCloudLink = ref(IS_BROWSER && opensWithCloudDocument())++function opensWithCloudDocument(): boolean {+ const address = new URL(globalThis.location.href)+ return (+ readCloudDocumentLink(address) !== null ||+ readCloudLink(address)?.kind === 'share' ||+ leftForCloudSignIn()+ )+}/*** Adds the server that serves this editor, if one does, checks every known server once the app@@ -30,25 +51,40 @@ export async function startCloudSessions(options: {/** Leaves a Cloud link's address, so its secret is not kept in history. */leaveLinkAddress(): Promise<unknown>}): Promise<void> {- if (IS_CLOUD_SITE) await addCloudSiteServer()- void checkCloudAvailability(globalThis.location.href)- const address = new URL(globalThis.location.href)- const link = readCloudLink(address)- const documentLink = readCloudDocumentLink(address)- // The link the tab opens with is the one to open, not one kept from an earlier sign-in.- if (documentLink || link) {- forgetCloudDocumentLink()- forgetCloudLink()- }- resumeCloudDocumentLink()- resumeCloudLink()- if (link) await options.leaveLinkAddress()+ // Taken first, so a sign-in this tab leaves for below is the only one left pending.const pending = takePendingCloudSignIn()- await Promise.all(cloudServers.value.map((server) => refreshCloudConnection(server)))- const server = pending ? findCloudServer(pending) : null- if (server) cloudSignedIn.value = { serverId: server.id }- if (link?.kind !== 'invitations') resumeCloudInvitation()- if (link) await openCloudLink(link)- if (documentLink) await openCloudDocumentLink(documentLink)+ try {+ if (IS_CLOUD_SITE) await addCloudSiteServer()+ void checkCloudAvailability(globalThis.location.href)+ const address = new URL(globalThis.location.href)+ const link = readCloudLink(address)+ const documentLink = readCloudDocumentLink(address)+ // The link the tab opens with is the one to open, not one kept from an earlier sign-in.+ if (documentLink || link) {+ forgetCloudDocumentLink()+ forgetCloudLink()+ }+ if (link) await options.leaveLinkAddress()+ await Promise.all(cloudServers.value.map((server) => refreshCloudConnection(server)))+ const server = pending ? findCloudServer(pending) : null+ if (server) cloudSignedIn.value = { serverId: server.id }+ if (server && cloudConnection(server.id).state === 'signed-in') {+ // What the sign-in was for opens before the window shows anything.+ await Promise.all([reopenCloudDocumentLink(server.id), reopenCloudLink(server.id)])+ } else if (server) {+ // Back from the sign-in page without signing in: what it was for is not asked for again.+ forgetCloudDocumentLink()+ forgetCloudLink()+ }+ // Later sign-ins, as in the connect dialog, open what they were for once they finish.+ resumeCloudDocumentLink()+ resumeCloudLink()+ if (link?.kind !== 'invitations') resumeCloudInvitation()+ if (link) await openCloudLink(link)+ if (documentLink) await openCloudDocumentLink(documentLink)+ } finally {+ // A link that needs a sign-in leaves for the server's page, so nothing shows before it goes.+ openingCloudLink.value = leftForCloudSignIn()+ }await bindDesktopCloudLinks()}diff --git a/src/app/collab/session.ts b/src/app/collab/session.tsindex 7d665d50e..0faa4c6d5 100644--- a/src/app/collab/session.ts+++ b/src/app/collab/session.ts@@ -178,7 +178,9 @@ export function openRoomSession({const status = computed(() =>deriveRoomStatus({- hasDocument: hasDocument.value,+ // A tab that holds the document keeps showing it while the room's copy arrives in parts:+ // the room's root can come before its layers, and the tab follows it once they are here.+ hasDocument: holdsDocument || hasDocument.value,savedCopyLoaded: savedCopyLoaded.value,openFor: now.value - openedAt,connectedFor: connectedSince.value === null ? null : now.value - connectedSince.value,diff --git a/src/app/editor/canvas/canvaskit.ts b/src/app/editor/canvas/canvaskit.tsindex e27c70320..56f7a7ab5 100644--- a/src/app/editor/canvas/canvaskit.ts+++ b/src/app/editor/canvas/canvaskit.ts@@ -1,6 +1,6 @@import canvasKitWasm from 'canvaskit-wasm/bin/canvaskit.wasm?url'-import { setCanvasKitLocator } from '@open-pencil/core/canvaskit'+import { getCanvasKit, setCanvasKitLocator } from '@open-pencil/core/canvaskit'/*** Importing CanvasKit's binary as an asset lets Vite serve it in development and emit a hashed@@ -10,3 +10,11 @@ import { setCanvasKitLocator } from '@open-pencil/core/canvaskit'export function installCanvasKitBinary(): void {setCanvasKitLocator(() => canvasKitWasm)}++/**+ * Starts loading CanvasKit as the app starts, so a document the app opens with does not wait for+ * the binary after its own download; the canvas shares this load. A failed one is retried there.+ */+export function preloadCanvasKit(): void {+ getCanvasKit().catch(() => undefined)+}diff --git a/src/app/editor/preparation/controller.ts b/src/app/editor/preparation/controller.tsindex 8dede5fbd..4bcf0959a 100644--- a/src/app/editor/preparation/controller.ts+++ b/src/app/editor/preparation/controller.ts@@ -37,6 +37,11 @@ export interface EditorPreparationController {* canvas, so its scene waits to be presented until the tab is shown, without timing out.*/attachCanvas(): () => void+ /**+ * A canvas could not start, so nothing presents the scene until one attaches: waiting for it+ * fails with this error rather than waiting with no time limit.+ */+ failCanvas(error: Error): voiddispose(): void}@@ -51,6 +56,7 @@ export function createEditorPreparationController(let activeCancel: ((reason: EditorPreparationCancelReason) => void) | null = nulllet presentedSceneVersion = -1let canvases = 0+ let canvasFailure: Error | null = nullconst presentationWaiters = new Map<number, PresentationWaiter>()function settle(id: number, outcome: Error | null) {@@ -171,10 +177,12 @@ export function createEditorPreparationController(}presentationWaiters.set(id, waiter)if (canvases > 0) startTimer(id, waiter)+ else if (canvasFailure) settle(id, canvasFailure)})},attachCanvas() {canvases += 1+ canvasFailure = nullfor (const [id, waiter] of presentationWaiters) startTimer(id, waiter)let attached = truereturn () => {@@ -182,9 +190,18 @@ export function createEditorPreparationController(attached = falsecanvases -= 1if (canvases > 0) return+ if (canvasFailure) {+ for (const id of presentationWaiters.keys()) settle(id, canvasFailure)+ return+ }for (const waiter of presentationWaiters.values()) pauseTimer(waiter)}},+ failCanvas(error) {+ canvasFailure = error+ if (canvases > 0) return+ for (const id of presentationWaiters.keys()) settle(id, error)+ },dispose() {activeCancel?.('tab-closed')activeAbort?.abort()diff --git a/src/app/integrations/storage/cloud/adapter.ts b/src/app/integrations/storage/cloud/adapter.tsindex dd85f9768..cfecfb262 100644--- a/src/app/integrations/storage/cloud/adapter.ts+++ b/src/app/integrations/storage/cloud/adapter.ts@@ -3,11 +3,7 @@ import { extractFigThumbnailFromReader } from '@open-pencil/fig'import { cloudServerHost } from '@/app/cloud/servers/address'import { findCloudServer } from '@/app/cloud/servers/store'-import {- cloudAPIClient,- cloudConnection,- refreshCloudConnection-} from '@/app/cloud/sessions/connection'+import { cloudAPIClient, recheckedCloudConnection } from '@/app/cloud/sessions/connection'import { StorageRevisionConflictError, StorageUnavailableError } from '../errors'import { storageFetch } from '../s3/fetch'@@ -32,12 +28,11 @@ export type CloudStorageDependencies = {objectFetch(input: string, init: RequestInit): Promise<Response>}-/** The API client of a signed-in server, checking once more before giving up. */+/** The API client of a signed-in server, asking it once more before giving up. */async function signedInClient(serverId: string): Promise<CloudAPIClient> {const server = findCloudServer(serverId)if (!server) throw new StorageUnavailableError('This Cloud server was removed from the app')- let connection = cloudConnection(server.id)- if (connection.state !== 'signed-in') connection = await refreshCloudConnection(server)+ const connection = await recheckedCloudConnection(server)if (connection.state !== 'signed-in' || !connection.discovery) {throw new StorageUnavailableError(`Sign in to ${cloudServerHost(server.url)} to sync`)}diff --git a/src/app/integrations/storage/s3/fetch.ts b/src/app/integrations/storage/s3/fetch.tsindex f9086d421..518d672b3 100644--- a/src/app/integrations/storage/s3/fetch.ts+++ b/src/app/integrations/storage/s3/fetch.ts@@ -1,19 +1,65 @@import { isTauri } from '@/app/tauri/env'-/** Avoid hung “Test connection” when CORS/network never resolves. */-const STORAGE_FETCH_TIMEOUT_MS = 20_000+/**+ * How long a request waits for its answer, or a download for its next bytes, before it fails, so a+ * “Test connection” whose CORS or network never answers does not hang. A slow transfer that keeps+ * moving goes on however long it takes.+ */+const STORAGE_STALL_TIMEOUT_MS = 20_000-interface StorageFetchSignal {- signal: AbortSignal- timedOut: () => boolean+function timedOut(): Error {+ return new Error(+ 'Storage request timed out. Check the endpoint URL, network, and bucket CORS settings.'+ )}-function storageFetchSignal(external?: AbortSignal | null): StorageFetchSignal {- const timeout = AbortSignal.timeout(STORAGE_FETCH_TIMEOUT_MS)+/** Fails a request once nothing arrives for `stallTimeoutMs`, from when it restarts. */+function stallWatch(external: AbortSignal | null, stallTimeoutMs: number) {+ const controller = new AbortController()+ let timer: ReturnType<typeof setTimeout> | undefined+ const stop = () => clearTimeout(timer)return {- signal: external ? AbortSignal.any([external, timeout]) : timeout,- timedOut: () => timeout.aborted+ signal: external ? AbortSignal.any([external, controller.signal]) : controller.signal,+ restart() {+ stop()+ timer = setTimeout(() => controller.abort(timedOut()), stallTimeoutMs)+ },+ stop,+ timedOut: () => controller.signal.aborted+ }+}++type StallWatch = ReturnType<typeof stallWatch>++/** The response with its body watched: each piece that arrives gives the next one more time. */+function watchBody(response: Response, watch: StallWatch): Response {+ if (!response.body) {+ watch.stop()+ return response}+ watch.restart()+ const body = response.body.pipeThrough(+ new TransformStream<Uint8Array, Uint8Array>({+ // Fails the body itself, whether or not the fetch stops its own on the abort.+ start(controller) {+ watch.signal.addEventListener('abort', () => controller.error(watch.signal.reason), {+ once: true+ })+ },+ transform(chunk, controller) {+ watch.restart()+ controller.enqueue(chunk)+ },+ flush: watch.stop+ })+ )+ const watched = new Response(body, {+ status: response.status,+ statusText: response.statusText,+ headers: response.headers+ })+ Object.defineProperty(watched, 'url', { value: response.url })+ return watched}type FetchImplementation = (input: RequestInfo | URL, init?: RequestInit) => Promise<Response>@@ -28,28 +74,41 @@ export function asFetch(implementation: FetchImplementation): typeof fetch {}/** Prefer Tauri HTTP bridge on desktop to avoid bucket CORS requirements. */-async function fetchWithTimeout(input: RequestInfo | URL, init?: RequestInit): Promise<Response> {- const { signal, timedOut } = storageFetchSignal(- init?.signal ?? (input instanceof Request ? input.signal : null)+async function fetchWithTimeout(+ input: RequestInfo | URL,+ init: RequestInit | undefined,+ stallTimeoutMs: number+): Promise<Response> {+ const watch = stallWatch(+ init?.signal ?? (input instanceof Request ? input.signal : null),+ stallTimeoutMs)+ const { signal } = watch+ // An upload shows no progress while its body goes out, so only cancelling it stops it.+ const uploads = init?.body != null || (input instanceof Request && input.body !== null)+ if (!uploads) watch.restart()+ let response: Responsetry {if (isTauri()) {const { tauriFetch } = await import('@/app/tauri/http')- return await tauriFetch(input, { ...init, signal })- }- // Request bodies are owned by the Request; re-wrap so we can attach a timeout signal.- if (input instanceof Request) {- return await fetch(new Request(input, { signal }))+ response = await tauriFetch(input, { ...init, signal })+ } else if (input instanceof Request) {+ // Request bodies are owned by the Request; re-wrap so we can attach a timeout signal.+ response = await fetch(new Request(input, { signal }))+ } else {+ response = await fetch(input, { ...init, signal })}- return await fetch(input, { ...init, signal })} catch (error) {- if (timedOut()) {- throw new Error(- 'Storage request timed out. Check the endpoint URL, network, and bucket CORS settings.'- )- }+ watch.stop()+ if (watch.timedOut()) throw timedOut()throw error}+ return watchBody(response, watch)+}++/** Storage requests that fail once nothing arrives for `stallTimeoutMs`. */+export function createStorageFetch(stallTimeoutMs = STORAGE_STALL_TIMEOUT_MS): typeof fetch {+ return asFetch((input, init) => fetchWithTimeout(input, init, stallTimeoutMs))}-export const storageFetch = asFetch(fetchWithTimeout)+export const storageFetch = createStorageFetch()diff --git a/src/app/shell/theme.ts b/src/app/shell/theme.tsindex 78c39145b..8536a7968 100644--- a/src/app/shell/theme.ts+++ b/src/app/shell/theme.ts@@ -12,6 +12,7 @@ import { ACCENT_TOKENS, type AccentPalette } from '@/app/shell/accent/palette'export const APP_THEMES = ['dark', 'light', 'auto'] as constexport type AppTheme = (typeof APP_THEMES)[number]+// `index.html` reads the same key, so its boot splash starts in this theme.const THEME_STORAGE_KEY = 'open-pencil:theme'const DEFAULT_THEME: AppTheme = 'dark'diff --git a/src/app/tabs/address.ts b/src/app/tabs/address.tsindex b2ddcad53..93121683b 100644--- a/src/app/tabs/address.ts+++ b/src/app/tabs/address.ts@@ -2,7 +2,7 @@ import { isEqual, omit } from 'es-toolkit'import { watch } from 'vue'import type { LocationQuery, RouteLocationNormalizedLoaded, Router } from 'vue-router'-import { cloudDocumentAddress } from '@/app/cloud/integration'+import { cloudDocumentAddress, openingCloudLink } from '@/app/cloud/integration'import { isRoomId } from '@/app/collab/room/id'import { activeRoom } from '@/app/collab/rooms'@@ -44,16 +44,21 @@ export function tabAddressFor(* screen.*/export function syncTabAddress(router: Router, route: RouteLocationNormalizedLoaded): () => void {- let opening = true+ let first = truereturn watch(() => {const store = activeTab.value?.store- return [activeRoom.value?.roomId ?? null, store ? cloudDocumentAddress(store) : null] as const+ return [+ activeRoom.value?.roomId ?? null,+ store ? cloudDocumentAddress(store) : null,+ openingCloudLink.value+ ] as const},- ([roomId, cloud]) => {+ ([roomId, cloud, opening]) => {const current = { path: route.path, query: route.query }- const next = tabAddressFor(roomId, cloud, current, opening)- opening = false+ // Until the link the tab started with has opened, its address stays, for a reload too.+ const next = tabAddressFor(roomId, cloud, current, first || opening)+ first = falseif (next.path === current.path && isEqual(next.query, current.query)) returnvoid router.replace({ ...next, hash: route.hash })},diff --git a/src/app/tabs/index.ts b/src/app/tabs/index.tsindex d3803ffd4..4ddd79f54 100644--- a/src/app/tabs/index.ts+++ b/src/app/tabs/index.ts@@ -157,6 +157,13 @@ export function switchTab(tabId: string): boolean {return true}+function disposeTabStore(store: EditorStore): void {+ coverThumbnailListeners.get(store)?.()+ coverThumbnailListeners.delete(store)+ store.preparationController.dispose()+ store.dispose()+}+/*** Close a tab, asking whether to save unsaved changes. Pass `unsaved` to decide without* asking, as automation must: nobody may be there to answer.@@ -175,12 +182,16 @@ export async function closeTab(tabId: string, unsaved?: 'save' | 'discard'): Proelse await closingTab.store.persistRecoveryNow()if (!tabsRef.value.includes(closingTab)) returnif (choice !== 'discard' && closingTab.store.hasUnsavedChanges()) return- const wasActive = activeTabId.value === tabId- coverThumbnailListeners.get(closingTab.store)?.()- coverThumbnailListeners.delete(closingTab.store)- closingTab.store.preparationController.dispose()- closingTab.store.dispose()- tabsRef.value = tabsRef.value.filter((t) => t.id !== tabId)+ removeTab(closingTab)+}++/** Takes a tab out of the window and disposes its store, showing a neighbour or a new Home. */+function removeTab(closingTab: Tab): void {+ const idx = tabsRef.value.indexOf(closingTab)+ if (idx === -1) return+ const wasActive = activeTabId.value === closingTab.id+ disposeTabStore(closingTab.store)+ tabsRef.value = tabsRef.value.filter((t) => t !== closingTab)if (tabsRef.value.length === 0) {createHomeTab()@@ -203,19 +214,53 @@ function isDOMImportFile(file: File): boolean {return /\.(html?|xhtml)$/i.test(file.name)}-function reusableTabStore(): { store: EditorStore; created: boolean } {+/** A tab a document opens in: a new one, Home, or an untouched empty document. */+type OpeningTab = { store: EditorStore; created: boolean; fromHome: boolean }++function reusableTabStore(): OpeningTab {const current = activeTab.valueif (current?.kind === 'home') {leaveHome(current.id)- return { store: current.store, created: false }+ return { store: current.store, created: false, fromHome: true }}const isUntouched =current?.store.state.documentName === 'Untitled' && !current.store.undo.canUndoif (isUntouched) {leaveHome(current.id)- return { store: current.store, created: false }+ return { store: current.store, created: false, fromHome: false }}- return { store: createTab().store, created: true }+ return { store: createTab().store, created: true, fromHome: false }+}++/**+ * After a document failed to open: a tab opened for it closes, and Home is Home again, with a+ * fresh store, so nothing of the failed document stays for the next one opened there.+ */+async function releaseOpeningTab(opening: OpeningTab): Promise<void> {+ const tab = getTabForStore(opening.store)+ if (!tab) return+ if (!opening.created && !opening.fromHome) return+ // The tab goes, or Home comes back, even when the recovery copy stays behind, which the next+ // start offers again; the open's own error is the one to report.+ await tab.store.discardRecovery().catch((error: unknown) => {+ console.warn(+ '[Tabs] Failed to discard the recovery copy of a document that failed to open',+ error+ )+ })+ if (opening.created) {+ removeTab(tab)+ return+ }+ // Tabs may have closed meanwhile, so the tab is found again, and only while it still holds this store.+ const tabIndex = tabsRef.value.findIndex(+ (candidate) => candidate.id === tab.id && candidate.store === tab.store+ )+ if (tabIndex === -1) return+ const home: Tab = { ...tab, kind: 'home', store: createEditorStore() }+ tabsRef.value = tabsRef.value.with(tabIndex, home)+ if (activeTabId.value === tab.id) activateTab(home)+ disposeTabStore(tab.store)}async function readFigForTab(file: File, signal?: AbortSignal): Promise<SceneGraph> {@@ -393,7 +438,8 @@ export async function openStorageDocumentInNewTab(return existing.store}- const { store, created } = reusableTabStore()+ const opening = reusableTabStore()+ const { store } = openingstore.state.documentName = document.nameconst load = store.preparationController.begin({kind: 'storage-open',@@ -420,10 +466,7 @@ export async function openStorageDocumentInNewTab(}))}- if (created) {- const tab = getTabForStore(store)- if (tab) await closeTab(tab.id)- }+ await releaseOpeningTab(opening)throw error} finally {if (succeeded) load.complete()@@ -460,7 +503,8 @@ export async function openFileInNewTab(return { kind: 'existing' as const, store: existing.store }}- const { store, created } = reusableTabStore()+ const opening = reusableTabStore()+ const { store } = openingstore.state.documentName = file.name.replace(/\.[^.]+$/i, '')const load = store.preparationController.begin({kind: isDOMImportFile(file) ? 'dom-import' : 'document-open',@@ -471,7 +515,7 @@ export async function openFileInNewTab(void completion.promise.catch(() => undefined)const pendingOpen = { completion: completion.promise, identity, store }fileOpenCoordinator.add(pendingOpen)- return { kind: 'owner' as const, completion, pendingOpen, store, created, load }+ return { kind: 'owner' as const, completion, pendingOpen, store, opening, load }})if (decision.kind === 'existing') return decision.store@@ -480,7 +524,7 @@ export async function openFileInNewTab(return decision.store}- const { completion, pendingOpen, store, created, load } = decision+ const { completion, pendingOpen, store, opening, load } = decisionlet succeeded = falsetry {if (isDOMImportFile(file)) {@@ -530,10 +574,7 @@ export async function openFileInNewTab(} catch (error) {failPreparation(load, 'decode-failed', error)completion.reject(error)- if (created) {- const tab = getTabForStore(store)- if (tab) await closeTab(tab.id)- }+ await releaseOpeningTab(opening)throw error} finally {if (succeeded) load.complete()diff --git a/src/boot.ts b/src/boot.tsindex fa3108907..610294bf7 100644--- a/src/boot.ts+++ b/src/boot.ts@@ -6,7 +6,7 @@ import { createRetainedScopePlugin } from '@open-pencil/vue/lifecycle/retention'import './app.css'import { recordRuntimeError } from '@/app/diagnostics'-import { installCanvasKitBinary } from '@/app/editor/canvas/canvaskit'+import { installCanvasKitBinary, preloadCanvasKit } from '@/app/editor/canvas/canvaskit'import { preloadFonts } from '@/app/editor/fonts'import { installBundledFonts } from '@/app/editor/fonts/bundled'import { observeBootErrors } from '@/app/shell/support/boot'@@ -24,6 +24,7 @@ import router from './router'export async function boot(): Promise<void> {installBundledFonts()installCanvasKitBinary()+ preloadCanvasKit()preloadFonts()const head = createHead()const app = createApp(App)diff --git a/src/cloud/main.ts b/src/cloud/main.tsindex db08634b1..ec3232b59 100644--- a/src/cloud/main.ts+++ b/src/cloud/main.ts@@ -1,5 +1,6 @@import { createHead } from '@unhead/vue/client'import { createApp } from 'vue'+import { isNavigationFailure, NavigationFailureType } from 'vue-router'import '@/app.css'import { loadPortalContext, PORTAL_CONTEXT } from '@/app/cloud-portal/context'@@ -26,7 +27,20 @@ async function start(): Promise<void> {console.error(error)}app.provide(PORTAL_CONTEXT, context)- app.use(createCloudPortalRouter(context)).use(head).mount('#app')+ const router = createCloudPortalRouter(context)+ app.use(router).use(head)+ // The splash stays until the first page can show, rather than a blank page between. A first+ // navigation the guards stop leaves for the editor, so nothing mounts then; one that fails, as+ // when a page's code does not load, says the pages are unavailable.+ try {+ await router.isReady()+ } catch (error) {+ if (isNavigationFailure(error, NavigationFailureType.aborted)) return+ console.error(error)+ createApp(CloudPortalUnavailableView).use(createHead()).mount('#app')+ return+ }+ app.mount('#app')}void start()diff --git a/src/components/EditorCanvas.vue b/src/components/EditorCanvas.vueindex c3238e0e4..4576ba12b 100644--- a/src/components/EditorCanvas.vue+++ b/src/components/EditorCanvas.vue@@ -94,8 +94,14 @@ const shouldSuspendRender = () =>/** The pan and zoom of the scene's last drawn frame, which preview islands follow. */const drawnView = shallowRef<ViewportTransform | null>(null)-// The tab's scene is presented only here, so waiting for it times out only while it is shown.-onUnmounted(store.preparationController.attachCanvas())+// The tab's scene is presented only here once the canvas can draw, so waiting for it times out+// only while it is shown and drawing, not while the renderer and its fonts download.+let detachCanvas: (() => void) | null = null+onUnmounted(() => detachCanvas?.())+function canvasReady() {+ store.markCanvasReady()+ detachCanvas ??= store.preparationController.attachCanvas()+}useCanvas(sceneCanvasRef, store, {layer: 'scene',@@ -103,7 +109,11 @@ useCanvas(sceneCanvasRef, store, {drawnView.value = view},sceneRenderer: appRuntimeConfig.sceneRenderer,- onReady: store.markCanvasReady,+ onReady: canvasReady,+ onFailed: (error) =>+ store.preparationController.failCanvas(+ new Error('The canvas could not start', { cause: error })+ ),shouldSuspendRender,showRulers: false,getRenderState,@@ -122,6 +132,8 @@ const {hitTestStatusLabel} = useCanvas(canvasRef, store, {layer: 'overlays',+ // The scene canvas reports a canvas that cannot start.+ onFailed: () => undefined,get showRulers() {return appRuntimeConfig.showRulers && store.state.showRulers && paneView.value.play === null},diff --git a/src/components/home/cloud/CloudSharedSection.vue b/src/components/home/cloud/CloudSharedSection.vueindex adb9393f3..47c44607d 100644--- a/src/components/home/cloud/CloudSharedSection.vue+++ b/src/components/home/cloud/CloudSharedSection.vue@@ -76,7 +76,8 @@ const matching = computed(() =>function open(row: CloudDocumentRow) {const document = documents.value.find((candidate) => candidate.id === row.id)if (!document) return- // A shared document stays in its owner's workspace; the direct grant is what opens it.+ // A shared document stays in its owner's workspace; the direct grant is what opens it. Opening+ // reports its own failure.void openStorageDocumentInNewTab({id: document.id,@@ -89,7 +90,7 @@ function open(row: CloudDocumentRow) {profileId: serverId,containerId: document.workspaceId}- )+ ).catch(() => undefined)}</script>diff --git a/src/components/home/cloud/CloudWorkspaceSection.vue b/src/components/home/cloud/CloudWorkspaceSection.vueindex 28c9ee162..3dab479d2 100644--- a/src/components/home/cloud/CloudWorkspaceSection.vue+++ b/src/components/home/cloud/CloudWorkspaceSection.vue@@ -141,7 +141,9 @@ function reviewConflicts() {function open(row: CloudDocumentRow) {const document = listed.value.find((candidate) => candidate.id === row.id)- if (document) void openStorageDocumentInNewTab(document, location.value)+ if (!document) return+ // Opening reports its own failure.+ void openStorageDocumentInNewTab(document, location.value).catch(() => undefined)}</script>diff --git a/src/components/shell/LoadingScreen.vue b/src/components/shell/LoadingScreen.vuenew file mode 100644index 000000000..c961effcf--- /dev/null+++ b/src/components/shell/LoadingScreen.vue@@ -0,0 +1,29 @@+<script setup lang="ts">+import { useI18n } from '@open-pencil/vue/i18n'++import { resolvedAppTheme } from '@/app/shell/theme'+import BrandMark from '@/components/brand/BrandMark.vue'++// The whole window while the app opens what it started with, drawn as the boot splash in+// `index.html` is, so the page goes on looking the same until there is something to show.+const { panels } = useI18n()+</script>++<template>+ <div+ data-test-id="loading-screen"+ role="status"+ aria-busy="true"+ :aria-label="panels.loading"+ class="fixed inset-0 z-50 flex items-center justify-center bg-canvas"+ >+ <BrandMark variant="app-icon" :appearance="resolvedAppTheme" decorative class="size-10" />+ <div+ class="absolute bottom-1/2 left-1/2 h-0.5 w-25 -translate-x-1/2 translate-y-10 overflow-hidden rounded-full bg-surface/8"+ >+ <div+ class="h-full w-2/5 animate-[slide_1s_ease-in-out_infinite] motion-reduce:animate-none rounded-full bg-surface/25"+ />+ </div>+ </div>+</template>diff --git a/src/views/WorkspaceView.vue b/src/views/WorkspaceView.vueindex 34bef95b7..6ccf4220b 100644--- a/src/views/WorkspaceView.vue+++ b/src/views/WorkspaceView.vue@@ -14,7 +14,7 @@ import { exposeAutomationTestRequests } from '@/app/automation/bridge/test-hooksimport { startMCPRuntime, stopMCPRuntime } from '@/app/automation/mcp/runtime'import { startWebMCP } from '@/app/automation/webmcp/runtime'import { exposeCollaborationActions } from '@/app/browser-bridge'-import { shownEditorStore, versionPreviewKey } from '@/app/cloud/integration'+import { openingCloudLink, shownEditorStore, versionPreviewKey } from '@/app/cloud/integration'import { useJoinRoom } from '@/app/collab/join'import { bindDesktopRoomLinks } from '@/app/collab/room/links'import { COLLAB_KEY, useCollab } from '@/app/collab/use'@@ -52,6 +52,7 @@ import FileApiBanner from '@/components/FileApiBanner.vue'import FontStatusBanner from '@/components/font-status/FontStatusBanner.vue'import HomeWorkspace from '@/components/home/HomeWorkspace.vue'import RenameSelectionDialog from '@/components/selection/RenameSelectionDialog.vue'+import LoadingScreen from '@/components/shell/LoadingScreen.vue'import TabBar from '@/components/TabBar.vue'import { IS_BROWSER, IS_CLOUD_SITE } from '@/constants'@@ -84,6 +85,13 @@ const shouldCreateHome =!appRuntimeConfig.test &&!route.meta.demo &&(recentFilesAvailable() || IS_CLOUD_SITE)+/**+ * A Cloud link's first tab is Home, which the document it opens takes over; Home is also where a+ * link that fails or waits for a sign-in leaves the person, never an empty document.+ */+const opensCloudLink = ['documentId', 'shareId', 'invitationId'].some(+ (param) => typeof route.params[param] === 'string'+)const { collaboration } = useI18n()const joinRoomFromInput = useJoinRoom()@@ -94,7 +102,7 @@ function openFirstTab(): Tab {if (joinRoomFromInput(roomId) && activeTab.value) return activeTab.valuetoast.error(collaboration.value.invalidRoomLink)}- return shouldCreateHome ? createHomeTab() : createTab()+ return shouldCreateHome || opensCloudLink ? createHomeTab() : createTab()}// Block-scoped so the view does not keep the first tab's store after that tab closes.@@ -130,7 +138,15 @@ if (welcomeShown) {{ once: true })} else {- void sharingStarted.then(() => offerUsageStatsPrompt('prompt'))+ // Asked once the window shows what it opened, not over the loading screen.+ whenever(+ () => !openingCloudLink.value,+ async () => {+ await sharingStarted+ offerUsageStatsPrompt('prompt')+ },+ { once: true, immediate: true }+ )}useHead({ title: route.meta.demo ? 'Demo' : undefined })@@ -278,5 +294,6 @@ onUnmounted(() => {<HomeWorkspace v-show="activeTab?.kind === 'home'" @new-document="createDocumentInCurrentTab" /><CloudVersionDialog /><EditorWorkspace v-if="shown && shown.tab.kind !== 'home'" :key="shown.key" :tab="shown.tab" />+ <LoadingScreen v-if="openingCloudLink" /></div></template>diff --git a/src/views/cloud/SignInView.vue b/src/views/cloud/SignInView.vueindex 8062e0c1d..ad787d7fb 100644--- a/src/views/cloud/SignInView.vue+++ b/src/views/cloud/SignInView.vue@@ -25,7 +25,9 @@ const emailPassword = computed(() => {})const returnsTo = computed(() => {if (redirect.value.startsWith('/auth/device')) return 'desktop'- if (redirect.value.startsWith('/auth/return')) return 'editor'+ // The editor sent the person here, or a document's link did.+ if (redirect.value.startsWith('/auth/return') || redirect.value.startsWith('/documents/'))+ return 'editor'return null})const error = ref<string | null>(callback(route.query))diff --git a/tests/app/cloud-portal/site.test.ts b/tests/app/cloud-portal/site.test.tsindex fce3129e5..8ef76256b 100644--- a/tests/app/cloud-portal/site.test.ts+++ b/tests/app/cloud-portal/site.test.ts@@ -3,7 +3,7 @@ import { describe, expect, test } from 'bun:test'import type { CloudAccountStatus } from '@open-pencil/cloud/contract'import {- isCloudLink,+ isSecretCloudLink,leaveAfterSignOut,openLocalEditor,siteDestination,@@ -20,10 +20,11 @@ function account(state: CloudAccountStatus['state']): CloudAccountStatus {const visit = (path: string,who: SiteAccount,- options: { localEditor?: boolean; choseLocalEditor?: boolean } = {}+ options: { localEditor?: boolean; choseLocalEditor?: boolean; search?: string } = {}) =>siteDestination({path,+ search: options.search,account: who,localEditor: options.localEditor ?? true,choseLocalEditor: options.choseLocalEditor ?? false@@ -52,9 +53,20 @@ describe('Cloud server editor pages', () => {expect(visit('/rooms/room', account('pending'), { localEditor: false })).toBe('/welcome')})- test('tell links, which sign in on their own, from look-alike addresses', () => {- const link = (address: string) => isCloudLink(new URL(address, 'https://cloud.example'))- expect(link('/documents/a')).toBe(true)+ test('send a document link to sign in first, and back to the document afterwards', () => {+ expect(visit('/documents/a', null, { search: '?version=v' })).toBe(+ '/auth/sign-in?redirect=%2Fdocuments%2Fa%3Fversion%3Dv'+ )+ expect(visit('/documents/a', null, { choseLocalEditor: true })).toBe(+ '/auth/sign-in?redirect=%2Fdocuments%2Fa'+ )+ expect(visit('/documents/a', account('pending'))).toBe('/welcome')+ expect(visit('/documents/a', account('active'))).toBeNull()+ })++ test('tell links that carry their secret, which open on their own, from look-alikes', () => {+ const link = (address: string) => isSecretCloudLink(new URL(address, 'https://cloud.example'))+ expect(link('/documents/a')).toBe(false)expect(link('/share/b#secret')).toBe(true)expect(link('/invitations/c#token')).toBe(true)expect(link('/share/b')).toBe(false)diff --git a/tests/app/cloud/sessions/connection.test.ts b/tests/app/cloud/sessions/connection.test.tsindex e5771b74c..4fe4ddc13 100644--- a/tests/app/cloud/sessions/connection.test.ts+++ b/tests/app/cloud/sessions/connection.test.ts@@ -1,7 +1,12 @@import { afterEach, beforeEach, describe, expect, spyOn, test } from 'bun:test'import { addCloudServer, cloudServers, removeCloudServer } from '@/app/cloud/servers/store'-import { cloudConnection, refreshCloudConnection } from '@/app/cloud/sessions/connection'+import {+ checkedCloudConnection,+ cloudConnection,+ recheckedCloudConnection,+ refreshCloudConnection+} from '@/app/cloud/sessions/connection'import { readCloudSessionToken, saveCloudSessionToken } from '@/app/cloud/sessions/token'import { cloudDiscoveryFixture } from '#tests/helpers/cloud/discovery'@@ -21,14 +26,17 @@ const workspace = {type Answer = { status: number; body?: unknown }let answers: Record<string, Answer> = {}let authorization: (string | null)[] = []+let statusRequests = 0beforeEach(() => {answers = {}authorization = []+ statusRequests = 0spyOn(globalThis, 'fetch').mockImplementation(fetchStub(async (input, init) => {const url = new URL(input instanceof Request ? input.url : String(input))authorization.push(new Headers(init?.headers).get('Authorization'))+ if (url.pathname === '/api/account/status') statusRequests += 1if (url.pathname === '/.well-known/openpencil')return Response.json(cloudDiscoveryFixture(ORIGIN))const answer = answers[url.pathname]@@ -89,4 +97,36 @@ describe('Cloud connections', () => {expect((await refreshCloudConnection(remembered)).state).toBe('expired')expect(cloudConnection(target.id).account?.email).toBe('[email protected]')})++ test('wait for the check under way instead of starting one that throws its answer away', async () => {+ answers['/api/account/status'] = { status: 200, body: { user, state: 'active' } }+ answers['/api/workspaces'] = { status: 200, body: { workspaces: [workspace] } }+ const target = await server()+ const starting = refreshCloudConnection(target)+ const waiting = checkedCloudConnection(target)+ await starting+ expect(cloudConnection(target.id).state).toBe('signed-in')+ expect((await waiting).state).toBe('signed-in')+ // One account status and one workspace list: the server was asked once.+ expect(authorization).toHaveLength(2)+ })++ test('ask a server out of reach again rather than keep its old answer', async () => {+ answers['/api/account/status'] = { status: 503, body: { error: { code: 'unavailable' } } }+ const target = await server()+ expect((await refreshCloudConnection(target)).state).toBe('unreachable')+ answers['/api/account/status'] = { status: 200, body: { user, state: 'active' } }+ answers['/api/workspaces'] = { status: 200, body: { workspaces: [workspace] } }+ expect((await recheckedCloudConnection(target)).state).toBe('signed-in')+ })++ test('take the answer of the check under way without asking twice', async () => {+ answers['/api/account/status'] = { status: 503, body: { error: { code: 'unavailable' } } }+ const target = await server()+ const starting = refreshCloudConnection(target)+ const waiting = recheckedCloudConnection(target)+ await starting+ expect((await waiting).state).toBe('unreachable')+ expect(statusRequests).toBe(1)+ })})diff --git a/tests/app/collab/session.test.ts b/tests/app/collab/session.test.tsindex c2142679b..cf9f301f8 100644--- a/tests/app/collab/session.test.ts+++ b/tests/app/collab/session.test.ts@@ -1,8 +1,11 @@import { describe, expect, test } from 'bun:test'+import type * as Y from 'yjs'+import { SceneGraph } from '@open-pencil/scene-graph'import { openRoomSession, type RoomSession, type RoomSessionOptions } from '@/app/collab/session'+import { claimRoot } from '@/app/collab/shared-tree/fields'import { createEditorStore, type EditorStore } from '@/app/editor/session'import { presenceOf } from '@/app/presence/registry'@@ -162,6 +165,26 @@ describe('room sessions', () => {})})+ test('a tab that holds the room’s document keeps showing it when the room’s root comes first', async () => {+ await withRooms(async (open) => {+ const room: { doc?: Y.Doc } = {}+ const session = open({+ roomId: ROOM_A,+ store: newStore('Poster'),+ origin: 'shared',+ holdsDocument: true,+ openSavedCopy: (_roomId, ydoc) => {+ room.doc = ydoc+ return noSavedCopy()+ }+ })+ // The root another editor claimed, before any of its layers.+ claimRoot(expectDefined(room.doc, 'room document').getMap('meta'), 'room:root')+ expect(session.hasDocument.value).toBe(false)+ expect(session.status.value).toBe('alone')+ })+ })+test('a room someone shared or joined can be left', async () => {await withRooms(async (open) => {const shared = open({ roomId: ROOM_A, store: newStore('Poster'), origin: 'shared' })diff --git a/tests/engine/app/editor/preparation/controller.test.ts b/tests/app/editor/preparation/controller.test.tssimilarity index 78%rename from tests/engine/app/editor/preparation/controller.test.tsrename to tests/app/editor/preparation/controller.test.tsindex 3913532ff..d78ff8f74 100644--- a/tests/engine/app/editor/preparation/controller.test.ts+++ b/tests/app/editor/preparation/controller.test.ts@@ -126,6 +126,44 @@ describe('editor preparation controller', () => {}})+ test('fails the wait when the canvas cannot start, before or after it begins', async () => {+ const state = createInitialAppEditorState('page')+ const controller = createEditorPreparationController(state)+ const failure = new Error('The canvas could not start')++ const first = controller.begin({ kind: 'page-switch' })+ const waiting = controller.waitForPresentation(first.id, 7)+ controller.failCanvas(failure)+ await expect(waiting).rejects.toBe(failure)+ first.fail({ code: 'render-failed', message: failure.message, retryable: true })++ const second = controller.begin({ kind: 'page-switch' })+ await expect(controller.waitForPresentation(second.id, 8)).rejects.toBe(failure)+ second.fail({ code: 'render-failed', message: failure.message, retryable: true })++ // A canvas that starts later presents scenes again.+ controller.attachCanvas()+ const third = controller.begin({ kind: 'page-switch' })+ const presenting = controller.waitForPresentation(third.id, 9)+ controller.acknowledgePresentation(9)+ await presenting+ third.complete()+ })++ test('fails the wait once the last working canvas leaves after another could not start', async () => {+ const state = createInitialAppEditorState('page')+ const controller = createEditorPreparationController(state)+ const failure = new Error('The canvas could not start')+ const handle = controller.begin({ kind: 'page-switch' })+ const detach = controller.attachCanvas()+ const waiting = controller.waitForPresentation(handle.id, 7)+ // Another pane fails while this one still draws; then this one closes before presenting.+ controller.failCanvas(failure)+ detach()+ await expect(waiting).rejects.toBe(failure)+ handle.fail({ code: 'render-failed', message: failure.message, retryable: true })+ })+test('counts the time a tab was shown toward the limit, across visits', async () => {jest.useFakeTimers()try {diff --git a/tests/engine/app/integrations/storage/cancellation.test.ts b/tests/engine/app/integrations/storage/cancellation.test.tsindex c144affd3..5d920284a 100644--- a/tests/engine/app/integrations/storage/cancellation.test.ts+++ b/tests/engine/app/integrations/storage/cancellation.test.ts@@ -1,8 +1,11 @@-import { expect, test } from 'bun:test'+import { expect, jest, spyOn, test } from 'bun:test'import { createS3StorageAdapter } from '@/app/integrations/storage/s3/adapter'import { readDownloadStream } from '@/app/integrations/storage/s3/client'-import { storageFetch } from '@/app/integrations/storage/s3/fetch'+import { createStorageFetch, storageFetch } from '@/app/integrations/storage/s3/fetch'++import { expectDefined } from '#tests/helpers/assert'+import { fetchStub } from '#tests/helpers/fetch'test('mid-stream cancellation discards partial bytes and stops progress', async () => {const abort = new AbortController()@@ -77,3 +80,60 @@ test('pre-aborted storage downloads do not resolve credentials or start network)expect(credentialResolutions).toBe(0)})++/** A download whose body sends one byte each time `send` is called, then ends on `end`. */+function trickle() {+ let stream: ReadableStreamDefaultController<Uint8Array> | undefined+ const body = new ReadableStream<Uint8Array>({+ start(controller) {+ stream = controller+ }+ })+ return {+ response: new Response(body),+ send: () => stream?.enqueue(new Uint8Array([1])),+ end: () => stream?.close()+ }+}++async function withFetch(response: Response, run: () => Promise<void>) {+ const stub = spyOn(globalThis, 'fetch').mockImplementation(+ fetchStub(() => Promise.resolve(response))+ )+ try {+ await run()+ } finally {+ stub.mockRestore()+ }+}++test('a slow download that keeps arriving finishes however long it takes', async () => {+ jest.useFakeTimers()+ try {+ const download = trickle()+ await withFetch(download.response, async () => {+ const response = await createStorageFetch(100)('https://storage.example.com/document.fig')+ const reader = expectDefined(response.body, 'download body').getReader()+ // Five times the stall time in all, with most of it passing before each next byte.+ for (let sent = 0; sent < 5; sent++) {+ download.send()+ expect((await reader.read()).value).toEqual(new Uint8Array([1]))+ jest.advanceTimersByTime(90)+ }+ download.end()+ expect((await reader.read()).done).toBe(true)+ })+ } finally {+ jest.useRealTimers()+ }+})++test('a download that stops arriving fails as timed out', async () => {+ const download = trickle()+ await withFetch(download.response, async () => {+ const response = await createStorageFetch(20)('https://storage.example.com/document.fig')+ const reading = response.arrayBuffer()+ download.send()+ await expect(reading).rejects.toThrow('Storage request timed out')+ })+})diff --git a/tests/engine/app/tabs/open-file-dedup.test.ts b/tests/engine/app/tabs/open-file-dedup.test.tsindex a345c4e1b..01e9ad496 100644--- a/tests/engine/app/tabs/open-file-dedup.test.ts+++ b/tests/engine/app/tabs/open-file-dedup.test.ts@@ -199,6 +199,48 @@ describe('openFileInNewTab deduplication', () => {expect(getTabsSnapshot().at(-1)?.kind).toBe('document')})+ test('leaves Home as it was when a file opened from it fails', async () => {+ ;(figModule.readFigFile as ReturnType<typeof vi.fn>).mockRejectedValueOnce(+ new Error('read failed')+ )+ createHomeTab()+ const home = expectDefined(getTabsSnapshot().at(-1), 'home tab')+ const count = tabCount()++ await expect(+ settleFileOpen(openFileInNewTab(new File([], 'broken.fig'), undefined, '/tmp/broken.fig'))+ ).rejects.toThrow('read failed')++ const after = expectDefined(getTabsSnapshot().at(-1), 'home tab')+ expect(tabCount()).toBe(count)+ expect(after.id).toBe(home.id)+ expect(after.kind).toBe('home')+ expect(after.store).not.toBe(home.store)+ expect(after.store.state.documentName).toBe('Untitled')+ expect(getActiveStore()).toBe(after.store)+ })++ test('brings Home back and reports the open failure when its recovery copy stays', async () => {+ ;(figModule.readFigFile as ReturnType<typeof vi.fn>).mockRejectedValueOnce(+ new Error('read failed')+ )+ createHomeTab()+ const home = expectDefined(getTabsSnapshot().at(-1), 'home tab')+ vi.spyOn(home.store, 'discardRecovery').mockRejectedValueOnce(new Error('disk full'))+ const warn = vi.spyOn(console, 'warn').mockImplementation(() => undefined)++ await expect(+ settleFileOpen(openFileInNewTab(new File([], 'broken.fig'), undefined, '/tmp/broken.fig'))+ ).rejects.toThrow('read failed')++ const after = expectDefined(getTabsSnapshot().at(-1), 'home tab')+ expect(after.id).toBe(home.id)+ expect(after.kind).toBe('home')+ expect(after.store).not.toBe(home.store)+ expect(warn).toHaveBeenCalled()+ warn.mockRestore()+ })+test('activates the existing tab when the same path is opened again', async () => {const initialCount = tabCount()const file = new File([], 'design.fig')diff --git a/tools/checks/test-homes/engine-baseline.txt b/tools/checks/test-homes/engine-baseline.txtindex f9aee33df..8770f8fe7 100644--- a/tools/checks/test-homes/engine-baseline.txt+++ b/tools/checks/test-homes/engine-baseline.txt@@ -57,7 +57,6 @@ tests/engine/app/document/recovery/controller.test.tstests/engine/app/document/recovery/store.test.tstests/engine/app/editor/fonts/browser-fetch.test.tstests/engine/app/editor/panes.test.ts-tests/engine/app/editor/preparation/controller.test.tstests/engine/app/editor/preparation/multi-tab.test.tstests/engine/app/editor/selection/focus.test.tstests/engine/app/editor/store-path.test.ts