AI-native design editor. Open-source Figma alternative.
fix: show a first-page preview for designs without a Cover page (#1487)
Danila Poyarkov4da325e94d72
diff --git a/changes/1487/fixed.md b/changes/1487/fixed.mdnew file mode 100644index 000000000..dbabd88a5--- /dev/null+++ b/changes/1487/fixed.md@@ -0,0 +1,2 @@+- Designs saved without a Cover page get a preview of their first page on Home, in recent files, and in their .fig thumbnail, as Figma's files do.+- The storage list keeps showing previews and errors while it refreshes instead of flashing blank.diff --git a/packages/core/src/io/formats/fig/export/setup.ts b/packages/core/src/io/formats/fig/export/setup.tsindex 7b3d4dab0..c935a5495 100644--- a/packages/core/src/io/formats/fig/export/setup.ts+++ b/packages/core/src/io/formats/fig/export/setup.ts@@ -30,7 +30,7 @@ import type { SkiaRenderer } from '#core/canvas'import { CANVAS_BG_COLOR, IS_BROWSER, IS_TAURI } from '#core/constants'import { getPageColor } from '#core/figma-api/page-backgrounds'import { applyDocumentPluginData } from '#core/io/formats/fig/document-metadata'-import { findFigThumbnailPageId } from '#core/io/formats/fig/thumbnail-page'+import { figThumbnailPageId } from '#core/io/formats/fig/thumbnail-page'import { renderThumbnail, thumbnailFrame } from '#core/io/formats/raster'import { settleFontDigestMap } from '#core/kiwi/fig/node-change/serialize'@@ -550,7 +550,8 @@ export async function figFileExtras(imageNames: ReadonlyMap<string, string>,options: FigFileExtrasOptions): Promise<FigFileExtras> {- const thumbnailPageId = options.pageId ?? findFigThumbnailPageId(graph.getPages(true))+ // Internal pages hold library data, not anything a person drew, so the thumbnail skips them.+ const thumbnailPageId = options.pageId ?? figThumbnailPageId(graph.getPages())const thumbnail = await renderFigThumbnail(graph, thumbnailPageId, options)const metaJSON = figArchiveMetaJSON({fileName: options.documentName || UNTITLED_FILE_NAME,diff --git a/packages/core/src/io/formats/fig/index.ts b/packages/core/src/io/formats/fig/index.tsindex 4600eb9b2..38fa2a425 100644--- a/packages/core/src/io/formats/fig/index.ts+++ b/packages/core/src/io/formats/fig/index.ts@@ -1,6 +1,6 @@export { readFigFile, parseFigFile, type ParseFigFileOptions } from './read'export { exportFigFile, compressFigData, type FigFileExtrasOptions } from './write'-export { findFigThumbnailPageId } from './thumbnail-page'+export { figThumbnailPageId } from './thumbnail-page'export {isReaderPagePending as isFigPagePending,populateFigPage,diff --git a/packages/core/src/io/formats/fig/thumbnail-page.ts b/packages/core/src/io/formats/fig/thumbnail-page.tsindex 4dedd240d..6cbfeb09f 100644--- a/packages/core/src/io/formats/fig/thumbnail-page.ts+++ b/packages/core/src/io/formats/fig/thumbnail-page.ts@@ -5,14 +5,18 @@ type ThumbnailPage = {const COVER_PAGE_NAME = 'cover'-/** Resolve the conventional Figma cover page without falling back to unrelated content. */-export function findFigThumbnailPageId(pages: readonly ThumbnailPage[]): string | undefined {+/**+ * The page a `.fig` thumbnail shows: the conventional Cover page, or the first page when there is+ * none, as Figma's own thumbnail does.+ */+export function figThumbnailPageId(pages: readonly ThumbnailPage[]): string | undefined {const normalizedNames = pages.map((page) => ({page,name: page.name.trim().toLocaleLowerCase()}))return (normalizedNames.find(({ name }) => name === COVER_PAGE_NAME)?.page.id ??- normalizedNames.find(({ name }) => name.includes(COVER_PAGE_NAME))?.page.id+ normalizedNames.find(({ name }) => name.includes(COVER_PAGE_NAME))?.page.id ??+ pages.at(0)?.id)}diff --git a/packages/core/tests/io/formats/fig/export/meta.test.ts b/packages/core/tests/io/formats/fig/export/meta.test.tsindex eb4dc6b98..486e786d1 100644--- a/packages/core/tests/io/formats/fig/export/meta.test.ts+++ b/packages/core/tests/io/formats/fig/export/meta.test.ts@@ -54,6 +54,18 @@ describe('.fig meta.json', () => {expect(meta.client_meta.render_coordinates).toEqual({ x: 49, y: 3, width: 345, height: 308 })})+ test('without a Cover page, the thumbnail shows the first page a person drew on', async () => {+ const { graph } = landingPage()+ // An internal page, such as the one library data lives on, listed before it.+ const internal = graph.addPage('Internal')+ graph.updateNode(internal.id, { internalOnly: true })+ graph.insertChildAt(internal.id, graph.rootId, 0)+ graph.createNode('RECTANGLE', internal.id, { x: 900, y: 900, width: 10, height: 10 })+ const { meta } = readArchive(await exportFigFile(graph, { renderHeadlessThumbnail: true }))++ expect(meta.client_meta.render_coordinates).toEqual({ x: 49, y: 3, width: 345, height: 308 })+ })+test('describes the placeholder when no thumbnail was rendered', async () => {const { graph } = landingPage()const { meta, thumbnailSize } = readArchive(await exportFigFile(graph))diff --git a/packages/vue/src/document/workspace/previews.ts b/packages/vue/src/document/workspace/previews.tsindex e4a613abf..1daddc241 100644--- a/packages/vue/src/document/workspace/previews.ts+++ b/packages/vue/src/document/workspace/previews.ts@@ -24,6 +24,8 @@ export function createDocumentPreviews<Item extends DocumentWorkspaceItem>(const previewQueue: string[] = []const queued = new Set<string>()const active = new Set<string>()+ // Previews whose document changed: shown until the new preview replaces them.+ const stale = new Set<string>()const requestedConcurrency = options.previewConcurrency ?? 6const concurrency = Number.isFinite(requestedConcurrency)? Math.max(1, Math.floor(requestedConcurrency))@@ -32,6 +34,11 @@ export function createDocumentPreviews<Item extends DocumentWorkspaceItem>(function removeURL(id: string): void {previewGenerations.set(id, (previewGenerations.get(id) ?? 0) + 1)+ dropURL(id)+ }++ function dropURL(id: string): void {+ stale.delete(id)const url = previewUrls.value[id]if (!url) returnURL.revokeObjectURL(url)@@ -65,7 +72,11 @@ export function createDocumentPreviews<Item extends DocumentWorkspaceItem>(const bytes = await options.source.loadPreview(id)if (bytes?.byteLength && generation === (previewGenerations.get(id) ?? 0)) {clearError(id)+ stale.delete(id)replaceURL(id, bytes)+ } else if (generation === (previewGenerations.get(id) ?? 0) && stale.has(id)) {+ // The design changed and has no preview now, so the old one would be wrong.+ dropURL(id)}} catch (error: unknown) {if (!disposed && generation === (previewGenerations.get(id) ?? 0)) {@@ -94,14 +105,14 @@ export function createDocumentPreviews<Item extends DocumentWorkspaceItem>(const id = previewQueue.shift()if (!id) breakif (!queued.delete(id)) continue- if (active.has(id) || previewUrls.value[id]) continue+ if (active.has(id) || (previewUrls.value[id] && !stale.has(id))) continueactive.add(id)void runLoad(id, previewGenerations.get(id) ?? 0)}}function loadPreview(id: string): void {- if (previewUrls.value[id] || active.has(id) || queued.has(id)) return+ if ((previewUrls.value[id] && !stale.has(id)) || active.has(id) || queued.has(id)) returnclearError(id)queued.add(id)previewQueue.push(id)@@ -119,12 +130,16 @@ export function createDocumentPreviews<Item extends DocumentWorkspaceItem>(])for (const id of trackedIds) {if (previous.get(id) === current.get(id)) continue- removeURL(id)- clearError(id)if (!current.has(id)) {+ removeURL(id)+ clearError(id)queued.delete(id)continue}+ // Keep the old preview on screen while the new one loads.+ previewGenerations.set(id, (previewGenerations.get(id) ?? 0) + 1)+ if (previewUrls.value[id]) stale.add(id)+ clearError(id)if (active.has(id) || queued.has(id)) continuequeued.add(id)previewQueue.push(id)@@ -142,6 +157,7 @@ export function createDocumentPreviews<Item extends DocumentWorkspaceItem>(for (const id of ids) removeURL(id)previewQueue.length = 0queued.clear()+ stale.clear()previewErrors.value = {}}diff --git a/packages/vue/src/document/workspace/use.ts b/packages/vue/src/document/workspace/use.tsindex b364f1905..3d4b06920 100644--- a/packages/vue/src/document/workspace/use.ts+++ b/packages/vue/src/document/workspace/use.ts@@ -50,12 +50,12 @@ export function useDocumentWorkspace<Item extends DocumentWorkspaceItem>(function refresh(): Promise<void> {if (refreshPromise) return refreshPromiseloading.value = true- error.value = nullconst nextRefresh = options.source.refresh().then((items) => {if (!disposed && items) {previews.reconcile(documents.value, items)+ error.value = nulldocuments.value = itemslastRefreshedAt.value = new Date()}diff --git a/src/app/diagnostics/events/storage/operation.ts b/src/app/diagnostics/events/storage/operation.tsindex 8cc3dc7be..e3eedcb68 100644--- a/src/app/diagnostics/events/storage/operation.ts+++ b/src/app/diagnostics/events/storage/operation.ts@@ -5,7 +5,6 @@ export type StorageDiagnosticOperation = 'upload' | 'download' | 'delete' | 'lisexport function storageOperationForJob(type: OutboxJobType): StorageDiagnosticOperation {switch (type) {case 'putCanvas':- case 'putThumb':return 'upload'case 'deleteCanvas':return 'delete'diff --git a/src/app/integrations/storage/namespace.ts b/src/app/integrations/storage/namespace.tsindex 0c3e750a5..8a8fdedfc 100644--- a/src/app/integrations/storage/namespace.ts+++ b/src/app/integrations/storage/namespace.ts@@ -11,10 +11,6 @@ export function documentMetaKey(documentId: string): string {return `${STORAGE_DOCUMENTS_PREFIX}${documentId}.meta.json`}-export function documentThumbnailKey(documentId: string): string {- return `${STORAGE_DOCUMENTS_PREFIX}${documentId}.thumb.jpg`-}-export function documentIdFromFigKey(key: string): string | null {if (!key.startsWith(STORAGE_DOCUMENTS_PREFIX) || !key.endsWith('.fig')) return nullconst id = key.slice(STORAGE_DOCUMENTS_PREFIX.length, -'.fig'.length)diff --git a/src/app/integrations/storage/s3/adapter.ts b/src/app/integrations/storage/s3/adapter.tsindex 2cfc05a82..ebbf43c1b 100644--- a/src/app/integrations/storage/s3/adapter.ts+++ b/src/app/integrations/storage/s3/adapter.ts@@ -12,8 +12,7 @@ import {STORAGE_NAMESPACE_MARKER,documentFigKey,documentIdFromFigKey,- documentMetaKey,- documentThumbnailKey+ documentMetaKey} from '../namespace'import type {StorageAdapter,@@ -248,8 +247,7 @@ export function createS3StorageAdapter(runtime: StorageProviderRuntime): S3Storaconst config = await resolveConfig(runtime)const results = await Promise.allSettled([deleteObject(config, documentFigKey(id)),- deleteObject(config, documentMetaKey(id)),- deleteObject(config, documentThumbnailKey(id))+ deleteObject(config, documentMetaKey(id))])const failure = results.find((result): result is PromiseRejectedResult => result.status === 'rejected'@@ -267,11 +265,6 @@ export function createS3StorageAdapter(runtime: StorageProviderRuntime): S3Stora}},- async putThumbnail(id, bytes) {- const config = await resolveConfig(runtime)- await putObject(config, documentThumbnailKey(id), bytes, 'image/jpeg')- },-async getThumbnail(id) {const config = await resolveConfig(runtime)const figKey = documentFigKey(id)diff --git a/src/app/integrations/storage/types.ts b/src/app/integrations/storage/types.tsindex 39dadb706..00ee274a9 100644--- a/src/app/integrations/storage/types.ts+++ b/src/app/integrations/storage/types.ts@@ -116,7 +116,6 @@ export interface StorageAdapter {getDocumentMetadata?(id: string): Promise<StorageDocumentMetadata | null>getUsage(): Promise<StorageUsage>getThumbnail?(id: string): Promise<Uint8Array | null>- putThumbnail?(id: string, bytes: Uint8Array): Promise<void>libraryObjects?: LibraryObjectStore}diff --git a/src/app/storage/sync/engine.ts b/src/app/storage/sync/engine.tsindex 454d3ba89..51134b164 100644--- a/src/app/storage/sync/engine.ts+++ b/src/app/storage/sync/engine.ts@@ -78,62 +78,53 @@ async function runJob(job: OutboxJob): Promise<void> {return}- if (job.type === 'putCanvas') {- // Superseded by a newer local revision already on disk- if (meta.revision > job.revision) return- if (!meta.hasFig) return- const fig = await store.readFig(job.canvasId)- if (!fig || fig.byteLength === 0) throw new Error('Local document missing for sync')- setUploadProgress(job.canvasId, 0)- let written: { revision: string | null }- try {- written = await adapter.putDocument(- job.canvasId,- fig,- {- name: meta.name,- updatedAt: meta.updatedAt- },- ({ transferredBytes, totalBytes }) => {- if (totalBytes) setUploadProgress(job.canvasId, transferredBytes / totalBytes)- },- { baseRevision: meta.remoteRevision ?? null }- )- } finally {- setUploadProgress(job.canvasId, null)- }- // Later local edits build on what was just stored, even when they arrived mid-upload.- if (written.revision !== null) {- await store.updateMeta(job.canvasId, { remoteRevision: written.revision })- }- // Only mark synced if still on this revision and no other pending work for newer rev- const latest = await store.getMeta(job.canvasId)- if (latest && latest.revision === job.revision && !latest.tombstoned) {- await store.updateMeta(- job.canvasId,- {- syncStatus: 'synced',- lastSyncedAt: new Date().toISOString(),- lastSyncError: null,- conflictRevision: null- },- { expectedRevision: job.revision }- )- await evictLocalFigCache(new Set([job.canvasId]))- emitStorageWorkspaceEvent({- ...location,- documentId: job.canvasId,- kind: 'synced'- })- }- return+ // Superseded by a newer local revision already on disk+ if (meta.revision > job.revision) return+ if (!meta.hasFig) return+ const fig = await store.readFig(job.canvasId)+ if (!fig || fig.byteLength === 0) throw new Error('Local document missing for sync')+ setUploadProgress(job.canvasId, 0)+ let written: { revision: string | null }+ try {+ written = await adapter.putDocument(+ job.canvasId,+ fig,+ {+ name: meta.name,+ updatedAt: meta.updatedAt+ },+ ({ transferredBytes, totalBytes }) => {+ if (totalBytes) setUploadProgress(job.canvasId, transferredBytes / totalBytes)+ },+ { baseRevision: meta.remoteRevision ?? null }+ )+ } finally {+ setUploadProgress(job.canvasId, null)+ }+ // Later local edits build on what was just stored, even when they arrived mid-upload.+ if (written.revision !== null) {+ await store.updateMeta(job.canvasId, { remoteRevision: written.revision })+ }+ // Only mark synced if still on this revision and no other pending work for newer rev+ const latest = await store.getMeta(job.canvasId)+ if (latest && latest.revision === job.revision && !latest.tombstoned) {+ await store.updateMeta(+ job.canvasId,+ {+ syncStatus: 'synced',+ lastSyncedAt: new Date().toISOString(),+ lastSyncError: null,+ conflictRevision: null+ },+ { expectedRevision: job.revision }+ )+ await evictLocalFigCache(new Set([job.canvasId]))+ emitStorageWorkspaceEvent({+ ...location,+ documentId: job.canvasId,+ kind: 'synced'+ })}-- // Remaining job type: putThumb- if (!adapter.putThumbnail) return- const thumb = await store.readThumb(job.canvasId)- if (!thumb) return- await adapter.putThumbnail(job.canvasId, thumb)}async function pumpOnce(): Promise<void> {@@ -212,34 +203,18 @@ async function pumpOnce(): Promise<void> {console.warn('[Storage sync] job failed:', job.type, job.canvasId, message)if (permanent) {- // A failed thumbnail upload must not poison the document's sync status —- // only canvas/delete jobs reflect into the meta row.- if (job.type !== 'putThumb') {- await getLocalCanvasStore().updateMeta(job.canvasId, {- syncStatus: 'error',- lastSyncError: message- })- setSyncUI('error', message.slice(0, 120))- } else {- // Keep a record without touching syncStatus so the stale remote- // thumbnail is at least diagnosable.- await getLocalCanvasStore().updateMeta(job.canvasId, { lastSyncError: message })- }- if (job.type === 'putThumb') {- await outbox.remove(job.id)- const remaining = await outbox.list()- setPendingSyncCount(remaining.length)- if (remaining.length > 0) scheduleWake(1000)- else setSyncUI('idle')- } else {- // Never discard a document mutation. Keep it durable until the user- // repairs credentials/permissions and explicitly wakes synchronization.- await outbox.update({- ...job,- attempts,- nextAttemptAt: PARKED_ATTEMPT_AT- })- }+ await getLocalCanvasStore().updateMeta(job.canvasId, {+ syncStatus: 'error',+ lastSyncError: message+ })+ setSyncUI('error', message.slice(0, 120))+ // Never discard a document mutation. Keep it durable until the user+ // repairs credentials/permissions and explicitly wakes synchronization.+ await outbox.update({+ ...job,+ attempts,+ nextAttemptAt: PARKED_ATTEMPT_AT+ })return}@@ -249,12 +224,10 @@ async function pumpOnce(): Promise<void> {nextAttemptAt: Date.now() + backoffMs(attempts)}await outbox.update(updated)- if (job.type !== 'putThumb') {- await getLocalCanvasStore().updateMeta(job.canvasId, {- syncStatus: 'pending',- lastSyncError: message- })- }+ await getLocalCanvasStore().updateMeta(job.canvasId, {+ syncStatus: 'pending',+ lastSyncError: message+ })// Wake for the next ready job across the whole queue — not this job's// full backoff, which starved other jobs that were ready sooner.const all = await outbox.list()@@ -319,11 +292,6 @@ export async function enqueuePutCanvas(canvasId: string, revision: number): Promvoid kickSyncEngine()}-export async function enqueuePutThumb(canvasId: string, revision: number): Promise<void> {- await getOutbox().enqueue({ canvasId, type: 'putThumb', revision })- void kickSyncEngine()-}-export async function enqueueDeleteCanvas(canvasId: string): Promise<void> {await getOutbox().enqueue({ canvasId, type: 'deleteCanvas', revision: 0 })void kickSyncEngine()diff --git a/src/app/storage/sync/index.ts b/src/app/storage/sync/index.tsindex 2f1447ed6..8a8f2ed25 100644--- a/src/app/storage/sync/index.ts+++ b/src/app/storage/sync/index.ts@@ -2,7 +2,6 @@ export {clearStorageLocalMirror,enqueueDeleteCanvas,enqueuePutCanvas,- enqueuePutThumb,kickSyncEngine,resumeStorageSync} from './engine'diff --git a/src/app/storage/sync/outbox.ts b/src/app/storage/sync/outbox.tsindex 59b11080e..82db9a557 100644--- a/src/app/storage/sync/outbox.ts+++ b/src/app/storage/sync/outbox.ts@@ -59,7 +59,7 @@ function buildJob(partial: OutboxEnqueueInput): OutboxJob {/*** Queue with the new job applied: putCanvas supersedes older revisions,- * and only one putThumb/delete per canvas survives (latest wins).+ * and only one delete per canvas survives (latest wins).*/function withJobQueued(queue: OutboxJob[], job: OutboxJob): OutboxJob[] {let next = queuediff --git a/src/app/storage/sync/types.ts b/src/app/storage/sync/types.tsindex 172cacf8f..4863aa97a 100644--- a/src/app/storage/sync/types.ts+++ b/src/app/storage/sync/types.ts@@ -1,4 +1,4 @@-export type OutboxJobType = 'putCanvas' | 'putThumb' | 'deleteCanvas'+export type OutboxJobType = 'putCanvas' | 'deleteCanvas'export type OutboxJob = {id: stringdiff --git a/src/app/tabs/index.ts b/src/app/tabs/index.tsindex 52341fff4..a91cf20ed 100644--- a/src/app/tabs/index.ts+++ b/src/app/tabs/index.ts@@ -2,7 +2,7 @@ import { promiseTimeout } from '@vueuse/core'import { shallowRef, computed, triggerRef } from 'vue'import { BUILTIN_IO_FORMATS, IORegistry } from '@open-pencil/core/io'-import { findFigThumbnailPageId, populateFigPage } from '@open-pencil/core/io/formats/fig'+import { figThumbnailPageId, populateFigPage } from '@open-pencil/core/io/formats/fig'import { renderThumbnail } from '@open-pencil/core/io/formats/raster'import { computeAllLayouts } from '@open-pencil/core/layout'import type { SceneGraph } from '@open-pencil/scene-graph'@@ -270,10 +270,10 @@ async function readFigForTab(file: File, signal?: AbortSignal): Promise<SceneGraconst layOut = (pageId: string) =>imported.applyDerivedLayoutDuring(() => computeAllLayouts(imported, pageId))if (firstPageId) layOut(firstPageId)- const coverPageId = findFigThumbnailPageId(imported.getPages())- if (coverPageId && coverPageId !== firstPageId) {- populateFigPage(imported, coverPageId)- layOut(coverPageId)+ const thumbnailPageId = figThumbnailPageId(imported.getPages())+ if (thumbnailPageId && thumbnailPageId !== firstPageId) {+ populateFigPage(imported, thumbnailPageId)+ layOut(thumbnailPageId)}return imported}@@ -299,26 +299,26 @@ async function showImportedGraph(async function cacheOpenedFigCover(path: string, store: EditorStore): Promise<void> {if (await loadCachedRecentFileThumbnail(path)) return- const coverPageId = findFigThumbnailPageId(store.graph.getPages())- if (!coverPageId) return+ const thumbnailPageId = figThumbnailPageId(store.graph.getPages())+ if (!thumbnailPageId) returnfor (let attempt = 0; attempt < 240 && !store.renderer; attempt++) {await promiseTimeout(250)}const renderer = store.rendererif (!renderer) {- console.warn('[Recent files] Cover thumbnail skipped because the renderer was unavailable')+ console.warn('[Recent files] Thumbnail skipped because the renderer was unavailable')return}const bytes = renderThumbnail(renderer.ck,renderer,store.graph,- coverPageId,+ thumbnailPageId,RECENT_FILE_THUMBNAIL_SIZE,RECENT_FILE_THUMBNAIL_SIZE)if (!bytes) {- console.warn('[Recent files] Cover thumbnail skipped because the Cover page was empty')+ console.warn('[Recent files] Thumbnail skipped because its page was empty')return}await cacheRecentFileThumbnail(path, bytes)@@ -326,14 +326,14 @@ async function cacheOpenedFigCover(path: string, store: EditorStore): Promise<vofunction watchOpenedFigCover(path: string, store: EditorStore): void {coverThumbnailListeners.get(store)?.()- const coverPageId = findFigThumbnailPageId(store.graph.getPages())- if (!coverPageId) return+ const thumbnailPageId = figThumbnailPageId(store.graph.getPages())+ if (!thumbnailPageId) returncoverThumbnailListeners.set(store,store.onEditorEvent('page:changed', (pageId) => {- if (pageId !== coverPageId) return+ if (pageId !== thumbnailPageId) returnvoid cacheOpenedFigCover(path, store).catch((error) => {- console.warn('[Recent files] Failed to cache the Cover thumbnail', error)+ console.warn('[Recent files] Failed to cache the thumbnail', error)})}))@@ -498,7 +498,7 @@ export async function openFileInNewTab(if (path?.toLowerCase().endsWith('.fig')) {watchOpenedFigCover(path, existing.store)void cacheOpenedFigCover(path, existing.store).catch((error) => {- console.warn('[Recent files] Failed to cache the Cover thumbnail', error)+ console.warn('[Recent files] Failed to cache the thumbnail', error)})}return { kind: 'existing' as const, store: existing.store }@@ -569,7 +569,7 @@ export async function openFileInNewTab()if (isFig && path) {void cacheOpenedFigCover(path, store).catch((error) => {- console.warn('[Recent files] Failed to cache the Cover thumbnail', error)+ console.warn('[Recent files] Failed to cache the thumbnail', error)})}completion.resolve(undefined)diff --git a/tests/engine/app/diagnostics/events.test.ts b/tests/engine/app/diagnostics/events.test.tsindex 68e65e4ec..672e873a1 100644--- a/tests/engine/app/diagnostics/events.test.ts+++ b/tests/engine/app/diagnostics/events.test.ts@@ -58,7 +58,6 @@ describe('diagnostic error metadata', () => {describe('storageOperationForJob', () => {test('maps every outbox operation explicitly', () => {expect(storageOperationForJob('putCanvas')).toBe('upload')- expect(storageOperationForJob('putThumb')).toBe('upload')expect(storageOperationForJob('deleteCanvas')).toBe('delete')})})diff --git a/tests/engine/app/integrations/storage/namespace.test.ts b/tests/engine/app/integrations/storage/namespace.test.tsindex e3f00fd4c..54426c87c 100644--- a/tests/engine/app/integrations/storage/namespace.test.ts+++ b/tests/engine/app/integrations/storage/namespace.test.ts@@ -6,8 +6,7 @@ import {STORAGE_NAMESPACE_MARKER,documentFigKey,documentIdFromFigKey,- documentMetaKey,- documentThumbnailKey+ documentMetaKey} from '@/app/integrations/storage/namespace'describe('storage namespace', () => {@@ -21,7 +20,6 @@ describe('storage namespace', () => {const id = 'abc-123'expect(documentFigKey(id)).toBe('open_pencil_storage/canvases/abc-123.fig')expect(documentMetaKey(id)).toBe('open_pencil_storage/canvases/abc-123.meta.json')- expect(documentThumbnailKey(id)).toBe('open_pencil_storage/canvases/abc-123.thumb.jpg')})test('parses document IDs from fig keys and ignores foreign keys', () => {diff --git a/tests/engine/app/storage/sync-outbox.test.ts b/tests/engine/app/storage/sync-outbox.test.tsindex 9738ead8a..722f9bd22 100644--- a/tests/engine/app/storage/sync-outbox.test.ts+++ b/tests/engine/app/storage/sync-outbox.test.ts@@ -19,7 +19,7 @@ describe('supersedePutCanvasJobs', () => {{id: 'b',canvasId: 'c1',- type: 'putThumb',+ type: 'deleteCanvas',revision: 1,createdAt: 2,attempts: 0,diff --git a/tests/engine/io/fig/thumbnail-page.test.ts b/tests/engine/io/fig/thumbnail-page.test.tsindex 00d330f6d..c00d7a0ee 100644--- a/tests/engine/io/fig/thumbnail-page.test.ts+++ b/tests/engine/io/fig/thumbnail-page.test.ts@@ -1,11 +1,11 @@import { describe, expect, test } from 'bun:test'-import { findFigThumbnailPageId } from '#core/io/formats/fig/thumbnail-page'+import { figThumbnailPageId } from '#core/io/formats/fig/thumbnail-page'describe('FIG thumbnail page selection', () => {test('prefers an exact Cover page case-insensitively', () => {expect(- findFigThumbnailPageId([+ figThumbnailPageId([{ id: 'first', name: 'Cover archive' },{ id: 'exact', name: ' COVER ' },{ id: 'last', name: 'Cover v2' }@@ -15,7 +15,7 @@ describe('FIG thumbnail page selection', () => {test('uses the first page containing Cover when no exact match exists', () => {expect(- findFigThumbnailPageId([+ figThumbnailPageId([{ id: 'unrelated', name: 'Homepage' },{ id: 'first-cover', name: '✨ Project cover' },{ id: 'second-cover', name: 'Cover archive' }@@ -23,7 +23,15 @@ describe('FIG thumbnail page selection', () => {).toBe('first-cover')})- test('does not fall back to an unrelated page', () => {- expect(findFigThumbnailPageId([{ id: 'first', name: 'Homepage' }])).toBeUndefined()+ // Live Figma 2026-10-25: a file saved with pages "Page 1" and "Second" and no Cover page embeds+ // a thumbnail of "Page 1".+ test('uses the first page when there is no Cover page, as Figma does', () => {+ expect(+ figThumbnailPageId([+ { id: 'first', name: 'Page 1' },+ { id: 'second', name: 'Second' }+ ])+ ).toBe('first')+ expect(figThumbnailPageId([])).toBeUndefined()})})diff --git a/tests/engine/vue/document-workspace.test.ts b/tests/engine/vue/document-workspace.test.tsindex 55e85e50d..f229451b5 100644--- a/tests/engine/vue/document-workspace.test.ts+++ b/tests/engine/vue/document-workspace.test.ts@@ -199,4 +199,76 @@ describe('useDocumentWorkspace', () => {await flushTasks()expect(createObjectURL).toHaveBeenCalledTimes(1)})++ test('keeps the list, its error, and the old preview on screen while a refresh reloads them', async () => {+ let urlCount = 0+ vi.spyOn(URL, 'createObjectURL').mockImplementation(() => `blob:preview-${++urlCount}`)+ vi.spyOn(URL, 'revokeObjectURL').mockImplementation(() => undefined)+ let updatedAt = '2026-10-01'+ let failNext = false+ const pending: { release: (() => void) | null } = { release: null }+ const held: { release: (() => void) | null } = { release: null }+ let holdNext = false+ const holder: { workspace: Workspace | null } = { workspace: null }+ const app = renderer.createApp(+ defineComponent({+ setup() {+ holder.workspace = useDocumentWorkspace<DocumentWorkspaceItem>({+ source: {+ async refresh() {+ if (holdNext) {+ holdNext = false+ await new Promise<void>((resolve) => {+ held.release = resolve+ })+ }+ if (failNext) throw new Error('offline')+ return [{ id: 'design', name: 'Design', updatedAt }]+ },+ loadPreview: (id) =>+ urlCount === 0+ ? Promise.resolve(new Uint8Array([1]))+ : new Promise((resolve) => {+ pending.release = () => resolve(new Uint8Array([id.length]))+ })+ },+ refreshOnFocus: false,+ refreshOnReconnect: false+ })+ return () => h('div')+ }+ })+ )+ app.mount(hostNode())+ const current = holder.workspace+ if (!current) throw new Error('Workspace did not initialize')+ await flushTasks()+ current.loadPreview('design')+ await flushTasks()+ expect(current.previewURL('design')).toBe('blob:preview-1')++ updatedAt = '2026-10-02'+ await current.refresh()+ expect(current.documents.value).toHaveLength(1)+ expect(current.previewURL('design')).toBe('blob:preview-1')+ pending.release?.()+ await flushTasks()+ expect(current.previewURL('design')).toBe('blob:preview-2')++ failNext = true+ await current.refresh()+ expect(current.error.value).toBeInstanceOf(Error)+ failNext = false+ holdNext = true+ const refreshing = current.refresh()+ await flushTasks()+ expect(held.release).not.toBeNull()+ expect(current.error.value).toBeInstanceOf(Error)+ expect(current.documents.value).toHaveLength(1)+ held.release?.()+ await refreshing+ expect(current.documents.value).toHaveLength(1)+ expect(current.error.value).toBeNull()+ app.unmount()+ })})