AI-native design editor. Open-source Figma alternative.
feat: tell boards from designs in Cloud and on Home (#1653)
Danila Poyarkov686a42f50182
diff --git a/changes/1653/added.md b/changes/1653/added.mdnew file mode 100644index 000000000..aaebaa552--- /dev/null+++ b/changes/1653/added.md@@ -0,0 +1 @@+- Cloud keeps whether a document is a design or a FigJam board, and Home marks each file with its kind and filters recent files by it.diff --git a/packages/cloud/src/client/api.ts b/packages/cloud/src/client/api.tsindex ce500ad79..08178a1de 100644--- a/packages/cloud/src/client/api.ts+++ b/packages/cloud/src/client/api.ts@@ -29,7 +29,7 @@ import {type CreateInvitationContinuationInput,type InvitationContinuation,type CommitUploadRequest,- type CreateDocumentInput,+ type CreateDocumentRequest,type CreateDocumentInvitationInput,type CreateDocumentShareInput,type CreateUploadInput,@@ -192,12 +192,12 @@ export function createCloudAPIClient(baseURL: string, options: CloudRequestOptio},async createDocument(workspaceId: string,- input: CreateDocumentInput+ input: CreateDocumentRequest): Promise<DocumentSummary> {const response = await parseResponse(client.workspaces[':workspaceId'].documents.$post({param: { workspaceId },- json: input+ json: { ...input, kind: input.kind ?? 'design' }}),documentResponseSchema,options.onDiagnosticdiff --git a/packages/cloud/src/contract/documents.ts b/packages/cloud/src/contract/documents.tsindex 0c2063dd1..06305a519 100644--- a/packages/cloud/src/contract/documents.ts+++ b/packages/cloud/src/contract/documents.ts@@ -62,10 +62,16 @@ export const documentAccessSchema = v.object({})export type DocumentAccess = v.InferOutput<typeof documentAccessSchema>+/** What a document is: a Figma design or a FigJam board, which the file it stores says too. */+export const documentKindSchema = v.picklist(['design', 'board'])+export type CloudDocumentKind = v.InferOutput<typeof documentKindSchema>+export const documentSummarySchema = v.object({id: v.pipe(v.string(), v.uuid()),workspaceId: v.pipe(v.string(), v.uuid()),name: v.string(),+ /** A design unless said otherwise; servers from before boards list no kind. */+ kind: v.optional(documentKindSchema, 'design'),currentRevisionId: v.nullable(v.pipe(v.string(), v.uuid())),version: v.number(),createdAt: v.string(),@@ -116,9 +122,13 @@ export const CLOUD_DOCUMENT_NAME_MAX_LENGTH = 255export const createDocumentSchema = v.object({id: v.optional(v.pipe(v.string(), v.uuid())),- name: v.pipe(v.string(), v.trim(), v.minLength(1), v.maxLength(CLOUD_DOCUMENT_NAME_MAX_LENGTH))+ name: v.pipe(v.string(), v.trim(), v.minLength(1), v.maxLength(CLOUD_DOCUMENT_NAME_MAX_LENGTH)),+ /** A design unless said otherwise; older clients create only designs. */+ kind: v.optional(documentKindSchema, 'design')})export type CreateDocumentInput = v.InferOutput<typeof createDocumentSchema>+/** A new document as a client sends it, which may leave out its kind to make a design. */+export type CreateDocumentRequest = v.InferInput<typeof createDocumentSchema>export const createUploadSchema = v.object({baseRevisionId: v.nullable(v.pipe(v.string(), v.uuid())),@@ -193,6 +203,8 @@ export const commitUploadSchema = v.object({checksum: checksumSchema,/** The document title captured with this revision; omitted by older clients. */name: v.optional(createDocumentSchema.entries.name),+ /** What the uploaded file is, which the document takes; omitted by older clients. */+ kind: v.optional(documentKindSchema),multipart: v.optional(v.object({uploadId: v.pipe(v.string(), v.minLength(1)),diff --git a/packages/cloud/src/contract/index.ts b/packages/cloud/src/contract/index.tsindex d30c9aec9..af9d8c9aa 100644--- a/packages/cloud/src/contract/index.ts+++ b/packages/cloud/src/contract/index.ts@@ -101,6 +101,7 @@ export {type CommitImageUploadsInput,type CommitUploadInput,type CommitUploadRequest,+ type CreateDocumentRequest,type CreateDocumentInput,type CreateUploadInput,type DocumentAccess,diff --git a/packages/cloud/src/server/db/migrate.ts b/packages/cloud/src/server/db/migrate.tsindex 01ddea892..2db3eb1a3 100644--- a/packages/cloud/src/server/db/migrate.ts+++ b/packages/cloud/src/server/db/migrate.ts@@ -27,6 +27,7 @@ import * as documentImages from './migrations/023_document_images'import * as accountActivity from './migrations/024_account_activity'import * as tableNames from './migrations/025_table_names'import * as userPicture from './migrations/026_user_picture'+import * as documentKind from './migrations/027_document_kind'import type { CloudDatabase } from './tables'const migrations: Record<string, Migration> = {@@ -55,7 +56,8 @@ const migrations: Record<string, Migration> = {'023_document_images': documentImages,'024_account_activity': accountActivity,'025_table_names': tableNames,- '026_user_picture': userPicture+ '026_user_picture': userPicture,+ '027_document_kind': documentKind}class CloudMigrationProvider implements MigrationProvider {diff --git a/packages/cloud/src/server/db/migrations/027_document_kind.ts b/packages/cloud/src/server/db/migrations/027_document_kind.tsnew file mode 100644index 000000000..88c913895--- /dev/null+++ b/packages/cloud/src/server/db/migrations/027_document_kind.ts@@ -0,0 +1,19 @@+import type { Kysely } from 'kysely'++import { addCheckConstraint } from './helpers'++/**+ * Whether each document is a Figma design or a FigJam board, so lists can tell them apart+ * without opening the file. Documents stored before this are designs; a board's next save says so.+ */+export async function up(database: Kysely<unknown>): Promise<void> {+ await database.schema+ .alterTable('document')+ .addColumn('kind', 'text', (column) => column.notNull().defaultTo('design'))+ .execute()+ await addCheckConstraint(database, 'document', 'document_kind_check', 'kind', ['design', 'board'])+}++export async function down(database: Kysely<unknown>): Promise<void> {+ await database.schema.alterTable('document').dropColumn('kind').execute()+}diff --git a/packages/cloud/src/server/db/tables.ts b/packages/cloud/src/server/db/tables.tsindex 74f650858..6f7f7e48b 100644--- a/packages/cloud/src/server/db/tables.ts+++ b/packages/cloud/src/server/db/tables.ts@@ -79,6 +79,8 @@ export interface DocumentTable {id: stringworkspaceId: stringname: string+ /** A design or a board; see migration 027. */+ kind: Generated<'design' | 'board'>currentRevisionId: string | nullcollaborationEpoch: Generated<number>version: Generated<number>diff --git a/packages/cloud/src/server/documents/repository.ts b/packages/cloud/src/server/documents/repository.tsindex 0363aba4c..3009589a2 100644--- a/packages/cloud/src/server/documents/repository.ts+++ b/packages/cloud/src/server/documents/repository.ts@@ -39,7 +39,16 @@ export async function listDocuments(if (!(await workspaceRole(database, userId, workspaceId))) return undefinedconst rows = await database.selectFrom('document')- .select(['id', 'workspaceId', 'name', 'currentRevisionId', 'version', 'createdAt', 'updatedAt'])+ .select([+ 'id',+ 'workspaceId',+ 'name',+ 'kind',+ 'currentRevisionId',+ 'version',+ 'createdAt',+ 'updatedAt'+ ]).where('workspaceId', '=', workspaceId).where('deletedAt', 'is', null).orderBy('updatedAt', 'desc')@@ -60,6 +69,7 @@ export async function listSharedDocuments('document.id','document.workspaceId','document.name',+ 'document.kind','document.currentRevisionId','document.version','document.createdAt',diff --git a/packages/cloud/src/server/documents/service.ts b/packages/cloud/src/server/documents/service.tsindex e56d9f5d5..7e127aced 100644--- a/packages/cloud/src/server/documents/service.ts+++ b/packages/cloud/src/server/documents/service.ts@@ -42,7 +42,7 @@ import { announceVersions, recordCheckpoint } from '#cloud/server/documents/versimport type { ObjectStore, StoredObject } from '#cloud/server/objects'import type { CloudPolicy } from '#cloud/server/policy/policy'import { createStorageQuotaService } from '#cloud/server/quota'-import { limitAsync, uniq, uniqBy } from 'es-toolkit'+import { isUndefined, limitAsync, omitBy, uniq, uniqBy } from 'es-toolkit'import type { Kysely, Transaction } from 'kysely'const DOWNLOAD_LIFETIME_MS = 5 * 60 * 1000@@ -93,7 +93,8 @@ export function createDocumentService(revisionId,storageObjectId,images: revisionImages,- name+ name,+ kind}: {userId: stringuploadId: string@@ -108,6 +109,7 @@ export function createDocumentService(storageObjectId: stringimages: CommitUploadInput['images']name: CommitUploadInput['name']+ kind: CommitUploadInput['kind']}): Promise<boolean> {const lockedUpload = await transaction@@ -156,7 +158,8 @@ export function createDocumentService(await transaction.updateTable('document').set({- ...(name === undefined ? {} : { name }),+ // A revision may also retitle its document, or say the file it holds is a board.+ ...omitBy({ name, kind }, isUndefined),currentRevisionId: revisionId,version: (expression) => expression('version', '+', 1)})@@ -328,7 +331,8 @@ export function createDocumentService(revisionId: crypto.randomUUID(),storageObjectId: crypto.randomUUID(),images: input.images,- name: input.name+ name: input.name,+ kind: input.kind})))@@ -438,6 +442,7 @@ export function createDocumentService(id: documentId,workspaceId,name: input.name,+ kind: input.kind,createdBy: userId})const document = await findDocument(database, userId, documentId)diff --git a/packages/cloud/src/server/documents/summary.ts b/packages/cloud/src/server/documents/summary.tsindex 5e436e8b4..0604e2776 100644--- a/packages/cloud/src/server/documents/summary.ts+++ b/packages/cloud/src/server/documents/summary.ts@@ -5,6 +5,7 @@ const SUMMARY_COLUMNS = ['id','workspaceId','name',+ 'kind','currentRevisionId','version','createdAt',diff --git a/packages/cloud/src/server/documents/types.ts b/packages/cloud/src/server/documents/types.tsindex 00c000ad6..ecc4fd64a 100644--- a/packages/cloud/src/server/documents/types.ts+++ b/packages/cloud/src/server/documents/types.ts@@ -4,6 +4,7 @@ export type CreateDocumentRecord = {id: stringworkspaceId: stringname: string+ kind: 'design' | 'board'createdBy: string}diff --git a/packages/cloud/src/server/documents/versions/service.ts b/packages/cloud/src/server/documents/versions/service.tsindex 824d2ff4f..75e04d7f9 100644--- a/packages/cloud/src/server/documents/versions/service.ts+++ b/packages/cloud/src/server/documents/versions/service.ts@@ -361,6 +361,7 @@ export function createDocumentVersionService(id: copyId,workspaceId: document.workspaceId,name: input.name,+ kind: document.kind,createdBy: userId})await transactiondiff --git a/packages/cloud/tests/client/api.test.ts b/packages/cloud/tests/client/api.test.tsindex 6f9882b45..5f138e60b 100644--- a/packages/cloud/tests/client/api.test.ts+++ b/packages/cloud/tests/client/api.test.ts@@ -1,6 +1,7 @@import { describe, expect, test } from 'bun:test'import { CloudAPIError, createCloudAPIClient } from '#cloud/client'+import { omit } from 'es-toolkit'const workspaceId = '11111111-1111-4111-8111-111111111111'const documentId = '22222222-2222-4222-8222-222222222222'@@ -21,6 +22,7 @@ const document = {id: documentId,workspaceId,name: 'Homepage',+ kind: 'board' as const,currentRevisionId: revisionId,version: 1,createdAt: '2026-01-01T00:00:00.000Z',@@ -28,6 +30,14 @@ const document = {}describe('createCloudAPIClient', () => {+ test('reads a document an older server lists without a kind as a design', async () => {+ const older = omit(document, ['kind'])+ const client = createCloudAPIClient('https://cloud.example.com/api', {+ fetch: async () => Response.json({ documents: [older] })+ })+ expect((await client.listDocuments(workspaceId))[0]?.kind).toBe('design')+ })+test('validates document metadata and sends authenticated requests', async () => {const requests: Request[] = []const client = createCloudAPIClient('https://cloud.example.com/api', {diff --git a/packages/cloud/tests/integration/server/documents/routes.test.ts b/packages/cloud/tests/integration/server/documents/routes.test.tsindex b86b7471e..f31a3ae48 100644--- a/packages/cloud/tests/integration/server/documents/routes.test.ts+++ b/packages/cloud/tests/integration/server/documents/routes.test.ts@@ -81,8 +81,17 @@ describe('Cloud document routes', () => {const list = await context.app.request(`/api/workspaces/${context.workspaceId}/documents`)expect(list.status).toBe(200)expect(await list.json()).toMatchObject({- documents: [{ id: created.document.id, name: 'Homepage', currentRevisionId: null }]+ documents: [+ { id: created.document.id, name: 'Homepage', kind: 'design', currentRevisionId: null }+ ]})++ const board = await context.app.request(`/api/workspaces/${context.workspaceId}/documents`, {+ method: 'POST',+ headers: { 'Content-Type': 'application/json' },+ body: JSON.stringify({ name: 'Retro', kind: 'board' })+ })+ expect(await board.json()).toMatchObject({ document: { name: 'Retro', kind: 'board' } })} finally {await context.runtime.close()}@@ -162,7 +171,7 @@ describe('Cloud document routes', () => {const commit = await context.app.request(`/api/uploads/${upload.id}/commit`, {method: 'POST',headers: { 'Content-Type': 'application/json' },- body: JSON.stringify({ checksum, name: 'Updated homepage' })+ body: JSON.stringify({ checksum, name: 'Updated homepage', kind: 'board' })})expect(commit.status).toBe(200)const committed = await responseJSON(@@ -171,13 +180,15 @@ describe('Cloud document routes', () => {document: v.object({currentRevisionId: v.string(),version: v.number(),- name: v.string()+ name: v.string(),+ kind: v.string()})}))expect(committed.document.currentRevisionId).toBeString()expect(committed.document.version).toBe(1)expect(committed.document.name).toBe('Updated homepage')+ expect(committed.document.kind).toBe('board')const repeatedCommit = await context.app.request(`/api/uploads/${upload.id}/commit`, {method: 'POST',@@ -333,6 +344,7 @@ describe('documents shared with a person', () => {v.object({id: v.string(),name: v.string(),+ kind: v.string(),workspaceName: v.string(),permission: v.string(),sharedBy: v.nullable(v.object({ name: v.string() }))@@ -340,7 +352,7 @@ describe('documents shared with a person', () => {)})- test('lists direct grants outside the person’s workspaces until they are revoked', async () => {+ test('lists direct grants outside the person’s workspaces, with their kind, until they are revoked', async () => {const aliceAccount = crypto.randomUUID()const context = await testApp({ ...actor, userId: aliceAccount })try {@@ -361,7 +373,7 @@ describe('documents shared with a person', () => {const create = await context.app.request(`/api/workspaces/${context.workspaceId}/documents`, {method: 'POST',headers: { 'Content-Type': 'application/json' },- body: JSON.stringify({ name: 'Brief' })+ body: JSON.stringify({ name: 'Brief', kind: 'board' })})const created = await responseJSON(create,@@ -384,6 +396,7 @@ describe('documents shared with a person', () => {{id: documentId,name: 'Brief',+ kind: 'board',workspaceName: 'Documents',permission: 'view',sharedBy: { name: 'Alice' }diff --git a/packages/fig/src/archive.ts b/packages/fig/src/archive.tsindex 2edb71340..668aab660 100644--- a/packages/fig/src/archive.ts+++ b/packages/fig/src/archive.ts@@ -5,6 +5,7 @@ import type { FigPageManifestEntry } from '@open-pencil/kiwi/fig'import type { NodeChange } from '@open-pencil/kiwi/fig/codec'import {buildFigKiwi,+ figFileKind,parseFigKiwiChunks,type FigDataCompressor,type FigFileKind@@ -68,6 +69,24 @@ function isCanonicalCanvasEntry(name: string): boolean {return name === 'canvas.fig' || name === 'canvas'}+/**+ * Whether a `.fig` or `.jam` archive, or a bare canvas, holds a design or a FigJam board, by its+ * canvas's header, without decoding the document; `null` when it holds no Figma canvas.+ */+export function figArchiveKind(bytes: Uint8Array): FigFileKind | null {+ const bare = figFileKind(bytes)+ if (bare) return bare+ try {+ const entries: Partial<Record<string, Uint8Array>> = unzipSync(bytes, {+ filter: ({ name }) => isCanonicalCanvasEntry(name)+ })+ const canvas = entries['canvas.fig'] ?? entries.canvas+ return canvas ? figFileKind(canvas) : null+ } catch {+ return null+ }+}+function parseRawFigKiwi(bytes: Uint8Array,onPages?: (pages: FigPageManifestEntry[]) => void,diff --git a/packages/fig/src/index.ts b/packages/fig/src/index.tsindex 17353300a..3b7e98fff 100644--- a/packages/fig/src/index.ts+++ b/packages/fig/src/index.ts@@ -11,6 +11,7 @@ export {export { figArchiveMetaSchema, type FigArchiveMetaJSON } from './schema'export {compressFigDataSync,+ figArchiveKind,figArchiveMetaJSON,parseFigBuffer,readFigArchiveMeta,diff --git a/packages/fig/tests/index.test.ts b/packages/fig/tests/index.test.tsindex 543f68fe8..acd267593 100644--- a/packages/fig/tests/index.test.ts+++ b/packages/fig/tests/index.test.ts@@ -3,6 +3,7 @@ import { beforeAll, describe, expect, it } from 'bun:test'import { expectDefined } from '#fig-tests/helpers/assert'import {FIG_PACKAGE_STATUS,+ figArchiveKind,figArchiveMetaJSON,parseFigBuffer,readFigArchiveMeta,@@ -133,6 +134,22 @@ describe('@open-pencil/fig package API', () => {expect(renameFigArchive(archive('{"version":1,"app":"OpenPencil"}'), 'New')).toBeNull()})+ it('tells a board archive from a design one by its canvas header', () => {+ const archive = (kind?: 'design' | 'board') =>+ writeFigArchive({+ schemaDeflated: deflateSync(getSchemaBytes()),+ kiwiData: encodeMessage(createNodeChangesMessage(0, 0, [])),+ thumbnailPNG: PNG_SIGNATURE,+ metaJSON: '{}',+ kind+ })++ expect(figArchiveKind(archive())).toBe('design')+ expect(figArchiveKind(archive('board'))).toBe('board')+ expect(figArchiveKind(new TextEncoder().encode('fig-jam.'))).toBe('board')+ expect(figArchiveKind(new Uint8Array([1, 2, 3]))).toBeNull()+ })+it('parses legacy raw fig-kiwi files and preserves their thumbnail chunk', () => {const container = writeFigContainer({diff --git a/packages/vue/src/i18n/locales/de/files.json b/packages/vue/src/i18n/locales/de/files.jsonindex 4b3afd698..9167a05e0 100644--- a/packages/vue/src/i18n/locales/de/files.json+++ b/packages/vue/src/i18n/locales/de/files.json@@ -22,12 +22,16 @@"recentFilesDescription": "Arbeite an einem Entwurf weiter oder beginne einen neuen.","noRecentFiles": "Noch keine zuletzt verwendeten Dateien","noRecentFilesDescription": "Dateien, die du in der Desktop-App öffnest, werden hier angezeigt.",+ "noRecentDesigns": "Keine zuletzt geöffneten Designs",+ "noRecentBoards": "Keine zuletzt geöffneten Boards","searchFiles": "Dateien suchen…","searchRecentAndStorageFiles": "Zuletzt verwendete und gespeicherte Dateien suchen…","newDesign": "Neues Design","newFile": "Neue Datei","createDesign": "Design","createBoard": "Board",+ "allFiles": "Alle Dateien",+ "fileKind": "Dateityp","createIn": "Wird in {place} erstellt","noMatchingFiles": "Keine Dateien entsprechen „{query}“.","documentActions": "Aktionen für {name}",diff --git a/packages/vue/src/i18n/locales/es/files.json b/packages/vue/src/i18n/locales/es/files.jsonindex 6a9c9191a..02cb9c838 100644--- a/packages/vue/src/i18n/locales/es/files.json+++ b/packages/vue/src/i18n/locales/es/files.json@@ -22,12 +22,16 @@"recentFilesDescription": "Continúa trabajando en un diseño o crea uno nuevo.","noRecentFiles": "Aún no hay archivos recientes","noRecentFilesDescription": "Los archivos que abras en la aplicación de escritorio aparecerán aquí.",+ "noRecentDesigns": "No hay diseños recientes",+ "noRecentBoards": "No hay tableros recientes","searchFiles": "Buscar archivos…","searchRecentAndStorageFiles": "Buscar en archivos recientes y almacenados…","newDesign": "Nuevo diseño","newFile": "Archivo nuevo","createDesign": "Diseño","createBoard": "Tablero",+ "allFiles": "Todos los archivos",+ "fileKind": "Tipo de archivo","createIn": "Se crea en {place}","noMatchingFiles": "Ningún archivo coincide con «{query}».","documentActions": "Acciones de {name}",diff --git a/packages/vue/src/i18n/locales/fr/files.json b/packages/vue/src/i18n/locales/fr/files.jsonindex 482743fbf..6a35944c1 100644--- a/packages/vue/src/i18n/locales/fr/files.json+++ b/packages/vue/src/i18n/locales/fr/files.json@@ -22,12 +22,16 @@"recentFilesDescription": "Continuez un design ou commencez-en un nouveau.","noRecentFiles": "Aucun fichier récent","noRecentFilesDescription": "Les fichiers ouverts dans l’application de bureau apparaîtront ici.",+ "noRecentDesigns": "Aucun design récent",+ "noRecentBoards": "Aucun tableau blanc récent","searchFiles": "Rechercher des fichiers…","searchRecentAndStorageFiles": "Rechercher dans les fichiers récents et stockés…","newDesign": "Nouveau design","newFile": "Nouveau fichier","createDesign": "Design","createBoard": "Tableau blanc",+ "allFiles": "Tous les fichiers",+ "fileKind": "Type de fichier","createIn": "Créé dans {place}","noMatchingFiles": "Aucun fichier ne correspond à « {query} ».","documentActions": "Actions pour {name}",diff --git a/packages/vue/src/i18n/locales/it/files.json b/packages/vue/src/i18n/locales/it/files.jsonindex 3275b052a..95c69d530 100644--- a/packages/vue/src/i18n/locales/it/files.json+++ b/packages/vue/src/i18n/locales/it/files.json@@ -22,12 +22,16 @@"recentFilesDescription": "Continua a lavorare su un progetto o iniziane uno nuovo.","noRecentFiles": "Nessun file recente","noRecentFilesDescription": "I file aperti nell’app desktop appariranno qui.",+ "noRecentDesigns": "Nessun design recente",+ "noRecentBoards": "Nessuna lavagna recente","searchFiles": "Cerca file…","searchRecentAndStorageFiles": "Cerca nei file recenti e archiviati…","newDesign": "Nuovo design","newFile": "Nuovo file","createDesign": "Design","createBoard": "Lavagna",+ "allFiles": "Tutti i file",+ "fileKind": "Tipo di file","createIn": "Viene creato in {place}","noMatchingFiles": "Nessun file corrisponde a «{query}».","documentActions": "Azioni per {name}",diff --git a/packages/vue/src/i18n/locales/ja/files.json b/packages/vue/src/i18n/locales/ja/files.jsonindex 9f4be918d..2bfcc64c4 100644--- a/packages/vue/src/i18n/locales/ja/files.json+++ b/packages/vue/src/i18n/locales/ja/files.json@@ -22,12 +22,16 @@"recentFilesDescription": "デザインの作業を続けるか、新しく始めます。","noRecentFiles": "最近使用したファイルはありません","noRecentFilesDescription": "デスクトップアプリで開いたファイルがここに表示されます。",+ "noRecentDesigns": "最近のデザインはありません",+ "noRecentBoards": "最近のボードはありません","searchFiles": "ファイルを検索…","searchRecentAndStorageFiles": "最近使用したファイルとストレージを検索…","newDesign": "新しいデザイン","newFile": "新規ファイル","createDesign": "デザイン","createBoard": "ボード",+ "allFiles": "すべてのファイル",+ "fileKind": "ファイルの種類","createIn": "{place} に作成します","noMatchingFiles": "「{query}」に一致するファイルはありません。","documentActions": "{name} の操作",diff --git a/packages/vue/src/i18n/locales/pl/files.json b/packages/vue/src/i18n/locales/pl/files.jsonindex 0dcdbc1b7..ed45016df 100644--- a/packages/vue/src/i18n/locales/pl/files.json+++ b/packages/vue/src/i18n/locales/pl/files.json@@ -22,12 +22,16 @@"recentFilesDescription": "Kontynuuj pracę nad projektem lub rozpocznij nowy.","noRecentFiles": "Brak ostatnich plików","noRecentFilesDescription": "Pliki otwarte w aplikacji komputerowej pojawią się tutaj.",+ "noRecentDesigns": "Brak ostatnich projektów",+ "noRecentBoards": "Brak ostatnich tablic","searchFiles": "Szukaj plików…","searchRecentAndStorageFiles": "Szukaj w ostatnich i zapisanych plikach…","newDesign": "Nowy projekt","newFile": "Nowy plik","createDesign": "Projekt","createBoard": "Tablica",+ "allFiles": "Wszystkie pliki",+ "fileKind": "Typ pliku","createIn": "Tworzy w: {place}","noMatchingFiles": "Brak plików pasujących do „{query}”.","documentActions": "Działania dla {name}",diff --git a/packages/vue/src/i18n/locales/ru/files.json b/packages/vue/src/i18n/locales/ru/files.jsonindex 341e35983..e3cedb671 100644--- a/packages/vue/src/i18n/locales/ru/files.json+++ b/packages/vue/src/i18n/locales/ru/files.json@@ -22,12 +22,16 @@"recentFilesDescription": "Продолжите работу над дизайном или начните новый.","noRecentFiles": "Недавних файлов пока нет","noRecentFilesDescription": "Файлы, открытые в приложении для компьютера, появятся здесь.",+ "noRecentDesigns": "Недавних дизайнов нет",+ "noRecentBoards": "Недавних досок нет","searchFiles": "Поиск файлов…","searchRecentAndStorageFiles": "Поиск в недавних файлах и хранилище…","newDesign": "Новый дизайн","newFile": "Новый файл","createDesign": "Дизайн","createBoard": "Доска",+ "allFiles": "Все файлы",+ "fileKind": "Тип файла","createIn": "Создаётся в {place}","noMatchingFiles": "Нет файлов по запросу «{query}».","documentActions": "Действия с {name}",diff --git a/packages/vue/src/i18n/locales/zh-cn/files.json b/packages/vue/src/i18n/locales/zh-cn/files.jsonindex 443f27ea9..274a2ef82 100644--- a/packages/vue/src/i18n/locales/zh-cn/files.json+++ b/packages/vue/src/i18n/locales/zh-cn/files.json@@ -22,12 +22,16 @@"recentFilesDescription": "继续编辑设计或新建设计。","noRecentFiles": "暂无最近使用的文件","noRecentFilesDescription": "在桌面应用中打开的文件会显示在这里。",+ "noRecentDesigns": "没有最近的设计",+ "noRecentBoards": "没有最近的白板","searchFiles": "搜索文件…","searchRecentAndStorageFiles": "搜索最近使用和存储的文件…","newDesign": "新建设计","newFile": "新建文件","createDesign": "设计","createBoard": "白板",+ "allFiles": "所有文件",+ "fileKind": "文件类型","createIn": "在 {place} 中创建","noMatchingFiles": "没有与“{query}”匹配的文件。","documentActions": "{name} 的操作",diff --git a/packages/vue/src/i18n/messages/files.ts b/packages/vue/src/i18n/messages/files.tsindex 47f4613ab..0c6333ada 100644--- a/packages/vue/src/i18n/messages/files.ts+++ b/packages/vue/src/i18n/messages/files.ts@@ -32,12 +32,16 @@ export const filesMessageDefaults = {recentFilesDescription: 'Continue working on a design or start a new one.',noRecentFiles: 'No recent files yet',noRecentFilesDescription: 'Files you open in the desktop app will appear here.',+ noRecentDesigns: 'No recent designs',+ noRecentBoards: 'No recent boards',searchFiles: 'Search files…',searchRecentAndStorageFiles: 'Search recent and storage files…',newDesign: 'New design',newFile: 'New file',createDesign: 'Design',createBoard: 'Board',+ allFiles: 'All files',+ fileKind: 'File type',createIn: params('Creates it in {place}'),noMatchingFiles: params('No files match “{query}”.'),documentActions: params('Actions for {name}'),diff --git a/src/app/cloud/documents/conflict.ts b/src/app/cloud/documents/conflict.tsindex c2720da98..825a0f65a 100644--- a/src/app/cloud/documents/conflict.ts+++ b/src/app/cloud/documents/conflict.ts@@ -26,7 +26,7 @@ export async function resolveCloudConflict(const copyId = await keepBothVersions(binding.documentId, copyName)const copy = { ...binding, documentId: copyId }store.setStorageDocumentSource(copy, copyName)- rememberRecentStorageDocument(copy, copyName)+ rememberRecentStorageDocument(copy, copyName, store.state.documentKind)} else if (choice === 'use-cloud') {await takeStoredVersion(binding.documentId)await reloadStorageDocumentInTab(store)diff --git a/src/app/integrations/storage/cloud/adapter.ts b/src/app/integrations/storage/cloud/adapter.tsindex d7b179281..54993c14f 100644--- a/src/app/integrations/storage/cloud/adapter.ts+++ b/src/app/integrations/storage/cloud/adapter.ts@@ -1,6 +1,6 @@import { CloudAPIError, type CloudAPIClient } from '@open-pencil/cloud/client'import { CLOUD_DOCUMENT_NAME_MAX_LENGTH } from '@open-pencil/cloud/contract'-import { extractFigThumbnailFromReader } from '@open-pencil/fig'+import { extractFigThumbnailFromReader, figArchiveKind } from '@open-pencil/fig'import { cloudServerHost } from '@/app/cloud/servers/address'import { findCloudServer } from '@/app/cloud/servers/store'@@ -101,6 +101,7 @@ export function createCloudStorageAdapter(return documents.map((document) => ({id: document.id,name: document.name,+ kind: document.kind,updatedAt: document.updatedAt,metadataAuthoritative: true,revision: document.currentRevisionId@@ -121,9 +122,11 @@ export function createCloudStorageAdapter(const cloud = await client()const baseRevision = options?.baseRevision ?? nullconst name = cloudDocumentName(metadata.name)+ // The file says whether it is a board, as its header does for Figma.+ const kind = figArchiveKind(bytes) ?? 'design'// Without a revision this is the first save; the document may not exist on the server yet.if (!baseRevision && !(await listed(id))) {- await cloud.createDocument(workspaceId(), { id, name })+ await cloud.createDocument(workspaceId(), { id, name, kind })}// The workspace keeps images once; the stored file names them and uploads only those it lacks.const { lean, images } = splitCloudDocument(bytes)@@ -147,6 +150,7 @@ export function createCloudStorageAdapter(const committed = await cloud.commitUpload(upload.uploadId, {checksum,name,+ kind,multipart: upload.multipart,images: named.map((image) => ({ name: image.name, checksum: image.checksum }))})diff --git a/src/app/integrations/storage/types.ts b/src/app/integrations/storage/types.tsindex 00ee274a9..8d9ebb0a3 100644--- a/src/app/integrations/storage/types.ts+++ b/src/app/integrations/storage/types.ts@@ -1,3 +1,5 @@+import type { DocumentKind } from '@open-pencil/scene-graph'+import type { CredentialResolver } from '@/app/settings/credentials/types'export type StorageProviderID = string@@ -30,6 +32,8 @@ export type StorageDocumentMetadata = {export type StorageDocument = StorageDocumentMetadata & {id: string+ /** A design or a board, when the provider lists it; providers that cannot say leave it out. */+ kind?: DocumentKindthumbnailURL?: string | nullmetadataAuthoritative?: boolean/**diff --git a/src/app/recent-files/index.ts b/src/app/recent-files/index.tsindex 5552936d8..36a71e02c 100644--- a/src/app/recent-files/index.ts+++ b/src/app/recent-files/index.ts@@ -7,6 +7,7 @@ export {recentFiles,recentLocalFileAt,recentLocalFilePaths,+ recentDocumentKind,rememberRecentFile,rememberRecentStorageDocument,type RecentDocument,diff --git a/src/app/recent-files/store.ts b/src/app/recent-files/store.tsindex 63738a023..a9e7197c8 100644--- a/src/app/recent-files/store.ts+++ b/src/app/recent-files/store.ts@@ -2,6 +2,9 @@ import { useLocalStorage } from '@vueuse/core'import { basename } from 'pathe'import { computed } from 'vue'+import { DOCUMENT_EXTENSIONS } from '@open-pencil/core/io'+import type { DocumentKind } from '@open-pencil/scene-graph'+import {DEFAULT_STORAGE_PROFILE,storageLocationOf,@@ -21,6 +24,8 @@ export interface RecentLocalDocument {path: stringname: stringupdatedAt: string+ /** A design or a board; entries recorded before this was kept have none. */+ documentKind?: DocumentKind}export interface RecentStorageDocument {@@ -32,6 +37,8 @@ export interface RecentStorageDocument {documentId: stringname: stringupdatedAt: string+ /** A design or a board; entries recorded before this was kept have none. */+ documentKind?: DocumentKind}export type RecentDocument = RecentLocalDocument | RecentStorageDocument@@ -73,24 +80,45 @@ function remember(document: RecentDocument): void {].slice(0, recentFilesLimit.value)}-export function rememberRecentFile(path: string): void {+/** What a file on this device is by its name: a FigJam `.jam` is a board, anything else a design. */+function localDocumentKind(path: string): DocumentKind {+ return path.toLowerCase().endsWith(`.${DOCUMENT_EXTENSIONS.board}`) ? 'board' : 'design'+}++/**+ * A recent file's kind: as recorded, or for one recorded before kinds were, by its name on this+ * device and as a design elsewhere, as storage lists files whose kind they do not know.+ */+export function recentDocumentKind(document: RecentDocument): DocumentKind {+ if (document.documentKind) return document.documentKind+ return document.kind === 'local' ? localDocumentKind(document.path) : 'design'+}++/** Remembers a file opened or saved on this device, as the kind the opened document is. */+export function rememberRecentFile(path: string, documentKind: DocumentKind): void {remember({id: localDocumentId(path),kind: 'local',path,name: fileName(path),- updatedAt: new Date().toISOString()+ updatedAt: new Date().toISOString(),+ documentKind})}-export function rememberRecentStorageDocument(binding: StorageDocumentBinding, name: string): void {+export function rememberRecentStorageDocument(+ binding: StorageDocumentBinding,+ name: string,+ documentKind: DocumentKind+): void {remember({id: storageDocumentId(binding),kind: 'storage',...storageLocationOf(binding),documentId: binding.documentId,name,- updatedAt: new Date().toISOString()+ updatedAt: new Date().toISOString(),+ documentKind})}diff --git a/src/app/shell/menu/files.ts b/src/app/shell/menu/files.tsindex 0b6d805d1..80b8ae6d8 100644--- a/src/app/shell/menu/files.ts+++ b/src/app/shell/menu/files.ts@@ -141,8 +141,8 @@ export async function chooseTauriOpenPaths(): Promise<string[]> {export async function openFileFromPath(path: string) {if (!isTauri()) returnconst file = await readTauriDesignFile(path)- await openFileInNewTab(file, undefined, path)- rememberRecentFile(path)+ const store = await openFileInNewTab(file, undefined, path)+ rememberRecentFile(path, store.state.documentKind)}/**diff --git a/src/app/storage/save-to/write.ts b/src/app/storage/save-to/write.tsindex add3667ca..ec12034da 100644--- a/src/app/storage/save-to/write.ts+++ b/src/app/storage/save-to/write.ts@@ -21,6 +21,6 @@ export async function writeDocumentTo(store.state.documentName = previousNamereturn null}- rememberRecentStorageDocument(binding, name)+ rememberRecentStorageDocument(binding, name, store.state.documentKind)return binding}diff --git a/src/app/storage/workspace/create.ts b/src/app/storage/workspace/create.tsindex c754b9a75..7eb7fb248 100644--- a/src/app/storage/workspace/create.ts+++ b/src/app/storage/workspace/create.ts@@ -15,5 +15,5 @@ export async function createStoredDocument(const { store } = createDocumentTab(kind)if (!(await store.saveFigFileToStorage(location))) returnconst binding = store.getStorageBinding()- if (binding) rememberRecentStorageDocument(binding, store.state.documentName)+ if (binding) rememberRecentStorageDocument(binding, store.state.documentName, kind)}diff --git a/src/app/tabs/index.ts b/src/app/tabs/index.tsindex fe7c43367..984e0506c 100644--- a/src/app/tabs/index.ts+++ b/src/app/tabs/index.ts@@ -495,7 +495,7 @@ export async function openStorageDocumentInNewTab(const existing = findStorageTab(binding)if (existing) {switchTab(existing.id)- rememberRecentStorageDocument(binding, document.name)+ rememberRecentStorageDocument(binding, document.name, existing.store.state.documentKind)return existing.store}@@ -509,7 +509,7 @@ export async function openStorageDocumentInNewTab(let succeeded = falsetry {await showStorageDocument(store, binding, document, load)- rememberRecentStorageDocument(binding, document.name)+ rememberRecentStorageDocument(binding, document.name, store.state.documentKind)succeeded = true} catch (error) {if (!load.signal.aborted) {diff --git a/src/components/home/HomeWorkspace.vue b/src/components/home/HomeWorkspace.vueindex 70f502c91..971d0cc15 100644--- a/src/components/home/HomeWorkspace.vue+++ b/src/components/home/HomeWorkspace.vue@@ -17,7 +17,7 @@ import {type StorageDocument,type StorageLocation} from '@/app/integrations/storage'-import type { RecentDocument } from '@/app/recent-files'+import { recentDocumentKind, type RecentDocument } from '@/app/recent-files'import {matchingRecentFiles,openRecentDocument,@@ -31,6 +31,7 @@ import { openStorageDocumentInNewTab } from '@/app/tabs'import { CloudSharedSection, CloudWorkspaceSection } from '@/components/cloud/integration'import DocumentDeleteDialog from '@/components/home/document/DocumentDeleteDialog.vue'import DocumentEntry from '@/components/home/document/DocumentEntry.vue'+import { ofKind, type DocumentKindFilter } from '@/components/home/document/filter'import HomeLayout from '@/components/home/HomeLayout.vue'import RecentFilesSection from '@/components/home/recent/RecentFilesSection.vue'import HomeSearchActions from '@/components/home/search/HomeSearchActions.vue'@@ -42,6 +43,8 @@ import IconButton from '@/components/ui/button/IconButton.vue'const emit = defineEmits<{ 'new-document': [kind: DocumentKind] }>()const { locale, storage, files, common, settings, credentials } = useI18n()const view = useLocalStorage<'grid' | 'list'>('open-pencil:home-files-view', 'grid')+/** Which kind of file Home lists, as Figma's file filter picks; a file of unknown kind shows in all. */+const kindFilter = useLocalStorage<DocumentKindFilter>('open-pencil:home-files-kind', 'all')const query = ref('')const openError = ref<string | null>(null)const storageConfigured = ref(storagePreferencesComplete(activeStorageProviderID.value))@@ -145,21 +148,32 @@ const newDesignTarget = computed<{ location: StorageLocation; label: string } |const storagePreviewURL = storageWorkspace.previewURLconst vStoragePreview = storageWorkspace.previewDirectiveconst normalizedQuery = computed(() => query.value.trim().toLocaleLowerCase(locale.value))-const filteredRecentFiles = computed(() =>+const searchedRecentFiles = computed(() =>matchingRecentFiles(documents.value, normalizedQuery.value, locale.value))-const filteredStorageDocuments = computed(() => {- if (!normalizedQuery.value) return storageDocuments.value- return storageDocuments.value.filter((document) =>- document.name.toLocaleLowerCase(locale.value).includes(normalizedQuery.value)+const filteredRecentFiles = computed(() =>+ searchedRecentFiles.value.filter((document) =>+ ofKind(recentDocumentKind(document), kindFilter.value))-})-const noSearchMatches = computed(- () =>- Boolean(normalizedQuery.value) &&- filteredRecentFiles.value.length === 0 &&- filteredStorageDocuments.value.length === 0)+// Only Recent files offers the kind filter, so storage lists every kind.+const filteredStorageDocuments = computed(() =>+ storageDocuments.value.filter(+ (document) =>+ !normalizedQuery.value ||+ document.name.toLocaleLowerCase(locale.value).includes(normalizedQuery.value)+ )+)+// Recent files counts matches before its kind filter, so its kind control stays to switch kinds;+// storage has none to count while its first listing loads.+const noSearchMatches = computed(() => {+ if (!normalizedQuery.value) return false+ if (places.location.value.kind !== 'storage') return searchedRecentFiles.value.length === 0+ return (+ filteredStorageDocuments.value.length === 0 &&+ !(storageLoading.value && storageDocuments.value.length === 0)+ )+})async function openRecent(document: RecentDocument): Promise<void> {openError.value = null@@ -249,6 +263,7 @@ function formattedDate(updatedAt: string): string {<RecentFilesSectionv-if="!noSearchMatches && places.location.value.kind === 'recent'"v-model:view="view"+ v-model:kind="kindFilter":workspace="workspace":documents="filteredRecentFiles":query="normalizedQuery"@@ -331,6 +346,7 @@ function formattedDate(updatedAt: string): string {:key="document.id"v-storage-preview="document.id":name="document.name"+ :kind="document.kind":metadata="formattedDate(document.updatedAt)":previewURL="storagePreviewURL(document.id)":menu="documentMenu(document)"@@ -348,6 +364,7 @@ function formattedDate(updatedAt: string): string {:key="document.id"view="list":name="document.name"+ :kind="document.kind":metadata="formattedDate(document.updatedAt)":menu="documentMenu(document)"@open="openStorageDocument(document)"diff --git a/src/components/home/cloud/CloudSharedSection.vue b/src/components/home/cloud/CloudSharedSection.vueindex 47c44607d..cd9e67ac0 100644--- a/src/components/home/cloud/CloudSharedSection.vue+++ b/src/components/home/cloud/CloudSharedSection.vue@@ -58,6 +58,7 @@ const rows = computed<CloudDocumentRow[]>(() =>documents.value.map((document) => ({id: document.id,name: document.name,+ kind: document.kind,editedAt: dates.relative(document.updatedAt),editedBy: document.sharedBy? t.value.homeSharedBy({ name: document.sharedBy.name })diff --git a/src/components/home/cloud/CloudWorkspaceSection.vue b/src/components/home/cloud/CloudWorkspaceSection.vueindex deb25ae56..f10e01e0d 100644--- a/src/components/home/cloud/CloudWorkspaceSection.vue+++ b/src/components/home/cloud/CloudWorkspaceSection.vue@@ -108,6 +108,7 @@ const rows = computed<CloudDocumentRow[]>(() =>listed.value.map((document) => ({id: document.id,name: document.name,+ kind: document.kind,previewURL: files.previewURL(document.id),editedAt: dates.relative(document.updatedAt),sync: cloudSyncState(diff --git a/src/components/home/cloud/CloudWorkspaceView.vue b/src/components/home/cloud/CloudWorkspaceView.vueindex 2286eef78..102728bc8 100644--- a/src/components/home/cloud/CloudWorkspaceView.vue+++ b/src/components/home/cloud/CloudWorkspaceView.vue@@ -201,6 +201,7 @@ const metadata = (document: CloudDocumentRow) =>:key="document.id":view="view":name="document.name"+ :kind="document.kind":metadata="metadata(document)":previewURL="document.previewURL":menu="menu(document)"diff --git a/src/components/home/cloud/types.ts b/src/components/home/cloud/types.tsindex 05c883c8a..28a3c5443 100644--- a/src/components/home/cloud/types.ts+++ b/src/components/home/cloud/types.ts@@ -1,3 +1,5 @@+import type { DocumentKind } from '@open-pencil/scene-graph'+/** A place the home tab lists documents from. */export type HomeLocation =| { kind: 'recent'; id: 'recent' }@@ -20,6 +22,8 @@ export type CloudSyncState = 'synced' | 'uploading' | 'pending' | 'offline' | 'cexport type CloudDocumentRow = {id: stringname: string+ /** A design or a board, when Cloud says which. */+ kind?: DocumentKindpreviewURL?: string | nulleditedAt: stringeditedBy?: stringdiff --git a/src/components/home/document/DocumentEntry.vue b/src/components/home/document/DocumentEntry.vueindex d0a3bd928..6181ca38b 100644--- a/src/components/home/document/DocumentEntry.vue+++ b/src/components/home/document/DocumentEntry.vue@@ -14,6 +14,10 @@ import {import { tv } from 'tailwind-variants'import { computed, normalizeClass, type HTMLAttributes } from 'vue'+import type { DocumentKind } from '@open-pencil/scene-graph'+import { useI18n } from '@open-pencil/vue/i18n'++import { DOCUMENT_KIND_ICONS } from '@/components/home/document/kinds'import { useMenuUI } from '@/components/ui/menu/menu'import MenuScrollArea from '@/components/ui/menu/MenuScrollArea.vue'import iconButtonTheme from '@/theme/button/icon-button'@@ -24,6 +28,7 @@ const iconButton = tv(iconButtonTheme)const {name,+ kind,metadata,previewURL,view = 'grid',@@ -32,6 +37,8 @@ const {class: className} = defineProps<{name: string+ /** A design or a board, marked before the name as Figma marks its files; unknown leaves no mark. */+ kind?: DocumentKindmetadata: stringpreviewURL?: string | nullview?: 'grid' | 'list'@@ -41,7 +48,11 @@ const {class?: HTMLAttributes['class']}>()const emit = defineEmits<{ open: []; delete: [] }>()-const styles = computed(() => documentEntry({ view }))+const styles = computed(() => documentEntry({ view, kind }))+const { files } = useI18n()+const kindLabel = computed(() =>+ kind ? { design: files.value.createDesign, board: files.value.createBoard }[kind] : null+)const menuUI = useMenuUI({ content: 'min-w-40', item: 'justify-start gap-2 text-error' })</script>@@ -50,7 +61,11 @@ const menuUI = useMenuUI({ content: 'min-w-40', item: 'justify-start gap-2 text-The entry's own element is its root, so a parent's directives and attributes reach it, as thepreview directives of Home do; under the context menu they would land on a fragment.-->- <div data-slot="document-entry" :class="styles.root({ class: normalizeClass(className) })">+ <div+ data-slot="document-entry"+ :data-kind="kind"+ :class="styles.root({ class: normalizeClass(className) })"+ ><ContextMenuRoot :disabled="!menu"><ContextMenuTrigger as="div" data-slot="surface" :class="styles.surface()"><button@@ -64,9 +79,22 @@ const menuUI = useMenuUI({ content: 'min-w-40', item: 'justify-start gap-2 text-<img v-if="previewURL" :src="previewURL" alt="" :class="styles.image()" /><icon-lucide-file-image v-else :class="styles.fallback()" /></span>+ <component+ :is="DOCUMENT_KIND_ICONS[kind]"+ v-else-if="kind"+ :class="styles.icon()"+ aria-hidden="true"+ /><icon-lucide-file-image v-else :class="styles.icon()" /><span data-slot="body" :class="styles.body()"><span data-slot="title" :class="styles.title()">+ <component+ :is="DOCUMENT_KIND_ICONS[kind]"+ v-if="kind && view === 'grid'"+ :class="styles.kind()"+ aria-hidden="true"+ />+ <span v-if="kindLabel" class="sr-only">{{ kindLabel }},</span><span data-slot="name" :class="styles.name()">{{ name }}</span><span v-if="$slots.status" data-slot="status" :class="styles.status()"><slot name="status" />diff --git a/src/components/home/document/filter.ts b/src/components/home/document/filter.tsnew file mode 100644index 000000000..d16dc191d--- /dev/null+++ b/src/components/home/document/filter.ts@@ -0,0 +1,9 @@+import type { DocumentKind } from '@open-pencil/scene-graph'++/** Which files a list shows: every file, or one kind of them. */+export type DocumentKindFilter = 'all' | DocumentKind++/** Whether a file of `kind` passes `filter`. */+export function ofKind(kind: DocumentKind, filter: DocumentKindFilter): boolean {+ return filter === 'all' || kind === filter+}diff --git a/src/components/home/document/kinds.ts b/src/components/home/document/kinds.tsnew file mode 100644index 000000000..45bf980a6--- /dev/null+++ b/src/components/home/document/kinds.ts@@ -0,0 +1,10 @@+import IconLucidePenTool from '~icons/lucide/pen-tool'+import IconLucideStickyNote from '~icons/lucide/sticky-note'++import type { DocumentKind } from '@open-pencil/scene-graph'++/** The icon each kind of document shows, on Home's create buttons and before its files' names. */+export const DOCUMENT_KIND_ICONS = {+ design: IconLucidePenTool,+ board: IconLucideStickyNote+} as const satisfies Record<DocumentKind, unknown>diff --git a/src/components/home/recent/RecentFilesSection.vue b/src/components/home/recent/RecentFilesSection.vueindex e17e6a44d..2de57afd6 100644--- a/src/components/home/recent/RecentFilesSection.vue+++ b/src/components/home/recent/RecentFilesSection.vue@@ -5,10 +5,12 @@ import { useViewportKind } from '@open-pencil/vue/editor/viewport-kind'import { useI18n } from '@open-pencil/vue/i18n'import { useDateFormat } from '@/app/i18n/date'-import { clearRecentFiles, type RecentDocument } from '@/app/recent-files'+import { clearRecentFiles, recentDocumentKind, type RecentDocument } from '@/app/recent-files'import type { RecentFilesWorkspace } from '@/app/recent-files/workspace'import DocumentEntry from '@/components/home/document/DocumentEntry.vue'+import type { DocumentKindFilter } from '@/components/home/document/filter'import IconButton from '@/components/ui/button/IconButton.vue'+import AppSelect from '@/components/ui/select/AppSelect.vue'import SegmentedControl from '@/components/ui/select/SegmentedControl.vue'/** The recent files, as a grid or a list, with the files `documents` keeps of them. */@@ -19,6 +21,12 @@ const { workspace, documents, query } = defineProps<{}>()const emit = defineEmits<{ open: [document: RecentDocument] }>()const view = defineModel<'grid' | 'list'>('view', { required: true })+const kind = defineModel<DocumentKindFilter>('kind', { required: true })+const kindOptions = computed(() => [+ { value: 'all', label: files.value.allFiles },+ { value: 'design', label: files.value.createDesign },+ { value: 'board', label: files.value.createBoard }+])const { panels, files, common } = useI18n()const { isTouch } = useViewportKind()const dates = useDateFormat()@@ -49,6 +57,13 @@ function formattedDate(updatedAt: string): string {><icon-lucide-trash-2 class="size-3.5" /></IconButton>+ <AppSelect+ v-model="kind"+ :label="files.fileKind"+ :options="kindOptions"+ class="w-28"+ data-test-id="home-files-kind"+ /><SegmentedControlv-model="view"required@@ -76,6 +91,7 @@ function formattedDate(updatedAt: string): string {:key="document.id"v-workspace-preview="document.id":name="document.name"+ :kind="recentDocumentKind(document)":metadata="formattedDate(document.updatedAt)":previewURL="previewURL(document.id)"@open="emit('open', document)"@@ -88,17 +104,34 @@ function formattedDate(updatedAt: string): string {:key="document.id"view="list":name="document.name"+ :kind="recentDocumentKind(document)":metadata="formattedDate(document.updatedAt)"@open="emit('open', document)"/></div><div- v-else-if="!query"+ v-else-if="!query && !hasRecentFiles"class="rounded-lg border border-dashed border-border px-4 py-4 text-center sm:py-6"><p class="text-xs font-medium">{{ files.noRecentFiles }}</p><p class="mt-1 text-xs text-muted">{{ files.noRecentFilesDescription }}</p></div>++ <!-- Recent files are all of another kind than the filter shows. -->+ <p+ v-else-if="!query"+ class="rounded-lg border border-dashed border-border px-4 py-8 text-center text-xs text-muted"+ >+ {{ kind === 'board' ? files.noRecentBoards : files.noRecentDesigns }}+ </p>++ <!-- The search matches files of another kind only. -->+ <p+ v-else+ class="rounded-lg border border-dashed border-border px-4 py-8 text-center text-xs text-muted"+ >+ {{ files.noMatchingFiles({ query }) }}+ </p></section></template>diff --git a/src/components/home/search/HomeSearchActions.vue b/src/components/home/search/HomeSearchActions.vueindex 2d76d2915..8e8b02fd6 100644--- a/src/components/home/search/HomeSearchActions.vue+++ b/src/components/home/search/HomeSearchActions.vue@@ -1,8 +1,6 @@<script setup lang="ts">import { templateRef } from '@vueuse/core'import { nextTick, watch } from 'vue'-import IconLucidePenTool from '~icons/lucide/pen-tool'-import IconLucideStickyNote from '~icons/lucide/sticky-note'import type { DocumentKind } from '@open-pencil/scene-graph'import { useViewportKind } from '@open-pencil/vue/editor/viewport-kind'@@ -10,6 +8,7 @@ import { useI18n } from '@open-pencil/vue/i18n'import { openFileDialog } from '@/app/shell/menu/use'import { activeTab } from '@/app/tabs'+import { DOCUMENT_KIND_ICONS } from '@/components/home/document/kinds'import AppButton from '@/components/ui/button/AppButton.vue'import AppInput from '@/components/ui/input/AppInput.vue'import Tip from '@/components/ui/overlay/Tip.vue'@@ -22,8 +21,8 @@ const emit = defineEmits<{ 'new-document': [kind: DocumentKind] }>()/** What Home offers to create, side by side, as Figma's Home and New file tab offer theirs. */const CREATE_CHOICES = [- { kind: 'design', label: 'createDesign', icon: IconLucidePenTool },- { kind: 'board', label: 'createBoard', icon: IconLucideStickyNote }+ { kind: 'design', label: 'createDesign', icon: DOCUMENT_KIND_ICONS.design },+ { kind: 'board', label: 'createBoard', icon: DOCUMENT_KIND_ICONS.board }] as const satisfies ReadonlyArray<{ kind: DocumentKind; label: string; icon: unknown }>const query = defineModel<string>({ required: true })const { menu, files } = useI18n()diff --git a/src/theme/home/document-entry.ts b/src/theme/home/document-entry.tsindex ec10d54a3..9f402d171 100644--- a/src/theme/home/document-entry.ts+++ b/src/theme/home/document-entry.ts@@ -10,6 +10,7 @@ export default {image: 'size-full object-cover transition-transform duration-200 group-hover:scale-[1.015]',fallback: 'size-8 text-muted/40',icon: 'size-4 shrink-0 text-primary',+ kind: 'size-3.5 shrink-0',body: 'min-w-0 flex-1',title: 'flex min-w-0 items-center gap-1.5',name: 'block min-w-0 truncate text-xs font-medium',@@ -22,6 +23,10 @@ export default {'shrink-0 opacity-0 transition-opacity group-hover:opacity-100 focus-visible:opacity-100 data-[state=open]:opacity-100 pointer-coarse:opacity-100'},variants: {+ kind: {+ design: { kind: 'text-primary' },+ board: { kind: 'text-board', icon: 'text-board' }+ },view: {grid: {body: 'mt-2 block',diff --git a/src/theme/tokens.css b/src/theme/tokens.cssindex 574e44bfc..a5fb3228f 100644--- a/src/theme/tokens.css+++ b/src/theme/tokens.css@@ -70,6 +70,8 @@--color-input: #1e1e1e;--color-component: #bb8cff;--color-slot: #f45cc4;+ /* A FigJam board's mark in file lists, after FigJam's own purple. */+ --color-board: #b38cff;/** Status colors: each is a text and icon color. Errors and warnings also have a tint (-bg) and a* border (-border) for panels in that status, and warnings -action for buttons on the tint.@@ -126,6 +128,7 @@ html[data-theme='light'] {--color-input: #ffffff;--color-component: #7c3aed;--color-slot: #db2777;+ --color-board: #8b5cf6;--color-warning: #8f5500;--color-warning-bg: rgb(245 158 11 / 0.14);--color-warning-border: rgb(245 158 11 / 0.32);diff --git a/tests/app/storage/workspace/delete.test.ts b/tests/app/storage/workspace/delete.test.tsindex 41121467a..3d9664e4d 100644--- a/tests/app/storage/workspace/delete.test.ts+++ b/tests/app/storage/workspace/delete.test.ts@@ -44,8 +44,8 @@ describe('deleting a stored document', () => {figBytes: new Uint8Array([1]),syncStatus: 'synced'})- rememberRecentStorageDocument({ ...BUCKET, documentId: POSTER.id }, POSTER.name)- rememberRecentStorageDocument({ ...BUCKET, documentId: 'flyer' }, 'Flyer')+ rememberRecentStorageDocument({ ...BUCKET, documentId: POSTER.id }, POSTER.name, 'design')+ rememberRecentStorageDocument({ ...BUCKET, documentId: 'flyer' }, 'Flyer', 'design')expect(recentPoster()).toBe(true)const events: string[] = []const stop = onStorageWorkspaceEvent((event) =>diff --git a/tests/engine/app/recent-files/store.test.ts b/tests/engine/app/recent-files/store.test.tsindex 1535c8694..939e0eb19 100644--- a/tests/engine/app/recent-files/store.test.ts+++ b/tests/engine/app/recent-files/store.test.ts@@ -3,11 +3,13 @@ import { afterEach, describe, expect, test } from 'bun:test'import {clearRecentFiles,forgetRecentFile,+ recentDocumentKind,recentDocuments,recentFiles,recentLocalFileAt,rememberRecentFile,- rememberRecentStorageDocument+ rememberRecentStorageDocument,+ type RecentDocument} from '@/app/recent-files'afterEach(() => clearRecentFiles())@@ -16,9 +18,9 @@ describe('recent documents', () => {test('keeps the latest local file first without duplicates', () => {recentDocuments.value = []- rememberRecentFile('/tmp/first.fig')- rememberRecentFile('/tmp/second.fig')- rememberRecentFile('/tmp/first.fig')+ rememberRecentFile('/tmp/first.fig', 'design')+ rememberRecentFile('/tmp/second.fig', 'design')+ rememberRecentFile('/tmp/first.fig', 'design')expect(recentFiles.value.map(({ kind, name }) => ({ kind, name }))).toEqual([{ kind: 'local', name: 'first.fig' },@@ -28,10 +30,11 @@ describe('recent documents', () => {})test('tracks storage documents alongside local files', () => {- rememberRecentFile('/tmp/local.fig')+ rememberRecentFile('/tmp/local.fig', 'design')rememberRecentStorageDocument({ providerId: 's3-compatible', documentId: 'remote-1' },- 'Remote design'+ 'Remote design',+ 'design')expect(recentFiles.value.map(({ id, kind, name }) => ({ id, kind, name }))).toEqual([@@ -51,8 +54,8 @@ describe('recent documents', () => {containerId: 'workspace-1',documentId: 'doc-1'}- rememberRecentStorageDocument({ ...document, profileId: 'server-a' }, 'On A')- rememberRecentStorageDocument({ ...document, profileId: 'server-b' }, 'On B')+ rememberRecentStorageDocument({ ...document, profileId: 'server-a' }, 'On A', 'design')+ rememberRecentStorageDocument({ ...document, profileId: 'server-b' }, 'On B', 'design')expect(recentFiles.value.map(({ id, name }) => ({ id, name }))).toEqual([{ id: 'storage:openpencil-cloud:server-b:doc-1', name: 'On B' },@@ -65,8 +68,8 @@ describe('recent documents', () => {})test('forgets missing local files and clears the list', () => {- rememberRecentFile('/tmp/first.fig')- rememberRecentFile('/tmp/second.fig')+ rememberRecentFile('/tmp/first.fig', 'design')+ rememberRecentFile('/tmp/second.fig', 'design')forgetRecentFile('/tmp/first.fig')expect(recentFiles.value.map((document) => document.name)).toEqual(['second.fig'])@@ -75,4 +78,37 @@ describe('recent documents', () => {expect(recentFiles.value).toEqual([])expect(recentLocalFileAt(0)).toBeNull()})++ test('remembers whether each file is a design or a board, whatever its name', () => {+ rememberRecentFile('/tmp/plan.fig', 'board')+ rememberRecentFile('/tmp/screens.fig', 'design')+ rememberRecentStorageDocument(+ { providerId: 's3-compatible', documentId: 'b' },+ 'Retro',+ 'board'+ )+ expect(recentFiles.value.map(({ name, documentKind }) => [name, documentKind])).toEqual([+ ['Retro', 'board'],+ ['screens.fig', 'design'],+ ['plan.fig', 'board']+ ])+ expect(recentFiles.value.map(recentDocumentKind)).toEqual(['board', 'design', 'board'])+ })++ test('reads the kind of files recorded before kinds were', () => {+ const updatedAt = new Date().toISOString()+ const legacy: RecentDocument[] = [+ { id: 'local:/tmp/plan.jam', kind: 'local', path: '/tmp/plan.jam', name: 'plan', updatedAt },+ { id: 'local:/tmp/ui.fig', kind: 'local', path: '/tmp/ui.fig', name: 'ui', updatedAt },+ {+ id: 'storage:s3-compatible:r',+ kind: 'storage',+ providerId: 's3-compatible',+ documentId: 'r',+ name: 'Remote',+ updatedAt+ }+ ]+ expect(legacy.map(recentDocumentKind)).toEqual(['board', 'design', 'design'])+ })})