AI-native design editor. Open-source Figma alternative.
feat(ai): modernize model picker
Danila Poyarkovf674f8c99d03
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex f94028a39..982c89c17 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -5,6 +5,7 @@### Added- Add a searchable command palette for editor and application actions.+- Search current AI provider catalogs from model pickers, with curated recommendations, recent compatible models, and offline fallbacks.- Render triangle and line arrow stroke caps on lines and open vector paths, and choose them from the stroke cap picker.- Expose component properties and instance-swap targets through the Figma API and automation.- Normalize imported stroke dash patterns for more reliable `.fig` compatibility.diff --git a/bun.lock b/bun.lockindex c456f3a50..d0aeceeff 100644--- a/bun.lock+++ b/bun.lock@@ -57,6 +57,7 @@"dedent": "^1.7.2","es-toolkit": "^1.51.0","fflate": "^0.8.3",+ "fuse.js": "^7.5.0","fzstd": "^0.1.1","hast-util-to-html": "^9.0.5","idb": "^8.0.3",diff --git a/package.json b/package.jsonindex ef3434a6d..f230ac2a1 100644--- a/package.json+++ b/package.json@@ -123,6 +123,7 @@"dedent": "^1.7.2","es-toolkit": "^1.51.0","fflate": "^0.8.3",+ "fuse.js": "^7.5.0","fzstd": "^0.1.1","hast-util-to-html": "^9.0.5","idb": "^8.0.3",diff --git a/packages/core/src/constants.ts b/packages/core/src/constants.tsindex beb5741c9..bd32ecce9 100644--- a/packages/core/src/constants.ts+++ b/packages/core/src/constants.ts@@ -196,6 +196,8 @@ export interface ModelOption {tag?: stringcapabilities?: readonly ('tools' | 'vision')[]recommendedMaxOutputTokens?: number+ releaseDate?: string+ status?: 'active' | 'beta' | 'deprecated'}export interface AIProviderDef {@@ -226,42 +228,46 @@ export const AI_PROVIDERS: AIProviderDef[] = [name: 'OpenRouter',keyPlaceholder: 'sk-or-…',keyURL: 'https://openrouter.ai/keys',- defaultModel: 'anthropic/claude-sonnet-4.6',+ defaultModel: 'anthropic/claude-sonnet-5',supportsCustomModel: true,models: [{- id: 'anthropic/claude-sonnet-4.6',- name: 'Claude Sonnet 4.6',+ id: 'anthropic/claude-sonnet-5',+ name: 'Claude Sonnet 5',tag: 'Best for design',capabilities: ['tools', 'vision']},{- id: 'anthropic/claude-opus-4.6',- name: 'Claude Opus 4.6',+ id: 'anthropic/claude-opus-5',+ name: 'Claude Opus 5',tag: 'Smartest',capabilities: ['tools', 'vision']},{- id: 'moonshotai/kimi-k2.5',- name: 'Kimi K2.5',- tag: 'Vision + code',+ id: 'openai/gpt-5.6',+ name: 'GPT-5.6',+ tag: 'Latest OpenAI',capabilities: ['tools', 'vision']},{- id: 'google/gemini-3.1-pro-preview',- name: 'Gemini 3.1 Pro',- tag: '1M context',+ id: 'google/gemini-3.8-flash',+ name: 'Gemini 3.8 Flash',+ tag: 'Fast',capabilities: ['tools', 'vision']},- { id: 'openai/gpt-5.3-codex', name: 'GPT-5.3 Codex' },+ { id: 'z-ai/glm-5.3', name: 'GLM-5.3', capabilities: ['tools'] },{- id: 'google/gemini-3-flash-preview',- name: 'Gemini 3 Flash',- tag: 'Fast',+ id: 'deepseek/deepseek-v4-pro',+ name: 'DeepSeek V4 Pro',+ tag: 'Reasoning',+ capabilities: ['tools']+ },+ {+ id: 'moonshotai/kimi-k2.5',+ name: 'Kimi K2.5',+ tag: 'Vision + code',capabilities: ['tools', 'vision']},- { id: 'deepseek/deepseek-v3.2', name: 'DeepSeek V3.2', tag: 'Cheap' },- { id: 'qwen/qwen3.5-flash-02-23', name: 'Qwen 3.5 Flash', tag: 'Cheap' },{ id: 'qwen/qwen3-coder:free', name: 'Qwen3 Coder', tag: 'Free' },{ id: 'openai/gpt-oss-120b:free', name: 'GPT-OSS 120B', tag: 'Free' }]@@ -271,19 +277,25 @@ export const AI_PROVIDERS: AIProviderDef[] = [name: 'Anthropic',keyPlaceholder: 'sk-ant-…',keyURL: 'https://console.anthropic.com/settings/keys',- defaultModel: 'claude-sonnet-4-6-20260301',+ defaultModel: 'claude-sonnet-5',models: [{- id: 'claude-sonnet-4-6-20260301',- name: 'Claude Sonnet 4.6',+ id: 'claude-sonnet-5',+ name: 'Claude Sonnet 5',tag: 'Best for design',capabilities: ['tools', 'vision']},{- id: 'claude-opus-4-6-20260301',- name: 'Claude Opus 4.6',+ id: 'claude-opus-5',+ name: 'Claude Opus 5',tag: 'Smartest',capabilities: ['tools', 'vision']+ },+ {+ id: 'claude-fable-5-1',+ name: 'Claude Fable 5.1',+ tag: 'Latest',+ capabilities: ['tools', 'vision']}]},@@ -292,12 +304,12 @@ export const AI_PROVIDERS: AIProviderDef[] = [name: 'OpenAI',keyPlaceholder: 'sk-…',keyURL: 'https://platform.openai.com/api-keys',- defaultModel: 'gpt-5.3-codex',+ defaultModel: 'gpt-5.6',models: [- { id: 'gpt-5.3-codex', name: 'GPT-5.3 Codex' },- { id: 'gpt-4.1', name: 'GPT-4.1' },- { id: 'o3', name: 'o3', tag: 'Reasoning' },- { id: 'o4-mini', name: 'o4-mini', tag: 'Fast reasoning' }+ { id: 'gpt-5.6', name: 'GPT-5.6', tag: 'Best' },+ { id: 'gpt-5.5', name: 'GPT-5.5' },+ { id: 'gpt-5.4-mini', name: 'GPT-5.4 mini', tag: 'Fast' },+ { id: 'gpt-5.4-nano', name: 'GPT-5.4 nano', tag: 'Cheap' }]},{@@ -305,18 +317,25 @@ export const AI_PROVIDERS: AIProviderDef[] = [name: 'Google AI',keyPlaceholder: 'AIza…',keyURL: 'https://aistudio.google.com/apikey',- defaultModel: 'gemini-3.1-pro-preview',+ defaultModel: 'gemini-3.8-flash',models: [{- id: 'gemini-3.1-pro-preview',- name: 'Gemini 3.1 Pro',- tag: '1M context',+ id: 'gemini-3.8-flash',+ name: 'Gemini 3.8 Flash',+ tag: 'Latest',capabilities: ['tools', 'vision']},+ { id: 'gemini-3.7-flash', name: 'Gemini 3.7 Flash', capabilities: ['tools', 'vision'] },{- id: 'gemini-3-flash-preview',- name: 'Gemini 3 Flash',- tag: 'Fast',+ id: 'gemini-flash-latest',+ name: 'Gemini Flash Latest',+ tag: 'Alias',+ capabilities: ['tools', 'vision']+ },+ {+ id: 'gemini-3.1-pro-preview',+ name: 'Gemini 3.1 Pro',+ tag: 'Pro',capabilities: ['tools', 'vision']}]@@ -337,9 +356,13 @@ export const AI_PROVIDERS: AIProviderDef[] = [name: 'Z.ai',keyPlaceholder: 'API key',keyURL: 'https://docs.z.ai/devpack/quick-start',- defaultModel: 'glm-5.1',+ defaultModel: 'glm-5.3',models: [- { id: 'glm-5.1', name: 'GLM-5.1', tag: 'Best' },+ { id: 'glm-5.3', name: 'GLM-5.3', tag: 'Best' },+ { id: 'glm-5.3-flash', name: 'GLM-5.3-Flash', tag: 'Fast' },+ { id: 'glm-5.2', name: 'GLM-5.2' },+ { id: 'glm-5v-turbo', name: 'GLM-5V-Turbo', tag: 'Vision' },+ { id: 'glm-5.1', name: 'GLM-5.1' },{ id: 'glm-5', name: 'GLM-5' },{ id: 'glm-5-code', name: 'GLM-5-Code' },{ id: 'glm-4.7', name: 'GLM-4.7' },diff --git a/packages/vue/src/i18n/locales/de/ai.json b/packages/vue/src/i18n/locales/de/ai.jsonindex 77bb803af..d565b9229 100644--- a/packages/vue/src/i18n/locales/de/ai.json+++ b/packages/vue/src/i18n/locales/de/ai.json@@ -85,6 +85,12 @@"apiType": "API Type","baseURL": "Base URL","modelID": "Model ID",+ "selectModel": "Modell auswählen",+ "searchModels": "Modelle suchen…",+ "recommendedModels": "Empfohlen",+ "latestModels": "Neueste",+ "allModels": "Alle Modelle",+ "latest": "Neu","customModelID": "Benutzerdefinierte Modell-ID","customModel": "Benutzerdefiniertes Modell…","advancedModelSettings": "Erweiterte Einstellungen",diff --git a/packages/vue/src/i18n/locales/es/ai.json b/packages/vue/src/i18n/locales/es/ai.jsonindex 6befdac1a..53379edcd 100644--- a/packages/vue/src/i18n/locales/es/ai.json+++ b/packages/vue/src/i18n/locales/es/ai.json@@ -85,6 +85,12 @@"apiType": "Tipo de API","baseURL": "URL base","modelID": "ID del modelo",+ "selectModel": "Seleccionar un modelo",+ "searchModels": "Buscar modelos…",+ "recommendedModels": "Recomendados",+ "latestModels": "Más recientes",+ "allModels": "Todos los modelos",+ "latest": "Nuevo","customModelID": "ID de modelo personalizado","customModel": "Modelo personalizado…","advancedModelSettings": "Ajustes avanzados",diff --git a/packages/vue/src/i18n/locales/fr/ai.json b/packages/vue/src/i18n/locales/fr/ai.jsonindex b0f900cb9..ea08c80cd 100644--- a/packages/vue/src/i18n/locales/fr/ai.json+++ b/packages/vue/src/i18n/locales/fr/ai.json@@ -85,6 +85,12 @@"apiType": "API Type","baseURL": "Base URL","modelID": "Model ID",+ "selectModel": "Sélectionner un modèle",+ "searchModels": "Rechercher des modèles…",+ "recommendedModels": "Recommandés",+ "latestModels": "Plus récents",+ "allModels": "Tous les modèles",+ "latest": "Nouveau","customModelID": "ID du modèle personnalisé","customModel": "Modèle personnalisé…","advancedModelSettings": "Paramètres avancés",diff --git a/packages/vue/src/i18n/locales/it/ai.json b/packages/vue/src/i18n/locales/it/ai.jsonindex d94ebd648..80dc5887e 100644--- a/packages/vue/src/i18n/locales/it/ai.json+++ b/packages/vue/src/i18n/locales/it/ai.json@@ -85,6 +85,12 @@"apiType": "Tipo di API","baseURL": "URL di base","modelID": "ID modello",+ "selectModel": "Seleziona un modello",+ "searchModels": "Cerca modelli…",+ "recommendedModels": "Consigliati",+ "latestModels": "Più recenti",+ "allModels": "Tutti i modelli",+ "latest": "Nuovo","customModelID": "ID modello personalizzato","customModel": "Modello personalizzato…","advancedModelSettings": "Impostazioni avanzate",diff --git a/packages/vue/src/i18n/locales/ja/ai.json b/packages/vue/src/i18n/locales/ja/ai.jsonindex ab4e726d2..5610c1904 100644--- a/packages/vue/src/i18n/locales/ja/ai.json+++ b/packages/vue/src/i18n/locales/ja/ai.json@@ -85,6 +85,12 @@"apiType": "APIタイプ","baseURL": "ベースURL","modelID": "モデルID",+ "selectModel": "モデルを選択",+ "searchModels": "モデルを検索…",+ "recommendedModels": "おすすめ",+ "latestModels": "最新",+ "allModels": "すべてのモデル",+ "latest": "新着","customModelID": "カスタムモデル ID","customModel": "カスタムモデル…","advancedModelSettings": "詳細設定",diff --git a/packages/vue/src/i18n/locales/pl/ai.json b/packages/vue/src/i18n/locales/pl/ai.jsonindex ebe8f3cc1..97d6446eb 100644--- a/packages/vue/src/i18n/locales/pl/ai.json+++ b/packages/vue/src/i18n/locales/pl/ai.json@@ -85,6 +85,12 @@"apiType": "API Type","baseURL": "Base URL","modelID": "Model ID",+ "selectModel": "Wybierz model",+ "searchModels": "Szukaj modeli…",+ "recommendedModels": "Polecane",+ "latestModels": "Najnowsze",+ "allModels": "Wszystkie modele",+ "latest": "Nowy","customModelID": "Identyfikator modelu niestandardowego","customModel": "Model niestandardowy…","advancedModelSettings": "Ustawienia zaawansowane",diff --git a/packages/vue/src/i18n/locales/ru/ai.json b/packages/vue/src/i18n/locales/ru/ai.jsonindex a7a4277a1..42de614d7 100644--- a/packages/vue/src/i18n/locales/ru/ai.json+++ b/packages/vue/src/i18n/locales/ru/ai.json@@ -85,6 +85,12 @@"apiType": "API Type","baseURL": "Base URL","modelID": "Model ID",+ "selectModel": "Выберите модель",+ "searchModels": "Поиск моделей…",+ "recommendedModels": "Рекомендуемые",+ "latestModels": "Новые",+ "allModels": "Все модели",+ "latest": "Новая","customModelID": "ID пользовательской модели","customModel": "Пользовательская модель…","advancedModelSettings": "Расширенные настройки",diff --git a/packages/vue/src/i18n/locales/zh-cn/ai.json b/packages/vue/src/i18n/locales/zh-cn/ai.jsonindex bc39d6996..b68ed80b4 100644--- a/packages/vue/src/i18n/locales/zh-cn/ai.json+++ b/packages/vue/src/i18n/locales/zh-cn/ai.json@@ -85,6 +85,12 @@"apiType": "API 类型","baseURL": "Base URL","modelID": "模型 ID",+ "selectModel": "选择模型",+ "searchModels": "搜索模型…",+ "recommendedModels": "推荐",+ "latestModels": "最新",+ "allModels": "所有模型",+ "latest": "新","customModelID": "自定义模型 ID","customModel": "自定义模型…","advancedModelSettings": "高级设置",diff --git a/packages/vue/src/i18n/messages/ai.ts b/packages/vue/src/i18n/messages/ai.tsindex 905e315fd..0a3205932 100644--- a/packages/vue/src/i18n/messages/ai.ts+++ b/packages/vue/src/i18n/messages/ai.ts@@ -98,6 +98,12 @@ export const aiMessageDefaults = {apiType: 'API Type',baseURL: 'Base URL',modelID: 'Model ID',+ selectModel: 'Select a model',+ searchModels: 'Search models…',+ recommendedModels: 'Recommended',+ latestModels: 'Latest',+ allModels: 'All models',+ latest: 'Latest',customModelID: 'Custom model ID',customModel: 'Custom model…',advancedModelSettings: 'Advanced settings',diff --git a/src/app/ai/models/catalog.ts b/src/app/ai/models/catalog.tsindex fec5224aa..ac5db879f 100644--- a/src/app/ai/models/catalog.ts+++ b/src/app/ai/models/catalog.ts@@ -1,3 +1,4 @@+import { AI_PROVIDERS } from '@open-pencil/core/constants'import type { AIProviderID, ModelOption } from '@open-pencil/core/constants'import { readCacheJSON, writeCacheJSON } from '@/app/cache'@@ -21,6 +22,9 @@ type ModelsDevModel = {name?: unknownattachment?: unknowntool_call?: unknown+ status?: unknown+ release_date?: unknown+ modalities?: { output?: unknown }limit?: { output?: unknown }}@@ -32,19 +36,27 @@ type ModelsDevCatalog = Record<string, ModelsDevProvider>let catalogPromise: Promise<ModelsDevCatalog | null> | null = null+function normalizedStatus(status: unknown): ModelOption['status'] {+ if (status === 'beta' || status === 'deprecated') return status+ return 'active'+}+function normalizeModel(id: string, model: ModelsDevModel): ModelOption {const capabilities: ('tools' | 'vision')[] = []if (model.tool_call === true) capabilities.push('tools')if (model.attachment === true) capabilities.push('vision')- const output = model.limit?.output- return {+ const normalized: ModelOption = {id,name: typeof model.name === 'string' && model.name ? model.name : id,capabilities,- ...(typeof output === 'number' && Number.isFinite(output)- ? { recommendedMaxOutputTokens: Math.min(128_000, Math.max(1024, output)) }- : {})+ status: normalizedStatus(model.status)+ }+ const output = model.limit?.output+ if (typeof output === 'number' && Number.isFinite(output)) {+ normalized.recommendedMaxOutputTokens = Math.min(128_000, Math.max(1024, output))}+ if (typeof model.release_date === 'string') normalized.releaseDate = model.release_date+ return normalized}async function loadCatalog(@@ -69,6 +81,16 @@ async function loadCatalog(}}+async function resolvedCatalog(fetcher?: typeof fetch): Promise<ModelsDevCatalog | null> {+ const nativeFetch = typeof globalThis.fetch === 'function' ? globalThis.fetch : undefined+ const resolvedFetcher = fetcher ?? nativeFetch+ if (!resolvedFetcher) return null+ const useCache = resolvedFetcher === nativeFetch+ return useCache+ ? (catalogPromise ??= loadCatalog(resolvedFetcher, { useCache: true }))+ : loadCatalog(resolvedFetcher, { useCache: false })+}+function modelIDCandidates(providerKey: string, modelID: string): string[] {const unprefixed = modelID.startsWith(`${providerKey}/`)? modelID.slice(providerKey.length + 1)@@ -83,6 +105,50 @@ function modelIDCandidates(providerKey: string, modelID: string): string[] {]}+function curatedProviderModels(providerID: AIProviderID): ModelOption[] {+ return AI_PROVIDERS.find((provider) => provider.id === providerID)?.models ?? []+}++function supportsDesignWork(model: ModelsDevModel): boolean {+ if (model.tool_call !== true || model.status === 'deprecated') return false+ const outputModalities = model.modalities?.output+ return !Array.isArray(outputModalities) || outputModalities.includes('text')+}++function mergeCuratedModels(curated: ModelOption[], catalog: ModelOption[]): ModelOption[] {+ const catalogById = new Map(catalog.map((model) => [model.id, model]))+ const recommended = curated.map((model) => ({+ ...catalogById.get(model.id),+ ...model,+ capabilities: catalogById.get(model.id)?.capabilities ?? model.capabilities,+ recommendedMaxOutputTokens:+ catalogById.get(model.id)?.recommendedMaxOutputTokens ?? model.recommendedMaxOutputTokens+ }))+ const curatedIds = new Set(curated.map((model) => model.id))+ const remaining = catalog+ .filter((model) => !curatedIds.has(model.id))+ .sort((left, right) => (right.releaseDate ?? '').localeCompare(left.releaseDate ?? ''))+ return [...recommended, ...remaining]+}++export async function listCatalogModels(+ providerID: AIProviderID,+ fetcher?: typeof fetch+): Promise<ModelOption[]> {+ const curated = curatedProviderModels(providerID)+ const providerKeys = PROVIDER_KEYS[providerID]+ if (!providerKeys?.length) return curated+ const catalog = await resolvedCatalog(fetcher)+ if (!catalog) return curated++ const models = providerKeys.flatMap((providerKey) =>+ Object.entries(catalog[providerKey]?.models ?? {})+ .filter(([, model]) => supportsDesignWork(model))+ .map(([id, model]) => normalizeModel(id, model))+ )+ return models.length ? mergeCuratedModels(curated, models) : curated+}+export async function resolveModelsDevModel(providerID: AIProviderID,modelID: string,@@ -90,13 +156,7 @@ export async function resolveModelsDevModel(): Promise<ModelOption | null> {const providerKeys = PROVIDER_KEYS[providerID]if (!providerKeys?.length || !modelID) return null- const nativeFetch = typeof globalThis.fetch === 'function' ? globalThis.fetch : undefined- const resolvedFetcher = fetcher ?? nativeFetch- if (!resolvedFetcher) return null- const useCache = resolvedFetcher === nativeFetch- const catalog = await (useCache- ? (catalogPromise ??= loadCatalog(resolvedFetcher, { useCache: true }))- : loadCatalog(resolvedFetcher, { useCache: false }))+ const catalog = await resolvedCatalog(fetcher)if (!catalog) return nullfor (const providerKey of providerKeys) {diff --git a/src/app/ai/models/use-provider-model-catalog.ts b/src/app/ai/models/use-provider-model-catalog.tsnew file mode 100644index 000000000..a751c9f38--- /dev/null+++ b/src/app/ai/models/use-provider-model-catalog.ts@@ -0,0 +1,26 @@+import { ref, watch, type Ref } from 'vue'++import type { AIProviderID, ModelOption } from '@open-pencil/core/constants'++import { listCatalogModels } from '@/app/ai/models/catalog'++export function useProviderModelCatalog(+ providerID: Readonly<Ref<AIProviderID>>,+ fallback: Readonly<Ref<ModelOption[]>>+) {+ const models = ref<ModelOption[]>(fallback.value)++ watch(+ providerID,+ async (currentProvider) => {+ const requestedProvider = currentProvider+ models.value = fallback.value+ const loaded = await listCatalogModels(requestedProvider)+ if (providerID.value !== requestedProvider) return+ models.value = loaded+ },+ { immediate: true }+ )++ return { models }+}diff --git a/src/components/chat/ProviderModelSelect.vue b/src/components/chat/ProviderModelSelect.vueindex 4e05ffe31..6956c4c37 100644--- a/src/components/chat/ProviderModelSelect.vue+++ b/src/components/chat/ProviderModelSelect.vue@@ -1,47 +1,62 @@<script setup lang="ts">-import {- SelectContent,- SelectItem,- SelectItemText,- SelectPortal,- SelectRoot,- SelectTrigger,- SelectViewport-} from 'reka-ui'+import { computed } from 'vue'-import AppBadge from '@/components/ui/AppBadge.vue'-import { useSelectUI } from '@/components/ui/select'+import { useI18n } from '@open-pencil/vue'++import AppCombobox from '@/components/ui/AppCombobox.vue'import { useAIChat } from '@/app/ai/chat/use'+import { useProviderModelCatalog } from '@/app/ai/models/use-provider-model-catalog'++const { modelID, providerDef, providerID } = useAIChat()+const { ai, common } = useI18n()+const fallbackModels = computed(() => providerDef.value.models)+const { models } = useProviderModelCatalog(providerID, fallbackModels)++function modelGroup(modelID: string, recommendedIds: Set<string>, latestIds: Set<string>): string {+ if (recommendedIds.has(modelID)) return ai.value.recommendedModels+ if (latestIds.has(modelID)) return ai.value.latestModels+ return ai.value.allModels+}-const { modelID, providerDef } = useAIChat()-const selectCls = useSelectUI({- trigger: 'gap-1 rounded border-none bg-transparent px-1.5 py-0.5 text-[10px] text-muted',- content: 'max-h-60 overflow-y-auto',- item: 'gap-2 rounded px-2 py-1.5 text-[11px]'+const options = computed(() => {+ const recommendedIds = new Set(providerDef.value.models.map((model) => model.id))+ const latestIds = new Set(+ models.value+ .filter((model) => !recommendedIds.has(model.id) && model.releaseDate)+ .slice(0, 8)+ .map((model) => model.id)+ )+ return models.value.map((model) => ({+ value: model.id,+ label: model.name,+ description: model.id,+ meta: model.tag ?? (latestIds.has(model.id) ? ai.value.latest : undefined),+ group: modelGroup(model.id, recommendedIds, latestIds)+ }))})</script><template>- <SelectRoot v-model="modelID">- <SelectTrigger data-test-id="chat-model-selector" :class="selectCls.trigger">- <icon-lucide-bot class="size-3" />- <slot name="value" />- <icon-lucide-chevron-down class="size-2.5" />- </SelectTrigger>- <SelectPortal>- <SelectContent position="popper" side="top" :side-offset="4" :class="selectCls.content">- <SelectViewport>- <SelectItem- v-for="model in providerDef.models"- :key="model.id"- :value="model.id"- :class="selectCls.item"- >- <SelectItemText class="flex-1">{{ model.name }}</SelectItemText>- <AppBadge v-if="model.tag">{{ model.tag }}</AppBadge>- </SelectItem>- </SelectViewport>- </SelectContent>- </SelectPortal>- </SelectRoot>+ <AppCombobox+ v-model="modelID"+ :options="options"+ :label="ai.modelID"+ :search-placeholder="ai.searchModels"+ :empty-label="common.noResults"+ data-test-id="chat-model-selector"+ :ui="{+ trigger: 'h-6 w-auto max-w-72 border-none bg-transparent hover:bg-hover',+ value: 'text-[10px] text-muted',+ content: 'min-w-72'+ }"+ >+ <template #value="{ option }">+ <div class="flex min-w-0 flex-1 items-center gap-1">+ <icon-lucide-bot class="size-3 shrink-0" />+ <slot name="value">+ <span class="truncate">{{ option?.label }}</span>+ </slot>+ </div>+ </template>+ </AppCombobox></template>diff --git a/src/components/settings/models/ProfileEditor.vue b/src/components/settings/models/ProfileEditor.vueindex be36ea9dd..3be4ed387 100644--- a/src/components/settings/models/ProfileEditor.vue+++ b/src/components/settings/models/ProfileEditor.vue@@ -7,6 +7,7 @@ import { ACP_AGENTS, AI_PROVIDERS, type AIProviderID } from '@open-pencil/core/cimport { refreshAIProviderStatus } from '@/app/ai/chat/storage'import { resolveModelsDevModel } from '@/app/ai/models/catalog'+import { useProviderModelCatalog } from '@/app/ai/models/use-provider-model-catalog'import {testProviderConnection,type ProviderConnectionTestFailureReason@@ -29,6 +30,7 @@ import ProviderSelect from '@/components/settings/provider-select/ProviderSelectimport ProviderSettingsField from '@/components/settings/provider/ProviderSettingsField.vue'import ProviderSettingsInput from '@/components/settings/provider/ProviderSettingsInput.vue'import ProviderSettingsKeyField from '@/components/settings/provider/ProviderSettingsKeyField.vue'+import AppCombobox from '@/components/ui/AppCombobox.vue'import AppInput from '@/components/ui/AppInput.vue'import AppSelect from '@/components/ui/AppSelect.vue'import AppSwitch from '@/components/ui/AppSwitch.vue'@@ -56,6 +58,9 @@ const catalogModel = ref<(typeof providerDef.value.models)[number] | null>(null)const providerDef = computed(() => AI_PROVIDERS.find((provider) => provider.id === draft.providerID) ?? AI_PROVIDERS[0])+const catalogProviderID = computed(() => draft.providerID)+const fallbackModels = computed(() => providerDef.value.models)+const { models: availableModels } = useProviderModelCatalog(catalogProviderID, fallbackModels)const isACP = computed(() => draft.providerID.startsWith('acp:'))const isHarness = computed(() => draft.providerID === 'harness:pi')const supportsReasoningEffort = computed(() =>@@ -66,12 +71,39 @@ const providerDisplayName = computed(() => {const agentID = draft.providerID.slice('acp:'.length)return ACP_AGENTS.find((agent) => agent.id === agentID)?.name ?? draft.providerID})-const modelOptions = computed(() => [- ...providerDef.value.models.map((model) => ({ value: model.id, label: model.name })),- ...(providerDef.value.supportsCustomModel- ? [{ value: CUSTOM_MODEL_VALUE, label: ai.value.customModel }]- : [])-])+function modelGroup(modelID: string, recommendedIds: Set<string>, latestIds: Set<string>): string {+ if (recommendedIds.has(modelID)) return ai.value.recommendedModels+ if (latestIds.has(modelID)) return ai.value.latestModels+ return ai.value.allModels+}++const modelOptions = computed(() => {+ const recommendedIds = new Set(providerDef.value.models.map((model) => model.id))+ const latestIds = new Set(+ availableModels.value+ .filter((model) => !recommendedIds.has(model.id) && model.releaseDate)+ .slice(0, 8)+ .map((model) => model.id)+ )+ return [+ ...availableModels.value.map((model) => ({+ value: model.id,+ label: model.name,+ description: model.id,+ meta: model.tag ?? (latestIds.has(model.id) ? ai.value.latest : undefined),+ group: modelGroup(model.id, recommendedIds, latestIds)+ })),+ ...(providerDef.value.supportsCustomModel+ ? [+ {+ value: CUSTOM_MODEL_VALUE,+ label: ai.value.customModel,+ group: ai.value.customModel+ }+ ]+ : [])+ ]+})const selectedModelValue = computed(() =>customModelSelected.value ? CUSTOM_MODEL_VALUE : draft.modelID)@@ -324,10 +356,13 @@ void refreshKeyStatus()</div><ProviderSettingsField v-if="modelOptions.length" :label="ai.modelID">- <AppSelect+ <AppCombobox:model-value="selectedModelValue":options="modelOptions":label="ai.modelID"+ :placeholder="ai.selectModel"+ :search-placeholder="ai.searchModels"+ :empty-label="common.noResults"@update:model-value="updateModel(String($event))"/></ProviderSettingsField>diff --git a/src/components/ui/AppCombobox.stories.ts b/src/components/ui/AppCombobox.stories.tsnew file mode 100644index 000000000..425fef1e7--- /dev/null+++ b/src/components/ui/AppCombobox.stories.ts@@ -0,0 +1,110 @@+import type { Meta, StoryObj } from '@storybook/vue3-vite'+import { expect, userEvent, within } from 'storybook/test'+import { ref } from 'vue'++import AppCombobox from './AppCombobox.vue'++const models = [+ {+ value: 'anthropic/claude-sonnet-5',+ label: 'Claude Sonnet 5',+ meta: 'Recommended',+ group: 'Recommended'+ },+ {+ value: 'openai/gpt-5.6',+ label: 'GPT-5.6',+ meta: 'Latest',+ group: 'Latest'+ },+ {+ value: 'google/gemini-3.8-flash',+ label: 'Gemini 3.8 Flash',+ meta: 'Latest',+ group: 'Latest'+ },+ {+ value: 'deepseek/deepseek-v4-pro',+ label: 'DeepSeek V4 Pro',+ group: 'All models'+ },+ {+ value: 'z-ai/glm-5.3-flash',+ label: 'GLM-5.3 Flash',+ group: 'All models'+ }+]++type AppComboboxStoryArgs = {+ options: Array<{+ value: string+ label: string+ meta?: string+ group?: string+ }>+ label: string+ placeholder: string+ searchPlaceholder: string+ emptyLabel: string+ disabled: boolean+ resultLimit: number+}++type Story = StoryObj<AppComboboxStoryArgs>++const meta = {+ title: 'Design System/Combobox',+ component: AppCombobox,+ parameters: { layout: 'centered' },+ render: (args) => ({+ components: { AppCombobox },+ setup() {+ const value = ref('anthropic/claude-sonnet-5')+ return { args, value }+ },+ template: `+ <div class="w-80 bg-app p-6 text-surface">+ <AppCombobox v-model="value" v-bind="args" />+ <p class="mt-3 font-mono text-[10px] text-muted">{{ value }}</p>+ </div>+ `+ }),+ args: {+ options: models,+ label: 'Model',+ placeholder: 'Select a model',+ searchPlaceholder: 'Search models…',+ emptyLabel: 'No matching models',+ resultLimit: 100+ }+} satisfies Meta<AppComboboxStoryArgs>++export default meta++export const Default: Story = {+ play: async ({ canvasElement }) => {+ const canvas = within(canvasElement)+ await userEvent.click(canvas.getByRole('button', { name: 'Model' }))+ const body = within(document.body)+ const search = body.getByRole('combobox', { name: 'Search models…' })+ await userEvent.type(search, 'gemni')+ await expect(body.getByRole('option', { name: /Gemini 3\.8 Flash/ })).toBeVisible()+ await expect(body.queryByRole('option', { name: /Claude Sonnet 5/ })).not.toBeInTheDocument()+ await userEvent.keyboard('{ArrowDown}{Enter}')+ await expect(canvas.getByText('google/gemini-3.8-flash')).toBeVisible()+ }+}+export const Disabled: Story = { args: { disabled: true } }+export const Empty: Story = { args: { options: [] } }+export const LongLabels: Story = {+ args: {+ options: [+ ...models,+ {+ value: 'provider/an-unusually-long-model-identifier-for-testing-overflow',+ label: 'An unusually long model name for testing overflow behavior',+ group: 'All models'+ }+ ]+ }+}diff --git a/src/components/ui/AppCombobox.vue b/src/components/ui/AppCombobox.vuenew file mode 100644index 000000000..8015125b1--- /dev/null+++ b/src/components/ui/AppCombobox.vue@@ -0,0 +1,189 @@+<script setup lang="ts">+import Fuse from 'fuse.js'+import { computed, ref } from 'vue'+import { tv } from 'tailwind-variants'+import {+ ComboboxAnchor,+ ComboboxContent,+ ComboboxEmpty,+ ComboboxGroup,+ ComboboxInput,+ ComboboxItem,+ ComboboxItemIndicator,+ ComboboxLabel,+ ComboboxPortal,+ ComboboxRoot,+ ComboboxTrigger,+ ComboboxViewport,+ type AcceptableValue+} from 'reka-ui'++import theme from '@/theme/combobox'+import type { AppComboboxTheme } from '@/theme/combobox'+import type { ComponentUI } from '@/components/ui/types'++export type AppComboboxOption = {+ value: string+ label: string+ description?: string+ meta?: string+ group?: string+ disabled?: boolean+}++interface AppComboboxProps {+ options: AppComboboxOption[]+ label?: string+ placeholder?: string+ searchPlaceholder?: string+ emptyLabel?: string+ disabled?: boolean+ resultLimit?: number+ ui?: ComponentUI<AppComboboxTheme>+}++defineOptions({ inheritAttrs: false })++const {+ options,+ label,+ placeholder,+ searchPlaceholder,+ emptyLabel = 'No results',+ disabled = false,+ resultLimit = 100,+ ui+} = defineProps<AppComboboxProps>()++const modelValue = defineModel<string>({ required: true })+const open = ref(false)+const searchTerm = ref('')+const styles = tv(theme)()++const selectedOption = computed(() => options.find((option) => option.value === modelValue.value))+const searchIndex = computed(+ () =>+ new Fuse(options, {+ keys: ['label', 'value', 'description', 'meta'],+ threshold: 0.2,+ ignoreLocation: true+ })+)+const filteredOptions = computed(() => {+ const query = searchTerm.value.trim()+ if (!query) return options.slice(0, resultLimit)+ return searchIndex.value+ .search(query)+ .slice(0, resultLimit)+ .map((result) => result.item)+})+const groupedOptions = computed(() => {+ const groups = new Map<string, AppComboboxOption[]>()+ for (const option of filteredOptions.value) {+ const group = option.group ?? ''+ const entries = groups.get(group)+ if (entries) entries.push(option)+ else groups.set(group, [option])+ }+ return [...groups.entries()]+})++function updateValue(value: AcceptableValue): void {+ if (typeof value !== 'string') return+ modelValue.value = value+}++function updateOpen(value: boolean): void {+ open.value = value+ if (!value) searchTerm.value = ''+}+</script>++<template>+ <ComboboxRoot+ :model-value="modelValue"+ :open="open"+ :disabled="disabled"+ :ignore-filter="true"+ @update:model-value="updateValue"+ @update:open="updateOpen"+ >+ <ComboboxAnchor as-child>+ <ComboboxTrigger+ v-bind="$attrs"+ :aria-label="label"+ :class="styles.trigger({ class: ui?.trigger })"+ >+ <slot name="value" :option="selectedOption">+ <span :class="styles.value({ class: ui?.value })">+ {{ selectedOption?.label ?? (modelValue || placeholder) }}+ </span>+ </slot>+ <icon-lucide-chevron-down :class="styles.chevron({ class: ui?.chevron })" />+ </ComboboxTrigger>+ </ComboboxAnchor>++ <ComboboxPortal>+ <ComboboxContent+ position="popper"+ :side-offset="2"+ :class="styles.content({ class: ui?.content })"+ >+ <div :class="styles.search({ class: ui?.search })">+ <icon-lucide-search :class="styles.searchIcon({ class: ui?.searchIcon })" />+ <ComboboxInput+ v-model="searchTerm"+ :aria-label="searchPlaceholder ?? label"+ :placeholder="searchPlaceholder"+ :display-value="() => ''"+ :class="styles.input({ class: ui?.input })"+ autocomplete="off"+ autocorrect="off"+ autocapitalize="off"+ spellcheck="false"+ />+ </div>++ <ComboboxViewport :class="styles.viewport({ class: ui?.viewport })">+ <ComboboxEmpty :class="styles.empty({ class: ui?.empty })">+ <slot name="empty" :query="searchTerm">+ {{ emptyLabel }}+ </slot>+ </ComboboxEmpty>+ <ComboboxGroup v-for="([group, entries], index) in groupedOptions" :key="group || index">+ <ComboboxLabel v-if="group" :class="styles.groupLabel({ class: ui?.groupLabel })">+ <slot name="group-label" :group="group">+ {{ group }}+ </slot>+ </ComboboxLabel>+ <ComboboxItem+ v-for="option in entries"+ :key="option.value"+ :value="option.value"+ :disabled="option.disabled"+ :class="styles.item({ class: ui?.item })"+ >+ <ComboboxItemIndicator :class="styles.indicator({ class: ui?.indicator })">+ <icon-lucide-check class="size-3 text-accent" />+ </ComboboxItemIndicator>+ <slot name="option" :option="option">+ <div class="min-w-0 flex-1">+ <div class="truncate text-surface">{{ option.label }}</div>+ <div+ v-if="option.description || option.value !== option.label"+ :class="styles.description({ class: ui?.description })"+ >+ {{ option.description ?? option.value }}+ </div>+ </div>+ <span v-if="option.meta" :class="styles.meta({ class: ui?.meta })">+ {{ option.meta }}+ </span>+ </slot>+ </ComboboxItem>+ </ComboboxGroup>+ </ComboboxViewport>+ </ComboboxContent>+ </ComboboxPortal>+ </ComboboxRoot>+</template>diff --git a/src/components/ui/AppComboboxInput.vue b/src/components/ui/AppComboboxInput.vuedeleted file mode 100644index 831e87048..000000000--- a/src/components/ui/AppComboboxInput.vue+++ /dev/null@@ -1,122 +0,0 @@-<script setup lang="ts">-import { computed, ref } from 'vue'-import {- ComboboxContent,- ComboboxInput,- ComboboxItem,- ComboboxPortal,- ComboboxRoot,- ComboboxViewport,- type AcceptableValue-} from 'reka-ui'--import AppBadge from '@/components/ui/AppBadge.vue'-import AppPlaceholder from '@/components/ui/AppPlaceholder.vue'-import { useInputUI } from '@/components/ui/input'-import { useSelectUI } from '@/components/ui/select'--export type AppComboboxOption = {- value: string- label: string- meta?: string-}--interface AppComboboxInputProps {- options: AppComboboxOption[]- placeholder?: string- emptyLabel?: string- ui?: {- input?: string- content?: string- item?: string- viewport?: string- empty?: string- }-}--defineOptions({ inheritAttrs: false })--const { options, placeholder, emptyLabel = 'No results', ui } = defineProps<AppComboboxInputProps>()--const modelValue = defineModel<string>({ required: true })-const open = ref(false)--const select = useSelectUI({- content: ui?.content ?? 'max-h-56 min-w-[var(--reka-combobox-trigger-width)]',- item: ui?.item ?? 'gap-2 rounded px-2 py-1.5 text-[11px]'-})-const inputClass = computed(() => useInputUI({ size: 'sm', ui: { base: ui?.input } }).base)-const viewportClass = ui?.viewport ?? 'max-h-56 overflow-y-auto p-0.5'--const filteredOptions = computed(() => {- const query = modelValue.value.trim().toLowerCase()- if (!query) return options.slice(0, 50)- return options- .filter((option) => {- const value = option.value.toLowerCase()- const label = option.label.toLowerCase()- return value.includes(query) || label.includes(query)- })- .slice(0, 50)-})--function updateValue(value: AcceptableValue) {- if (typeof value !== 'string') return- modelValue.value = value-}-</script>--<template>- <ComboboxRoot- v-model:open="open"- :model-value="modelValue"- :ignore-filter="true"- open-on-focus- @update:model-value="updateValue"- >- <ComboboxInput- :model-value="modelValue"- :display-value="() => modelValue"- type="text"- v-bind="$attrs"- :placeholder="placeholder"- :class="inputClass"- autocomplete="off"- autocorrect="off"- autocapitalize="off"- spellcheck="false"- @update:model-value="updateValue"- />-- <ComboboxPortal>- <ComboboxContent- v-if="filteredOptions.length || options.length"- position="popper"- :side-offset="2"- :class="select.content"- >- <ComboboxViewport :class="viewportClass">- <ComboboxItem- v-for="option in filteredOptions"- :key="option.value"- :value="option.value"- :class="select.item"- >- <div class="min-w-0 flex-1">- <div class="truncate text-surface">{{ option.label }}</div>- <div class="truncate font-mono text-[10px] text-muted">{{ option.value }}</div>- </div>- <AppBadge v-if="option.meta">{{ option.meta }}</AppBadge>- </ComboboxItem>- <AppPlaceholder- v-if="filteredOptions.length === 0"- :label="emptyLabel"- :fill="false"- size="compact"- :ui="{ root: ui?.empty }"- />- </ComboboxViewport>- </ComboboxContent>- </ComboboxPortal>- </ComboboxRoot>-</template>diff --git a/src/theme/combobox.ts b/src/theme/combobox.tsnew file mode 100644index 000000000..047389a15--- /dev/null+++ b/src/theme/combobox.ts@@ -0,0 +1,26 @@+import { panelFieldBase } from './panel/field'++const appComboboxTheme = {+ slots: {+ trigger: [panelFieldBase, 'flex w-full min-w-0 items-center justify-between px-2'],+ value: 'min-w-0 flex-1 truncate text-left text-[11px] text-surface',+ chevron: 'ml-1 size-3 shrink-0 text-muted',+ content:+ 'z-[110] max-h-72 min-w-[var(--reka-combobox-trigger-width)] overflow-hidden rounded-md bg-panel text-[11px] shadow-[0_8px_30px_rgb(0_0_0/0.4)]',+ search: 'relative m-1 flex h-7 items-center rounded-md border border-border bg-input',+ input:+ 'h-full min-w-0 flex-1 bg-transparent pr-2 pl-7 text-[11px] text-surface outline-none placeholder:text-muted',+ searchIcon: 'pointer-events-none absolute left-2 size-3 text-muted',+ viewport: 'max-h-64 overflow-y-auto p-0.5',+ empty: 'px-2 py-4 text-center text-[11px] text-muted',+ groupLabel:+ 'sticky top-0 z-10 bg-panel px-2 py-1 text-[9px] font-medium uppercase tracking-wide text-muted',+ item: 'relative flex min-h-8 cursor-pointer items-center gap-2 rounded py-1 pr-2 pl-6 text-surface outline-none select-none data-[disabled]:pointer-events-none data-[highlighted]:bg-hover data-[disabled]:opacity-50',+ indicator: 'absolute left-1.5 inline-flex items-center justify-center',+ description: 'truncate font-mono text-[9px] text-muted',+ meta: 'shrink-0 rounded bg-accent/10 px-1 py-px text-[9px] text-accent'+ }+}++export type AppComboboxTheme = typeof appComboboxTheme+export default appComboboxThemediff --git a/tests/engine/app/ai/catalog.test.ts b/tests/engine/app/ai/catalog.test.tsindex 8eee2e622..6946490dd 100644--- a/tests/engine/app/ai/catalog.test.ts+++ b/tests/engine/app/ai/catalog.test.ts@@ -1,6 +1,10 @@import { afterEach, describe, expect, test } from 'bun:test'-import { resetModelsDevCatalogForTests, resolveModelsDevModel } from '@/app/ai/models/catalog'+import {+ listCatalogModels,+ resetModelsDevCatalogForTests,+ resolveModelsDevModel+} from '@/app/ai/models/catalog'function catalogResponse(body: unknown): typeof fetch {return (async () => new Response(JSON.stringify(body), { status: 200 })) as typeof fetch@@ -31,10 +35,67 @@ describe('models.dev catalog', () => {id: 'claude-sonnet-4-6-20260301',name: 'Claude Sonnet 4.6',capabilities: ['tools', 'vision'],- recommendedMaxOutputTokens: 64_000+ recommendedMaxOutputTokens: 64_000,+ status: 'active'})})+ test('lists compatible models with curated recommendations first and latest models next', async () => {+ const models = await listCatalogModels(+ 'openai',+ catalogResponse({+ openai: {+ models: {+ 'gpt-5.6': {+ name: 'GPT-5.6 from catalog',+ tool_call: true,+ attachment: true,+ release_date: '2026-07-09',+ modalities: { output: ['text'] },+ limit: { output: 128_000 }+ },+ 'gpt-6-preview': {+ name: 'GPT-6 Preview',+ tool_call: true,+ release_date: '2026-09-01',+ modalities: { output: ['text'] }+ },+ 'gpt-image': {+ name: 'GPT Image',+ tool_call: false,+ release_date: '2026-09-02',+ modalities: { output: ['image'] }+ },+ legacy: {+ name: 'Legacy',+ tool_call: true,+ status: 'deprecated',+ release_date: '2025-01-01'+ }+ }+ }+ })+ )++ expect(models[0]).toMatchObject({+ id: 'gpt-5.6',+ name: 'GPT-5.6',+ tag: 'Best',+ capabilities: ['tools', 'vision'],+ releaseDate: '2026-07-09'+ })+ expect(models.findIndex((model) => model.id === 'gpt-6-preview')).toBeGreaterThan(0)+ expect(models.some((model) => model.id === 'gpt-image')).toBeFalse()+ expect(models.some((model) => model.id === 'legacy')).toBeFalse()+ })++ test('falls back to curated models when the catalog request fails', async () => {+ const failingFetch = (async () => new Response(null, { status: 503 })) as typeof fetch+ const models = await listCatalogModels('anthropic', failingFetch)++ expect(models[0]).toMatchObject({ id: 'claude-sonnet-5', tag: 'Best for design' })+ })+test('returns null when the provider or model is unknown', async () => {expect(await resolveModelsDevModel('openai-compatible', 'local', catalogResponse({}))