The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.
Rust agent-orchestrationai-agentsai-assistantdesktopllmlocal-firstmcppersonal-aiprivacyrustsecond-braintauri
fix(settings): correct provider model picker dialog test and Playwright specs
Steven Enamakelb2f5d5c918e9
diff --git a/app/src/components/settings/panels/ai/ProviderModelPickerDialog.test.tsx b/app/src/components/settings/panels/ai/ProviderModelPickerDialog.test.tsxindex d569d8a43c..37d90a3979 100644--- a/app/src/components/settings/panels/ai/ProviderModelPickerDialog.test.tsx+++ b/app/src/components/settings/panels/ai/ProviderModelPickerDialog.test.tsx@@ -91,7 +91,7 @@ describe('ProviderModelPickerDialog', () => {/*** The managed backend's OpenRouter passthrough catalog is offered under- * "Managed by OpenHuman" so a specific model can be pinned while still+ * "OpenRouter — Managed by TinyHumans" so a specific model can be pinned while still* billing through managed credits. Automatic stays the default.*/it('lists the managed catalog and forwards a pinned model', async () => {@@ -230,6 +230,38 @@ describe('ProviderModelPickerDialog', () => {expect(vi.mocked(listProviderModels)).toHaveBeenCalledTimes(1);});+ it('the search box narrows the managed model list, not the provider column', async () => {+ vi.mocked(listProviderModels).mockResolvedValue([+ { id: 'openrouter/a/alpha', owned_by: 'openrouter', display_name: 'Alpha' },+ { id: 'openrouter/b/beta', owned_by: 'openrouter', display_name: 'Beta' },+ ]);++ render(+ <ProviderModelPickerDialog+ cloudProviders={[+ { id: 'p1', slug: 'openai', label: 'OpenAI', maskedKey: '', endpoint: '' } as never,+ ]}+ localModels={[]}+ ollamaRunning={false}+ claudeCodeEnabled={false}+ initial={null}+ onClose={() => {}}+ onSelect={() => {}}+ />+ );+ await screen.findByTestId('model-picker-managed-option-openrouter/a/alpha');++ fireEvent.change(screen.getByLabelText('Search models'), { target: { value: 'bet' } });++ expect(screen.queryByTestId('model-picker-managed-option-openrouter/a/alpha')).toBeNull();+ expect(screen.getByTestId('model-picker-managed-option-openrouter/b/beta')).toBeInTheDocument();+ // "Automatic" is not a model; it steps aside while a query is active.+ expect(screen.queryByTestId('model-picker-managed-automatic')).toBeNull();+ // Providers are untouched by the query.+ expect(screen.getByText('OpenAI')).toBeInTheDocument();+ expect(screen.getByText('OpenRouter')).toBeInTheDocument();+ });+it('omits managed when the host opts out', () => {render(<ProviderModelPickerDialogdiff --git a/app/test/playwright/specs/chat-model-managed-catalog.spec.ts b/app/test/playwright/specs/chat-model-managed-catalog.spec.tsindex dd17e843f5..ec195a63b0 100644--- a/app/test/playwright/specs/chat-model-managed-catalog.spec.ts+++ b/app/test/playwright/specs/chat-model-managed-catalog.spec.ts@@ -112,7 +112,9 @@ async function openChat(page: Page): Promise<void> {const modelChip = (page: Page): Locator =>page.locator('[data-analytics-id="chat-model-selector"]');const pickerTitle = (page: Page): Locator => page.getByText('Choose provider and model');-const managedSelect = (page: Page): Locator => page.getByTestId('model-picker-managed-select');+const managedOption = (page: Page, id: string): Locator =>+ page.getByTestId(`model-picker-managed-option-${id}`);+const managedAutomatic = (page: Page): Locator => page.getByTestId('model-picker-managed-automatic');/*** Open the picker and land on the managed source's pane.@@ -129,7 +131,7 @@ async function openManagedPane(page: Page): Promise<void> {await modelChip(page).click();await expect(pickerTitle(page)).toBeVisible({ timeout: 10_000 });if ((await page.getByTestId('model-picker-managed-pane').count()) === 0) {- await page.getByText('Managed by OpenHuman', { exact: true }).first().click();+ await page.getByText('OpenRouter', { exact: true }).first().click();}await expect(page.getByTestId('model-picker-managed-pane')).toBeVisible();}@@ -148,31 +150,31 @@ test.describe('Managed OpenRouter catalog in the model picker', () => {await openChat(page);await openManagedPane(page);- const select = managedSelect(page);+ // The catalog reached the browser through the real core fetch, not a stub,+ // and is rendered as a list filling the pane rather than a dropdown.await expect(- select,+ managedOption(page, PLAIN_ID),'before #6201 the managed pane rendered prose and no model control at all').toBeVisible({ timeout: 20_000 });-- // The catalog reached the browser through the real core fetch, not a stub.- const optionValues = await select- .locator('option')- .evaluateAll(nodes => nodes.map(node => (node as HTMLOptionElement).value));- expect(optionValues).toContain(PLAIN_ID);- expect(optionValues).toContain(FREE_ID);+ await expect(managedOption(page, FREE_ID)).toBeVisible();// "Automatic" is always present so a pin is reversible.- expect(optionValues).toContain('');+ await expect(managedAutomatic(page)).toBeVisible();// Labelled by display name + charged price, not the bare slug. Asserting// the price text matters: the id alone would satisfy a label that ignored// `display_name` / `pricing` entirely.- const plainLabel = await select.locator(`option[value="${PLAIN_ID}"]`).textContent();- expect(plainLabel?.trim()).toBe('Nex N2.5 Mini — $0.15/$0.6 per 1M');+ await expect(managedOption(page, PLAIN_ID)).toContainText('Nex N2.5 Mini');+ await expect(managedOption(page, PLAIN_ID)).toContainText('$0.15/$0.6 per 1M');// A catalog entry with neither name nor pricing falls back to the bare id- // rather than rendering "undefined" or an empty option.- const plainestLabel = await select.locator(`option[value="${NO_METADATA_ID}"]`).textContent();- expect(plainestLabel?.trim()).toBe(NO_METADATA_ID);+ // rather than rendering "undefined" or an empty row.+ await expect(managedOption(page, NO_METADATA_ID)).toContainText(NO_METADATA_ID);++ // The search box narrows this list, not the provider column.+ await page.getByPlaceholder('Search models').fill('free');+ await expect(managedOption(page, FREE_ID)).toBeVisible();+ await expect(managedOption(page, PLAIN_ID)).toHaveCount(0);+ await expect(page.getByText('OpenRouter', { exact: true }).first()).toBeVisible();});test('a pinned managed model survives closing and reopening the picker', async ({ page }) => {@@ -185,8 +187,8 @@ test.describe('Managed OpenRouter catalog in the model picker', () => {expect(before, 'the model chip must name the current model').not.toBe('');await openManagedPane(page);- await expect(managedSelect(page)).toBeVisible({ timeout: 20_000 });- await managedSelect(page).selectOption(PLAIN_ID);+ await expect(managedOption(page, PLAIN_ID)).toBeVisible({ timeout: 20_000 });+ await managedOption(page, PLAIN_ID).click();await page.getByRole('button', { name: 'Use this model' }).click();await expect(pickerTitle(page)).toHaveCount(0);@@ -195,23 +197,22 @@ test.describe('Managed OpenRouter catalog in the model picker', () => {await expect(chip).toHaveText(/nex-n2\.5-mini/, { timeout: 10_000 });expect((await chip.textContent())?.trim() ?? '').not.toBe(before);- // The round trip: reopen and the select still shows the pinned id.+ // The round trip: reopen and the list still marks the pinned id.// `selectionFromValue` decoded a bare id (no `:`) to null, so the selection// was silently dropped here and the pane reopened on "Automatic".await openManagedPane(page);- await expect(managedSelect(page)).toBeVisible({ timeout: 20_000 });await expect(- managedSelect(page),+ managedOption(page, PLAIN_ID),'a pinned managed id round-trips through selectionValue/selectionFromValue'- ).toHaveValue(PLAIN_ID);+ ).toHaveAttribute('aria-selected', 'true', { timeout: 20_000 });});test('a :free variant keeps its full name on the chip', async ({ page }) => {await openChat(page);await openManagedPane(page);- await expect(managedSelect(page)).toBeVisible({ timeout: 20_000 });+ await expect(managedOption(page, FREE_ID)).toBeVisible({ timeout: 20_000 });- await managedSelect(page).selectOption(FREE_ID);+ await managedOption(page, FREE_ID).click();await page.getByRole('button', { name: 'Use this model' }).click();await expect(pickerTitle(page)).toHaveCount(0);@@ -226,22 +227,26 @@ test.describe('Managed OpenRouter catalog in the model picker', () => {// And it round-trips: the variant suffix is not lost on reopen either.await openManagedPane(page);- await expect(managedSelect(page)).toHaveValue(FREE_ID, { timeout: 20_000 });+ await expect(managedOption(page, FREE_ID)).toHaveAttribute('aria-selected', 'true', {+ timeout: 20_000,+ });});test('a pinned model can be cleared back to automatic', async ({ page }) => {await openChat(page);await openManagedPane(page);- await expect(managedSelect(page)).toBeVisible({ timeout: 20_000 });- await managedSelect(page).selectOption(PLAIN_ID);+ await expect(managedOption(page, PLAIN_ID)).toBeVisible({ timeout: 20_000 });+ await managedOption(page, PLAIN_ID).click();await page.getByRole('button', { name: 'Use this model' }).click();await expect(pickerTitle(page)).toHaveCount(0);const pinned = (await modelChip(page).textContent())?.trim() ?? '';expect(pinned).toMatch(/nex-n2\.5-mini/);await openManagedPane(page);- await expect(managedSelect(page)).toHaveValue(PLAIN_ID, { timeout: 20_000 });- await managedSelect(page).selectOption('');+ await expect(managedOption(page, PLAIN_ID)).toHaveAttribute('aria-selected', 'true', {+ timeout: 20_000,+ });+ await managedAutomatic(page).click();await page.getByRole('button', { name: 'Use this model' }).click();await expect(pickerTitle(page)).toHaveCount(0);@@ -249,7 +254,7 @@ test.describe('Managed OpenRouter catalog in the model picker', () => {await expect(modelChip(page)).not.toHaveText(/nex-n2\.5-mini/, { timeout: 10_000 });});- test('an empty catalog renders no select, exactly as before the feature', async ({ page }) => {+ test('an empty catalog renders only the automatic row', async ({ page }) => {// Models the real backend with OPENROUTER_PASSTHROUGH_ENABLED off: it// returns an empty set with HTTP 200, not an error. The managed pane must// degrade to its pre-#6201 appearance rather than surfacing a failure.@@ -258,7 +263,8 @@ test.describe('Managed OpenRouter catalog in the model picker', () => {await openManagedPane(page);await expect(page.getByTestId('model-picker-managed-pane')).toBeVisible();- await expect(managedSelect(page)).toHaveCount(0);+ await expect(managedAutomatic(page)).toBeVisible();+ await expect(page.locator('[data-testid^="model-picker-managed-option-"]')).toHaveCount(0);// Managed is still selectable with no model id — the original contract.await page.getByRole('button', { name: 'Use this model' }).click();await expect(pickerTitle(page)).toHaveCount(0);diff --git a/app/test/playwright/specs/chat-model-override.spec.ts b/app/test/playwright/specs/chat-model-override.spec.tsindex c03171ff57..95cab95ef2 100644--- a/app/test/playwright/specs/chat-model-override.spec.ts+++ b/app/test/playwright/specs/chat-model-override.spec.ts@@ -17,7 +17,7 @@** Which providers appear in the picker comes from core config, and the e2e* fixture does not seed a cloud provider. The always-available option is the- * managed tier ("Managed by OpenHuman"), which the dialog deliberately lets you+ * managed tier ("OpenRouter — Managed by TinyHumans"), which the dialog deliberately lets you* pick with no model id (`ProviderModelPickerDialog.tsx:189-196`). Where a case* needs a provider this fixture does not have, it skips with a reason rather* than asserting something weaker — per the lane rules, a case that cannot be