Skip to content

AI-native design editor. Open-source Figma alternative.

feat: make recent files limit configurable (#1289)

Victor Wadse78030138846
diff --git a/changes/1289/added.md b/changes/1289/added.md
new file mode 100644
index 000000000..0c046f3a1
--- /dev/null
+++ b/changes/1289/added.md
@@ -0,0 +1,2 @@
+- General settings on desktop choose how many recent files to keep; the default stays at ten.
+- MCP `list_recent_files` lists recently opened files inside the MCP root, so agents can reopen them with `open_file`.
diff --git a/packages/docs/programmable/mcp-server.md b/packages/docs/programmable/mcp-server.md
index cb17db258..484aff2da 100644
--- a/packages/docs/programmable/mcp-server.md
+++ b/packages/docs/programmable/mcp-server.md
@@ -149,7 +149,7 @@ Endpoints are available over both active transports:
## Workflow
1. **Discover targets** — call `list_documents` first when more than one document or page may be open. It returns stable `document_id` and page IDs.
-2. **Open** — `open_file` to load an existing `.fig`, or `new_document` for a blank canvas. These return target metadata for the opened or created document.
+2. **Open** — `open_file` to load an existing `.fig`, or `new_document` for a blank canvas. `list_recent_files` lists recently opened files inside the MCP root to reopen. These return target metadata for the opened or created document.
3. **Read** — `get_page_tree`, `find_nodes`, `get_node`, `list_pages`
4. **Create** — `create_shape`, `render` (JSX)
5. **Modify** — `set_fill`, `set_stroke`, `set_layout`, `update_node`, `set_effects`
@@ -186,6 +186,7 @@ OpenPencil currently registers 100+ shared design tools, plus MCP-only document
| `save_file` | Save the current document to a `.fig` file |
| `new_document` | Create a new empty document |
| `list_documents` | List open app documents/tabs and their pages |
+| `list_recent_files` | List recently opened files inside the MCP root, newest first, up to the app's recent files limit |
| `activate_document` | Bring a document tab to the front, optionally on a given page |
### History
diff --git a/packages/mcp/src/tool/manifest.ts b/packages/mcp/src/tool/manifest.ts
index 6391359ec..4e9c927b6 100644
--- a/packages/mcp/src/tool/manifest.ts
+++ b/packages/mcp/src/tool/manifest.ts
@@ -66,6 +66,15 @@ export function createToolDescriptors(filesystemEnabled: boolean): ToolDescripto
capabilities: ['filesystem:read', 'document:read'],
enabled: true
} satisfies ToolDescriptor,
+ {
+ name: 'list_recent_files',
+ description:
+ 'List recently opened design files inside the configured MCP root, newest first, with their paths, names, and when they were last opened. Reopen one with open_file.',
+ effect: 'read',
+ availability: 'filesystem',
+ capabilities: ['filesystem:read'],
+ enabled: true
+ } satisfies ToolDescriptor,
{
name: 'new_document',
description:
diff --git a/packages/mcp/src/tool/registration.ts b/packages/mcp/src/tool/registration.ts
index 9684b1cc2..469df4c34 100644
--- a/packages/mcp/src/tool/registration.ts
+++ b/packages/mcp/src/tool/registration.ts
@@ -40,6 +40,11 @@ function splitAutomationTarget(args: Record<string, unknown>): {
type RPCResponse = { ok?: boolean; result?: unknown; target?: unknown; error?: string }
+/** The app's recent files; the server keeps only those `open_file` could reach. */
+const RecentFilesResult = v.object({
+ files: v.array(v.object({ path: v.string(), name: v.string(), updated_at: v.string() }))
+})
+
async function sendCommand(
sendRPC: RPCSender,
command: string,
@@ -273,6 +278,24 @@ export function registerTools(mcpServer: McpServer, options: RegisterToolsOption
}
)
+ register('list_recent_files', { inputSchema: v.strictObject({}) }, async () => {
+ try {
+ const res = await sendCommand(sendRPC, 'list_recent_files', {})
+ const { files } = v.parse(RecentFilesResult, res.result)
+ const insideRoot = await Promise.all(
+ files.map((file) =>
+ resolveSafePath(file.path, resolvedRoot).then(
+ () => true,
+ () => false
+ )
+ )
+ )
+ return ok({ files: files.filter((_, index) => insideRoot[index]) })
+ } catch (e) {
+ return fail(e)
+ }
+ })
+
register(
'new_document',
{
diff --git a/packages/vue/src/i18n/locales/de/settings.json b/packages/vue/src/i18n/locales/de/settings.json
index 795f8390b..8f4249993 100644
--- a/packages/vue/src/i18n/locales/de/settings.json
+++ b/packages/vue/src/i18n/locales/de/settings.json
@@ -1,4 +1,9 @@
{
+ "recentFiles": "Zuletzt verwendete Dateien",
+ "recentFilesDescription": "Wähle, wie viele Dateien in der Liste und im Menü „Zuletzt verwendet“ gespeichert werden.",
+ "recentFilesLimit": "Anzahl zuletzt verwendeter Dateien",
+ "recentFilesLimitCustom": "Benutzerdefiniert…",
+ "recentFilesLimitRange": "Gib eine ganze Zahl zwischen {min} und {max} ein.",
"appearance": "Darstellung",
"snapToGeometry": "An Geometrie ausrichten",
"snapToGeometryDescription": "Gezogene Vektorpunkte an anderen Punkten im Pfad ausrichten.",
diff --git a/packages/vue/src/i18n/locales/es/settings.json b/packages/vue/src/i18n/locales/es/settings.json
index 81ccd12f5..dc36964f7 100644
--- a/packages/vue/src/i18n/locales/es/settings.json
+++ b/packages/vue/src/i18n/locales/es/settings.json
@@ -1,4 +1,9 @@
{
+ "recentFiles": "Archivos recientes",
+ "recentFilesDescription": "Elige cuántos archivos conservar en la lista de recientes y en el menú Abrir recientes.",
+ "recentFilesLimit": "Número de archivos recientes",
+ "recentFilesLimitCustom": "Personalizado…",
+ "recentFilesLimitRange": "Introduce un número entero entre {min} y {max}.",
"appearance": "Apariencia",
"snapToGeometry": "Ajustar a la geometría",
"snapToGeometryDescription": "Alinea los puntos vectoriales arrastrados con otros puntos del trazado.",
diff --git a/packages/vue/src/i18n/locales/fr/settings.json b/packages/vue/src/i18n/locales/fr/settings.json
index e28bcba1f..2d94abc54 100644
--- a/packages/vue/src/i18n/locales/fr/settings.json
+++ b/packages/vue/src/i18n/locales/fr/settings.json
@@ -1,4 +1,9 @@
{
+ "recentFiles": "Fichiers récents",
+ "recentFilesDescription": "Choisissez combien de fichiers conserver dans la liste et le menu des fichiers récents.",
+ "recentFilesLimit": "Nombre de fichiers récents",
+ "recentFilesLimitCustom": "Personnalisé…",
+ "recentFilesLimitRange": "Saisissez un nombre entier entre {min} et {max}.",
"appearance": "Apparence",
"snapToGeometry": "Aligner sur la géométrie",
"snapToGeometryDescription": "Aligne les points vectoriels déplacés sur les autres points du tracé.",
diff --git a/packages/vue/src/i18n/locales/it/settings.json b/packages/vue/src/i18n/locales/it/settings.json
index 925f108a4..b2d83dc54 100644
--- a/packages/vue/src/i18n/locales/it/settings.json
+++ b/packages/vue/src/i18n/locales/it/settings.json
@@ -1,4 +1,9 @@
{
+ "recentFiles": "File recenti",
+ "recentFilesDescription": "Scegli quanti file conservare nell’elenco e nel menu dei file recenti.",
+ "recentFilesLimit": "Numero di file recenti",
+ "recentFilesLimitCustom": "Personalizzato…",
+ "recentFilesLimitRange": "Inserisci un numero intero da {min} a {max}.",
"appearance": "Aspetto",
"snapToGeometry": "Aggancia alla geometria",
"snapToGeometryDescription": "Allinea i punti vettoriali trascinati agli altri punti del tracciato.",
diff --git a/packages/vue/src/i18n/locales/ja/settings.json b/packages/vue/src/i18n/locales/ja/settings.json
index 26b7dd8c4..bde6aa61d 100644
--- a/packages/vue/src/i18n/locales/ja/settings.json
+++ b/packages/vue/src/i18n/locales/ja/settings.json
@@ -1,4 +1,9 @@
{
+ "recentFiles": "最近使ったファイル",
+ "recentFilesDescription": "最近使ったファイルの一覧とメニューに保持するファイル数を選択します。",
+ "recentFilesLimit": "最近使ったファイルの数",
+ "recentFilesLimitCustom": "カスタム…",
+ "recentFilesLimitRange": "{min} から {max} までの整数を入力してください。",
"appearance": "外観",
"snapToGeometry": "ジオメトリにスナップ",
"snapToGeometryDescription": "ドラッグしたベクターポイントをパス内の他のポイントに揃えます。",
diff --git a/packages/vue/src/i18n/locales/pl/settings.json b/packages/vue/src/i18n/locales/pl/settings.json
index 417e31055..16380f532 100644
--- a/packages/vue/src/i18n/locales/pl/settings.json
+++ b/packages/vue/src/i18n/locales/pl/settings.json
@@ -1,4 +1,9 @@
{
+ "recentFiles": "Ostatnie pliki",
+ "recentFilesDescription": "Wybierz, ile plików zachować na liście ostatnich plików i w menu ich otwierania.",
+ "recentFilesLimit": "Liczba ostatnich plików",
+ "recentFilesLimitCustom": "Własna…",
+ "recentFilesLimitRange": "Wpisz liczbę całkowitą od {min} do {max}.",
"appearance": "Wygląd",
"snapToGeometry": "Przyciągaj do geometrii",
"snapToGeometryDescription": "Wyrównuj przeciągane punkty wektorowe do innych punktów ścieżki.",
diff --git a/packages/vue/src/i18n/locales/ru/settings.json b/packages/vue/src/i18n/locales/ru/settings.json
index f9bfb44eb..64da44d84 100644
--- a/packages/vue/src/i18n/locales/ru/settings.json
+++ b/packages/vue/src/i18n/locales/ru/settings.json
@@ -1,4 +1,9 @@
{
+ "recentFiles": "Недавние файлы",
+ "recentFilesDescription": "Выберите, сколько файлов хранить в списке недавних файлов и меню их открытия.",
+ "recentFilesLimit": "Количество недавних файлов",
+ "recentFilesLimitCustom": "Другое…",
+ "recentFilesLimitRange": "Введите целое число от {min} до {max}.",
"appearance": "Внешний вид",
"snapToGeometry": "Привязка к геометрии",
"snapToGeometryDescription": "Выравнивать перетаскиваемые векторные точки по другим точкам контура.",
diff --git a/packages/vue/src/i18n/locales/zh-cn/settings.json b/packages/vue/src/i18n/locales/zh-cn/settings.json
index c45c75a6c..5fb0a6ce5 100644
--- a/packages/vue/src/i18n/locales/zh-cn/settings.json
+++ b/packages/vue/src/i18n/locales/zh-cn/settings.json
@@ -1,4 +1,9 @@
{
+ "recentFiles": "最近的文件",
+ "recentFilesDescription": "选择在最近文件列表和“打开最近的文件”菜单中保留的文件数量。",
+ "recentFilesLimit": "最近文件数量",
+ "recentFilesLimitCustom": "自定义…",
+ "recentFilesLimitRange": "请输入 {min} 到 {max} 之间的整数。",
"appearance": "外观",
"snapToGeometry": "吸附到几何图形",
"snapToGeometryDescription": "将拖动的矢量点与路径中的其他点对齐。",
diff --git a/packages/vue/src/i18n/messages/settings.ts b/packages/vue/src/i18n/messages/settings.ts
index 88e9942fb..f8827f625 100644
--- a/packages/vue/src/i18n/messages/settings.ts
+++ b/packages/vue/src/i18n/messages/settings.ts
@@ -32,6 +32,11 @@ export const settingsMessageDefaults = {
title: 'Settings',
description: 'Manage integrations and app preferences.',
general: 'General',
+ recentFiles: 'Recent files',
+ recentFilesDescription: 'Choose how many files to keep in the recent list and Open Recent menu.',
+ recentFilesLimit: 'Number of recent files',
+ recentFilesLimitCustom: 'Custom…',
+ recentFilesLimitRange: params('Enter a whole number from {min} to {max}.'),
languageDescription: 'Choose the language used by the app interface.',
editing: 'Editing',
snappingDescription: 'Control alignment while editing paths, moving, and resizing layers.',
diff --git a/skills/open-pencil/SKILL.md b/skills/open-pencil/SKILL.md
index cc2f98998..56bf88aa2 100644
--- a/skills/open-pencil/SKILL.md
+++ b/skills/open-pencil/SKILL.md
@@ -298,7 +298,7 @@ The CLI defaults the filesystem root to the home directory on Windows and the cu
### MCP workflow
-1. **Find or open a document** — `list_documents` for open tabs and their IDs; `open_file { path }` within the effective filesystem root, or `new_document {}`. Pass `document_id` and `page_id` explicitly instead of relying on the active tab; `activate_document { document_id }` brings a tab to the front when the user should see it.
+1. **Find or open a document** — `list_documents` for open tabs and their IDs; `open_file { path }` within the effective filesystem root (`list_recent_files` lists recently opened files there), or `new_document {}`. Pass `document_id` and `page_id` explicitly instead of relying on the active tab; `activate_document { document_id }` brings a tab to the front when the user should see it.
2. **Query** — `get_page_tree`, `find_nodes`, `query_nodes`, `get_node`, `list_pages`, `get_current_page`.
3. **Inspect** — `get_jsx`, `diff_jsx`, `diff_create`, `diff_visual`, `describe`, `export_image`, `export_svg`, `export_pdf`.
4. **Modify** — `render`, `batch_update`, `update_node`, `set_fill`, `set_layout`, `create_shape`, `import_svg`, etc.
diff --git a/src/app/automation/bridge/app-handlers.ts b/src/app/automation/bridge/app-handlers.ts
index 7276edbed..c277d777d 100644
--- a/src/app/automation/bridge/app-handlers.ts
+++ b/src/app/automation/bridge/app-handlers.ts
@@ -1,5 +1,6 @@
import type { AutomationTarget } from '@/app/automation/bridge/target'
import { isAutomationUndoLabel } from '@/app/automation/execution/editor'
+import { recentFiles } from '@/app/recent-files'
import { readAutomationSettings, updateAutomationSettings } from '@/app/settings/automation'
import { switchTab } from '@/app/tabs'
@@ -49,6 +50,16 @@ export function handleGetSettings(): unknown {
return { ok: true, result: { settings: readAutomationSettings() } }
}
+/** Local design files from the recent files list, newest first, within the user's limit. */
+export function handleListRecentFiles(): unknown {
+ const files = recentFiles.value.flatMap((document) =>
+ document.kind === 'local'
+ ? [{ path: document.path, name: document.name, updated_at: document.updatedAt }]
+ : []
+ )
+ return { ok: true, result: { files } }
+}
+
export function handleUpdateSettings(args: unknown): unknown {
const settings = (args as { settings?: unknown } | undefined)?.settings
return { ok: true, result: { settings: updateAutomationSettings(settings ?? {}) } }
diff --git a/src/app/automation/bridge/handlers.ts b/src/app/automation/bridge/handlers.ts
index 27997f45c..f987efebe 100644
--- a/src/app/automation/bridge/handlers.ts
+++ b/src/app/automation/bridge/handlers.ts
@@ -4,6 +4,7 @@ import { endAgentSession } from '@/app/automation/agents'
import {
handleActivateDocument,
handleGetSettings,
+ handleListRecentFiles,
handleRedo,
handleUndo,
handleUpdateSettings
@@ -77,6 +78,7 @@ export function createAutomationCommandHandlers(makeFigma: FigmaFactory) {
if (command === 'list_documents') {
return { ok: true, result: { documents: listAutomationDocuments(store) } }
}
+ if (command === 'list_recent_files') return handleListRecentFiles()
if (command === 'agent_session_closed') {
const session = isUnknownRecord(args) ? args.session : undefined
if (typeof session === 'string') endAgentSession(session)
diff --git a/src/app/recent-files/limit.ts b/src/app/recent-files/limit.ts
new file mode 100644
index 000000000..d55af16f8
--- /dev/null
+++ b/src/app/recent-files/limit.ts
@@ -0,0 +1,17 @@
+import * as v from 'valibot'
+
+export const DEFAULT_RECENT_FILES_LIMIT = 10
+export const RECENT_FILES_LIMIT_MIN = 1
+export const RECENT_FILES_LIMIT_MAX = 1000
+
+export const recentFilesLimitSchema = v.pipe(
+ v.number(),
+ v.integer(),
+ v.minValue(RECENT_FILES_LIMIT_MIN),
+ v.maxValue(RECENT_FILES_LIMIT_MAX)
+)
+
+export function resolveRecentFilesLimit(value: unknown): number {
+ const result = v.safeParse(recentFilesLimitSchema, value)
+ return result.success ? result.output : DEFAULT_RECENT_FILES_LIMIT
+}
diff --git a/src/app/recent-files/preferences.ts b/src/app/recent-files/preferences.ts
new file mode 100644
index 000000000..f31dfaca5
--- /dev/null
+++ b/src/app/recent-files/preferences.ts
@@ -0,0 +1,22 @@
+import { computed } from 'vue'
+
+import { appRuntimeConfig } from '@/app/runtime/config'
+import { appPreferences } from '@/app/settings/preferences/store'
+import { isTauri } from '@/app/tauri/env'
+
+import { resolveRecentFilesLimit } from './limit'
+
+export const recentFilesLimit = computed({
+ get: () => resolveRecentFilesLimit(appPreferences.value.files.recentLimit),
+ set: (value: number) => {
+ appPreferences.value = {
+ ...appPreferences.value,
+ files: { ...appPreferences.value.files, recentLimit: resolveRecentFilesLimit(value) }
+ }
+ }
+})
+
+/** Whether the app shows recent files: always on desktop, in the browser only with `?recent-files`. */
+export function recentFilesAvailable(): boolean {
+ return isTauri() || appRuntimeConfig.recentFiles
+}
diff --git a/src/app/recent-files/store.ts b/src/app/recent-files/store.ts
index 1de5b29bd..0bc3c6f98 100644
--- a/src/app/recent-files/store.ts
+++ b/src/app/recent-files/store.ts
@@ -9,9 +9,9 @@ import {
type StorageProviderID
} from '@/app/integrations/storage'
+import { recentFilesLimit } from './preferences'
import { clearRecentFileThumbnails } from './thumbnails'
-const MAX_RECENT_DOCUMENTS = 10
const RECENT_DOCUMENTS_STORAGE_KEY = 'open-pencil:recent-documents'
export interface RecentLocalDocument {
@@ -54,7 +54,7 @@ function storageDocumentId(binding: StorageDocumentBinding): string {
}
function normalizedRecentDocuments(): RecentDocument[] {
- return recentDocuments.value.slice(0, MAX_RECENT_DOCUMENTS)
+ return recentDocuments.value.slice(0, recentFilesLimit.value)
}
export const recentFiles = computed<RecentDocument[]>(normalizedRecentDocuments)
@@ -69,7 +69,7 @@ function remember(document: RecentDocument): void {
recentDocuments.value = [
document,
...normalizedRecentDocuments().filter((recent) => recent.id !== document.id)
- ].slice(0, MAX_RECENT_DOCUMENTS)
+ ].slice(0, recentFilesLimit.value)
}
export function rememberRecentFile(path: string): void {
diff --git a/src/app/settings/preferences/store.ts b/src/app/settings/preferences/store.ts
index cf0895a0d..ad83a207b 100644
--- a/src/app/settings/preferences/store.ts
+++ b/src/app/settings/preferences/store.ts
@@ -11,6 +11,7 @@ import {
normalizeToolbarLayout,
type ToolbarLayout
} from '@/app/editor/toolbar/layout'
+import { DEFAULT_RECENT_FILES_LIMIT, recentFilesLimitSchema } from '@/app/recent-files/limit'
import {
accentPreferenceSchema,
DEFAULT_ACCENT,
@@ -77,6 +78,7 @@ export interface AppPreferences {
/** Whether the view follows our AI agents while they work. */
followAgents: boolean
}
+ files: { recentLimit: number }
version: 1
recovery: {
enabled: boolean
@@ -104,6 +106,7 @@ export const DEFAULT_APP_PREFERENCES: Readonly<AppPreferences> = {
changePreviewSize: 'medium',
followAgents: true
},
+ files: { recentLimit: DEFAULT_RECENT_FILES_LIMIT },
version: 1,
recovery: { enabled: true },
editing: {
@@ -152,6 +155,9 @@ const appPreferencesSchema = section({
),
followAgents: v.fallback(v.boolean(), defaults.chat.followAgents)
}),
+ files: section({
+ recentLimit: v.fallback(recentFilesLimitSchema, defaults.files.recentLimit)
+ }),
version: v.fallback(v.literal(1), 1),
recovery: section({ enabled: v.fallback(v.boolean(), defaults.recovery.enabled) }),
editing: section({
diff --git a/src/components/settings/general/GeneralSettingsPanel.vue b/src/components/settings/general/GeneralSettingsPanel.vue
index c7727b1f3..60cc3a57f 100644
--- a/src/components/settings/general/GeneralSettingsPanel.vue
+++ b/src/components/settings/general/GeneralSettingsPanel.vue
@@ -4,6 +4,8 @@ import { computed } from 'vue'
import { type Locale, useI18n } from '@open-pencil/vue'
import { recoveryEnabled, setRecoveryEnabled } from '@/app/document/recovery/preferences'
+import { RECENT_FILES_LIMIT_MIN, RECENT_FILES_LIMIT_MAX } from '@/app/recent-files/limit'
+import { recentFilesAvailable, recentFilesLimit } from '@/app/recent-files/preferences'
import { setSnappingPreference } from '@/app/settings/preferences/apply'
import { appPreferences } from '@/app/settings/preferences/store'
import { animationPreference } from '@/app/shell/motion'
@@ -13,12 +15,20 @@ import AccentColorPicker from '@/components/settings/general/AccentColorPicker.v
import CollaborationNameSection from '@/components/settings/general/CollaborationNameSection.vue'
import RenderingSettingsSection from '@/components/settings/general/RenderingSettingsSection.vue'
import SettingsGroup from '@/components/settings/layout/SettingsGroup.vue'
+import SettingsRow from '@/components/settings/layout/SettingsRow.vue'
import SettingsSection from '@/components/settings/layout/SettingsSection.vue'
+import PresetNumberField from '@/components/ui/input/PresetNumberField.vue'
import AppSelect from '@/components/ui/select/AppSelect.vue'
import AppSwitch from '@/components/ui/toggle/AppSwitch.vue'
const { availableLocales, locale, localeLabels, menu, recovery, setLocale, settings } = useI18n()
+const showRecentFiles = recentFilesAvailable()
+const recentFilesPresets = [10, 25, 50, 100]
+const recentFilesRangeMessage = computed(() =>
+ settings.value.recentFilesLimitRange({ min: RECENT_FILES_LIMIT_MIN, max: RECENT_FILES_LIMIT_MAX })
+)
+
const { theme } = useAppTheme()
const selectUI = { trigger: 'w-full sm:w-52' }
@@ -178,6 +188,27 @@ const snapToPixelGrid = computed({
<p class="text-[11px] text-muted">{{ settings.temporaryDisableSnappingHint }}</p>
</SettingsSection>
+ <SettingsSection v-if="showRecentFiles">
+ <template #title>{{ settings.recentFiles }}</template>
+ <template #description>{{ settings.recentFilesDescription }}</template>
+ <SettingsGroup>
+ <SettingsRow
+ :label="settings.recentFilesLimit"
+ class="max-sm:flex-col max-sm:items-stretch"
+ >
+ <PresetNumberField
+ v-model:number="recentFilesLimit"
+ :presets="recentFilesPresets"
+ :min="RECENT_FILES_LIMIT_MIN"
+ :max="RECENT_FILES_LIMIT_MAX"
+ :label="settings.recentFilesLimit"
+ :custom-label="settings.recentFilesLimitCustom"
+ :range-message="recentFilesRangeMessage"
+ />
+ </SettingsRow>
+ </SettingsGroup>
+ </SettingsSection>
+
<CredentialSettingsSection />
<RenderingSettingsSection />
</section>
diff --git a/src/views/WorkspaceView.vue b/src/views/WorkspaceView.vue
index 063e967d8..7c7ac54f4 100644
--- a/src/views/WorkspaceView.vue
+++ b/src/views/WorkspaceView.vue
@@ -25,6 +25,7 @@ import { openWebLinkFromLocation, withoutWebLinkParams } from '@/app/document/io
import { setActiveEditorStore } from '@/app/editor/active-store'
import { focusNodesByName } from '@/app/editor/selection/focus'
import { notificationMessages } from '@/app/i18n/notifications'
+import { recentFilesAvailable } from '@/app/recent-files/preferences'
import { appRuntimeConfig } from '@/app/runtime/config'
import { useDocumentDrop } from '@/app/shell/document-drop'
import { useKeyboard } from '@/app/shell/keyboard/use'
@@ -77,10 +78,7 @@ watch(
const router = useRouter()
const createdInitialTab = tabCount() === 0
const shouldCreateHome =
- route.path === '/' &&
- !appRuntimeConfig.test &&
- !route.meta.demo &&
- (isTauri() || appRuntimeConfig.recentFiles)
+ route.path === '/' && !appRuntimeConfig.test && !route.meta.demo && recentFilesAvailable()
const { collaboration } = useI18n()
const joinRoomFromInput = useJoinRoom()
diff --git a/tests/app/automation/bridge/handlers.test.ts b/tests/app/automation/bridge/handlers.test.ts
index 747b68b98..643425db4 100644
--- a/tests/app/automation/bridge/handlers.test.ts
+++ b/tests/app/automation/bridge/handlers.test.ts
@@ -1,10 +1,15 @@
import 'fake-indexeddb/auto'
import { afterEach, beforeEach, describe, expect, test, vi } from 'bun:test'
+import { toRaw } from 'vue'
+
import * as layoutModule from '@open-pencil/core/layout'
import { makeFigmaFromStore } from '@/app/automation/bridge/figma-factory'
import { createAutomationCommandHandlers } from '@/app/automation/bridge/handlers'
+import { recentDocuments } from '@/app/recent-files'
+import { recentFilesLimit } from '@/app/recent-files/preferences'
+import { appPreferences } from '@/app/settings/preferences/store'
import { createTab, getActiveStore, getActiveTabId, getTabById, getTabsSnapshot } from '@/app/tabs'
import { asDouble } from '#tests/helpers/doubles'
@@ -364,3 +369,43 @@ describe('close_file and save_file never prompt', () => {
expect(tab.store.hasWritableSource()).toBe(false)
})
})
+
+describe('list_recent_files', () => {
+ let previousPreferences: typeof appPreferences.value
+
+ beforeEach(() => {
+ previousPreferences = structuredClone(toRaw(appPreferences.value))
+ })
+
+ afterEach(() => {
+ recentDocuments.value = []
+ appPreferences.value = previousPreferences
+ })
+
+ test('lists local files newest first within the recent files limit', async () => {
+ const updatedAt = '2026-01-01T00:00:00.000Z'
+ recentDocuments.value = [
+ { id: 'local:/a.fig', kind: 'local', path: '/a.fig', name: 'a.fig', updatedAt },
+ {
+ id: 'storage:s3:doc',
+ kind: 'storage',
+ providerId: 's3',
+ documentId: 'doc',
+ name: 'Stored',
+ updatedAt
+ },
+ { id: 'local:/b.fig', kind: 'local', path: '/b.fig', name: 'b.fig', updatedAt },
+ { id: 'local:/c.fig', kind: 'local', path: '/c.fig', name: 'c.fig', updatedAt }
+ ]
+ recentFilesLimit.value = 3
+
+ const response = await request('list_recent_files')
+
+ expect(response.result).toEqual({
+ files: [
+ { path: '/a.fig', name: 'a.fig', updated_at: updatedAt },
+ { path: '/b.fig', name: 'b.fig', updated_at: updatedAt }
+ ]
+ })
+ })
+})
diff --git a/tests/app/settings/preferences/store.test.ts b/tests/app/settings/preferences/store.test.ts
index fb92fddf4..fc6199046 100644
--- a/tests/app/settings/preferences/store.test.ts
+++ b/tests/app/settings/preferences/store.test.ts
@@ -9,6 +9,14 @@ describe('parseAppPreferences', () => {
}
})
+ test('keeps a valid recent files limit and defaults missing or invalid limits to ten', () => {
+ expect(parseAppPreferences({}).files.recentLimit).toBe(10)
+ expect(parseAppPreferences({ files: { recentLimit: 25 } }).files.recentLimit).toBe(25)
+ for (const recentLimit of [undefined, null, '25', 0, -1, 2.5, 1001, Infinity, Number.NaN]) {
+ expect(parseAppPreferences({ files: { recentLimit } }).files.recentLimit).toBe(10)
+ }
+ })
+
test('pings by default and treats an unreadable usage stats answer as never asked', () => {
expect(DEFAULT_APP_PREFERENCES.sharing).toEqual({ dailyPing: true, usageStats: 'unset' })
expect(
diff --git a/tests/e2e/app/recent-files.spec.ts b/tests/e2e/app/recent-files.spec.ts
index eb579acec..345f20199 100644
--- a/tests/e2e/app/recent-files.spec.ts
+++ b/tests/e2e/app/recent-files.spec.ts
@@ -1,5 +1,60 @@
import { expect, test } from '#tests/e2e/fixtures'
+test.describe('a populated recent files list', () => {
+ test.use({
+ storageState: async ({ baseURL }, use) => {
+ if (!baseURL) throw new Error('Browser test baseURL is required')
+ await use({
+ cookies: [],
+ origins: [
+ {
+ origin: new URL(baseURL).origin,
+ localStorage: [
+ {
+ name: 'open-pencil:preferences:v1',
+ value: JSON.stringify({ version: 1, onboarding: { aiSetup: 'done' } })
+ },
+ {
+ name: 'open-pencil:recent-documents',
+ value: JSON.stringify(
+ Array.from({ length: 12 }, (_, index) => ({
+ id: `local:/design-${index}.fig`,
+ kind: 'local',
+ path: `/design-${index}.fig`,
+ name: `Recent design ${index}`,
+ updatedAt: '2026-01-01T00:00:00.000Z'
+ }))
+ )
+ }
+ ]
+ }
+ ]
+ })
+ }
+ })
+
+ test('the recent files limit in General settings updates the list and persists', async ({
+ page
+ }) => {
+ await page.goto('/?recent-files')
+ await page.getByTestId('recent-files-home').waitFor()
+ const documents = page.getByRole('button', { name: /Recent design/ })
+ await expect(documents).toHaveCount(10)
+
+ await page.keyboard.press(process.platform === 'darwin' ? 'Meta+,' : 'Control+,')
+ const limit = page.getByRole('combobox', { name: 'Number of recent files' })
+ await limit.click()
+ await page.getByRole('option', { name: '25', exact: true }).click()
+ await page.getByTestId('app-settings-done').click()
+ await expect(documents).toHaveCount(12)
+
+ await page.reload()
+ await expect(documents).toHaveCount(12)
+ await page.keyboard.press(process.platform === 'darwin' ? 'Meta+,' : 'Control+,')
+ await expect(limit).toHaveText('25')
+ })
+})
+
test('keeps the New tab layout usable on mobile', async ({ page }) => {
await page.setViewportSize({ width: 390, height: 844 })
await page.goto('/?recent-files')
diff --git a/tests/engine/mcp/server/index.test.ts b/tests/engine/mcp/server/index.test.ts
index 93b3de04d..5c9fab48a 100644
--- a/tests/engine/mcp/server/index.test.ts
+++ b/tests/engine/mcp/server/index.test.ts
@@ -187,6 +187,7 @@ describe('MCP server', () => {
expect(byName.get('save_file')?.effect).toBe('write')
expect(byName.get('open_file')?.effect).toBe('read')
expect(byName.get('open_file')?.capabilities).toEqual(['filesystem:read', 'document:read'])
+ expect(byName.get('list_recent_files')?.capabilities).toEqual(['filesystem:read'])
expect(byName.get('close_file')?.effect).toBe('write')
expect(byName.get('update_node')?.effect).toBe('write')
expect(byName.get('new_document')?.capabilities).toEqual(['document:write', 'filesystem:write'])
@@ -487,6 +488,26 @@ describe('MCP server with mcpRoot', () => {
})
})
+ test('list_recent_files keeps only recent files inside mcpRoot', async () => {
+ await withMCPRootServer(TEST_MCP_ROOT, async (client, browser) => {
+ const inside = join(TEST_MCP_ROOT, 'recent.fig')
+ const outside = join(TEST_MCP_ROOT, '..', 'outside.fig')
+ const updatedAt = '2026-01-01T00:00:00.000Z'
+ browser.results.set('list_recent_files', {
+ files: [
+ { path: inside, name: 'recent.fig', updated_at: updatedAt },
+ { path: outside, name: 'outside.fig', updated_at: updatedAt }
+ ]
+ })
+
+ const result = await client.callTool({ name: 'list_recent_files', arguments: {} })
+ expect(result.isError).not.toBe(true)
+ expect(parseResult(result)).toEqual({
+ files: [{ path: inside, name: 'recent.fig', updated_at: updatedAt }]
+ })
+ })
+ })
+
test('registers close_file as destructive and forwards its unsaved choice and target', async () => {
await withMCPRootServer(TEST_MCP_ROOT, async (client, browser) => {
const { tools } = await client.listTools()
@@ -586,6 +607,7 @@ describe('MCP server with mcpRoot', () => {
const { tools } = await client.listTools()
const names = tools.map((t) => t.name)
expect(names).not.toContain('open_file')
+ expect(names).not.toContain('list_recent_files')
expect(names).not.toContain('new_document')
})
})
diff --git a/tests/helpers/mcp/server.ts b/tests/helpers/mcp/server.ts
index 02b01600b..aa28a4942 100644
--- a/tests/helpers/mcp/server.ts
+++ b/tests/helpers/mcp/server.ts
@@ -46,6 +46,8 @@ export interface MockBrowser {
ws: WebSocket
graph: SceneGraph
requests: MockBrowserRequest[]
+ /** Results a test sets for app commands, sent instead of the mock's own. */
+ results: Map<string, unknown>
close: () => void
}
@@ -272,6 +274,7 @@ export function connectMockBrowser(
return new Promise((resolve, reject) => {
const ws = new WebSocket(`ws://127.0.0.1:${port}`)
const requests: MockBrowserRequest[] = []
+ const results = new Map<string, unknown>()
const token = authToken ?? 'test-token-' + randomHex(8)
let settled = false
@@ -292,7 +295,9 @@ export function connectMockBrowser(
try {
requests.push({ command: msg.command, args: msg.args })
- const result = await handleMockCommand(graph, msg.command, msg.args)
+ const result = results.has(msg.command)
+ ? results.get(msg.command)
+ : await handleMockCommand(graph, msg.command, msg.args)
ws.send(JSON.stringify({ type: 'response', id: msg.id, ok: true, result }))
} catch (e) {
ws.send(
@@ -313,7 +318,7 @@ export function connectMockBrowser(
// the browser as connected, causing race conditions.
void waitForBrowserRegistration(port).then(
() => {
- resolve({ ws, graph, requests, close: () => ws.close() })
+ resolve({ ws, graph, requests, results, close: () => ws.close() })
return undefined
},
(err) => {