The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(desktop): split look-alike model picker rows with a -flash variant tag (#118083)
Brooklyn Nicholson212d1d6fba5f
diff --git a/apps/desktop/src/app/shell/model-catalog-menu.search-fold.test.tsx b/apps/desktop/src/app/shell/model-catalog-menu.search-fold.test.tsxindex d44db50b8b0..1b83f7cf98e 100644--- a/apps/desktop/src/app/shell/model-catalog-menu.search-fold.test.tsx+++ b/apps/desktop/src/app/shell/model-catalog-menu.search-fold.test.tsx@@ -61,16 +61,21 @@ function renderMenu() {it('matches and highlights separator-equivalent queries without revealing unrelated models', async () => {renderMenu()- await screen.findByText(/Qwen3\.8 Flash/i)+ await screen.findByText('Qwen3.8')- for (const [query, marked] of [- ['qwen3.8-flash', 'Qwen3.8 Flash'],- ['qwen3 8', 'Qwen3.8']- ]) {- fireEvent.change(screen.getByRole('textbox', { name: 'Search models' }), { target: { value: query } })- await vi.waitFor(() => {- expect(screen.getByText(marked, { selector: 'mark' })).not.toBeNull()- expect(screen.queryByText(/GPT-5\.1/i)).toBeNull()- })- }+ // The `-flash` suffix renders as the row's variant tag, so an id-style+ // query still finds the row through the id fold even though the label no+ // longer spells the word — nothing is marked, the row stays visible.+ fireEvent.change(screen.getByRole('textbox', { name: 'Search models' }), { target: { value: 'qwen3.8-flash' } })+ await vi.waitFor(() => {+ expect(screen.getByText('Qwen3.8')).toBeDefined()+ expect(screen.queryByText(/GPT-5\.1/i)).toBeNull()+ })++ // A separator-folded query highlights the name span itself.+ fireEvent.change(screen.getByRole('textbox', { name: 'Search models' }), { target: { value: 'qwen3 8' } })+ await vi.waitFor(() => {+ expect(screen.getByText('Qwen3.8', { selector: 'mark' })).not.toBeNull()+ expect(screen.queryByText(/GPT-5\.1/i)).toBeNull()+ })})diff --git a/apps/desktop/src/app/shell/model-catalog-menu.test.tsx b/apps/desktop/src/app/shell/model-catalog-menu.test.tsxindex a6545a26043..407a1fb7646 100644--- a/apps/desktop/src/app/shell/model-catalog-menu.test.tsx+++ b/apps/desktop/src/app/shell/model-catalog-menu.test.tsx@@ -86,14 +86,14 @@ describe('the current row effort', () => {$defaultReasoningEffort.set('ultra')renderMenu({ effortPending: true, model: 'gemini-2.5-flash', provider: 'google' })- const row = (await screen.findByText(/Gemini 2\.5 Flash/i)).closest('[role="menuitem"]')!+ const row = (await screen.findByText('Gemini 2.5')).closest('[role="menuitem"]')!expect(row.textContent).not.toContain('Ultra')cleanup()renderMenu({ model: 'gemini-2.5-flash', provider: 'google' })- const settled = (await screen.findByText(/Gemini 2\.5 Flash/i)).closest('[role="menuitem"]')!+ const settled = (await screen.findByText('Gemini 2.5')).closest('[role="menuitem"]')!expect(settled.textContent).toContain('Ultra')})@@ -180,7 +180,7 @@ describe('the catalog owns model curation', () => {renderMenu()- await screen.findByText(/Gemini 2\.5 Flash/i)+ await screen.findByText('Gemini 2.5')expect(screen.queryByText(/Gemini 3\.1 Pro/i)).toBeNull()})@@ -188,7 +188,7 @@ describe('the catalog owns model curation', () => {setVisibleModels(new Set([modelVisibilityKey('google', 'gemini-2.5-flash')]))renderMenu()- await screen.findByText(/Gemini 2\.5 Flash/i)+ await screen.findByText('Gemini 2.5')const input = screen.getByRole('textbox', { name: 'Search models' })diff --git a/apps/desktop/src/lib/model-status-label.test.ts b/apps/desktop/src/lib/model-status-label.test.tsindex d995a471bc2..a299a7d7597 100644--- a/apps/desktop/src/lib/model-status-label.test.ts+++ b/apps/desktop/src/lib/model-status-label.test.ts@@ -1,6 +1,12 @@import { describe, expect, it } from 'vitest'-import { currentPickerSelection, displayModelName, formatModelPillLabel, modelDisplayParts } from './model-status-label'+import {+ currentPickerSelection,+ displayModelName,+ formatModelPillLabel,+ modelDisplayParts,+ modelVariantTag+} from './model-status-label'describe('model-status-label', () => {it('strips trailing date-pin snapshots and dots hyphenated Anthropic versions', () => {@@ -53,11 +59,17 @@ describe('model-status-label', () => {expect(displayModelName('google/gemini-2.5-flash-lite')).toBe('Gemini 2.5 Flash Lite')})- it('keeps the model pill to name + Fast; the effort lives on its own pill', () => {- expect(formatModelPillLabel('openai/gpt-5.5', { fastMode: true })).toBe('GPT-5.5 · Fast')- expect(formatModelPillLabel('anthropic/claude-opus-4.8-fast')).toBe('Opus 4.8 Fast')- expect(formatModelPillLabel('openai/gpt-5.5')).toBe('GPT-5.5')- expect(formatModelPillLabel('')).toBe('No model')+ it('distinguishes the deepseek-flash alias from its deepseek-v4.1-flash sibling (#118083)', () => {+ // models.dev carries both ids for the provider: `deepseek-flash` (alias)+ // and `deepseek-v4.1-flash` (full id). Two distinct ids must never render+ // as near-identical tagless rows the user reads as one model listed twice.+ // The `-flash` variant tag splits the pair the same way `-fast` splits+ // `…-4.8` vs `…-4.8-fast`, and the vendor casing closes the gap that made+ // the alias read "DeepSeek" while its sibling read "Deepseek".+ expect(modelDisplayParts('deepseek-flash')).toEqual({ name: 'DeepSeek', tag: 'Flash' })+ expect(modelDisplayParts('deepseek-v4.1-flash')).toEqual({ name: 'DeepSeek V4.1', tag: 'Flash' })+ // Non-flash siblings stay tagless and distinct from their flash variant.+ expect(modelDisplayParts('deepseek-v4.1')).toEqual({ name: 'DeepSeek V4.1', tag: '' })})it('keeps the variant tag in the display name so distinct ids never collapse (#88597)', () => {@@ -72,6 +84,46 @@ describe('model-status-label', () => {expect(displayModelName('claude-sonnet-5[1m]')).toBe('Sonnet 5 1M')})+ it('keeps the model pill to name + Fast; the effort lives on its own pill', () => {+ expect(formatModelPillLabel('openai/gpt-5.5', { fastMode: true })).toBe('GPT-5.5 · Fast')+ expect(formatModelPillLabel('anthropic/claude-opus-4.8-fast')).toBe('Opus 4.8 · Fast')+ expect(formatModelPillLabel('openai/gpt-5.5')).toBe('GPT-5.5')+ expect(formatModelPillLabel('')).toBe('No model')+ })++ it('rides the same variant tags on the pill as the catalog rows (#118083)', () => {+ // A `-flash` id must render its tag on the composer pill too: without it,+ // `gemini-2.5-flash` and `gemini-2.5` produce identical pill text, so a+ // model switch reads as a no-op — the exact look-alike collapse the+ // catalog-row split exists to prevent, one screen over.+ expect(formatModelPillLabel('gemini-2.5-flash')).toBe('Gemini 2.5 · Flash')+ expect(formatModelPillLabel('deepseek-v4.1-flash')).toBe('DeepSeek V4.1 · Flash')+ expect(formatModelPillLabel('qwen3.8-flash')).toBe('Qwen3.8 · Flash')+ // The bare models stay tagless — and distinct from their flash variants.+ expect(formatModelPillLabel('gemini-2.5')).toBe('Gemini 2.5')+ expect(formatModelPillLabel('deepseek-v4.1')).toBe('DeepSeek V4.1')+ })++ it('agrees with the catalog rows on the variant for local ids that carry both a variant and a quant', () => {+ // A local GGUF id can carry the variant and the quant in either order —+ // `…-flash-Q4_K_XL` and `…-Q4_K_XL-flash` are the same model. The row+ // used to split only on whichever suffix it saw first (quant soup in the+ // name for one order, no variant tag for the other), while the pill+ // re-derived the variant from the raw id, so the two screens disagreed+ // (#118083 review).+ expect(modelVariantTag('Qwen3.6-27B-flash-Q4_K_XL')).toBe('Flash')+ expect(modelVariantTag('Qwen3.6-27B-Q4_K_XL-flash')).toBe('Flash')+ // Both orders decompose identically: clean name, variant + quant tag.+ expect(modelDisplayParts('Qwen3.6-27B-flash-Q4_K_XL')).toEqual({ name: 'Qwen3.6 27B', tag: 'Flash Q4' })+ expect(modelDisplayParts('Qwen3.6-27B-Q4_K_XL-flash')).toEqual({ name: 'Qwen3.6 27B', tag: 'Flash Q4' })+ // The pill rides the variant and keeps the quant as picker-row detail.+ expect(formatModelPillLabel('Qwen3.6-27B-flash-Q4_K_XL')).toBe('Qwen3.6 27B · Flash')+ expect(formatModelPillLabel('Qwen3.6-27B-Q4_K_XL-flash')).toBe('Qwen3.6 27B · Flash')+ // Quant-only ids are unchanged: quant stays off the pill.+ expect(modelDisplayParts('Qwen3.6-27B-Q8_0')).toEqual({ name: 'Qwen3.6 27B', tag: 'Q8' })+ expect(formatModelPillLabel('Qwen3.6-27B-Q8_0')).toBe('Qwen3.6 27B')+ })+describe('currentPickerSelection', () => {const store = { model: 'opus', provider: 'anthropic' }const options = { model: 'hermes-4', provider: 'nous' }diff --git a/apps/desktop/src/lib/model-status-label.ts b/apps/desktop/src/lib/model-status-label.tsindex 8c3b3698112..80dbcce5229 100644--- a/apps/desktop/src/lib/model-status-label.ts+++ b/apps/desktop/src/lib/model-status-label.ts@@ -32,9 +32,9 @@ export function currentPickerSelection(}/** Canonical provider labels shared by onboarding and the model pill. OAuth- * provider ids stay distinct from their direct-API counterparts so a session on- * `xai-oauth` never reads as the plain `xai` key path, and internal route names- * never reach user-facing copy. */+ * provider ids stay distinct from their direct-API counterparts so a session on+ * `xai-oauth` never reads as the plain `xai` key path, and internal route names+ * never reach user-facing copy. */export const PROVIDER_DISPLAY_NAMES: Readonly<Record<string, string>> = {anthropic: 'Anthropic Account','claude-code': 'Anthropic OAuth: Required Extra Usage Credits to Use Subscription',@@ -62,9 +62,12 @@ export function modelBaseId(model: string): string {// Trailing model-id variants that should render as a grayed tag beside the// name (e.g. "Opus 4.8" + "Fast") rather than collapsing two distinct ids to-// the same display name.+// the same display name. `-flash` splits look-alike pairs the same way+// (#118083): models.dev carries both `deepseek-flash` (alias) and+// `deepseek-v4.1-flash` (full id) for the provider.const VARIANT_TAGS: ReadonlyArray<readonly [RegExp, string]> = [[/-fast$/i, 'Fast'],+ [/-flash$/i, 'Flash'],[/-thinking$/i, 'Thinking'],[/-preview$/i, 'Preview'],[/-latest$/i, 'Latest']@@ -107,10 +110,6 @@ const applyVendorCasing = (text: string): string => {}function prettifyBase(base: string): string {- if (/^deepseek-flash$/i.test(base)) {- return 'DeepSeek V4.1 Flash'- }-if (/^claude-/i.test(base)) {// Anthropic ids spell the version with hyphens (`haiku-4-5`, `fable-5-1`);// the human name is dotted ("Haiku 4.5"), not "Haiku 4 5".@@ -137,49 +136,67 @@ function prettifyBase(base: string): string {return applyVendorCasing(titleCase(base.replace(/-/g, ' ')))}-/** Split a model id into a clean display name plus an optional grayed variant- * tag, so distinct ids (e.g. `…-4.8` vs `…-4.8-fast`) don't collapse. */-export function modelDisplayParts(model: string): { name: string; tag: string } {- let base = modelBaseId(model)- let tag = ''-- // Local GGUF ids carry a quant suffix (`…-UD-Q4_K_XL`, `…-Q8_0`). Render it- // as a quiet tag — "Qwen3.6 27B · Q4" — never as part of the name. Without- // this the composer pill reads raw quant soup ("Qwen3.6 27B UD Q4 K XL").- const quant = base.match(/-(?:UD-)?(Q\d(?:_[A-Z0-9]+)*|IQ\d(?:_[A-Z0-9]+)*|F16|BF16)$/i)-- if (quant) {- tag = quant[1].split('_')[0].toUpperCase()- base = base.slice(0, -quant[0].length)- // Instruct/chat markers are noise once the quant confirmed a local build.- base = base.replace(/-(?:Instruct|Chat)(?:-\d{4})?$/i, '')- }+// Split the trailing suffixes a local id can carry — a variant tag+// (`…-flash`, `…-fast`) and a GGUF quant (`…-UD-Q4_K_XL`, `…-Q8_0`) — in+// EITHER order: `…-flash-Q4_K_XL` and `…-Q4_K_XL-flash` are the same model.+// One decomposition feeds both the catalog rows and the composer pill, so+// the two screens can never disagree on which variant an id carries.+function splitTrailingTags(base: string): { base: string; variant: string; quant: string } {+ let variant = ''+ let quant = ''++ for (let progress = true; progress;) {+ progress = false++ if (!variant) {+ for (const [pattern, label] of VARIANT_TAGS) {+ if (pattern.test(base)) {+ variant = label+ base = base.replace(pattern, '')+ progress = true++ break+ }+ }+ }- if (!tag) {- for (const [pattern, label] of VARIANT_TAGS) {- if (pattern.test(base)) {- tag = label- base = base.replace(pattern, '')+ if (!quant) {+ const quantMatch = base.match(/-(?:UD-)?(Q\d(?:_[A-Z0-9]+)*|IQ\d(?:_[A-Z0-9]+)*|F16|BF16)$/i)- break+ if (quantMatch) {+ quant = quantMatch[1].split('_')[0].toUpperCase()+ base = base.slice(0, -quantMatch[0].length)+ // Instruct/chat markers are noise once the quant confirmed a local build.+ base = base.replace(/-(?:Instruct|Chat)(?:-\d{4})?$/i, '')+ progress = true}}}+ return { base, variant, quant }+}++/** Split a model id into a clean display name plus an optional grayed variant+ * tag, so distinct ids (e.g. `…-4.8` vs `…-4.8-fast`) don't collapse. */+export function modelDisplayParts(model: string): { name: string; tag: string } {+ let { base, variant, quant } = splitTrailingTags(modelBaseId(model))++ const tags = [variant, quant].filter(Boolean)+// Anthropic's `[1m]` route suffix selects the 1M-context window. It is a// variant of the same model, so it renders as a tag ("Sonnet 5 · 1M") rather// than raw brackets that read like an ANSI escape ("Sonnet 5[1m]").const contextWindow = base.match(/\[(\d+[mk])\]$/i)if (contextWindow) {- tag = tag ? `${tag} ${contextWindow[1].toUpperCase()}` : contextWindow[1].toUpperCase()+ tags.push(contextWindow[1].toUpperCase())base = base.slice(0, -contextWindow[0].length)}// Drop a trailing date-pin (`…-20251101`) — snapshot noise, not a name.base = base.replace(/-\d{8}$/, '')- return { name: prettifyBase(base) || model.trim() || 'No model', tag }+ return { name: prettifyBase(base) || model.trim() || 'No model', tag: tags.join(' ') }}/** Friendly one-line model name for menus and the status bar. The variant@@ -191,19 +208,27 @@ export function displayModelName(model: string): string {return tag ? `${name} ${tag}` : name}-/** Composer model-pill label — model name plus Fast when it applies. The- * reasoning level is NOT here: it has its own pill (`ReasoningPill`), so a- * long model name can no longer push the effort out of the truncating span. */+/** The variant tag a model id carries (Fast, Flash, Thinking, Preview,+ * Latest) — the one taxonomy both the catalog rows and the composer pill+ * split on, so distinct ids never render as one model listed twice.+ * Quant and context-window tags stay picker-row detail. Derived from the+ * same suffix split as `modelDisplayParts`, so a quant-bearing local id+ * (`…-flash-Q4_K_XL`, `…-Q4_K_XL-flash`) reports the same variant on the+ * pill as the catalog row shows. */+export function modelVariantTag(model: string): string {+ return splitTrailingTags(modelBaseId(model)).variant+}++/** Composer model-pill label — model name plus its variant tag (Fast, Flash,+ * …) when one applies, separated by a `·` so the pill reads as+ * "name · variant" at a glance. The reasoning level is NOT here: it has its+ * own pill (`ReasoningPill`), so a long model name can no longer push the+ * effort out of the truncating span. Fast shows when the speed=fast param is+ * on OR the active model is a `…-fast` variant — never both. */export function formatModelPillLabel(model: string, options?: { fastMode?: boolean }): string {- const label = displayModelName(model)-- // Fast is shown when the speed=fast param is on (options.fastMode) OR the- // active model is a `…-fast` variant (fast via a separate model id). The- // variant's tag already reads Fast in the label above, so only the- // param-driven case appends it — never both (#88597).- if (model.trim() && options?.fastMode && !/-fast$/i.test(modelBaseId(model))) {- return `${label} · Fast`- }+ const name = modelDisplayParts(model).name++ const tag = model.trim() ? (options?.fastMode ? 'Fast' : modelVariantTag(model)) : ''- return label+ return tag ? `${name} · ${tag}` : name}