The all-in-one local AI studio for your desktop: chat, image and video generation and a coding agent in one free, open source app. Windows and Linux. No Docker, no terminal, no cloud required.
TypeScript agentai-chatai-studioall-in-onecoding-agentdesktop-appfluximage-generationlinuxllmlocal-ailocal-llmopen-sourceprivacyself-hostedstable-diffusionuncensoreduncensored-aivideo-generationwindows
feat(models): new model picker in Cloud mode for Chat, Agent and Code
purplefb58109b016b
diff --git a/e2e/cloud-chat-waits-for-a-model.spec.ts b/e2e/cloud-chat-waits-for-a-model.spec.tsindex 51b07028..e9006f47 100644--- a/e2e/cloud-chat-waits-for-a-model.spec.ts+++ b/e2e/cloud-chat-waits-for-a-model.spec.ts@@ -23,7 +23,7 @@ import { routeCloud, seedOnboardingDone, signInViaGate, cloudSwitch } from './suconst TEXT = 'a message that waits for its model'const NOTE = { name: 'notes.txt', mimeType: 'text/plain', buffer: Buffer.from('the attachment stays too') }-const HINT = 'Pick a model to send your message. Your text and attachments are kept.'+const HINT = 'Choose a model to send your message. Your text and attachments are kept.'const REPLY = 'Cloud answer on the named model.'const CORS = { 'access-control-allow-origin': '*', 'access-control-allow-headers': 'authorization, content-type' }diff --git a/e2e/cloud-model-picker-search-and-tags.spec.ts b/e2e/cloud-model-picker-search-and-tags.spec.tsnew file mode 100644index 00000000..ba7bc1f3--- /dev/null+++ b/e2e/cloud-model-picker-search-and-tags.spec.ts@@ -0,0 +1,235 @@+import { test, expect, type Page } from '@playwright/test'+import { tauriMockInit, DEFAULT_ASSISTANT_REPLY, DEFAULT_MODEL_NAME, type TauriMockOptions } from './support/tauri-mock'+import { routeCloud, seedOnboardingDone, signInViaGate, cloudSwitch } from './support/cloud-mock'+import { MOCK_CHAT_CATALOGUE, mockModelsAnswer } from './support/chat-catalogue'++/**+ * The model picker in Cloud mode since 3.0.5, in the running app.+ *+ * David, 05.10.2026: grouped by family, a search on top, chips that narrow the+ * list, a keyboard that works from the search field, and per row a tiny+ * question mark that opens the model's credit rates per one million tokens.+ * And the lesson of GitHub #149: the app is zoomed by 1.15, and a menu that+ * does its own sums ends up outside the window. So the menu and the rate+ * popover are measured here in a real layout, in a large and in small windows.+ *+ * Run: CI=1 LU_E2E_PORT=5311 npx playwright test e2e/cloud-model-picker-search-and-tags.spec.ts+ */++const OPTS: TauriMockOptions = {+ assistantReply: DEFAULT_ASSISTANT_REPLY,+ modelName: DEFAULT_MODEL_NAME,+ platform: 'windows',+}+const TOTAL = MOCK_CHAT_CATALOGUE.length+const MARKED = MOCK_CHAT_CATALOGUE.filter((m) => m.unfiltered === 'full').length++const trigger = (page: Page) => page.getByRole('button', { name: 'Select chat model', exact: true })+const menu = (page: Page) => page.getByTestId('model-picker-menu')+const search = (page: Page) => page.getByTestId('model-picker-search')+const rows = (page: Page) => menu(page).getByRole('option')+const count = (page: Page) => page.getByTestId('model-picker-count')+const cursorName = (page: Page) => menu(page).locator('[role="option"][data-cursor="true"] .lu-picker-name')++async function bootIntoCloud(page: Page) {+ await page.addInitScript(tauriMockInit, OPTS)+ await seedOnboardingDone(page)+ await routeCloud(page, { license: 'active', access: true, mediaLive: true, paidPlan: true })+ await page.route('**/api/inference/v1/models', (route) =>+ route.fulfill({ status: 200, contentType: 'application/json', body: JSON.stringify(mockModelsAnswer()) }))+ await page.goto('/')+ await expect(cloudSwitch(page)).toBeVisible({ timeout: 20_000 })+ await signInViaGate(page)+ await expect(cloudSwitch(page)).toBeChecked({ timeout: 20_000 })+ await expect(trigger(page)).toContainText('Choose a model')+}++async function openPicker(page: Page) {+ await trigger(page).click()+ await expect(menu(page)).toBeVisible()+ // The open animation scales the menu; measure and click once it has settled.+ await expect.poll(() => menu(page).evaluate((el) => getComputedStyle(el).opacity)).toBe('1')+ await expect(rows(page)).toHaveCount(TOTAL)+}++/** A box completely inside the window, in visible pixels. */+async function expectInsideWindow(page: Page, testId: string) {+ const m = await page.getByTestId(testId).evaluate((el) => {+ const r = el.getBoundingClientRect()+ return { top: r.top, bottom: r.bottom, left: r.left, right: r.right, w: window.innerWidth, h: window.innerHeight }+ })+ expect(m.top, `${testId} starts above the window`).toBeGreaterThanOrEqual(0)+ expect(m.left, `${testId} starts left of the window`).toBeGreaterThanOrEqual(0)+ expect(m.bottom, `${testId} runs ${Math.round(m.bottom - m.h)} px below the window`).toBeLessThanOrEqual(m.h)+ expect(m.right, `${testId} runs ${Math.round(m.right - m.w)} px past the right edge`).toBeLessThanOrEqual(m.w)+ return m+}++test('open, search, narrow by a tag, pick with the keyboard', async ({ page }) => {+ await bootIntoCloud(page)+ await openPicker(page)++ // The whole catalogue under one-line family heads, the search has the keyboard.+ await expect(menu(page)).toHaveAttribute('data-picker', 'cloud')+ await expect(count(page)).toHaveText(`${TOTAL} cloud models`)+ await expect(menu(page).locator('.lu-picker-head b').first()).toHaveText('Qwen')+ await expect(menu(page).locator('.lu-picker-head b').last()).toHaveText('Other')+ await expect(search(page)).toBeFocused()+ await expect(page.getByTestId('picker-choose-a-model')).toHaveText('Choose a model to send your message.')++ // A head is one line and stays at the top of the list while its rows scroll.+ const head = menu(page).locator('[data-family="Qwen"]')+ const list = menu(page).getByRole('listbox')+ const before = await head.boundingBox()+ await list.evaluate((el) => { el.scrollTop = 120 })+ const after = await head.boundingBox()+ expect(Math.abs(after!.y - before!.y), 'the head sticks while the list scrolls').toBeLessThanOrEqual(1)+ expect(before!.height).toBeLessThanOrEqual(22 * 1.15 + 1)+ await list.evaluate((el) => { el.scrollTop = 0 })++ // Typing narrows, the heads give way to a hit list, the hit is underlined.+ await page.keyboard.type('qwen 3.6')+ await expect(rows(page)).toHaveCount(2)+ await expect(menu(page).locator('.lu-picker-head')).toHaveCount(0)+ await expect(count(page)).toHaveText(`2 of ${TOTAL}`)+ await expect(rows(page).first().locator('mark').first()).toHaveText('Qwen')++ // Escape empties the search first, the menu stays.+ await page.keyboard.press('Escape')+ await expect(search(page)).toHaveValue('')+ await expect(menu(page)).toBeVisible()+ await expect(rows(page)).toHaveCount(TOTAL)++ // A tag narrows to the measured models, a second one narrows further.+ const marked = menu(page).locator('[data-chip="marked"]')+ await expect(marked).toHaveText(`No refusals ${MARKED}`)+ await marked.click()+ await expect(marked).toHaveAttribute('aria-pressed', 'true')+ await expect(rows(page)).toHaveCount(MARKED)+ await expect(menu(page).locator('[role="option"] [data-mark="unfiltered"]')).toHaveCount(MARKED)+ await menu(page).locator('[data-chip="vision"]').click()+ const both = MOCK_CHAT_CATALOGUE.filter((m) => m.unfiltered === 'full' && m.vision).length+ await expect(rows(page)).toHaveCount(both)+ await menu(page).locator('[data-chip="vision"]').click()+ await marked.click()+ await expect(rows(page)).toHaveCount(TOTAL)++ // Nothing that matches is said in words.+ await search(page).fill('no such model')+ await expect(page.getByTestId('model-picker-no-match')).toHaveText('No models match. Clear the search or a tag.')+ await search(page).fill('')++ // The keyboard: arrows move the cursor from the search field, Enter picks.+ await search(page).fill('deepseek')+ await expect(cursorName(page)).toHaveText('DeepSeek V3.2')+ await page.keyboard.press('ArrowDown')+ const second = await cursorName(page).innerText()+ expect(second).not.toBe('DeepSeek V3.2')+ await page.keyboard.press('Enter')+ await expect(menu(page)).toHaveCount(0)+ await expect(trigger(page)).toContainText(second)++ // Reopened, the picked row is the selected one and the hint is gone.+ await openPicker(page)+ await expect(menu(page).locator('[role="option"][aria-selected="true"] .lu-picker-name')).toHaveText(second)+ await expect(page.getByTestId('picker-choose-a-model')).toHaveCount(0)+ // Escape with an empty search closes, and the trigger has the keyboard back.+ await page.keyboard.press('Escape')+ await expect(menu(page)).toHaveCount(0)+ await expect(trigger(page)).toBeFocused()+})++test('a click on a row picks that model', async ({ page }) => {+ await bootIntoCloud(page)+ await openPicker(page)+ await menu(page).getByRole('button', { name: /Qwen 3\.6 27B/ }).click()+ await expect(menu(page)).toHaveCount(0)+ await expect(trigger(page)).toContainText('Qwen 3.6 27B')+})++test('the question mark shows credit rates per one million tokens, and never money', async ({ page }) => {+ await bootIntoCloud(page)+ await openPicker(page)++ const row = rows(page).filter({ hasText: 'Qwen 3.6 27B' })+ const model = MOCK_CHAT_CATALOGUE.find((m) => m.label === 'Qwen 3.6 27B')!+ await row.getByRole('button', { name: 'Credit rates' }).click()+ const pop = page.getByTestId('model-rate-popover')+ await expect(pop).toBeVisible()+ await expect(pop.locator('h4')).toHaveText('Credits per 1M tokens')+ await expect(pop.locator('[data-rate="input"]')).toHaveText(model.rates![0].toLocaleString('en-US'))+ await expect(pop.locator('[data-rate="output"]')).toHaveText(model.rates![1].toLocaleString('en-US'))+ expect(await pop.innerText()).not.toMatch(/[$€£]|usd|eur|dollar|price|cost/i)+ await expectInsideWindow(page, 'model-rate-popover')+ // It hangs on its question mark, a few pixels away and not a hand's width.+ const gap = await page.evaluate(() => {+ const p = document.querySelector('[data-testid="model-rate-popover"]')!.getBoundingClientRect()+ const b = document.querySelector('.lu-picker-rate-btn[aria-expanded="true"]')!.getBoundingClientRect()+ const vertical = p.top >= b.bottom ? p.top - b.bottom : b.top - p.bottom+ return { vertical, right: Math.abs(p.right - b.right) }+ })+ expect(gap.vertical).toBeGreaterThanOrEqual(0)+ expect(gap.vertical).toBeLessThanOrEqual(8)+ expect(gap.right).toBeLessThanOrEqual(2)+ // The menu is still open and nothing was picked.+ await expect(menu(page)).toBeVisible()+ await expect(trigger(page)).toContainText('Choose a model')+ await page.keyboard.press('Escape')+ await expect(pop).toHaveCount(0)+ await expect(menu(page)).toBeVisible()++ // Focus plus Enter opens it too.+ await row.getByRole('button', { name: 'Credit rates' }).focus()+ await page.keyboard.press('Enter')+ await expect(pop).toBeVisible()+ await expect(trigger(page)).toContainText('Choose a model')+ await page.keyboard.press('Escape')++ // A Flash model on a paid plan draws nothing, and says so there.+ const flash = MOCK_CHAT_CATALOGUE.find((m) => m.flash)!+ await rows(page).filter({ hasText: flash.label }).first().getByRole('button', { name: 'Credit rates' }).click()+ await expect(pop).toHaveText('No credits on your plan, up to 2,000,000 tokens per day.')+ await page.keyboard.press('Escape')++ // The server sent no rates for this one: no question mark, nothing invented.+ const bare = rows(page).filter({ hasText: 'Kimi K3' })+ await expect(bare).toHaveCount(1)+ await expect(bare.getByRole('button', { name: 'Credit rates' })).toHaveCount(0)+ await expect(bare.locator('[data-context]')).toHaveText('')+})++for (const size of [+ { width: 1280, height: 800 },+ { width: 900, height: 420 },+ { width: 560, height: 520 },+ { width: 640, height: 400 },+]) {+ test(`the menu and its rate popover stay inside a ${size.width} x ${size.height} window`, async ({ page }) => {+ await page.setViewportSize(size)+ await bootIntoCloud(page)+ await openPicker(page)+ const m = await expectInsideWindow(page, 'model-picker-menu')+ // On its trigger: a few pixels of gap, above or below.+ const t = await trigger(page).boundingBox()+ const gap = m.bottom <= t!.y + 1 ? t!.y - m.bottom : m.top - (t!.y + t!.height)+ expect(gap, 'gap between trigger and menu').toBeGreaterThanOrEqual(0)+ expect(gap, 'gap between trigger and menu').toBeLessThanOrEqual(10)+ // Head and foot are always there, the list between them scrolls.+ await expect(search(page)).toBeInViewport()+ await expect(count(page)).toBeInViewport()+ // The last model of the catalogue can be reached and picked.+ const last = rows(page).last()+ await last.scrollIntoViewIfNeeded()+ await expectInsideWindow(page, 'model-picker-menu')+ const rate = last.getByRole('button', { name: 'Credit rates' })+ if (await rate.count()) {+ await rate.click()+ await expectInsideWindow(page, 'model-rate-popover')+ await page.keyboard.press('Escape')+ }+ const name = await last.locator('.lu-picker-name').innerText()+ await last.locator('.lu-picker-pick').click()+ await expect(menu(page)).toHaveCount(0)+ await expect(trigger(page)).toContainText(name.slice(0, 8))+ })+}diff --git a/e2e/cloud-model-picker.spec.ts b/e2e/cloud-model-picker.spec.tsindex 6cf271c3..69e1618c 100644--- a/e2e/cloud-model-picker.spec.ts+++ b/e2e/cloud-model-picker.spec.ts@@ -91,22 +91,24 @@ test('production says every catalogue model can call tools', () => {expect([...flags.values()].every((v) => v === true)).toBe(true)})-test('the chat picker marks the unrestricted models as tool capable', async ({ page }) => {+test('the chat picker offers the unrestricted models without a chat-only tag', async ({ page }) => {test.skip(!enabled, 'needs the live catalogue')await bootIntoCloud(page)await openPicker(page)- // One row per unrestricted model, each carrying the wrench the app uses for- // "this one runs Agent and Code", not the ban marker.+ // One row per unrestricted model. Since the picker of 3.0.5 a row shows the+ // exception and not the normal case: a model that can call tools carries no+ // sign for it, and only one that cannot is tagged "Chat only".+ const menu = page.getByTestId('model-picker-menu')for (const id of UNRESTRICTED) {const label = (liveCatalogue.data.find((m) => m.id === id)?.name as string) ?? id- const row = page.getByRole('button', { name: label, exact: false }).filter({ hasText: label })+ const row = menu.getByRole('option').filter({ hasText: label })await row.first().scrollIntoViewIfNeeded()await expect(row.first(), `${label} is offered`).toBeVisible({ timeout: 15_000 })await expect(- row.first().locator('[title*="Supports tool calling"]'),- `${label} is marked tool capable`,- ).toHaveCount(1)+ row.first().locator('[data-mark="chat-only"]'),+ `${label} is not marked as unable to call tools`,+ ).toHaveCount(0)}expect(await page.locator('[title*="does not support tool calling"]').count()).toBe(0)@@ -125,5 +127,5 @@ test('the code surface offers them too, where they used to be hidden', async ({const label =(liveCatalogue.data.find((m) => m.id === 'Sao10K/L3.1-70B-Euryale-v2.2')?.name as string) ??'Euryale'- await expect(page.locator('div', { hasText: label }).last()).toBeVisible({ timeout: 15_000 })+ await expect(page.getByTestId('model-picker-menu').getByRole('option').filter({ hasText: label }).first()).toBeVisible({ timeout: 15_000 })})diff --git a/e2e/flash-chat-billing.spec.ts b/e2e/flash-chat-billing.spec.tsindex 36b3d689..e7ceb04a 100644--- a/e2e/flash-chat-billing.spec.ts+++ b/e2e/flash-chat-billing.spec.ts@@ -37,18 +37,23 @@ test('flash metadata and paid fallback reach the actual desktop composer', async// The model first, then the chat: in Cloud the app picks no model by// itself (3.0.5), and "New Chat" without one stays on the landing page.await page.getByRole('button', { name: 'Select chat model', exact: true }).click()- const row = page.getByRole('button', { name: /Llama 3.1 8B Turbo/ })+ const menu = page.getByTestId('model-picker-menu')+ const row = menu.getByRole('option').filter({ hasText: 'Llama 3.1 8B Turbo' })// Der Aufdruck der Marke ist zweimal gewandert: "Flash", dann "No credits",// dann "Included". David am 12.09.2026 endgueltig zurueck auf "No credits",// weil "Included" nur sagt, dass etwas dabei ist. Dass die Marke am KONTO- // haengt, traegt die Logik daneben und der Titel, nicht das Etikett. Die- // Zeile selbst ist unveraendert, nur ihr Aufdruck. Sie steht weiterhin in- // der Modellauswahl selbst (`ModelRowMarks`), unabhaengig vom Etikett in- // der Sitzungsleiste.- const marke = row.getByText('No credits', { exact: true })- await expect(marke).toBeVisible()- await expect(marke).toHaveAttribute('title', 'No credits on your plan, up to 50,000 tokens per day.')- await row.click()+ // haengt, traegt die Logik daneben und der Satz dazu, nicht das Etikett.+ //+ // Seit dem Waehler von 3.0.5 steht sie nicht mehr in der Zeile: die Zeile+ // traegt keine Credit-Angabe. "No credits" ist ein Etikett ueber der Liste,+ // das auf diese Modelle einengt, und der Satz mit der Tagesmenge steht+ // hinter dem Fragezeichen der Zeile.+ await expect(row.getByText('No credits', { exact: true })).toHaveCount(0)+ await expect(menu.locator('[data-chip="free"]')).toContainText('No credits')+ await row.getByRole('button', { name: 'Credit rates' }).click()+ await expect(page.getByTestId('model-rate-popover')).toHaveText('No credits on your plan, up to 50,000 tokens per day.')+ await page.keyboard.press('Escape')+ await row.locator('.lu-picker-pick').click()await page.getByRole('button', { name: /New Chat/i }).first().click()// Runde 3 (Abnahme 19.09.2026, Blocker A2): kein Dauerband mehr ueber derdiff --git a/e2e/send-without-a-model-keeps-the-message.spec.ts b/e2e/send-without-a-model-keeps-the-message.spec.tsindex 28aa07cd..a0f36c92 100644--- a/e2e/send-without-a-model-keeps-the-message.spec.ts+++ b/e2e/send-without-a-model-keeps-the-message.spec.ts@@ -21,7 +21,7 @@ import { seedOnboardingDone } from './support/cloud-mock'const SMALL_MODEL = 'Hermes-3-Llama-3.2-3B.Q4_K_M'const TEXT = 'a message that must not get lost'const NOTE = { name: 'notes.txt', mimeType: 'text/plain', buffer: Buffer.from('the attachment stays too') }-const HINT = 'Pick a model to send your message. Your text and attachments are kept.'+const HINT = 'Choose a model to send your message. Your text and attachments are kept.'async function boot(page: Page) {await page.addInitScript(tauriMockInit, { assistantReply: DEFAULT_ASSISTANT_REPLY, modelName: SMALL_MODEL })diff --git a/e2e/support/chat-catalogue.ts b/e2e/support/chat-catalogue.tsnew file mode 100644index 00000000..2c83f830--- /dev/null+++ b/e2e/support/chat-catalogue.ts@@ -0,0 +1,95 @@+/**+ * A hosted chat catalogue for the specs of the Cloud model picker, in the+ * shape the LU Cloud models route answers.+ *+ * The 47 models, their labels, marks, vision, thinking and Flash class follow+ * the web catalogue as of 2026-10-05 (19 models measured "full"). The credit+ * rates are the catalogue prices in credits per one million tokens. The+ * context windows are SAMPLE values for the mock: the app prints whatever the+ * server states and nothing else, which is exactly what the one entry without+ * a window and without rates (Kimi K3, an older server's answer) is here for.+ */+export interface MockChatModel {+ id: string+ label: string+ unfiltered?: 'full' | 'partial'+ flash?: boolean+ vision?: boolean+ think: 'toggle' | 'always' | 'never'+ context?: number+ rates?: [number, number]+}++export const MOCK_CHAT_CATALOGUE: MockChatModel[] = [+ { id: 'meta-llama/Meta-Llama-3.1-8B-Instruct-Turbo', label: 'Llama 3.1 8B Turbo', unfiltered: 'partial', flash: true, think: 'never', context: 131072, rates: [2000, 4000] },+ { id: 'inclusionAI/Ling-3.0-flash', label: 'Ling 3.0 flash', unfiltered: 'partial', flash: true, think: 'toggle', context: 131072, rates: [6000, 18000] },+ { id: 'Qwen/Qwen3-30B-A3B', label: 'Qwen3 30B A3B', unfiltered: 'partial', think: 'toggle', context: 40960, rates: [12000, 50000] },+ { id: 'google/gemma-4-26B-A4B-it', label: 'Gemma 4 26B', unfiltered: 'full', flash: true, vision: true, think: 'toggle', context: 131072, rates: [7000, 34000] },+ { id: 'Qwen/Qwen3.6-35B-A3B', label: 'Qwen 3.6 35B A3B', unfiltered: 'partial', vision: true, think: 'toggle', context: 262144, rates: [10000, 95000] },+ { id: 'zai-org/GLM-5.3-Flash', label: 'GLM 5.3 Flash', unfiltered: 'partial', flash: true, vision: true, think: 'always', context: 1048576, rates: [15000, 50000] },+ { id: 'Sao10K/L3-8B-Lunaris-v1-Turbo', label: 'Lunaris 8B', unfiltered: 'full', think: 'never', context: 131072, rates: [4000, 5000] },+ { id: 'Gryphe/MythoMax-L2-13b', label: 'MythoMax 13B', unfiltered: 'full', think: 'never', context: 4096, rates: [40000, 40000] },+ { id: 'NousResearch/Hermes-3-Llama-3.1-70B', label: 'Hermes 3 70B', unfiltered: 'full', think: 'never', context: 131072, rates: [70000, 70000] },+ { id: 'Sao10K/L3.1-70B-Euryale-v2.2', label: 'Euryale 70B', unfiltered: 'partial', think: 'never', context: 131072, rates: [85000, 85000] },+ { id: 'openai/gpt-oss-120b', label: 'gpt-oss 120B', flash: true, think: 'always', context: 131072, rates: [3700, 17000] },+ { id: 'deepseek-ai/DeepSeek-V3.2', label: 'DeepSeek V3.2', unfiltered: 'full', think: 'toggle', context: 131072, rates: [26000, 38000] },+ { id: 'NousResearch/Hermes-3-Llama-3.1-405B', label: 'Hermes 3 405B', unfiltered: 'full', think: 'never', context: 131072, rates: [100000, 100000] },+ { id: 'Qwen/Qwen3-Coder-480B-A35B-Instruct-Turbo', label: 'Qwen3 Coder 480B', unfiltered: 'partial', think: 'never', context: 131072, rates: [30000, 100000] },+ { id: 'moonshotai/Kimi-K3', label: 'Kimi K3', unfiltered: 'partial', vision: true, think: 'toggle' },+ { id: 'deepseek-ai/DeepSeek-V3.1', label: 'DeepSeek V3.1', unfiltered: 'full', think: 'toggle', context: 131072, rates: [25000, 95000] },+ { id: 'deepseek-ai/DeepSeek-V4-Flash-0731', label: 'DeepSeek V4 Flash 0731', unfiltered: 'partial', flash: true, think: 'toggle', context: 1048576, rates: [6000, 18000] },+ { id: 'deepseek-ai/DeepSeek-V4.1-Flash', label: 'DeepSeek V4.1 Flash', vision: true, think: 'always', context: 1048576, rates: [30000, 120000] },+ { id: 'deepseek-ai/DeepSeek-V4-Pro-0813', label: 'DeepSeek V4 Pro 0813', unfiltered: 'partial', think: 'toggle', context: 1048576, rates: [130000, 260000] },+ { id: 'deepseek-ai/DeepSeek-R1-0528', label: 'DeepSeek R1', unfiltered: 'partial', think: 'always', context: 131072, rates: [50000, 215000] },+ { id: 'Qwen/Qwen3-32B', label: 'Qwen3 32B', unfiltered: 'partial', flash: true, think: 'toggle', context: 131072, rates: [8000, 28000] },+ { id: 'Qwen/Qwen3-235B-A22B-Instruct-2507', label: 'Qwen3 235B A22B', unfiltered: 'partial', think: 'never', context: 131072, rates: [9000, 55000] },+ { id: 'Qwen/Qwen3.5-9B', label: 'Qwen 3.5 9B', unfiltered: 'full', flash: true, vision: true, think: 'toggle', context: 262144, rates: [10000, 15000] },+ { id: 'Qwen/Qwen3.5-35B-A3B', label: 'Qwen 3.5 35B A3B', unfiltered: 'partial', vision: true, think: 'toggle', context: 262144, rates: [14000, 100000] },+ { id: 'Qwen/Qwen3.5-397B-A17B', label: 'Qwen 3.5 397B A17B', unfiltered: 'partial', vision: true, think: 'toggle', context: 262144, rates: [45000, 300000] },+ { id: 'Qwen/Qwen3.6-27B', label: 'Qwen 3.6 27B', unfiltered: 'full', vision: true, think: 'toggle', context: 262144, rates: [32000, 320000] },+ { id: 'Qwen/Qwen3-VL-30B-A3B-Instruct', label: 'Qwen3 VL 30B', unfiltered: 'partial', vision: true, think: 'never', context: 131072, rates: [15000, 60000] },+ { id: 'Qwen/Qwen3-VL-235B-A22B-Instruct', label: 'Qwen3 VL 235B', unfiltered: 'full', vision: true, think: 'never', context: 131072, rates: [20000, 88000] },+ { id: 'Qwen/Qwen3.8-27B', label: 'Qwen 3.8 27B', unfiltered: 'partial', vision: true, think: 'toggle', context: 262144, rates: [40000, 300000] },+ { id: 'Qwen/Qwen3.8-Max', label: 'Qwen 3.8 Max', think: 'toggle', context: 262144, rates: [165000, 495100] },+ { id: 'Qwen/Qwen3.8-2.4T-A95B', label: 'Qwen 3.8 A95B', unfiltered: 'full', think: 'always', context: 262144, rates: [200000, 600000] },+ { id: 'meta-llama/Llama-3.3-70B-Instruct-Turbo', label: 'Llama 3.3 70B Turbo', unfiltered: 'full', flash: true, think: 'never', context: 131072, rates: [10000, 32000] },+ { id: 'meta-llama/Llama-4-Maverick-17B-128E-Instruct-FP8', label: 'Llama 4 Maverick', unfiltered: 'full', vision: true, think: 'never', context: 131072, rates: [20000, 80000] },+ { id: 'meta-llama/Llama-4-Scout-17B-16E-Instruct', label: 'Llama 4 Scout', unfiltered: 'partial', vision: true, think: 'never', context: 131072, rates: [10000, 30000] },+ { id: 'google/gemma-4-31B-it-turbo', label: 'Gemma 4 31B Turbo', unfiltered: 'full', flash: true, vision: true, think: 'toggle', context: 131072, rates: [9000, 34000] },+ { id: 'zai-org/GLM-4.7', label: 'GLM 4.7', unfiltered: 'full', think: 'toggle', context: 131072, rates: [40000, 175000] },+ { id: 'zai-org/GLM-5', label: 'GLM 5', unfiltered: 'partial', think: 'toggle', context: 131072, rates: [60000, 208000] },+ { id: 'zai-org/GLM-5.1', label: 'GLM 5.1', unfiltered: 'partial', think: 'toggle', context: 131072, rates: [105000, 350000] },+ { id: 'zai-org/GLM-5.2', label: 'GLM 5.2', unfiltered: 'partial', think: 'toggle', context: 131072, rates: [75000, 240000] },+ { id: 'zai-org/GLM-5.3', label: 'GLM 5.3', unfiltered: 'partial', think: 'always', context: 131072, rates: [120000, 400000] },+ { id: 'nvidia/NVIDIA-Nemotron-3-Super-120B-A12B', label: 'Nemotron 3 Super 120B', unfiltered: 'partial', think: 'toggle', context: 131072, rates: [8500, 40000] },+ { id: 'openai/gpt-oss-20b', label: 'gpt-oss 20B', flash: true, think: 'always', context: 131072, rates: [3000, 14000] },+ { id: 'moonshotai/Kimi-K2.6', label: 'Kimi K2.6', unfiltered: 'full', vision: true, think: 'toggle', context: 131072, rates: [75000, 350000] },+ { id: 'moonshotai/Kimi-K2.7-Code', label: 'Kimi K2.7 Code', unfiltered: 'full', vision: true, think: 'toggle', context: 131072, rates: [68000, 340000] },+ { id: 'MiniMaxAI/MiniMax-M2.7', label: 'MiniMax M2.7', unfiltered: 'partial', think: 'always', context: 131072, rates: [25000, 100000] },+ { id: 'MiniMaxAI/MiniMax-M3', label: 'MiniMax M3', unfiltered: 'full', vision: true, think: 'toggle', context: 131072, rates: [28000, 110000] },+ { id: 'mistralai/Mistral-Small-3.2-24B-Instruct-2506', label: 'Mistral Small 3.2 24B', unfiltered: 'full', flash: true, vision: true, think: 'never', context: 131072, rates: [7500, 20000] },+]++/** The body of GET /api/inference/v1/models for that catalogue. */+export function mockModelsAnswer(tier = 'hosted-pro') {+ return {+ object: 'list',+ tier,+ data: MOCK_CHAT_CATALOGUE.map((m) => ({+ id: m.id,+ object: 'model',+ owned_by: 'lu-labs',+ name: m.label,+ ...(m.context ? { context_length: m.context } : {}),+ max_output_length: 8192,+ input_modalities: m.vision ? ['text', 'image'] : ['text'],+ think: m.think,+ supports_tools: m.id !== 'Gryphe/MythoMax-L2-13b',+ ...(m.unfiltered ? { unfiltered: m.unfiltered } : {}),+ ...(m.flash+ ? { usage_class: 'flash', flash: { sessions_only: true, concurrent_requests: 1, daily_tokens: 2_000_000, default_max_output: 4096, request_seconds: 120 } }+ : {}),+ ...(m.rates ? { credit_rates: { input_per_million: m.rates[0], output_per_million: m.rates[1] } } : {}),+ })),+ }+}diff --git a/src/api/providers/openai-provider.ts b/src/api/providers/openai-provider.tsindex aabab14a..079e53f6 100644--- a/src/api/providers/openai-provider.ts+++ b/src/api/providers/openai-provider.ts@@ -16,7 +16,7 @@ import type {ProviderClient, ProviderModel, ProviderConfig, ChatMessage, ChatOptions,ChatStreamChunk, ToolCall, ToolDefinition,} from './types'-import { ProviderError } from './types'+import { ProviderError, type CreditRates } from './types'import { RepetitionStop } from '../../lib/repetition-stop'import { parseSSEStream } from '../sse'import { idleAbortGuard, isStreamIdleTimeout } from '../stream-idle'@@ -162,6 +162,18 @@ interface OpenAIModelEntry {// missing ladder as "keep doing exactly what you did before".reasoning_effort_levels?: string[]reasoning_effort_default?: string+ // What the model draws per one million tokens, in credits. LU Cloud sends it+ // since 3.0.5; absent everywhere else and on an older deployment.+ credit_rates?: CreditRates+}++/** The models route's `credit_rates`, or nothing. Both sides must be real+ * numbers: half a rate would print as a price list with a hole in it. */+function parseCreditRates(raw: unknown): CreditRates | undefined {+ if (!raw || typeof raw !== 'object') return undefined+ const { input_per_million: i, output_per_million: o } = raw as Record<string, unknown>+ const ok = (n: unknown): n is number => typeof n === 'number' && Number.isFinite(n) && n >= 0+ return ok(i) && ok(o) ? { inputPerMillion: i, outputPerMillion: o } : undefined}/**@@ -218,9 +230,15 @@ function toModelEntry(m: Record<string, unknown>): OpenAIModelEntry {// becomes, and it already answers this case; a second answer here would be// a second place to keep right.reasoning_effort_default: asString(m.reasoning_effort_default),+ credit_rates: parseCreditRates(m.credit_rates),}}+/** The window a listing stated itself, for the picker's context column. */+function declaredContextOf(m: OpenAIModelEntry): number | undefined {+ return m.context_length && m.context_length > 0 ? m.context_length : undefined+}+/*** Only the two measured values survive. Anything else a foreign server* writes into this field is dropped, same rule at both call sites, one@@ -1170,6 +1188,8 @@ export class OpenAIProvider implements ProviderClient {unfiltered: asUnfiltered(m.unfiltered),effortLevels: m.reasoning_effort_levels,effortDefault: m.reasoning_effort_default,+ declaredContext: declaredContextOf(m),+ creditRates: m.credit_rates,}}))}@@ -1199,6 +1219,8 @@ export class OpenAIProvider implements ProviderClient {// whole effort feature off for this model.effortLevels: m.reasoning_effort_levels,effortDefault: m.reasoning_effort_default,+ declaredContext: declaredContextOf(m),+ creditRates: m.credit_rates,}})}diff --git a/src/api/providers/types.ts b/src/api/providers/types.tsindex adce2a0f..7bfcaef5 100644--- a/src/api/providers/types.ts+++ b/src/api/providers/types.ts@@ -144,6 +144,21 @@ export interface ProviderModel {/** The rung the model itself defaults to (`reasoning_effort_default`). Used* only where no wish was made; the user's own choice always wins. */effortDefault?: string+ /** The context window the server itself stated in its listing, and nothing+ * else: no table, no guess from the name. `contextLength` above always+ * holds a number to budget with; this one is absent when nobody stated+ * one, so the model picker can leave the figure empty. */+ declaredContext?: number+ /** What the model draws per one million tokens, in credits, input and output+ * apart (LU Cloud /models `credit_rates`, from the meter's own price+ * source). Credits per token count only, never a money amount. Absent on a+ * server that does not send the field. */+ creditRates?: CreditRates+}++export interface CreditRates {+ inputPerMillion: number+ outputPerMillion: number}// ── Chat Messages (unified format) ────────────────────────────diff --git a/src/components/chat/__tests__/senden-ohne-modell-verliert-nichts.test.tsx b/src/components/chat/__tests__/senden-ohne-modell-verliert-nichts.test.tsxindex 98f6ce02..88c33d5a 100644--- a/src/components/chat/__tests__/senden-ohne-modell-verliert-nichts.test.tsx+++ b/src/components/chat/__tests__/senden-ohne-modell-verliert-nichts.test.tsx@@ -140,7 +140,7 @@ describe('what Chat counts as a model to send with', () => {})describe('the model picker after a send without a model', () => {- const HINT = 'Pick a model to send your message. Your text and attachments are kept.'+ const HINT = 'Choose a model to send your message. Your text and attachments are kept.'const picker = () => screen.getByRole('button', { name: 'Select chat model' })const withModels = () => useModelStore.setState({activeModel: null,diff --git a/src/components/models/CloudModelPicker.tsx b/src/components/models/CloudModelPicker.tsxnew file mode 100644index 00000000..c5af3fc3--- /dev/null+++ b/src/components/models/CloudModelPicker.tsx@@ -0,0 +1,517 @@+import { useEffect, useId, useMemo, useRef, useState, type ReactNode, type RefObject } from 'react'+import { createPortal } from 'react-dom'+import { Eye, Lightbulb, LockOpen, Search, X } from 'lucide-react'+import { usePopoverPlatz } from '../../hooks/usePopoverPlatz'+import { displayModelName } from '../../api/providers'+import { formatContextWindow } from '../../lib/formatters'+import { FLASH_MARK_LABEL, flashMarkTitle, useFlashEntitlement } from '../../lib/flash-entitlement'+import { UNFILTERED_MARK_LABEL } from '../../lib/unfiltered-mark'+import { log } from '../../lib/logger'+import {+ PICKER_FILTERS, filterCounts, filterRows, formatCreditRate, highlightParts, moveCursor, pickerGroups, pickerRows,+ searchTokens,+ type PickerFilter, type PickerGroup, type PickerRow,+} from '../../lib/model-picker'+import type { AIModel } from '../../types/models'+import { ModelPickerSkeleton } from '../layout/ViewSkeletons'+import { ModelRowMarks } from './ModelRowMarks'++/**+ * The chat model picker in Cloud mode, for Chat, Agent and Code.+ *+ * David, 05.10.2026: grouped by model family under one-line sticky heads, a+ * search on top, filter chips, a footer with the count and the keys. A row+ * reads name, the measured mark, vision, thinking and the context window the+ * server stated. There is no credit column: a small question mark per row+ * opens the model's credit rates per one million tokens.+ *+ * This component draws the inside of the menu. The menu itself (the sheet, its+ * place next to the trigger, opening and closing, what a pick does) stays with+ * ModelSelector, which also draws the local list. What a row shows and how the+ * list narrows is decided in lib/model-picker.+ */++/** The width of the menu in Cloud mode, in the app's own pixels. */+export const CLOUD_PICKER_WIDTH = 400+/** Never taller than this, and never taller than the room next to the trigger. */+export const CLOUD_PICKER_MAX_HEIGHT = 520++/** What the list is not showing in Cloud mode, and how to get it back (G20:+ * the silence used to read as "my local models are gone"). */+export const CLOUD_MODE_LIST_NOTE =+ 'Cloud mode shows hosted models only. Switch the app to Local mode to use Ollama, LM Studio or the LU Engine.'++// A full agent tool set is about 5k tokens of definitions before the+// conversation starts, so a 4k model calls tools in Chat but cannot carry+// Agent or Code. Saying that on the context figure beats letting the user find+// out from the upstream's own words after the first message.+const TIGHT_CONTEXT = 8192++function contextTitle(ctx: number): string | undefined {+ return ctx < TIGHT_CONTEXT+ ? `A ${formatContextWindow(ctx)} context window is too small for a full Agent or Code tool set`+ : undefined+}++const FILTER_LABEL: Record<PickerFilter, string> = {+ marked: UNFILTERED_MARK_LABEL,+ vision: 'Vision',+ thinking: 'Thinking',+ free: FLASH_MARK_LABEL,+}++const FILTER_ICON: Partial<Record<PickerFilter, typeof Eye>> = {+ marked: LockOpen,+ vision: Eye,+ thinking: Lightbulb,+}++/** One line under the search for what needs attention now. */+export interface PickerNote {+ testId: string+ text: string+ tone: 'info' | 'error'+ onDismiss?: () => void+}++export interface CloudModelPickerProps {+ /** The text models this surface offers. */+ models: AIModel[]+ activeModel: string | null+ /** No model list has arrived yet. */+ loading: boolean+ notes: PickerNote[]+ /** Hosted models left out here because Code cannot use them. */+ hiddenForCode: number+ /** What the list says when it holds no model at all. */+ empty: ReactNode+ /** The scrolling list, for the menu's own placement. */+ listRef: RefObject<HTMLDivElement | null>+ onPick: (model: AIModel) => void+ /** The element that had the keyboard before the search field took it. */+ onTookFocus: (from: HTMLElement | null) => void+}++/** The rows, or a flat list of bare names when building them threw. A single+ * malformed entry must not take the chat view down with it (K6, 3.0.1). */+function safeRows(models: AIModel[], paidPlan: boolean | null): PickerRow[] {+ try {+ return pickerRows(models, paidPlan)+ } catch (e) {+ log.error('[CloudModelPicker] building the rows threw, showing bare names', { err: e, modelCount: models.length })+ return models.filter((m) => m.type === 'text').map((model) => ({+ name: model.name, model, label: displayModelName(model.name), family: 'Other',+ unfiltered: false, vision: false, thinking: null, free: null, context: null, rates: null, chatOnly: false,+ }))+ }+}++// The question mark of a row and what it opens.+//+// HARD RULE: credits per token count only. Never a money amount, never how+// many tokens a sum of money buys. The figures are the server's+// (`credit_rates` of the models route); a server that does not send them+// gives the row no question mark at all.+//+// Placed by the app's one placement rule (hooks/usePopoverPlatz, GitHub #149)+// and lifted out of the list, so neither the list's own edge nor the window's+// can cut it.+function RateControl({ row, open, tabbable, popId, onToggle }: {+ row: PickerRow+ open: boolean+ tabbable: boolean+ popId: string+ onToggle: () => void+}) {+ const buttonRef = useRef<HTMLButtonElement>(null)+ const popRef = useRef<HTMLDivElement>(null)+ const lage = usePopoverPlatz(popRef, open, { anker: buttonRef, fest: 'rechts', abstand: 4, luft: 8 })+ return (+ <>+ <button+ ref={buttonRef}+ type="button"+ className="lu-picker-rate-btn"+ tabIndex={tabbable ? 0 : -1}+ data-model-rate+ // The row's name stays out of the label on purpose: the row already+ // says it, and a second button carrying it would answer to the same+ // name as the one that picks the model.+ aria-label="Credit rates"+ title={`Credit rates of ${row.label}`}+ aria-expanded={open}+ aria-describedby={open ? popId : undefined}+ onClick={onToggle}+ >+ ?+ </button>+ {open && createPortal(+ <div+ ref={popRef}+ id={popId}+ role="tooltip"+ data-model-rate+ data-testid="model-rate-popover"+ className="lu-picker-rate"+ style={lage.style}+ >+ {row.free ? (+ <span>{flashMarkTitle(row.free.dailyTokens)}</span>+ ) : row.rates && (+ <>+ <h4>Credits per 1M tokens</h4>+ <dl>+ <dt>Input</dt>+ <dd data-rate="input">{formatCreditRate(row.rates.inputPerMillion)}</dd>+ <dt>Output</dt>+ <dd data-rate="output">{formatCreditRate(row.rates.outputPerMillion)}</dd>+ </dl>+ </>+ )}+ </div>,+ document.body,+ )}+ </>+ )+}++export function CloudModelPicker({+ models, activeModel, loading, notes, hiddenForCode, empty, listRef, onPick, onTookFocus,+}: CloudModelPickerProps) {+ const paidPlan = useFlashEntitlement()+ const [query, setQuery] = useState('')+ const [filters, setFilters] = useState<ReadonlySet<PickerFilter>>(new Set())+ /** The row whose rates are shown. */+ const [rate, setRate] = useState<string | null>(null)+ const inputRef = useRef<HTMLInputElement>(null)+ const uid = useId()+ const optionId = (index: number) => `${uid}-option-${index}`++ const rows = useMemo(() => safeRows(models, paidPlan), [models, paidPlan])+ const counts = useMemo(() => filterCounts(rows), [rows])+ const tokens = useMemo(() => searchTokens(query), [query])+ const groups: PickerGroup[] = useMemo(+ () => pickerGroups(filterRows(rows, query, filters), tokens.length > 0),+ [rows, query, filters, tokens],+ )+ const visible = useMemo(() => groups.flatMap((g) => g.rows), [groups])+ const chips = PICKER_FILTERS.filter((f) => counts[f] > 0)++ // The keyboard cursor. It starts on the selected model, so Enter confirms it+ // and the arrows start from where the user is. `null` until the user moves+ // it or narrows the list: the list may still be arriving when the menu+ // opens, and a fixed number from the first render would point at whatever+ // row happens to stand there later.+ const [moved, setMoved] = useState<number | null>(null)+ const selectedAt = visible.findIndex((r) => r.name === activeModel)+ const cursor = Math.min(moved ?? Math.max(0, selectedAt), Math.max(0, visible.length - 1))+ /** Set when the cursor moved by key or by opening, so the list follows it.+ * A cursor that follows the mouse must not scroll the list under it. */+ const followCursor = useRef(true)++ // The search field takes the keyboard when the menu opens: typing filters,+ // the arrows move, Enter picks. Who had it before is handed up, so the menu+ // can give it back when it closes.+ useEffect(() => {+ const before = document.activeElement+ // An effect can run twice (React's strict mode does that on purpose). The+ // second time the field already has the keyboard, and it is not where the+ // keyboard came from.+ if (before !== inputRef.current) onTookFocus(before instanceof HTMLElement ? before : null)+ inputRef.current?.focus({ preventScroll: true })+ // Once, on the way in.+ // eslint-disable-next-line react-hooks/exhaustive-deps+ }, [])++ // Keep the cursor row in view. Done by hand on the list alone:+ // scrollIntoView would also move every scrolling ancestor of the menu.+ useEffect(() => {+ if (!followCursor.current) return+ const list = listRef.current+ const el = document.getElementById(optionId(cursor))+ if (!list || !el) return+ followCursor.current = false+ // 24 px is the sticky group head a row must not hide under.+ const top = el.offsetTop - 24+ const bottom = el.offsetTop + el.offsetHeight+ if (top < list.scrollTop) list.scrollTop = Math.max(0, top)+ else if (bottom > list.scrollTop + list.clientHeight) list.scrollTop = bottom - list.clientHeight+ // optionId is stable for the life of the menu.+ // eslint-disable-next-line react-hooks/exhaustive-deps+ }, [cursor, visible.length, listRef])++ const narrow = (next: { query?: string; filters?: ReadonlySet<PickerFilter> }) => {+ if (next.query !== undefined) setQuery(next.query)+ if (next.filters) setFilters(next.filters)+ followCursor.current = true+ setMoved(0)+ setRate(null)+ }++ const toggleFilter = (f: PickerFilter) => {+ const next = new Set(filters)+ if (next.has(f)) next.delete(f)+ else next.add(f)+ narrow({ filters: next })+ }++ const onKeyDown = (e: React.KeyboardEvent) => {+ if (e.key === 'Escape') {+ // Escape goes one step back at a time: the rates, then the search, and+ // only then the menu itself. Stopped here, the event does not reach the+ // menu's own Escape (hooks/useDismissOnEscape listens on the document).+ if (rate) { e.stopPropagation(); setRate(null); return }+ if (query) { e.stopPropagation(); narrow({ query: '' }); inputRef.current?.focus() }+ return+ }+ const inSearch = e.target === inputRef.current+ if (e.key === 'Enter') {+ if (!inSearch) return+ e.preventDefault()+ if (visible[cursor]) onPick(visible[cursor].model)+ return+ }+ // Home and End move the caret while the field holds text.+ const next = moveCursor(cursor, e.key, visible.length, inSearch && query.length > 0)+ if (next === null) return+ e.preventDefault()+ followCursor.current = true+ setRate(null)+ setMoved(next)+ // The arrows belong to the list wherever the keyboard stands in the menu.+ if (!inSearch) inputRef.current?.focus()+ }++ let index = -1++ return (+ <div+ className="flex min-h-0 flex-1 flex-col"+ onKeyDown={onKeyDown}+ onClick={(e) => {+ // A press anywhere but on a question mark puts the rates away.+ if (rate && !(e.target as HTMLElement).closest('[data-model-rate]')) setRate(null)+ }}+ >+ <div className="lu-picker-search">+ <Search size={13} aria-hidden="true" />+ <input+ ref={inputRef}+ type="text"+ role="combobox"+ aria-expanded="true"+ aria-autocomplete="list"+ aria-controls={`${uid}-list`}+ aria-activedescendant={visible[cursor] ? optionId(cursor) : undefined}+ aria-label="Search models"+ placeholder="Search models"+ spellCheck={false}+ autoComplete="off"+ value={query}+ onChange={(e) => narrow({ query: e.target.value })}+ data-testid="model-picker-search"+ />+ {query && (+ <button+ type="button"+ className="lu-picker-text-btn"+ onClick={() => { narrow({ query: '' }); inputRef.current?.focus() }}+ >+ Clear+ </button>+ )}+ </div>++ {notes.map((note) => (+ <div+ key={note.testId}+ className={`lu-picker-note${note.tone === 'error' ? ' is-err' : ''}`}+ data-tone={note.tone}+ >+ <span className={`lu-picker-dot ${note.tone === 'error' ? 'is-err' : 'is-accent'}`} />+ <span data-testid={note.testId}>{note.text}</span>+ {note.onDismiss && (+ <button+ type="button"+ className="lu-picker-text-btn"+ onClick={note.onDismiss}+ aria-label="Dismiss"+ title="Dismiss"+ >+ <X size={10} />+ </button>+ )}+ </div>+ ))}++ {chips.length > 0 && (+ <div className="lu-picker-chips" role="group" aria-label="Narrow the list">+ {chips.map((f) => {+ const Icon = FILTER_ICON[f]+ return (+ <button+ key={f}+ type="button"+ className="lu-picker-chip"+ aria-pressed={filters.has(f)}+ data-chip={f}+ onClick={() => toggleFilter(f)}+ >+ {Icon && <Icon size={11} aria-hidden="true" />}+ {FILTER_LABEL[f]} <i>{counts[f]}</i>+ </button>+ )+ })}+ </div>+ )}++ {rows.some((r) => r.context !== null) && (+ <div className="lu-picker-cap" aria-hidden="true">+ <span>Model</span>+ <span>Context</span>+ </div>+ )}++ <div+ ref={listRef}+ id={`${uid}-list`}+ role="listbox"+ aria-label="Models"+ className="lu-picker-list"+ onScroll={(e) => {+ // The rates follow their question mark while the list scrolls, and+ // go away once that row has left the list's window.+ if (!rate) return+ const button = e.currentTarget.querySelector('.lu-picker-rate-btn[aria-expanded="true"]')+ if (!button) return+ const list = e.currentTarget.getBoundingClientRect()+ const b = button.getBoundingClientRect()+ if (b.bottom < list.top || b.top > list.bottom) setRate(null)+ }}+ >+ {loading && rows.length === 0 && <ModelPickerSkeleton />}+ {!loading && rows.length === 0 && empty}+ {rows.length > 0 && visible.length === 0 && (+ <p className="lu-picker-empty" data-testid="model-picker-no-match">+ No models match. Clear the search or a tag.+ </p>+ )}++ {groups.map((group) => (+ <div key={group.family ?? 'all'} role="presentation">+ {group.family && (+ <div className="lu-picker-head" role="presentation" data-family={group.family}>+ <b>{group.family}</b>+ <span className="n">{group.rows.length}</span>+ </div>+ )}++ {group.rows.map((row) => {+ index += 1+ const at = index+ const isActive = row.name === activeModel+ const ctx = row.context+ return (+ /* The part that picks the model is a <button>; the rate+ control is a button of its own NEXT to it, because no+ browser allows one inside another. The keyboard reaches a+ row through the cursor (arrows, then Enter), so the pick+ button stays out of the Tab order and Tab walks the+ controls instead of every row. */+ <div+ key={row.name}+ id={optionId(at)}+ role="option"+ aria-selected={isActive}+ data-cursor={at === cursor}+ className="lu-picker-row"+ title={displayModelName(row.name)}+ onMouseMove={() => { if (at !== cursor) setMoved(at) }}+ >+ <button+ type="button"+ tabIndex={-1}+ className="lu-picker-pick"+ aria-current={isActive ? 'true' : undefined}+ onClick={() => onPick(row.model)}+ >+ <span className="lu-picker-name">+ {highlightParts(row.label, tokens).map((part, i) =>+ part.hit ? <mark key={i}>{part.text}</mark> : <span key={i}>{part.text}</span>)}+ </span>+ {/* The mark from the catalogue, out of the one component+ that draws it everywhere. */}+ <ModelRowMarks model={{ unfiltered: row.unfiltered ? 'full' : undefined }} row />+ {row.chatOnly && (+ <span+ className="t-micro lu-picker-tag"+ title="This model does not support tool calling, so Agent and Code mode cannot use it"+ data-mark="chat-only"+ >+ Chat only+ </span>+ )}+ <span className="lu-picker-fill" />+ <span className="lu-picker-icons">+ <span title={row.vision ? 'Reads images' : undefined} data-icon={row.vision ? 'vision' : undefined}>+ {row.vision && <Eye size={14} aria-label="Reads images" />}+ </span>+ <span+ title={row.thinking === 'always' ? 'Always thinks before it answers'+ : row.thinking === 'toggle' ? 'Can think before it answers' : undefined}+ data-icon={row.thinking ? 'thinking' : undefined}+ >+ {row.thinking && <Lightbulb size={14} aria-label="Thinks before it answers" />}+ </span>+ </span>+ {/* Only a context window the server stated is printed. A+ model nobody stated one for keeps the cell empty. */}+ <span className="lu-picker-num" title={ctx === null ? undefined : contextTitle(ctx)} data-context>+ {ctx === null ? '' : formatContextWindow(ctx)}+ </span>+ </button>++ {/* No rates from the server and no free allowance: nothing+ true to show, so no question mark. The slot keeps its+ width, the context column stays in line. */}+ <span className="lu-picker-rate-anchor">+ {(row.rates || row.free) && (+ <RateControl+ row={row}+ open={rate === row.name}+ tabbable={at === cursor}+ popId={`${uid}-rate`}+ onToggle={() => setRate(rate === row.name ? null : row.name)}+ />+ )}+ </span>+ </div>+ )+ })}+ </div>+ ))}+ </div>++ <div className="lu-picker-foot">+ <span data-testid="model-picker-count" title={CLOUD_MODE_LIST_NOTE}>+ {visible.length === rows.length+ ? `${rows.length} cloud ${rows.length === 1 ? 'model' : 'models'}`+ : `${visible.length} of ${rows.length}`}+ </span>+ {/* Say WHY the list is shorter here than in Chat, otherwise a missing+ favourite reads as a bug. */}+ {hiddenForCode > 0 && (+ <span+ data-testid="model-picker-hidden-for-code"+ title={`${hiddenForCode} cloud ${hiddenForCode === 1 ? 'model is' : 'models are'} hidden here because they cannot call tools. They are still in Chat.`}+ >+ {hiddenForCode} hidden, no tool calling+ </span>+ )}+ <span className="lu-picker-keys" aria-hidden="true">+ <kbd>↑</kbd><kbd>↓</kbd><kbd>Enter</kbd><kbd>Esc</kbd>+ </span>+ </div>+ </div>+ )+}diff --git a/src/components/models/ModelRowMarks.tsx b/src/components/models/ModelRowMarks.tsxindex 3d89af51..163c4a89 100644--- a/src/components/models/ModelRowMarks.tsx+++ b/src/components/models/ModelRowMarks.tsx@@ -1,6 +1,6 @@-import { Unlock } from 'lucide-react'import type { CloudModel } from '../../types/models'import { FLASH_MARK_LABEL, flashMarkTitle, useFlashEntitlement } from '../../lib/flash-entitlement'+import { traegtDieMarke, UNFILTERED_MARK_LABEL, UNFILTERED_MARK_TITLE } from '../../lib/unfiltered-mark'/*** Die Marken an einer Zeile der Modellauswahl.@@ -20,32 +20,33 @@ import { FLASH_MARK_LABEL, flashMarkTitle, useFlashEntitlement } from '../../lib* an jedes Konto mit Cloud; ein Konto ohne bezahlten Plan zahlt fuer genau* diese Modelle und darf die Marke nicht sehen. Eine noch unbeantwortete* Abfrage verspricht nichts.+ *+ * `row` ist die Zeile des Cloud-Waehlers: sie zeigt nur die gemessene Marke,+ * denn was ein Modell dieses Konto kostet, steht dort hinter dem Fragezeichen+ * der Zeile.+ *+ * Das Aussehen ist das Etikett der Waehler (index.css, .lu-picker-tag): eine+ * Haarlinie, der eine Akzent fuer "No refusals", Helligkeit und keine Farbe+ * fuer "No credits". K12 (3.0.1, die Marke war nicht auffindbar) ist damit+ * anders geloest als frueher mit Icon und Fettung: die Marke hat einen eigenen+ * Rahmen, und der Waehler hat einen Filter, der nur markierte Modelle zeigt.*/-export function ModelRowMarks({ model }: { model: { flash?: CloudModel['flash']; unfiltered?: CloudModel['unfiltered'] } }) {+export function ModelRowMarks({ model, row = false }: {+ model: { flash?: CloudModel['flash']; unfiltered?: CloudModel['unfiltered'] }+ row?: boolean+}) {const paidPlan = useFlashEntitlement()- const freeFlash = model.flash && paidPlan === true ? model.flash : undefined+ const freeFlash = !row && model.flash && paidPlan === true ? model.flash : undefinedreturn (<>- {model.unfiltered === 'full' && (- // K12 (3.0.1): unbeantwortete Discord-Meldung, die Marke war nicht- // auffindbar. Sie stand als reiner Fliesstext in derselben Groesse- // wie jede andere Kleinschrift der Zeile, ohne Icon, ohne Gewicht,- // im Sammelbild der Liste ging sie unter. Bleibt auf derselben- // Stufe der Typo-Leiter (t-micro setzt NUR die Groesse, siehe- // index.css), bekommt aber ein Icon und Fettung dazu, beides- // Tailwind-Utilities, die t-micro nicht ueberschreibt.- <span- className="t-micro font-semibold text-purple-600 dark:text-purple-300 inline-flex items-center gap-0.5"- title="Measured: this model answers without refusing. Your account's content policy still applies."- data-mark="unfiltered"- >- <Unlock size={9} className="shrink-0" aria-hidden="true" />- No refusals+ {traegtDieMarke(model.unfiltered) && (+ <span className="t-micro lu-picker-tag is-accent" title={UNFILTERED_MARK_TITLE} data-mark="unfiltered">+ {UNFILTERED_MARK_LABEL}</span>)}{freeFlash && (<span- className="t-micro text-emerald-600 dark:text-emerald-400"+ className="t-micro lu-picker-tag is-bright"title={flashMarkTitle(freeFlash.dailyTokens)}data-mark="unlimited">diff --git a/src/components/models/ModelSelector.tsx b/src/components/models/ModelSelector.tsxindex 4dd50d65..9aa78893 100644--- a/src/components/models/ModelSelector.tsx+++ b/src/components/models/ModelSelector.tsx@@ -44,6 +44,8 @@ import { ModelPickerSkeleton } from '../layout/ViewSkeletons'import type { AIModel } from '../../types/models'import { MOTION_S } from '../ui/motion'import { ModelRowMarks } from './ModelRowMarks'+import { CloudModelPicker, CLOUD_PICKER_MAX_HEIGHT, CLOUD_PICKER_WIDTH, type PickerNote } from './CloudModelPicker'+import { modelFamily, OTHER_FAMILY } from '../../lib/model-family'import type { CloudModel as CloudModelMarks } from '../../types/models'// ── Local-mode cloud discovery (2.5.8): an "LU Cloud" section at the list's@@ -328,68 +330,33 @@ function getProviderBadge(model: AIModel) {//// Pure visual grouping, model name + provider still resolve chat// routing exactly as before.--// Normalize a model name into a comparable base form:-// openai::qwen3.6-27b → qwen3.6-27b-// richardyoung/qwen3-14b:… → qwen3-14b-// Qwen3.6-27B-Q4_K_M.gguf → qwen3.6-27b-q4_k_m.gguf-function normalizeModelName(name: string): string {- return (name || '')- .toLowerCase()- .replace(/^[^:]+::/, '') // strip openai:: / anthropic::- .replace(/^[^/]+\//, '') // strip repo-author/ prefix- .replace(/:.+$/, '') // strip :tag suffix-}--// Ordered, first match wins. Prefixes/infixes on the normalized name.-const FAMILY_MATCHERS: Array<{ family: string; test: RegExp }> = [- { family: 'Qwen', test: /^qwen|^qwq/ },- { family: 'Gemma', test: /^gemma/ },- { family: 'Llama', test: /^llama|^meta[-_]?llama/ },- { family: 'Mistral', test: /^mistral|^mixtral|^mistral-nemo|^mistral-small|^mistral-large/ },- { family: 'DeepSeek', test: /^deepseek/ },- { family: 'Phi', test: /^phi-?\d|^phi_?\d/ },- { family: 'Hermes', test: /^hermes|^nous-/ },- { family: 'Dolphin', test: /^dolphin/ },- { family: 'Claude', test: /^claude/ },- { family: 'GPT-OSS', test: /^gpt-oss/ },- { family: 'GPT / o-series', test: /^gpt-|^o1-|^o3-/ },- { family: 'Command', test: /^command/ },- { family: 'GLM', test: /^glm|^chatglm|^zai/ },- { family: 'Yi', test: /^yi-/ },- { family: 'Gemini', test: /^gemini/ },- { family: 'Grok', test: /^grok/ },-]--function getModelFamily(modelName: string): string {- const n = normalizeModelName(modelName)- for (const { family, test } of FAMILY_MATCHERS) {- if (test.test(n)) return family- }- return 'Other'-}+//+// This is the LOCAL list. It keeps its own order and its own head per family,+// also over a single row (David, 05.10.2026: the local list stays as it is).+// Which family a name belongs to is asked in lib/model-family, the same table+// the Cloud picker groups by.// Family display order, Qwen/Gemma/Llama surface first since they're// the most common local-chat picks; cloud-only families (Claude/GPT)// come after the local ones; 'Other' always last.const FAMILY_ORDER: string[] = ['Qwen', 'Gemma', 'Llama', 'Mistral', 'DeepSeek', 'Phi', 'Hermes',- 'Dolphin', 'GLM', 'GPT-OSS', 'Yi', 'Command',+ 'Dolphin', 'GLM', 'gpt-oss', 'Yi', 'Command','Claude', 'GPT / o-series', 'Gemini', 'Grok',]function groupByFamily(models: AIModel[]): { family: string; models: AIModel[] }[] {const groups: Record<string, AIModel[]> = {}for (const m of models) {- const fam = getModelFamily(m.name)+ const fam = modelFamily(m.name)if (!groups[fam]) groups[fam] = []groups[fam].push(m)}return Object.entries(groups).sort(([a], [b]) => {- if (a === 'Other') return 1- if (b === 'Other') return -1+ if (a === OTHER_FAMILY) return 1+ if (b === OTHER_FAMILY) return -1const ai = FAMILY_ORDER.indexOf(a)const bi = FAMILY_ORDER.indexOf(b)if (ai >= 0 && bi >= 0) return ai - bi@@ -658,8 +625,13 @@ export interface ModelSelectorProps {* that is the normal state of a new account: the app never picks a hosted* model by itself (lib/active-model-mode). */const NO_MODEL_LABEL = 'Choose a model'-/** The first line of the menu in Cloud mode while nothing is picked. */-const CHOOSE_TO_SEND = 'Choose a model to send your message.'+/** The first line of the menu while nothing is picked, in the words of the+ * web app. One wording for both reasons the line can stand there. */+export const CHOOSE_TO_SEND = 'Choose a model to send your message.'+/** Added to it, in the same line, after a send was tried without a model. */+export const MESSAGE_IS_KEPT = 'Your text and attachments are kept.'+/** The line when a send is waiting and the list holds no model at all. */+export const NO_MODEL_LISTED = `Your message needs a chat model, and none is listed yet. ${MESSAGE_IS_KEPT}`// `openUpward` flips the dropdown to open above the trigger, right-aligned, // used when the picker lives in the composer action bar (bottom of the screen)// instead of the header. Header usage keeps the default downward/centered menu.@@ -834,7 +806,29 @@ export function ModelSelector({ openUpward = false, surface = 'chat', answeredBy* die Seite, die reicht, die Hoehe, die bleibt, keine Mindesthoehe mehr.*/const menueRef = useRef<HTMLDivElement>(null)- const menue = usePopoverPlatz(menueRef, open, { bevorzugt: openUpward ? 'oben' : 'unten', abstand: 6, luft: 12 })+ // In Cloud mode the menu is the new picker: a fixed head and foot around a+ // list that scrolls by itself, capped in height, and never wider than the+ // area that would cut it.+ const cloudListRef = useRef<HTMLDivElement>(null)+ const cloudPicker = appMode === 'cloud'+ const menue = usePopoverPlatz(menueRef, open, cloudPicker+ ? { bevorzugt: openUpward ? 'oben' : 'unten', abstand: 6, luft: 12, deckel: CLOUD_PICKER_MAX_HEIGHT, rolle: cloudListRef, breiteDeckeln: true }+ : { bevorzugt: openUpward ? 'oben' : 'unten', abstand: 6, luft: 12 })++ // The Cloud picker's search field takes the keyboard when the menu opens.+ // When the menu closes while the keyboard is still in it (a pick, Escape),+ // the keyboard goes back to where it came from: the composer, so Enter+ // sends the kept message, or the trigger.+ const triggerRef = useRef<HTMLButtonElement>(null)+ const focusCameFrom = useRef<HTMLElement | null>(null)+ useEffect(() => {+ if (open || !cloudPicker) return+ const menu = menueRef.current+ if (!menu || !menu.contains(document.activeElement)) return+ const back = focusCameFrom.current+ focusCameFrom.current = null+ ;(back && back.isConnected && back !== document.body ? back : triggerRef.current)?.focus({ preventScroll: true })+ }, [open, cloudPicker])// Keep the per-row On/Off LOAD state LIVE while the dropdown is open// (David 2026-06-12: "on und offload button sehr delayed und nicht immer@@ -1227,6 +1221,9 @@ export function ModelSelector({ openUpward = false, surface = 'chat', answeredByuseEffect(() => {const handler = (e: MouseEvent) => {+ // The rate popover of the Cloud picker is lifted out to the body. It+ // belongs to the menu, so a press on it is not a press outside.+ if (e.target instanceof Element && e.target.closest('[data-model-rate]')) returnif (ref.current && !ref.current.contains(e.target as Node)) setOpen(false)}document.addEventListener('mousedown', handler)@@ -1298,10 +1295,70 @@ export function ModelSelector({ openUpward = false, surface = 'chat', answeredByconst hasOllamaModels = textModels.some(m => ('provider' in m && m.provider === 'ollama') || !('provider' in m))textModelsEmptyRef.current = textModels.length === 0+ // The one reason this picker switches rows off: a pick is already running.+ // Kept as its own name because a refused click hands exactly this to+ // `blockedPickWait`, which is what keeps any future second reason silent+ // (A17).+ const pickInFlight = selectingLms !== null || togglingLms !== null++ // What an empty list says, in both modes. An empty picker after the user+ // switched the last backend off in Settings used to say only "No models+ // available", which reads like a machine with nothing installed+ // (Nebenbefund 1, R9 re-measure). The reason and the way back belong here.+ // Ruhiger Ton aus `lib/hinweis.ts`: der Nutzer hat das Backend selbst+ // ausgeschaltet, das ist kein Zwischenfall, sondern die Antwort auf „warum+ // ist die Liste leer". Der Knopf darunter traegt den Weg zurueck.+ const emptyList = (+ <div className="px-2.5 py-3 text-center">+ <p className="t-micro text-gray-600">No models available</p>+ {noBackendEnabled ? (+ <>+ <p className={`mt-1 t-micro leading-snug text-left ${HINWEIS_TEXT.ruhig}`}>+ No AI backend is enabled, so there is nothing to list. Open Settings, go to AI Backends, and press Enable on the backend you switched off, or Add Provider.+ </p>+ <button+ onClick={() => { setOpen(false); openSettingsAt({ tab: 'backends' }) }}+ className="mt-2 inline-flex items-center gap-1 px-2 py-1 rounded bg-white/5 border border-white/10 t-micro text-gray-300 hover:bg-white/10 transition-colors"+ >+ <SettingsIcon size={10} /> Open Settings+ </button>+ </>+ ) : emptyReason && (+ <p className={`mt-1 t-micro leading-snug text-left ${HINWEIS_TEXT.ruhig}`}>{emptyReason}</p>+ )}+ </div>+ )++ // The lines under the search of the Cloud picker: what needs attention now.+ // Same sentences and the same test ids as the lines of the local menu.+ const cloudNotes: PickerNote[] = [+ ...(selectError ? [{ testId: 'model-picker-error', text: selectError, tone: 'error' as const }] : []),+ ...(engineSwitchNote ? [{+ testId: 'picker-engine-note',+ text: engineSwitchNote,+ tone: engineSwitchTone === 'error' ? 'error' as const : 'info' as const,+ onDismiss: () => useLuEngineSwitchStore.getState().dismiss(),+ }] : []),+ // In Cloud the app picks no model by itself, so a menu without a pick is+ // the normal state of a new account there. The line says what the pick is+ // for; after a send was tried it adds, in the same line, that the message+ // is still in the composer.+ ...(sendNeedsModel+ ? [{+ testId: 'picker-send-needs-model',+ text: textModels.length > 0 ? `${CHOOSE_TO_SEND} ${MESSAGE_IS_KEPT}` : NO_MODEL_LISTED,+ tone: 'info' as const,+ }]+ : !activeModel && textModels.length > 0+ ? [{ testId: 'picker-choose-a-model', text: CHOOSE_TO_SEND, tone: 'info' as const }]+ : []),+ ]+return (<div ref={ref} className="relative">{/* ── Trigger Button ── */}<button+ ref={triggerRef}onClick={() => setOpen(!open)}title={answeredBy@@ -1391,9 +1448,16 @@ export function ModelSelector({ openUpward = false, surface = 'chat', answeredBy{open && (<motion.divdata-testid="model-picker-menu"+ data-picker={cloudPicker ? 'cloud' : 'local'}ref={menueRef}- style={menue.style}- className={`absolute w-72 rounded-lg overflow-x-hidden overflow-y-auto scrollbar-thin z-50 lu-elevated ${+ style={cloudPicker ? { width: CLOUD_PICKER_WIDTH, ...menue.style } : menue.style}+ className={`absolute z-50 lu-elevated ${+ // Cloud: the new picker, a column whose list scrolls by itself.+ // Local: the list as it always was, the menu scrolls as a whole.+ cloudPicker+ ? 'lu-picker flex flex-col overflow-hidden'+ : 'w-72 rounded-lg overflow-x-hidden overflow-y-auto scrollbar-thin'+ } ${menue.nachOben ? 'bottom-full mb-1.5' : 'top-full mt-1.5'} ${openUpward ? 'right-0' : 'left-1/2 -translate-x-1/2'}`}initial={{ opacity: 0, y: menue.nachOben ? 6 : -6, scale: 0.98 }}@@ -1401,26 +1465,32 @@ export function ModelSelector({ openUpward = false, surface = 'chat', answeredByexit={{ opacity: 0, y: menue.nachOben ? 6 : -6, scale: 0.98 }}transition={{ duration: MOTION_S.fast, ease: 'easeOut' }}>+ {cloudPicker ? (+ <CloudModelPicker+ models={textModels}+ activeModel={activeModel}+ loading={!inventoryLoaded}+ notes={cloudNotes}+ hiddenForCode={hiddenForCode}+ empty={emptyList}+ listRef={cloudListRef}+ onPick={(model) => {+ // A17: a pick while another one is running is refused, and+ // says which wait it ran into.+ if (pickInFlight) { announceBlockedPick(pickInFlight); return }+ void handleSelectModel(model)+ }}+ onTookFocus={(from) => { focusCameFrom.current = from }}+ />+ ) : (<>{/* First of all: why the menu opened by itself. The message theuser tried to send is still in the composer. */}- {sendNeedsModel ? (+ {sendNeedsModel && (<divdata-testid="picker-send-needs-model"className={`px-2.5 py-1.5 border-b border-black/5 dark:border-white/[0.06] t-micro leading-snug ${HINWEIS_TEXT.ruhig}`}>- {textModels.length > 0- ? 'Pick a model to send your message. Your text and attachments are kept.'- : 'Your message needs a chat model, and none is listed yet. Your text and attachments are kept.'}- </div>- ) : appMode === 'cloud' && !activeModel && textModels.length > 0 && (- // In Cloud the app picks no model by itself, so a menu without- // a pick is the normal state of a new account there. The line- // says what the pick is for, in the words of the web app.- <div- data-testid="picker-choose-a-model"- className={`px-2.5 py-1.5 border-b border-black/5 dark:border-white/[0.06] t-micro leading-snug ${HINWEIS_TEXT.ruhig}`}- >- {CHOOSE_TO_SEND}+ {textModels.length > 0 ? `${CHOOSE_TO_SEND} ${MESSAGE_IS_KEPT}` : NO_MODEL_LISTED}</div>)}{/* Noch vor der Engine-Zeile: was sich am Modell selbst geaendert@@ -1483,15 +1553,6 @@ export function ModelSelector({ openUpward = false, surface = 'chat', answeredBy"can't choose any models i have installed" symptom. */}<LmStudioServerHint onStarted={fetchModels} />- {/* Same honesty as the hiddenForCode note below: in Cloud mode the- local models are hidden on purpose, so say so instead of- letting an empty local section read as a bug (G20). */}- {appMode === 'cloud' && (- <div className="px-2.5 py-1.5 border-b border-black/5 dark:border-white/[0.06] text-[0.55rem] text-gray-500">- Cloud mode shows hosted models only. Switch the app to Local mode to use Ollama, LM Studio or the LU Engine.- </div>- )}-{/* K6: grouping threw and was caught above instead of crashing thewhole chat view. Says so, in the dropdown itself, with a wayto try again, the fallback list below still works, this is@@ -1547,35 +1608,7 @@ export function ModelSelector({ openUpward = false, surface = 'chat', answeredBy{/* Scrollable model list */}<div className="py-1 max-h-[280px] overflow-y-auto scrollbar-thin">{!inventoryLoaded && textModels.length === 0 && <ModelPickerSkeleton />}- {inventoryLoaded && textModels.length === 0 && (- <div className="px-2.5 py-3 text-center">- <p className="t-micro text-gray-600">No models available</p>- {/* An empty picker after the user switched the last backend- off in Settings used to say only that, which reads like a- machine with nothing installed (Nebenbefund 1, R9- re-measure). The reason and the way back belong here.- Beide Saetze standen in Gelb. Der Nutzer hat das Backend- selbst ausgeschaltet; das ist kein Zwischenfall, sondern- die Antwort auf „warum ist die Liste leer". Ruhiger Ton- aus `lib/hinweis.ts`, der Knopf darunter traegt den- Weg zurueck. */}- {noBackendEnabled ? (- <>- <p className={`mt-1 t-micro leading-snug text-left ${HINWEIS_TEXT.ruhig}`}>- No AI backend is enabled, so there is nothing to list. Open Settings, go to AI Backends, and press Enable on the backend you switched off, or Add Provider.- </p>- <button- onClick={() => { setOpen(false); openSettingsAt({ tab: 'backends' }) }}- className="mt-2 inline-flex items-center gap-1 px-2 py-1 rounded bg-white/5 border border-white/10 t-micro text-gray-300 hover:bg-white/10 transition-colors"- >- <SettingsIcon size={10} /> Open Settings- </button>- </>- ) : emptyReason && (- <p className={`mt-1 t-micro leading-snug text-left ${HINWEIS_TEXT.ruhig}`}>{emptyReason}</p>- )}- </div>- )}+ {inventoryLoaded && textModels.length === 0 && emptyList}{groups.map(({ family, models: groupModels }) => (<div key={family}>@@ -1612,11 +1645,6 @@ export function ModelSelector({ openUpward = false, surface = 'chat', answeredBy// a <button>. A <button> can't nest a <button> (invalid HTML →// React hydration error + flaky clicks), so the row is a// role="button" <div> with explicit keyboard activation.- // The one reason this picker switches rows off: a pick is- // already running. Kept as its own name because the click- // below hands exactly this to `blockedPickWait`, which is- // what keeps any future second reason silent (A17).- const pickInFlight = selectingLms !== null || togglingLms !== nullconst rowDisabled = pickInFlightreturn (@@ -1826,6 +1854,7 @@ export function ModelSelector({ openUpward = false, surface = 'chat', answeredBy</button></div>)}+ </>)}</motion.div>)}</AnimatePresence>diff --git a/src/components/models/__tests__/cloud-model-picker.test.tsx b/src/components/models/__tests__/cloud-model-picker.test.tsxnew file mode 100644index 00000000..4914d4d0--- /dev/null+++ b/src/components/models/__tests__/cloud-model-picker.test.tsx@@ -0,0 +1,535 @@+// @vitest-environment jsdom+/**+ * The new model picker in Cloud mode, on the real component.+ *+ * 05.10.2026, David's decisions on the approved draft: grouped by family with+ * one-line heads, a search on top, chips that narrow the list, a footer with+ * the count, and a keyboard that works from the search field. The row shows+ * the name, the measured mark, vision, thinking and the context window the+ * server stated. It shows NO credit column: a tiny question mark at the end of+ * the row opens the model's credit rates per one million tokens, input and+ * output apart.+ *+ * HARD RULE held at the bottom of this file: credits per token count only,+ * never a money amount, never how many tokens a sum of money buys.+ *+ * Run: npx vitest run src/components/models/__tests__/cloud-model-picker.test.tsx+ */+import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'+import { cleanup, fireEvent, render, screen } from '@testing-library/react'+import { readFileSync } from 'node:fs'+import { resolve } from 'node:path'+import { PICKER_FIXTURE, pickerFixtureModels } from '../../../lib/__tests__/model-picker-fixture'+import type { ModelSelectorProps } from '../ModelSelector'++const setActiveModel = vi.fn()+vi.mock('../../../hooks/useModels', async () => {+ const { useModelStore: store } = await import('../../../stores/modelStore')+ return {+ useModels: () => ({+ models: store((s) => s.models),+ activeModel: store((s) => s.activeModel),+ setActiveModel,+ fetchModels: async () => {},+ }),+ }+})+vi.mock('../../../api/lmstudio', () => ({+ loadLmStudioModel: vi.fn(async () => {}),+ unloadLmStudioModel: vi.fn(async () => {}),+ listLoadedLmStudioModels: vi.fn(async () => [] as string[]),+}))+vi.mock('../../../api/ollama', () => ({+ listRunningModels: vi.fn(async () => [] as string[]),+ loadModel: vi.fn(async () => {}),+ unloadModel: vi.fn(async () => {}),+ unloadAllModels: vi.fn(async () => {}),+}))+const backendCall = vi.fn(async (_cmd: string): Promise<unknown> => null)+vi.mock('../../../api/backend', () => ({ backendCall: (cmd: string) => backendCall(cmd) }))+vi.mock('../../../api/builtin-ensure', () => ({ diagnoseBuiltinEngine: vi.fn(async () => null) }))++const { ModelSelector } = await import('../ModelSelector')+const { useModelStore } = await import('../../../stores/modelStore')+const { useSettingsStore } = await import('../../../stores/settingsStore')+const { useCloudAuthStore } = await import('../../../stores/cloudAuthStore')+const { useUIStore } = await import('../../../stores/uiStore')+const { useLuEngineSwitchStore } = await import('../../../stores/luEngineSwitchStore')+const { DEFAULT_SETTINGS } = await import('../../../lib/constants')++const MODELS = pickerFixtureModels()+const TOTAL = PICKER_FIXTURE.length+const ACTIVE = 'lu-cloud::Qwen/Qwen3.6-27B'++const trigger = () => screen.getByRole('button', { name: 'Select chat model' })+const menu = () => screen.getByTestId('model-picker-menu')+const search = () => screen.getByTestId('model-picker-search') as HTMLInputElement+const isOpen = () => trigger().getAttribute('aria-expanded') === 'true'+const rows = () => Array.from(menu().querySelectorAll<HTMLElement>('[role="option"]'))+const labels = () => rows().map((r) => r.querySelector('.lu-picker-name')!.textContent)+const heads = () => Array.from(menu().querySelectorAll<HTMLElement>('.lu-picker-head b')).map((b) => b.textContent)+const chip = (f: string) => menu().querySelector<HTMLElement>(`[data-chip="${f}"]`)+const count = () => screen.getByTestId('model-picker-count').textContent+const cursorRow = () => menu().querySelector<HTMLElement>('[role="option"][data-cursor="true"]')+const row = (label: string) => rows().find((r) => r.querySelector('.lu-picker-name')!.textContent === label)!+const rateButton = (label: string) => row(label).querySelector<HTMLButtonElement>('.lu-picker-rate-btn')+const ratePopover = () => screen.queryByTestId('model-rate-popover')+const type = (text: string) => fireEvent.change(search(), { target: { value: text } })+const key = (k: string) => fireEvent.keyDown(document.activeElement ?? search(), { key: k })++function signIn(paidPlan: boolean | null) {+ useCloudAuthStore.getState().setSignedIn(+ { id: 'u1' },+ { licenseActive: true, tier: 'hosted', access: true, quota: null, paidPlan },+ )+}++function open(active: string | null = ACTIVE, props: ModelSelectorProps = {}) {+ useModelStore.setState({ models: MODELS, activeModel: active, inventoryLoaded: true } as never)+ render(<ModelSelector openUpward {...props} />)+ fireEvent.click(trigger())+}++beforeEach(() => {+ cleanup()+ setActiveModel.mockClear()+ backendCall.mockClear()+ backendCall.mockImplementation(async () => null)+ useSettingsStore.setState({ settings: { ...DEFAULT_SETTINGS, appMode: 'cloud' } })+ useModelStore.setState({ models: [], activeModel: null, foldedRows: null, inventoryLoaded: true } as never)+ useLuEngineSwitchStore.getState().dismiss()+ useUIStore.setState({ modelAskSeq: 0 })+ signIn(true)+})+afterEach(() => { cleanup() })++describe('the open picker', () => {+ it('is the Cloud picker, not the local list', () => {+ open()+ expect(menu().getAttribute('data-picker')).toBe('cloud')+ expect(menu().className).toContain('lu-picker')+ expect(menu().querySelectorAll('[role="button"]')).toHaveLength(0)+ })++ it('lists every model under one-line family heads, Other last', () => {+ open()+ expect(rows()).toHaveLength(TOTAL)+ expect(heads()).toEqual(['Qwen', 'DeepSeek', 'Llama', 'Other'])+ expect(count()).toBe(`${TOTAL} cloud models`)+ })++ it('writes the head count next to the family', () => {+ open()+ expect(menu().querySelector('[data-family="Qwen"] .n')!.textContent).toBe('4')+ expect(menu().querySelector('[data-family="Other"] .n')!.textContent).toBe('2')+ })++ it('shows the catalogue label on the row and on the trigger, the id in the hover', () => {+ open()+ expect(trigger().textContent).toContain('Qwen 3.6 27B')+ expect(row('Qwen 3.6 27B').getAttribute('title')).toBe('Qwen/Qwen3.6-27B')+ })++ it('marks the selected row for a screen reader and puts the cursor on it', () => {+ open()+ expect(row('Qwen 3.6 27B').getAttribute('aria-selected')).toBe('true')+ expect(cursorRow()).toBe(row('Qwen 3.6 27B'))+ expect(rows().filter((r) => r.getAttribute('aria-selected') === 'true')).toHaveLength(1)+ })++ it('puts the keyboard into the search field', () => {+ open()+ expect(document.activeElement).toBe(search())+ expect(search().getAttribute('aria-activedescendant')).toBe(cursorRow()!.id)+ })++ it('says in the footer that the list is the hosted one, and how to get the local one', () => {+ open()+ expect(screen.getByTestId('model-picker-count').getAttribute('title'))+ .toBe('Cloud mode shows hosted models only. Switch the app to Local mode to use Ollama, LM Studio or the LU Engine.')+ })++ it('has no LM Studio line and no unload button: those belong to the local list', async () => {+ backendCall.mockImplementation(async (cmd) => cmd === 'lmstudio_server_status'+ ? { running: false, port: 1234, lms_present: true, models_detected: true, model_count: 7 }+ : null)+ open()+ await Promise.resolve()+ expect(screen.queryByTestId('lmstudio-status-line')).toBeNull()+ expect(menu().textContent).not.toMatch(/Unload all/)+ })+})++describe('a row', () => {+ it('carries the measured mark only where it was measured full', () => {+ open()+ expect(row('Qwen 3.6 27B').querySelector('[data-mark="unfiltered"]')!.textContent).toBe('No refusals')+ expect(row('Qwen3 30B A3B').querySelector('[data-mark="unfiltered"]')).toBeNull()+ expect(row('Llama 4 Scout').querySelector('[data-mark="unfiltered"]')).toBeNull()+ })++ it('shows the eye and the bulb only where the server stated them', () => {+ open()+ expect(row('Qwen 3.6 27B').querySelector('[data-icon="vision"] svg')).toBeTruthy()+ expect(row('Qwen 3.6 27B').querySelector('[data-icon="thinking"] svg')).toBeTruthy()+ expect(row('Llama 3.1 8B Turbo').querySelector('[data-icon="vision"]')).toBeNull()+ expect(row('Llama 3.1 8B Turbo').querySelector('[data-icon="thinking"]')).toBeNull()+ })++ it('prints the context window in the app spelling, and leaves it empty where none was stated', () => {+ open()+ expect(row('Qwen 3.6 27B').querySelector('[data-context]')!.textContent).toBe('256K')+ expect(row('Qwen3 30B A3B').querySelector('[data-context]')!.textContent).toBe('40K')+ // Kimi K3 budgets with 8192 in the fixture. That number is not printed.+ expect(row('Kimi K3').querySelector('[data-context]')!.textContent).toBe('')+ })++ it('says on a tight context window that Agent and Code will not fit', () => {+ open()+ expect(row('MythoMax L2 13B').querySelector('[data-context]')!.getAttribute('title')).toMatch(/too small/)+ expect(row('Qwen 3.6 27B').querySelector('[data-context]')!.getAttribute('title')).toBeNull()+ })++ it('tags a model that cannot call tools as chat only', () => {+ open()+ expect(row('MythoMax L2 13B').querySelector('[data-mark="chat-only"]')!.textContent).toBe('Chat only')+ expect(row('Qwen 3.6 27B').querySelector('[data-mark="chat-only"]')).toBeNull()+ })++ it('has no credit column and no "No credits" word in the row', () => {+ open()+ for (const r of rows()) {+ expect(r.querySelector('.lu-picker-pick')!.textContent).not.toMatch(/credit/i)+ }+ })++ it('picks its model and closes the menu', () => {+ open()+ fireEvent.click(row('DeepSeek V3.2').querySelector('.lu-picker-pick')!)+ expect(setActiveModel).toHaveBeenCalledWith('lu-cloud::deepseek-ai/DeepSeek-V3.2')+ expect(isOpen()).toBe(false)+ })+})++describe('search', () => {+ it('narrows the list as the user types and drops the heads', () => {+ open()+ type('qwen 3.6')+ expect(labels()).toEqual(['Qwen 3.6 27B'])+ expect(heads()).toEqual([])+ expect(count()).toBe(`1 of ${TOTAL}`)+ })++ it('underlines what the words hit', () => {+ open()+ type('deep')+ expect(Array.from(row('DeepSeek V3.2').querySelectorAll('mark')).map((m) => m.textContent)).toEqual(['Deep'])+ })++ it('finds a model by its id', () => {+ open()+ type('moonshotai')+ expect(labels()).toEqual(['Kimi K3'])+ })++ it('says so when nothing matches, in words the copy rules allow', () => {+ open()+ type('no such model')+ expect(rows()).toHaveLength(0)+ expect(screen.getByTestId('model-picker-no-match').textContent).toBe('No models match. Clear the search or a tag.')+ })++ it('"Clear" empties the field and brings the heads back', () => {+ open()+ type('qwen')+ fireEvent.click(screen.getByRole('button', { name: 'Clear' }))+ expect(search().value).toBe('')+ expect(rows()).toHaveLength(TOTAL)+ expect(heads()).toContain('Qwen')+ })+})++describe('chips', () => {+ it('stand in the fixed order with their counts', () => {+ open()+ const all = Array.from(menu().querySelectorAll<HTMLElement>('[data-chip]'))+ expect(all.map((c) => c.getAttribute('data-chip'))).toEqual(['marked', 'vision', 'thinking', 'free'])+ expect(chip('marked')!.textContent).toBe('No refusals 4')+ expect(chip('vision')!.textContent).toBe('Vision 2')+ expect(chip('thinking')!.textContent).toBe('Thinking 7')+ expect(chip('free')!.textContent).toBe('No credits 1')+ })++ it('narrow the list when pressed and give it back when pressed again', () => {+ open()+ fireEvent.click(chip('marked')!)+ expect(chip('marked')!.getAttribute('aria-pressed')).toBe('true')+ expect(labels()).toEqual(['Qwen 3.6 27B', 'Qwen 3.8 A95B', 'DeepSeek V3.2', 'MythoMax L2 13B'])+ expect(count()).toBe(`4 of ${TOTAL}`)+ fireEvent.click(chip('marked')!)+ expect(chip('marked')!.getAttribute('aria-pressed')).toBe('false')+ expect(rows()).toHaveLength(TOTAL)+ })++ it('combine: two pressed chips must both hold', () => {+ open()+ fireEvent.click(chip('marked')!)+ fireEvent.click(chip('vision')!)+ expect(labels()).toEqual(['Qwen 3.6 27B'])+ })++ it('offer no "No credits" chip to an account that pays for every model', () => {+ signIn(false)+ open()+ expect(chip('free')).toBeNull()+ expect(chip('marked')).toBeTruthy()+ })+})++describe('the keyboard', () => {+ it('moves the cursor with the arrows from the search field, and Enter picks', () => {+ open()+ expect(cursorRow()).toBe(row('Qwen 3.6 27B'))+ key('ArrowDown')+ expect(cursorRow()).toBe(row('Qwen 3.8 A95B'))+ key('ArrowUp')+ key('ArrowUp')+ expect(cursorRow()).toBe(row('Qwen3 32B'))+ key('Enter')+ expect(setActiveModel).toHaveBeenCalledWith('lu-cloud::Qwen/Qwen3-32B')+ expect(isOpen()).toBe(false)+ })++ it('jumps with Home and End while the field is empty', () => {+ open()+ key('End')+ expect(cursorRow()).toBe(rows()[TOTAL - 1])+ key('Home')+ expect(cursorRow()).toBe(rows()[0])+ })++ it('starts at the first hit of a search, and Enter picks it', () => {+ open()+ type('deepseek')+ expect(cursorRow()).toBe(row('DeepSeek V3.2'))+ key('ArrowDown')+ key('Enter')+ expect(setActiveModel).toHaveBeenCalledWith('lu-cloud::deepseek-ai/DeepSeek-R2')+ })++ it('Escape empties the search first and closes the menu second', () => {+ open()+ type('qwen')+ key('Escape')+ expect(search().value).toBe('')+ expect(isOpen()).toBe(true)+ key('Escape')+ expect(isOpen()).toBe(false)+ })++ it('gives the keyboard back to the trigger when the menu closes', () => {+ open()+ trigger().focus()+ cleanup()+ // Opened from the trigger with the keyboard on it.+ useModelStore.setState({ models: MODELS, activeModel: ACTIVE, inventoryLoaded: true } as never)+ render(<ModelSelector openUpward />)+ trigger().focus()+ fireEvent.click(trigger())+ expect(document.activeElement).toBe(search())+ key('Escape')+ expect(document.activeElement).toBe(trigger())+ })++ it('keeps the rows out of the Tab order, the keyboard reaches them through the cursor', () => {+ open()+ for (const r of rows()) {+ expect(r.querySelector('.lu-picker-pick')!.getAttribute('tabindex')).toBe('-1')+ }+ // Exactly one rate control can be tabbed to: the one of the cursor row.+ const tabbable = Array.from(menu().querySelectorAll('.lu-picker-rate-btn')).filter((b) => b.getAttribute('tabindex') === '0')+ expect(tabbable).toHaveLength(1)+ expect(row('Qwen 3.6 27B').contains(tabbable[0])).toBe(true)+ })+})++describe('the rate popover', () => {+ it('is closed until the question mark is pressed', () => {+ open()+ expect(ratePopover()).toBeNull()+ expect(rateButton('Qwen 3.6 27B')!.getAttribute('aria-expanded')).toBe('false')+ })++ it('shows the credit rates of that model per one million tokens, input and output apart', () => {+ open()+ fireEvent.click(rateButton('Qwen 3.6 27B')!)+ const pop = ratePopover()!+ expect(pop.querySelector('h4')!.textContent).toBe('Credits per 1M tokens')+ expect(pop.querySelector('[data-rate="input"]')!.textContent).toBe('32,000')+ expect(pop.querySelector('[data-rate="output"]')!.textContent).toBe('320,000')+ expect(rateButton('Qwen 3.6 27B')!.getAttribute('aria-expanded')).toBe('true')+ expect(rateButton('Qwen 3.6 27B')!.getAttribute('aria-describedby')).toBe(pop.id)+ })++ it('opens from the keyboard: the control is a real button, so focus and Enter press it', () => {+ open()+ const button = rateButton('Qwen 3.6 27B')!+ expect(button.tagName).toBe('BUTTON')+ button.focus()+ // Enter on a focused button is a click in every browser. The menu must+ // not take that Enter for a pick of the cursor row.+ fireEvent.keyDown(button, { key: 'Enter' })+ expect(setActiveModel).not.toHaveBeenCalled()+ fireEvent.click(button)+ expect(ratePopover()).toBeTruthy()+ expect(isOpen()).toBe(true)+ })++ it('does not pick the model and does not close the menu', () => {+ open()+ fireEvent.click(rateButton('DeepSeek R2')!)+ expect(setActiveModel).not.toHaveBeenCalled()+ expect(isOpen()).toBe(true)+ // A press on the popover itself, which is lifted out to the body, is not+ // a press outside the menu.+ fireEvent.mouseDown(ratePopover()!)+ expect(isOpen()).toBe(true)+ })++ it('switches to another row, and closes on a second press', () => {+ open()+ fireEvent.click(rateButton('Qwen 3.6 27B')!)+ fireEvent.click(rateButton('DeepSeek R2')!)+ expect(screen.getAllByTestId('model-rate-popover')).toHaveLength(1)+ expect(ratePopover()!.querySelector('[data-rate="input"]')!.textContent).toBe('50,000')+ fireEvent.click(rateButton('DeepSeek R2')!)+ expect(ratePopover()).toBeNull()+ })++ it('Escape puts the rates away before anything else', () => {+ open()+ fireEvent.click(rateButton('Qwen 3.6 27B')!)+ rateButton('Qwen 3.6 27B')!.focus()+ key('Escape')+ expect(ratePopover()).toBeNull()+ expect(isOpen()).toBe(true)+ })++ it('offers no question mark where the server sent no rates: nothing wrong is shown', () => {+ open()+ expect(rateButton('Kimi K3')).toBeNull()+ expect(rateButton('Qwen 3.6 27B')).toBeTruthy()+ })++ it('offers none at all on a server that does not send the field yet', () => {+ useModelStore.setState({+ models: MODELS.map((m) => ({ ...m, creditRates: undefined, flash: undefined })),+ activeModel: ACTIVE, inventoryLoaded: true,+ } as never)+ render(<ModelSelector openUpward />)+ fireEvent.click(trigger())+ expect(rows()).toHaveLength(TOTAL)+ expect(menu().querySelectorAll('.lu-picker-rate-btn')).toHaveLength(0)+ })++ it('says "No credits" for a Flash model on a paid plan, with the daily number the server sent', () => {+ open()+ fireEvent.click(rateButton('Qwen3 32B')!)+ expect(ratePopover()!.textContent).toBe('No credits on your plan, up to 500,000 tokens per day.')+ })++ it('shows the rates of that same model to an account whose plan does not pay', () => {+ signIn(false)+ open()+ fireEvent.click(rateButton('Qwen3 32B')!)+ expect(ratePopover()!.querySelector('[data-rate="input"]')!.textContent).toBe('10,000')+ })++ // HARD RULE (feedback-keine-token-je-geld): credits per token count only.+ it('never names money: no currency in any popover, and none in the source', () => {+ open()+ for (const m of PICKER_FIXTURE) {+ const button = rateButton(m.label)+ if (!button) continue+ fireEvent.click(button)+ const text = ratePopover()!.textContent!+ expect(text, m.label).not.toMatch(/[$€£]|usd|eur|dollar|cent|price|cost/i)+ expect(text, m.label).not.toMatch(/tokens? (per|for|je) (credit|\d)/i)+ fireEvent.click(button)+ }+ const source = readFileSync(resolve(__dirname, '..', 'CloudModelPicker.tsx'), 'utf8')+ expect(source).not.toMatch(/[$€£]\s?\d|CREDIT_USD|usdPer|perDollar|perEuro/)+ })+})++describe('the line under the search', () => {+ it('says what the pick is for while nothing is picked', () => {+ open(null)+ expect(screen.getByTestId('picker-choose-a-model').textContent).toBe('Choose a model to send your message.')+ expect(screen.queryByTestId('picker-send-needs-model')).toBeNull()+ })++ it('is absent once a model is picked', () => {+ open()+ expect(screen.queryByTestId('picker-choose-a-model')).toBeNull()+ expect(menu().querySelectorAll('.lu-picker-note')).toHaveLength(0)+ })++ it('opens by itself on a send without a model and adds, in the same one line, that the message is kept', async () => {+ useModelStore.setState({ models: MODELS, activeModel: null, inventoryLoaded: true } as never)+ const { rerender } = render(<ModelSelector openUpward />)+ const { act } = await import('@testing-library/react')+ act(() => { useUIStore.getState().askForModel() })+ rerender(<ModelSelector openUpward />)+ expect(isOpen()).toBe(true)+ expect(screen.getByTestId('picker-send-needs-model').textContent)+ .toBe('Choose a model to send your message. Your text and attachments are kept.')+ expect(screen.queryByTestId('picker-choose-a-model')).toBeNull()+ expect(menu().querySelectorAll('.lu-picker-note')).toHaveLength(1)+ })++ it('carries a standing model note with its tone and its way out', async () => {+ const { act } = await import('@testing-library/react')+ open()+ act(() => { useLuEngineSwitchStore.getState().announce('The chat switched models.', 'error') })+ const note = screen.getByTestId('picker-engine-note')+ expect(note.textContent).toBe('The chat switched models.')+ expect(note.closest('.lu-picker-note')!.getAttribute('data-tone')).toBe('error')+ fireEvent.click(screen.getByRole('button', { name: 'Dismiss' }))+ expect(screen.queryByTestId('picker-engine-note')).toBeNull()+ })+})++describe('Code', () => {+ it('leaves out a hosted model that cannot call tools and says so in the footer', () => {+ open(ACTIVE, { surface: 'code' })+ expect(rows()).toHaveLength(TOTAL - 1)+ expect(labels()).not.toContain('MythoMax L2 13B')+ const hidden = screen.getByTestId('model-picker-hidden-for-code')+ expect(hidden.textContent).toBe('1 hidden, no tool calling')+ expect(hidden.getAttribute('title')).toBe('1 cloud model is hidden here because they cannot call tools. They are still in Chat.')+ })++ it('says nothing of it in Chat', () => {+ open()+ expect(screen.queryByTestId('model-picker-hidden-for-code')).toBeNull()+ })+})++describe('loading and empty', () => {+ it('shows a skeleton and no claim while no list has arrived', () => {+ useModelStore.setState({ models: [], activeModel: null, inventoryLoaded: false } as never)+ render(<ModelSelector openUpward />)+ fireEvent.click(trigger())+ expect(screen.getByRole('status').textContent).toContain('Loading model list')+ expect(menu().textContent).not.toContain('No models available')+ })++ it('says that no model is there once the list arrived empty', () => {+ useModelStore.setState({ models: [], activeModel: null, inventoryLoaded: true } as never)+ render(<ModelSelector openUpward />)+ fireEvent.click(trigger())+ expect(menu().textContent).toContain('No models available')+ expect(count()).toBe('0 cloud models')+ })+})diff --git a/src/components/models/__tests__/model-row-marks.test.tsx b/src/components/models/__tests__/model-row-marks.test.tsxindex 1853de69..a07e9e74 100644--- a/src/components/models/__tests__/model-row-marks.test.tsx+++ b/src/components/models/__tests__/model-row-marks.test.tsx@@ -33,15 +33,25 @@ describe('ModelRowMarks', () => {expect(screen.getByText('No refusals')).toBeTruthy()})- // K12 (3.0.1): the Discord report was "can't find it", not "it's wrong",- // plain text at the smallest size on a crowded row, no icon at all. An- // icon is the cheapest signal that survives a quick scan of the list; the- // text itself and the typography ladder step stay unchanged (see the- // comment on the mark in ModelRowMarks.tsx).- it('carries a findable icon, not just plain text (K12)', () => {+ // K12 (3.0.1): the Discord report was "can't find it", not "it's wrong":+ // plain text at the smallest size on a crowded row. First answered with an+ // icon and bold type; since the picker of 3.0.5 the mark is a tag of its+ // own, framed by a hairline and set in the one accent, and the picker has a+ // chip that narrows the list to the marked models.+ it('is a framed tag in the accent, not plain text (K12)', () => {render(<ModelRowMarks model={{ unfiltered: 'full' }} />)- const mark = screen.getByText('No refusals').closest('[data-mark="unfiltered"]')- expect(mark?.querySelector('svg')).toBeTruthy()+ const mark = screen.getByText('No refusals')+ expect(mark.getAttribute('data-mark')).toBe('unfiltered')+ expect(mark.className).toContain('lu-picker-tag')+ expect(mark.className).toContain('is-accent')+ expect(mark.getAttribute('title')).toContain('Measured')+ })++ it('in a picker row shows the measured mark only, the allowance stands behind the question mark', () => {+ signIn(true)+ render(<ModelRowMarks model={{ unfiltered: 'full', flash }} row />)+ expect(screen.getByText('No refusals')).toBeTruthy()+ expect(screen.queryByText(FLASH_MARK_LABEL)).toBeNull()})it('stays silent on partial and on a model with nothing measured', () => {diff --git a/src/hooks/usePopoverPlatz.ts b/src/hooks/usePopoverPlatz.tsindex d9b8182c..b8002bf0 100644--- a/src/hooks/usePopoverPlatz.ts+++ b/src/hooks/usePopoverPlatz.ts@@ -45,6 +45,13 @@ export interface PopoverOptionen {rolle?: RefObject<HTMLElement | null>/** Herausgehoben mit `position: fixed`, an dieser Kante des Ausloesers ausgerichtet. */fest?: 'links' | 'rechts'+ /**+ * Im Baum: breiter als die abschneidende Flaeche wird es nie. Fuer ein+ * Popover mit fester Breite, das breiter sein kann als ein schmales Fenster+ * (die Modellauswahl im Cloud-Modus, 400 px). Der Schub allein rettet dann+ * nur die linke Kante, die rechte bliebe geschnitten.+ */+ breiteDeckeln?: boolean}export interface PopoverLage {@@ -100,7 +107,7 @@ export function usePopoverPlatz(open: boolean,optionen: PopoverOptionen = {},): PopoverLage {- const { bevorzugt = 'unten', abstand = 4, luft = 8, deckel, anker: ankerRef, rolle: rolleRef, fest } = optionen+ const { bevorzugt = 'unten', abstand = 4, luft = 8, deckel, anker: ankerRef, rolle: rolleRef, fest, breiteDeckeln = false } = optionenconst [lage, setLage] = useState<PopoverLage | null>(null)/* `useLayoutEffect` und nicht `useEffect`: die Messung braucht das@@ -159,9 +166,11 @@ export function usePopoverPlatz(nachOben: platz.nachOben,// Beide Raender, weil das Popover links ODER rechts verankert sein// kann: der Rand an der freien Seite bleibt ohne Wirkung.- style: schub === 0- ? { maxHeight: platz.maxHoehe }- : { maxHeight: platz.maxHoehe, marginLeft: schub, marginRight: -schub },+ style: {+ maxHeight: platz.maxHoehe,+ ...(breiteDeckeln ? { maxWidth: Math.max(0, Math.floor(grenze.right - grenze.left - 2 * luft)) } : {}),+ ...(schub === 0 ? {} : { marginLeft: schub, marginRight: -schub }),+ },}}setLage((vorher) => (gleich(vorher, neu) ? vorher : neu))@@ -203,7 +212,7 @@ export function usePopoverPlatz(window.removeEventListener('scroll', beimScrollen, true)beobachter?.disconnect()}- }, [open, popRef, ankerRef, rolleRef, bevorzugt, abstand, luft, deckel, fest])+ }, [open, popRef, ankerRef, rolleRef, bevorzugt, abstand, luft, deckel, fest, breiteDeckeln])return lage ?? { nachOben: bevorzugt === 'oben', style: KEIN_STIL }}diff --git a/src/index.css b/src/index.cssindex 5398ceb4..23a6d927 100644--- a/src/index.css+++ b/src/index.css@@ -1009,6 +1009,340 @@ input:is(box-shadow: var(--shadow-lg);}+/* Model pickers: one row grammar.+ The chat model picker in Cloud mode (components/models/CloudModelPicker)+ and the Create select (components/create/ui/Select) are two components and+ one look: the elevated sheet, a hairline, one-line sticky group heads, a+ 24 px row with the accent bar on the selected one, hairline tags. Greys+ plus the one accent, state dots in green, grey and red, no yellow. Both+ themes are set here through variables, so neither component names a colour+ of its own. Same classes and values as the web app (globals.css). */+/* The rate popover is lifted out to the body, so it brings the palette+ along. So does a tag. */+.lu-picker,+.lu-picker-tag,+.lu-picker-rate {+ --pk-sheet: var(--color-lu-overlay);+ --pk-edge: rgba(255, 255, 255, 0.08);+ --pk-hair: rgba(255, 255, 255, 0.07);+ --pk-hover: rgba(255, 255, 255, 0.07);+ --pk-t1: #f3f4f6;+ --pk-t2: #d1d5db;+ --pk-t3: #9ca3af;+ --pk-accent: var(--color-lu-accent);+ --pk-ok: #34d399;+ --pk-err: #f87171;+ --pk-off: #6b7280;+}+.lu-picker {+ border-radius: 10px;+ color: var(--pk-t2);+}+.light .lu-picker,+.light .lu-picker-tag,+.light .lu-picker-rate {+ --pk-sheet: #ffffff;+ --pk-edge: rgba(0, 0, 0, 0.1);+ --pk-hair: rgba(0, 0, 0, 0.08);+ --pk-hover: rgba(0, 0, 0, 0.05);+ --pk-t1: #111827;+ --pk-t2: #374151;+ --pk-t3: #6b7280;+ --pk-accent: var(--color-lu-cloud);+ --pk-ok: #059669;+ --pk-err: #dc2626;+ --pk-off: #9ca3af;+}++.lu-picker-search {+ flex: none;+ height: 34px;+ display: flex;+ align-items: center;+ gap: 8px;+ padding: 0 10px 0 12px;+ border-bottom: 1px solid var(--pk-hair);+ color: var(--pk-t3);+}+.lu-picker-search input {+ flex: 1;+ min-width: 0;+ height: 100%;+ background: none;+ border: 0;+ box-shadow: none;+ color: var(--pk-t1);+ font-size: var(--text-control);+ /* The field has the keyboard for as long as the menu is open, so a ring+ around it says nothing. The house focus rule reads its width here; the+ lens lights up instead, and the cursor row shows where Enter goes. */+ --lu-focus-w: 0px;+}+.lu-picker-search:focus-within { color: var(--pk-t2); }+.lu-picker-search input::placeholder { color: var(--pk-t3); }+.lu-picker-text-btn {+ flex: none;+ padding: 2px 5px;+ border-radius: 4px;+ font-size: var(--text-label);+ font-weight: 600;+ color: var(--pk-t2);+}+.lu-picker-text-btn:hover:not(:disabled) { color: var(--pk-t1); background: var(--pk-hover); }+.lu-picker-text-btn:disabled { opacity: 0.6; }++/* The one line for what needs attention now. No box: a dot and a sentence. */+.lu-picker-note {+ flex: none;+ min-height: 24px;+ display: flex;+ align-items: center;+ gap: 7px;+ padding: 3px 10px 3px 12px;+ border-bottom: 1px solid var(--pk-hair);+ font-size: var(--text-mono);+ line-height: 1.35;+ color: var(--pk-t2);+}+.lu-picker-note.is-err { color: var(--pk-err); }+.lu-picker-note > span:not(.lu-picker-dot) { flex: 1; min-width: 0; overflow-wrap: anywhere; }++.lu-picker-dot { flex: none; width: 6px; height: 6px; border-radius: 50%; background: var(--pk-off); }+.lu-picker-dot.is-accent { background: var(--pk-accent); }+.lu-picker-dot.is-ok { background: var(--pk-ok); }+.lu-picker-dot.is-err { background: var(--pk-err); }++.lu-picker-chips {+ flex: none;+ height: 30px;+ display: flex;+ align-items: center;+ gap: 2px;+ padding: 0 6px;+ overflow-x: auto;+ scrollbar-width: none;+}+.lu-picker-chips::-webkit-scrollbar { display: none; }+.lu-picker-chip {+ flex: none;+ height: 20px;+ padding: 0 5px;+ border-radius: var(--radius-pill);+ border: 1px solid var(--pk-hair);+ display: inline-flex;+ align-items: center;+ gap: 4px;+ font-size: var(--text-label);+ font-weight: 500;+ color: var(--pk-t3);+ white-space: nowrap;+ transition: background-color 120ms, color 120ms, border-color 120ms;+}+.lu-picker-chip:hover { color: var(--pk-t1); }+.lu-picker-chip[aria-pressed='true'] { background: var(--pk-hover); color: var(--pk-t1); border-color: var(--pk-edge); }+.lu-picker-chip i { font-style: normal; font-variant-numeric: tabular-nums; opacity: 0.7; }++.lu-picker-cap {+ flex: none;+ height: 18px;+ display: flex;+ align-items: center;+ justify-content: space-between;+ padding: 0 40px 0 16px;+ border-bottom: 1px solid var(--pk-hair);+ font-size: var(--text-label);+ font-weight: 500;+ color: var(--pk-t3);+ opacity: 0.8;+}++.lu-picker-list {+ /* Rows measure their place against the list (CloudModelPicker keeps the+ keyboard cursor in view by hand). */+ position: relative;+ flex: 1 1 auto;+ min-height: 0;+ overflow-y: auto;+ overscroll-behavior: contain;+ padding-bottom: 4px;+ scrollbar-width: thin;+ scrollbar-color: var(--pk-edge) transparent;+}+.lu-picker-empty { padding: 18px 16px; font-size: var(--text-mono); color: var(--pk-t3); text-align: center; }++/* Group head: one line of 22 px that sticks to the top while its rows scroll. */+.lu-picker-head {+ position: sticky;+ top: 0;+ z-index: 1;+ height: 22px;+ display: flex;+ align-items: center;+ gap: 7px;+ padding: 0 14px 0 16px;+ background: var(--pk-sheet);+ font-size: var(--text-label);+ color: var(--pk-t3);+}+.lu-picker-head b { font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; white-space: nowrap; }+.lu-picker-head .n { margin-left: auto; font-variant-numeric: tabular-nums; opacity: 0.8; }+div + div > .lu-picker-head { margin-top: 2px; }++.lu-picker-row {+ position: relative;+ display: flex;+ align-items: center;+ gap: 6px;+ min-height: 24px;+ margin: 0 4px;+ padding: 0 6px 0 12px;+ border-radius: 6px;+ font-size: var(--text-control);+ line-height: 1.2;+ color: var(--pk-t2);+ /* The sticky head above must not cover a row the keyboard scrolls to. */+ scroll-margin-top: 24px;+}+.lu-picker-row:hover,+.lu-picker-row[data-cursor='true'] { background: var(--pk-hover); color: var(--pk-t1); }+/* Selected: an option of either picker. */+.lu-picker-row[aria-selected='true'] { color: var(--pk-t1); }+.lu-picker-row[aria-selected='true'] .lu-picker-name { font-weight: 500; }+.lu-picker-row[aria-selected='true']::before {+ content: '';+ position: absolute;+ left: 3px;+ top: 6px;+ bottom: 6px;+ width: 2px;+ border-radius: 2px;+ background: var(--pk-accent);+}+/* The part of a row that picks the model. A button of its own, because the+ row also carries the rate control, and a button cannot hold another one. */+.lu-picker-pick {+ flex: 1;+ min-width: 0;+ align-self: stretch;+ display: flex;+ align-items: center;+ gap: 6px;+ text-align: left;+ color: inherit;+ font-weight: inherit;+}+.lu-picker-row .lu-picker-pick:focus-visible { outline: 0; }+.lu-picker-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }+.lu-picker-name mark {+ background: none;+ color: var(--pk-t1);+ font-weight: 600;+ text-decoration: underline;+ text-decoration-color: var(--pk-accent);+ text-underline-offset: 2px;+}+.lu-picker-sub { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--pk-t3); }+.lu-picker-fill { flex: 1; min-width: 0; }++.lu-picker-tag {+ flex: none;+ display: inline-flex;+ align-items: center;+ height: 14px;+ padding: 0 5px;+ border-radius: 4px;+ border: 1px solid var(--pk-hair);+ font-weight: 500;+ line-height: 1;+ color: var(--pk-t3);+ white-space: nowrap;+}+.lu-picker-tag.is-accent { color: var(--pk-accent); }+.lu-picker-tag.is-bright { color: var(--pk-t1); }+.lu-picker-tag.is-quiet { opacity: 0.7; }++.lu-picker-icons { flex: none; display: grid; grid-template-columns: 14px 14px; column-gap: 4px; color: var(--pk-t3); }+.lu-picker-icons svg { display: block; opacity: 0.85; }+.lu-picker-num {+ flex: none;+ min-width: 38px;+ text-align: right;+ font-size: var(--text-mono);+ font-variant-numeric: tabular-nums;+ color: var(--pk-t3);+ white-space: nowrap;+}+.lu-picker-row:hover .lu-picker-num,+.lu-picker-row[data-cursor='true'] .lu-picker-num,+.lu-picker-row[aria-selected='true'] .lu-picker-num { color: var(--pk-t2); }++/* The tiny question mark at the end of a row: what the model draws. */+/* The slot keeps its width on a row without one, so the context column+ stays in line. */+.lu-picker-rate-anchor { flex: none; width: 14px; height: 14px; display: inline-flex; }+.lu-picker-rate-btn {+ width: 14px;+ height: 14px;+ border-radius: 50%;+ border: 1px solid var(--pk-edge);+ display: inline-grid;+ place-items: center;+ font-size: 9px;+ font-weight: 600;+ line-height: 1;+ color: var(--pk-t3);+}+.lu-picker-rate-btn:hover,+.lu-picker-rate-btn[aria-expanded='true'] { color: var(--pk-t1); border-color: var(--pk-t3); }+/* Lifted out to the body and placed by hooks/usePopoverPlatz, which sets the+ coordinates, the width and the height it may take. */+.lu-picker-rate {+ position: fixed;+ z-index: 100;+ overflow-y: auto;+ padding: 7px 10px 8px;+ border-radius: 8px;+ background: var(--pk-sheet);+ border: 1px solid var(--pk-edge);+ box-shadow: 0 8px 24px -6px rgba(0, 0, 0, 0.45);+ font-size: var(--text-mono);+ font-weight: 400;+ line-height: 1.4;+ color: var(--pk-t2);+ white-space: normal;+ text-align: left;+}+.lu-picker-rate h4 { margin: 0 0 3px; font-size: var(--text-label); font-weight: 500; color: var(--pk-t3); }+.lu-picker-rate dl { margin: 0; min-width: 146px; display: grid; grid-template-columns: 1fr auto; column-gap: 16px; }+.lu-picker-rate > span { display: block; max-width: 220px; }+.lu-picker-rate dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; color: var(--pk-t1); }++.lu-picker-foot {+ flex: none;+ height: 26px;+ display: flex;+ align-items: center;+ gap: 10px;+ padding: 0 10px 0 16px;+ border-top: 1px solid var(--pk-hair);+ font-size: var(--text-label);+ color: var(--pk-t3);+ white-space: nowrap;+}+.lu-picker-foot > span:not(.lu-picker-keys) { min-width: 0; overflow: hidden; text-overflow: ellipsis; }+.lu-picker-keys { margin-left: auto; display: inline-flex; align-items: center; gap: 4px; }+.lu-picker-keys kbd {+ font: inherit;+ font-size: 9px;+ min-width: 14px;+ height: 14px;+ padding: 0 3px;+ border-radius: 3px;+ border: 1px solid var(--pk-hair);+ display: inline-grid;+ place-items: center;+}+/* ─────────────────────────────────────────────────────────────────────`shadow-sm` ist ein Hellmodus-Rezept — eine Regel statt zwoelfCall-Sites (D-T09).diff --git a/src/lib/__tests__/g20-builtin-return-path.test.ts b/src/lib/__tests__/g20-builtin-return-path.test.tsindex 7b9c312e..ea00780b 100644--- a/src/lib/__tests__/g20-builtin-return-path.test.ts+++ b/src/lib/__tests__/g20-builtin-return-path.test.ts@@ -64,9 +64,14 @@ describe('wiring and the second G20 leftover', () => {})it('the picker says WHY local models are hidden in Cloud mode', () => {- const sel = read('../../components/models/ModelSelector.tsx')- expect(sel).toContain('Cloud mode shows hosted models only.')- expect(sel).toContain("appMode === 'cloud' && (")+ // Since the picker of 3.0.5 the sentence stands behind the count in the+ // footer of the Cloud picker ("47 cloud models"), no longer as a standing+ // band over the list. The count names the mode, the hover says the rest.+ const picker = read('../../components/models/CloudModelPicker.tsx')+ expect(picker).toContain('Cloud mode shows hosted models only. Switch the app to Local mode')+ expect(picker).toContain('title={CLOUD_MODE_LIST_NOTE}')+ expect(picker).toMatch(/\$\{rows\.length\} cloud \$\{rows\.length === 1 \? 'model' : 'models'\}/)+ expect(read('../../components/models/ModelSelector.tsx')).toContain("const cloudPicker = appMode === 'cloud'")})it('NEGATIVE CONTROL: the cloud-mode filter itself is untouched, only named', () => {diff --git a/src/lib/__tests__/model-picker-fixture.ts b/src/lib/__tests__/model-picker-fixture.tsnew file mode 100644index 00000000..29b9edbf--- /dev/null+++ b/src/lib/__tests__/model-picker-fixture.ts@@ -0,0 +1,59 @@+import { cloudModelRow } from '../cloud-model-row'+import type { AIModel } from '../../types/models'++/**+ * A small hosted catalogue for the picker tests, in the shape the LU Cloud+ * models route sends it and the model store keeps it. Small on purpose: every+ * row is here for a reason the tests name.+ */+export interface PickerFixtureModel {+ id: string+ label: string+ unfiltered?: 'full' | 'partial'+ vision?: boolean+ think?: 'toggle' | 'always' | 'never'+ /** A Flash model: no credits on a paid plan. */+ flash?: boolean+ /** The context window the server stated. Absent = it stated none. */+ context?: number+ /** Credits per one million tokens [input, output]. Absent = an older server. */+ rates?: [number, number]+ /** false = the server said this model cannot call tools. */+ tools?: boolean+}++export const PICKER_FIXTURE: PickerFixtureModel[] = [+ { id: 'meta-llama/Meta-Llama-3.1-8B-Instruct-Turbo', label: 'Llama 3.1 8B Turbo', think: 'never', context: 131072, rates: [2000, 3000] },+ { id: 'Qwen/Qwen3-30B-A3B', label: 'Qwen3 30B A3B', unfiltered: 'partial', think: 'toggle', context: 40960, rates: [12000, 50000] },+ { id: 'Qwen/Qwen3-32B', label: 'Qwen3 32B', think: 'toggle', flash: true, context: 131072, rates: [10000, 28000] },+ { id: 'Qwen/Qwen3.6-27B', label: 'Qwen 3.6 27B', unfiltered: 'full', vision: true, think: 'toggle', context: 262144, rates: [32000, 320000] },+ { id: 'Qwen/Qwen3.8-A95B', label: 'Qwen 3.8 A95B', unfiltered: 'full', think: 'always', context: 262144, rates: [200000, 600000] },+ { id: 'deepseek-ai/DeepSeek-V3.2', label: 'DeepSeek V3.2', unfiltered: 'full', think: 'toggle', context: 131072, rates: [26000, 38000] },+ { id: 'deepseek-ai/DeepSeek-R2', label: 'DeepSeek R2', think: 'always', context: 131072, rates: [50000, 215000] },+ { id: 'meta-llama/Llama-4-Scout-17B-16E-Instruct', label: 'Llama 4 Scout', unfiltered: 'partial', vision: true, think: 'never', context: 327680, rates: [8000, 30000] },+ // No rates and no context: what an older server sends. One model of its+ // family, so it is listed under Other.+ { id: 'moonshotai/Kimi-K3', label: 'Kimi K3', think: 'toggle' },+ { id: 'Gryphe/MythoMax-L2-13b', label: 'MythoMax L2 13B', unfiltered: 'full', think: 'never', context: 4096, rates: [6500, 6500], tools: false },+]++const FLASH = { dailyTokens: 500_000, defaultMaxOutput: 8192, requestSeconds: 240, billingKey: 'k' }++/** The fixture as the model store holds it after a listing. */+export function pickerFixtureModels(): AIModel[] {+ return PICKER_FIXTURE.map((m) => cloudModelRow({+ id: m.id,+ name: m.label,+ provider: 'lu-cloud',+ providerName: 'LU Cloud',+ // What the app budgets with. Always a number, stated or not.+ contextLength: m.context ?? 8192,+ declaredContext: m.context,+ supportsTools: m.tools ?? true,+ supportsVision: m.vision || undefined,+ thinkMode: m.think,+ unfiltered: m.unfiltered,+ flash: m.flash ? FLASH : undefined,+ creditRates: m.rates ? { inputPerMillion: m.rates[0], outputPerMillion: m.rates[1] } : undefined,+ }))+}diff --git a/src/lib/__tests__/model-picker.test.ts b/src/lib/__tests__/model-picker.test.tsnew file mode 100644index 00000000..f08a0430--- /dev/null+++ b/src/lib/__tests__/model-picker.test.ts@@ -0,0 +1,236 @@+/**+ * The Cloud model picker's logic: rows, chips, search, groups, keyboard.+ *+ * 05.10.2026, the new model picker for Chat, Agent and Code in Cloud mode.+ * The component draws; lib/model-picker decides, and this file holds it+ * against rows in the exact shape the model store keeps them after a listing+ * (lib/cloud-model-row), so nothing here is tested on a shape the app never+ * sees.+ *+ * Run: npx vitest run src/lib/__tests__/model-picker.test.ts+ */+import { describe, expect, it } from 'vitest'+import { cloudModelRow } from '../cloud-model-row'+import { assignFamilies, groupByFamily, modelFamily, OTHER_FAMILY } from '../model-family'+import {+ PICKER_FILTERS, filterCounts, filterRows, formatCreditRate, highlightParts, moveCursor, pickerGroups, pickerRows,+ searchTokens,+ type PickerFilter,+} from '../model-picker'+import { PICKER_FIXTURE, pickerFixtureModels } from './model-picker-fixture'+import type { AIModel } from '../../types/models'++const MODELS = pickerFixtureModels()+const ROWS = pickerRows(MODELS, true)+const only = (...f: PickerFilter[]) => new Set<PickerFilter>(f)+const byLabel = (label: string) => ROWS.find((r) => r.label === label)!+const labels = (rows: { label: string }[]) => rows.map((r) => r.label)++describe('rows', () => {+ it('carry the catalogue label, with the prefixed id as the name the store keeps', () => {+ expect(ROWS).toHaveLength(PICKER_FIXTURE.length)+ expect(byLabel('Qwen 3.6 27B').name).toBe('lu-cloud::Qwen/Qwen3.6-27B')+ expect(byLabel('Qwen 3.6 27B').model).toBe(MODELS.find((m) => m.name === 'lu-cloud::Qwen/Qwen3.6-27B'))+ })++ it('fall back to the id where the server gave no short name', () => {+ const [row] = pickerRows([cloudModelRow({ id: 'a/model', name: 'a/model', provider: 'lu-cloud', providerName: 'LU Cloud' })], null)+ expect(row.label).toBe('a/model')+ })++ it('print a context window only when the server stated one, never the budget fallback', () => {+ // `contextLength` always holds a number to budget with (a table value or a+ // guess from the name). The picker must not print that as a fact.+ const [guessed, stated] = pickerRows([+ cloudModelRow({ id: 'a/one', name: 'One', provider: 'lu-cloud', providerName: 'LU Cloud', contextLength: 8192 }),+ cloudModelRow({ id: 'a/two', name: 'Two', provider: 'lu-cloud', providerName: 'LU Cloud', contextLength: 40960, declaredContext: 40960 }),+ ], null)+ expect(guessed.context).toBeNull()+ expect(stated.context).toBe(40960)+ })++ it('show image and video models nowhere, the picker is for text', () => {+ const image = { name: 'flux.safetensors', model: 'flux', size: 1, format: '', architecture: '', type: 'image' } as unknown as AIModel+ expect(pickerRows([...MODELS.slice(0, 2), image], true)).toHaveLength(2)+ })++ it('read vision and thinking from what the server stated, not from the name', () => {+ expect(byLabel('Qwen 3.6 27B').vision).toBe(true)+ expect(byLabel('Qwen 3.6 27B').thinking).toBe('toggle')+ expect(byLabel('DeepSeek R2').thinking).toBe('always')+ expect(byLabel('Llama 3.1 8B Turbo').vision).toBe(false)+ expect(byLabel('Llama 3.1 8B Turbo').thinking).toBeNull()+ // A name that sounds like a vision model and a server that said nothing.+ const [row] = pickerRows([cloudModelRow({ id: 'x/llava-next', name: 'Llava', provider: 'lu-cloud', providerName: 'LU Cloud' })], null)+ expect(row.vision).toBe(false)+ expect(row.thinking).toBeNull()+ })++ it('carry the credit rates the server sent, and none where it sent none', () => {+ expect(byLabel('Qwen 3.6 27B').rates).toEqual({ inputPerMillion: 32000, outputPerMillion: 320000 })+ expect(byLabel('Kimi K3').rates).toBeNull()+ })++ it('call a hosted model that cannot call tools chat only', () => {+ expect(byLabel('MythoMax L2 13B').chatOnly).toBe(true)+ expect(byLabel('Qwen 3.6 27B').chatOnly).toBe(false)+ })++ it('promise a free model only to an account whose plan pays', () => {+ expect(byLabel('Qwen3 32B').free?.dailyTokens).toBe(500_000)+ for (const plan of [false, null]) {+ expect(pickerRows(MODELS, plan).every((r) => r.free === null), String(plan)).toBe(true)+ }+ })+})++describe('the marks on the rows', () => {+ it('give the mark to the models measured full and to no partial one', () => {+ const marked = labels(ROWS.filter((r) => r.unfiltered))+ expect(marked).toEqual(PICKER_FIXTURE.filter((m) => m.unfiltered === 'full').map((m) => m.label))+ expect(byLabel('Qwen3 30B A3B').unfiltered).toBe(false)+ })+})++describe('chips', () => {+ it('stand in one fixed order', () => {+ expect(PICKER_FILTERS).toEqual(['marked', 'vision', 'thinking', 'free'])+ })++ it('count over the whole list', () => {+ expect(filterCounts(ROWS)).toEqual({+ marked: PICKER_FIXTURE.filter((m) => m.unfiltered === 'full').length,+ vision: PICKER_FIXTURE.filter((m) => m.vision).length,+ thinking: PICKER_FIXTURE.filter((m) => m.think === 'toggle' || m.think === 'always').length,+ free: PICKER_FIXTURE.filter((m) => m.flash).length,+ })+ })++ it('narrow to the rows that pass, and two chips must both pass', () => {+ expect(filterRows(ROWS, '', only('marked')).every((r) => r.unfiltered)).toBe(true)+ const both = filterRows(ROWS, '', only('marked', 'vision'))+ expect(both.length).toBeGreaterThan(0)+ expect(both.every((r) => r.unfiltered && r.vision)).toBe(true)+ expect(both.length).toBeLessThan(filterRows(ROWS, '', only('marked')).length)+ })++ it('keep nothing for "No credits" on an account that pays for every model', () => {+ expect(filterRows(pickerRows(MODELS, false), '', only('free'))).toEqual([])+ expect(filterCounts(pickerRows(MODELS, false)).free).toBe(0)+ })+})++describe('search', () => {+ it('splits into lower case words', () => {+ expect(searchTokens(' Qwen 3.6 ')).toEqual(['qwen', '3.6'])+ expect(searchTokens(' ')).toEqual([])+ })++ it('finds by label, and several words must all match', () => {+ expect(labels(filterRows(ROWS, 'qwen 3.6', only()))).toEqual(['Qwen 3.6 27B'])+ expect(filterRows(ROWS, 'qwen kimi', only())).toEqual([])+ })++ it('finds by the id and by the family too', () => {+ expect(labels(filterRows(ROWS, 'deepseek-ai', only()))).toEqual(['DeepSeek V3.2', 'DeepSeek R2'])+ // MythoMax has no family of its own, it is listed under Other.+ expect(labels(filterRows(ROWS, 'other', only()))).toContain('MythoMax L2 13B')+ })++ it('works together with a chip', () => {+ const hits = filterRows(ROWS, 'qwen', only('marked'))+ expect(hits.length).toBeGreaterThan(0)+ expect(hits.every((r) => r.unfiltered && r.label.toLowerCase().includes('qwen'))).toBe(true)+ })+})++describe('families', () => {+ it('reads the family from the id, whatever prefix the store put in front', () => {+ expect(modelFamily('lu-cloud::Qwen/Qwen3.6-27B')).toBe('Qwen')+ expect(modelFamily('lu-cloud::deepseek-ai/DeepSeek-V3.2')).toBe('DeepSeek')+ expect(modelFamily('lu-cloud::moonshotai/Kimi-K3')).toBe('Kimi')+ expect(modelFamily('lu-cloud::Gryphe/MythoMax-L2-13b')).toBe(OTHER_FAMILY)+ })++ it('gives a family with a single model no head of its own', () => {+ const families = assignFamilies(MODELS.map((m) => m.name))+ expect(families.get('lu-cloud::moonshotai/Kimi-K3')).toBe(OTHER_FAMILY)+ expect(families.get('lu-cloud::Qwen/Qwen3.6-27B')).toBe('Qwen')+ })++ it('puts the groups in the fixed order with Other last, rows as given', () => {+ const groups = pickerGroups(ROWS, false)+ expect(groups.map((g) => g.family)).toEqual(['Qwen', 'DeepSeek', 'Llama', OTHER_FAMILY])+ expect(labels(groups[0].rows)).toEqual(labels(ROWS.filter((r) => r.family === 'Qwen')))+ expect(groups.flatMap((g) => g.rows)).toHaveLength(ROWS.length)+ })++ it('drops the heads while a search is active, in the same row order', () => {+ const grouped = pickerGroups(ROWS, false).flatMap((g) => g.rows)+ const flat = pickerGroups(ROWS, true)+ expect(flat).toHaveLength(1)+ expect(flat[0].family).toBeNull()+ expect(labels(flat[0].rows)).toEqual(labels(grouped))+ })++ it('draws no head over a list of one family, and nothing over an empty one', () => {+ const qwen = ROWS.filter((r) => r.family === 'Qwen')+ expect(pickerGroups(qwen, false)).toEqual([{ family: null, rows: qwen }])+ expect(pickerGroups([], false)).toEqual([])+ })++ it('groups any rows that name a family', () => {+ expect(groupByFamily([{ family: OTHER_FAMILY }, { family: 'GLM' }, { family: 'Qwen' }]).map((g) => g.family))+ .toEqual(['Qwen', 'GLM', OTHER_FAMILY])+ })+})++describe('the keyboard cursor', () => {+ it('moves by one with the arrows and stops at both ends', () => {+ expect(moveCursor(0, 'ArrowDown', 5, false)).toBe(1)+ expect(moveCursor(4, 'ArrowDown', 5, false)).toBe(4)+ expect(moveCursor(1, 'ArrowUp', 5, false)).toBe(0)+ expect(moveCursor(0, 'ArrowUp', 5, false)).toBe(0)+ })++ it('moves by ten with Page Up and Page Down', () => {+ expect(moveCursor(2, 'PageDown', 47, false)).toBe(12)+ expect(moveCursor(44, 'PageDown', 47, false)).toBe(46)+ expect(moveCursor(12, 'PageUp', 47, false)).toBe(2)+ expect(moveCursor(3, 'PageUp', 47, false)).toBe(0)+ })++ it('jumps with Home and End only while the search field is empty', () => {+ expect(moveCursor(7, 'Home', 47, false)).toBe(0)+ expect(moveCursor(7, 'End', 47, false)).toBe(46)+ expect(moveCursor(7, 'Home', 47, true)).toBeNull()+ expect(moveCursor(7, 'End', 47, true)).toBeNull()+ })++ it('leaves every other key alone, and an empty list too', () => {+ expect(moveCursor(3, 'a', 47, false)).toBeNull()+ expect(moveCursor(3, 'Enter', 47, false)).toBeNull()+ expect(moveCursor(0, 'ArrowDown', 0, false)).toBe(0)+ })+})++describe('the underline of a hit', () => {+ it('cuts the label into hit and miss', () => {+ expect(highlightParts('Qwen 3.6 27B', ['qwen', '27'])).toEqual([+ { text: 'Qwen', hit: true }, { text: ' 3.6 ', hit: false }, { text: '27', hit: true }, { text: 'B', hit: false },+ ])+ })++ it('returns the label whole without a search', () => {+ expect(highlightParts('Kimi K3', [])).toEqual([{ text: 'Kimi K3', hit: false }])+ })+})++describe('a credit rate', () => {+ it('is printed as whole credits with digit groups, and carries no money sign', () => {+ expect(formatCreditRate(32000)).toBe('32,000')+ expect(formatCreditRate(1234567.4)).toBe('1,234,567')+ expect(formatCreditRate(0)).toBe('0')+ expect(formatCreditRate(320000)).not.toMatch(/[$€£]|usd|eur/i)+ })+})diff --git a/src/lib/cloud-model-row.ts b/src/lib/cloud-model-row.tsindex 3650b66d..5ead1036 100644--- a/src/lib/cloud-model-row.ts+++ b/src/lib/cloud-model-row.ts@@ -29,6 +29,8 @@ export function cloudModelRow(pm: ProviderModel): CloudModel {thinkMode: pm.thinkMode,effortLevels: pm.effortLevels,effortDefault: pm.effortDefault,+ declaredContext: pm.declaredContext,+ creditRates: pm.creditRates,// Friendly server label (LU Cloud). Pickers prefer it over the raw id.displayName: pm.name !== pm.id ? pm.name : undefined,}diff --git a/src/lib/model-family.ts b/src/lib/model-family.tsnew file mode 100644index 00000000..c706c3d7--- /dev/null+++ b/src/lib/model-family.ts@@ -0,0 +1,85 @@+// Model families, the grouping of the chat model picker.+//+// Users pick by lineage first (Qwen, DeepSeek, GLM ...); which backend serves+// a model is a detail of the row. Grouping is purely visual: name and provider+// still resolve chat routing exactly as before.++// Normalize a model name into a comparable base form:+// openai::qwen3.6-27b -> qwen3.6-27b+// richardyoung/qwen3-14b:... -> qwen3-14b+// Qwen3.6-27B-Q4_K_M.gguf -> qwen3.6-27b-q4_k_m.gguf+function normalizeModelName(name: string): string {+ return (name || '')+ .toLowerCase()+ .replace(/^[^:]+::/, '') // strip openai:: / anthropic::+ .replace(/^[^/]+\//, '') // strip repo-author/ prefix+ .replace(/:.+$/, '') // strip :tag suffix+}++// Ordered, first match wins. Prefixes on the normalized name.+const FAMILY_MATCHERS: Array<{ family: string; test: RegExp }> = [+ { family: 'Qwen', test: /^qwen|^qwq/ },+ { family: 'DeepSeek', test: /^deepseek/ },+ { family: 'GLM', test: /^glm|^chatglm|^zai/ },+ { family: 'Kimi', test: /^kimi|^moonshot/ },+ { family: 'Llama', test: /^llama|^meta[-_]?llama/ },+ { family: 'Gemma', test: /^gemma/ },+ { family: 'MiniMax', test: /^minimax/ },+ { family: 'Hermes', test: /^hermes|^nous-/ },+ { family: 'gpt-oss', test: /^gpt-oss/ },+ { family: 'Mistral', test: /^mistral|^mixtral/ },+ { family: 'Phi', test: /^phi-?\d|^phi_?\d/ },+ { family: 'Dolphin', test: /^dolphin/ },+ { family: 'Yi', test: /^yi-/ },+ { family: 'Command', test: /^command/ },+ { family: 'Claude', test: /^claude/ },+ { family: 'GPT / o-series', test: /^gpt-|^o1-|^o3-/ },+ { family: 'Gemini', test: /^gemini/ },+ { family: 'Grok', test: /^grok/ },+]++/** Everything without a family of its own, always the last group. */+export const OTHER_FAMILY = 'Other'++/** Display order of the groups: the matcher order above, then 'Other'. */+const FAMILY_RANK: Record<string, number> = Object.fromEntries(FAMILY_MATCHERS.map((m, i) => [m.family, i]))++export function modelFamily(modelName: string): string {+ const n = normalizeModelName(modelName)+ for (const { family, test } of FAMILY_MATCHERS) {+ if (test.test(n)) return family+ }+ return OTHER_FAMILY+}++/**+ * The family each name is listed under.+ *+ * A family with a single model does not get a head of its own: it goes to+ * 'Other'. A head over one row is a line of chrome that says what the row+ * already says, and a list of seven local models used to need four of them.+ * Decided over the WHOLE list, before any search or filter, so a model does+ * not change its group while the user narrows the list.+ */+export function assignFamilies(names: readonly string[]): Map<string, string> {+ const count = new Map<string, number>()+ for (const name of names) {+ const family = modelFamily(name)+ count.set(family, (count.get(family) ?? 0) + 1)+ }+ return new Map(names.map((name) => {+ const family = modelFamily(name)+ return [name, (count.get(family) ?? 0) > 1 ? family : OTHER_FAMILY]+ }))+}++/** Rows in family groups, groups in display order, rows in the order given. */+export function groupByFamily<T extends { family: string }>(rows: readonly T[]): { family: string; rows: T[] }[] {+ const groups = new Map<string, T[]>()+ for (const row of rows) groups.set(row.family, [...(groups.get(row.family) ?? []), row])+ const rank = (family: string) =>+ family === OTHER_FAMILY ? Number.MAX_SAFE_INTEGER : FAMILY_RANK[family] ?? Number.MAX_SAFE_INTEGER - 1+ return [...groups.entries()]+ .sort(([a], [b]) => rank(a) - rank(b) || a.localeCompare(b))+ .map(([family, grouped]) => ({ family, rows: grouped }))+}diff --git a/src/lib/model-picker.ts b/src/lib/model-picker.tsnew file mode 100644index 00000000..df8cb86e--- /dev/null+++ b/src/lib/model-picker.ts@@ -0,0 +1,183 @@+// What the chat model picker shows in Cloud mode and how it narrows, without+// any surface.+//+// The component (components/models/CloudModelPicker) draws; this file decides.+// Kept pure so the search, the filters, the grouping and the keyboard can be+// held by tests that need no DOM. Same rules as the web app's lib/model-picker.++import type { AIModel } from '../types/models'+import type { CreditRates } from '../api/providers/types'+import type { FlashPolicy } from './flash-ui'+import { displayModelName } from '../api/providers/model-name'+import { resolveToolSupport } from './tool-support'+import { traegtDieMarke } from './unfiltered-mark'+import { assignFamilies, groupByFamily } from './model-family'++export type PickerFilter = 'marked' | 'vision' | 'thinking' | 'free'++/** The order the filter chips stand in. */+export const PICKER_FILTERS: readonly PickerFilter[] = ['marked', 'vision', 'thinking', 'free']++export interface PickerRow {+ /** The store's name for the model, what setActiveModel takes. */+ name: string+ /** The store's row, handed back to the pick. */+ model: AIModel+ /** What the row reads: the catalogue's short name, or the id. */+ label: string+ family: string+ /** Carries the measured "No refusals" mark. */+ unfiltered: boolean+ vision: boolean+ /** 'always' = reasons on every turn, 'toggle' = on request, null = never or+ * not stated. */+ thinking: 'toggle' | 'always' | null+ /** No credits on THIS account: a Flash model and a paid plan, both. */+ free: FlashPolicy | null+ /** Context window in tokens as the server stated it. null when it stated+ * none: the column then stays empty, no default is invented. */+ context: number | null+ /** Credits per one million tokens from the server. null on a server that+ * does not send them yet, and then the row offers no rate control. */+ rates: CreditRates | null+ /** Cannot call tools, so Agent and Code cannot use it. */+ chatOnly: boolean+}++function declared<K extends string>(model: AIModel, key: K): unknown {+ return key in model ? (model as unknown as Record<K, unknown>)[key] : undefined+}++function thinkingOf(model: AIModel): PickerRow['thinking'] {+ const stated = declared(model, 'thinkMode')+ return stated === 'toggle' || stated === 'always' ? stated : null+}++/** The rows of the picker, text models only, in the order the store has them.+ * `paidPlan` is the account's answer (lib/flash-entitlement); anything but+ * true promises no free model. Only what the server stated is printed: a+ * hosted row gets no eye, no bulb and no context figure from its name. */+export function pickerRows(models: readonly AIModel[], paidPlan: boolean | null): PickerRow[] {+ const text = models.filter((m) => m.type === 'text')+ const families = assignFamilies(text.map((m) => m.name))+ return text.map((model) => {+ const context = declared(model, 'declaredContext')+ const flash = declared(model, 'flash') as FlashPolicy | undefined+ const label = declared(model, 'displayName')+ const tools = declared(model, 'supportsTools')+ return {+ name: model.name,+ model,+ label: typeof label === 'string' && label ? label : displayModelName(model.name),+ family: families.get(model.name)!,+ unfiltered: traegtDieMarke(declared(model, 'unfiltered') as 'full' | 'partial' | undefined),+ vision: declared(model, 'supportsVision') === true,+ thinking: thinkingOf(model),+ free: flash && paidPlan === true ? flash : null,+ context: typeof context === 'number' && context > 0 ? context : null,+ rates: (declared(model, 'creditRates') as CreditRates | undefined) ?? null,+ chatOnly: resolveToolSupport({+ name: model.name,+ supportsTools: typeof tools === 'boolean' ? tools : undefined,+ }) === 'none',+ }+ })+}++const FILTER_TEST: Record<PickerFilter, (row: PickerRow) => boolean> = {+ marked: (row) => row.unfiltered,+ vision: (row) => row.vision,+ thinking: (row) => row.thinking !== null,+ free: (row) => row.free !== null,+}++/** How many rows each filter would keep, counted over the whole list so the+ * number on a chip does not move while another chip is pressed. */+export function filterCounts(rows: readonly PickerRow[]): Record<PickerFilter, number> {+ return Object.fromEntries(+ PICKER_FILTERS.map((f) => [f, rows.filter(FILTER_TEST[f]).length]),+ ) as Record<PickerFilter, number>+}++/** The words of a search, lower case. Several words must ALL match. */+export function searchTokens(query: string): string[] {+ return query.toLowerCase().split(/\s+/).filter(Boolean)+}++/** Rows that pass every pressed filter and every search word. A word is looked+ * for in the label, the family and the id, so "qwen 3.5" and "deepseek-ai"+ * both find what they name. */+export function filterRows(+ rows: readonly PickerRow[],+ query: string,+ filters: ReadonlySet<PickerFilter>,+): PickerRow[] {+ const tokens = searchTokens(query)+ return rows.filter((row) => {+ for (const f of filters) if (!FILTER_TEST[f](row)) return false+ const hay = `${row.label} ${row.family} ${displayModelName(row.name)}`.toLowerCase()+ return tokens.every((t) => hay.includes(t))+ })+}++export interface PickerGroup {+ /** null = no head: a search is active, or there is only one family. */+ family: string | null+ rows: PickerRow[]+}++/** The visible list. Grouped by family with one head per group; a search+ * drops the heads, because the result is a hit list and not a catalogue. In+ * both cases the rows stand in family order, so the flat list and the grouped+ * one do not shuffle against each other. */+export function pickerGroups(rows: readonly PickerRow[], searching: boolean): PickerGroup[] {+ const groups = groupByFamily(rows)+ if (groups.length === 0) return []+ if (searching || groups.length === 1) return [{ family: null, rows: groups.flatMap((g) => g.rows) }]+ return groups+}++/** How far Page Up and Page Down move the cursor. */+const PAGE = 10++/**+ * Where the keyboard cursor goes for `key`, or null when the key is not a+ * cursor key. Home and End belong to the text field while it holds a query,+ * so they only move the cursor when the search is empty.+ */+export function moveCursor(cursor: number, key: string, count: number, searching: boolean): number | null {+ const last = Math.max(0, count - 1)+ switch (key) {+ case 'ArrowDown': return Math.min(last, cursor + 1)+ case 'ArrowUp': return Math.max(0, cursor - 1)+ case 'PageDown': return Math.min(last, cursor + PAGE)+ case 'PageUp': return Math.max(0, cursor - PAGE)+ case 'Home': return searching ? null : 0+ case 'End': return searching ? null : last+ default: return null+ }+}++/** A label cut into the stretches a search word hits and the ones it misses,+ * for the underline in the list. */+export function highlightParts(label: string, tokens: readonly string[]): { text: string; hit: boolean }[] {+ const lower = label.toLowerCase()+ const hit = new Array<boolean>(label.length).fill(false)+ for (const t of tokens) {+ for (let at = lower.indexOf(t); at !== -1; at = lower.indexOf(t, at + t.length)) {+ hit.fill(true, at, at + t.length)+ }+ }+ const parts: { text: string; hit: boolean }[] = []+ for (let i = 0; i < label.length; i++) {+ const tail = parts[parts.length - 1]+ if (tail && tail.hit === hit[i]) tail.text += label[i]+ else parts.push({ text: label[i], hit: hit[i] })+ }+ return parts+}++/** The one line a rate popover prints per direction: whole credits, grouped. */+export function formatCreditRate(credits: number): string {+ return Math.round(credits).toLocaleString('en-US')+}diff --git a/src/lib/unfiltered-mark.ts b/src/lib/unfiltered-mark.tsnew file mode 100644index 00000000..bbf83f74--- /dev/null+++ b/src/lib/unfiltered-mark.ts@@ -0,0 +1,22 @@+import type { CloudModel } from '../types/models'++/**+ * Wer die Marke "No refusals" traegt, an genau einer Stelle.+ *+ * Streng: nur ein Modell, das der Server als `full` gemessen meldet, traegt+ * die Marke. Der Messwert `partial` reist weiter im Katalog, aber keine+ * Flaeche macht daraus eine Marke: eine Marke, die manchmal stimmt, ist im+ * Kaufmoment schlimmer als keine, weil der Kunde sie als Zusage liest.+ *+ * Die Messung selbst steht in `no-refusals-measurement.md` neben dieser Datei.+ */+export function traegtDieMarke(unfiltered: CloudModel['unfiltered'] | null | undefined): boolean {+ return unfiltered === 'full'+}++/** Der Wortlaut der Marke und ihr Hovertext, an genau einer Stelle: die Zeile+ * der Modellauswahl, die Eingabezeile und der Filter im Waehler lesen ihn+ * hier. Zeichengleich mit dem Web. */+export const UNFILTERED_MARK_LABEL = 'No refusals'+export const UNFILTERED_MARK_TITLE =+ "Measured: this model answers without refusing. Your account's content policy still applies."diff --git a/src/types/models.ts b/src/types/models.tsindex 153dbdfb..bd15b4d8 100644--- a/src/types/models.ts+++ b/src/types/models.ts@@ -46,6 +46,13 @@ export interface CloudModel {* fixed behaviour. See lib/effort.ts. */effortLevels?: string[]effortDefault?: string+ /** The context window the server stated in its listing. Absent when it+ * stated none; `contextLength` may then hold a table value or a guess,+ * which is fine for a budget and wrong for a printed figure. */+ declaredContext?: number+ /** Credits per one million tokens, input and output apart, as LU Cloud+ * states them. Shown in the picker's rate popover and nowhere else. */+ creditRates?: import('../api/providers/types').CreditRates/** Friendly picker label when the server provides one (LU Cloud /models* `name`) — pickers fall back to the raw id otherwise. */displayName?: string