Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.
TypeScript agentaiai-agentsall-in-onecrmcrm-systememaillinearmcpmessagingnotesnotionofficerustslackslack-alternativestartupstartup-toolstypescriptworkspace
fix(agents): restore the model selector and use it everywhere (#8865)
Wolf Mermelsteinabfeb6876dc4
diff --git a/apps/web/AGENTS.md b/apps/web/AGENTS.mdindex 53c3ca489a..b6db9a64a4 100644--- a/apps/web/AGENTS.md+++ b/apps/web/AGENTS.md@@ -221,7 +221,6 @@ ownership. Cancel, logout, and the ten-minute timeout retire pending callbacks.and Tasks headers: title, filters, view options, New, expandable Search. Put sidebar search in`ViewSidebar.Header` so its icon precedes collapse and its field opens above New.- Keep desktop headers on the shared `ListHeader` / `HeaderActionGroup` pattern: view `Tabs` as pills after the title, 32px semantic islands with 8px gaps on the right, fully rounded elevated frames, New then expandable Search; preserve touch layouts. Pick each control by role from the [design system rule](../../.agents/rules/web/design-system.md); see [UI conventions](../../docs/agent-guide/ui-conventions.md#top-bars). Never use recessed/inset backgrounds in headers.-- Keep desktop model and effort controls separate: the model selector opens the catalog and the speedometer opens the runtime's advertised slider stops; retain the mobile effort sheet.- Passive PR mentions must not retry initial GitHub status failures on remount; preserve confirmed status through refetch errors and keep pending data reads out of their parent Suspense boundary.- Keep native booking exit navigation in the route shell, outside page loading boundaries, and use the router so the native hash route stays intact.- Diagnose native full reloads with `native_webview_started`, `native_diagnostic_recovered`, and the shared `frontend_instance_id`; use `reloadApp(reason)` for frontend reloads and keep breadcrumbs content-free. Treat `previous_document_*` checkpoints as last-observed lifecycle evidence, never a crash verdict; clear them on logout. `previous_document_last_*` comes from the native navigation breadcrumb (route and entity type, never ids). See [frontend checkpoints](docs/native-reload-diagnostics.md) and `tauri/src-tauri/README.md`.diff --git a/apps/web/src/features/agents-view/components/ModelSelector.tsx b/apps/web/src/features/agents-view/components/ModelSelector.tsxindex 1c2bebd75a..4218194d7e 100644--- a/apps/web/src/features/agents-view/components/ModelSelector.tsx+++ b/apps/web/src/features/agents-view/components/ModelSelector.tsx@@ -1,16 +1,10 @@-import {- AgentModelSelector,- type AgentModelSelectorProps,-} from '@app/features/block-agent/ui/AgentModelSelector';+import type { AgentModelSelectorProps } from '@app/features/block-agent/ui/AgentModelSelector';import {ModelCatalogPicker,type ModelRowProps,} from '@core/component/AI/component/input/ModelCatalogPicker';import { modelLabel } from '@core/component/AI/constant/model-label';-import { isTouchDevice } from '@core/mobile/isTouchDevice';-import { composerMenuAnchorRect } from '@core/util/composerMenuAnchor';import type { Component, JSX } from 'solid-js';-import { Show } from 'solid-js';export type ModelChoice = {id: string;@@ -45,11 +39,8 @@ export function ModelSelector(props: {triggerLabel={props.label}placeholder={modelLabel(props.model)}triggerClass="h-[33.75px] min-w-0 max-w-full gap-[5.625px] rounded-full border-0 bg-transparent hover:bg-hover px-[7.5px] text-base font-normal text-ink-muted light-mode:text-composer-placeholder [&_svg]:size-[15px]"- contentClass="w-[min(42rem,calc(100vw-2rem))] rounded-2xl border-0"ariaLabel="Model"- placement="bottom-start"- getAnchorRect={composerMenuAnchorRect}- gutter={8}+ placement="top-end"disabled={props.disabled}pending={props.pending}onSelect={props.onSelect}@@ -67,27 +58,30 @@ export function ModelSelector(props: {export function SessionModelSelector(props: AgentModelSelectorProps) {const shown = () => props.changingTo ?? props.model ?? undefined;return (- <Show when={!isTouchDevice()} fallback={<AgentModelSelector {...props} />}>- <ModelSelector- onCloseAutoFocus={props.onCloseAutoFocus}- model={shown()}- label={modelLabel(+ <ModelSelector+ onCloseAutoFocus={props.onCloseAutoFocus}+ model={shown()}+ label={[+ modelLabel(shown(),props.options.find((option) => option.id === shown())?.name- )}- modelRow={props.modelRow}- options={props.options.map((option) => ({- id: option.id,- name: option.name,- group: option.group ?? undefined,- description: option.description ?? undefined,- }))}- disabled={props.disabled}- pending={props.changingTo !== undefined}- onSelect={(id) => {- if (id !== props.model) props.onSelect(id);- }}- />- </Show>+ ),+ props.effortLabel,+ ]+ .filter(Boolean)+ .join(' · ')}+ modelRow={props.modelRow}+ options={props.options.map((option) => ({+ id: option.id,+ name: option.name,+ group: option.group ?? undefined,+ description: option.description ?? undefined,+ }))}+ disabled={props.disabled}+ pending={props.changingTo !== undefined}+ onSelect={(id) => {+ if (id !== props.model) props.onSelect(id);+ }}+ />);}diff --git a/apps/web/src/features/agents-view/views/AgentPicker.tsx b/apps/web/src/features/agents-view/views/AgentPicker.tsxindex 952e163024..fa509c0f13 100644--- a/apps/web/src/features/agents-view/views/AgentPicker.tsx+++ b/apps/web/src/features/agents-view/views/AgentPicker.tsx@@ -2,7 +2,6 @@ import { ModelCatalogMenu } from '@core/component/AI/component/input/ModelCataloimport { ModelIcon } from '@core/component/AI/component/ProviderIcon';import { modelLabel } from '@core/component/AI/constant/model-label';import { isTouchDevice } from '@core/mobile/isTouchDevice';-import { composerMenuAnchorRect } from '@core/util/composerMenuAnchor';import CaretDownIcon from '@icon/system/regular/caret-down.svg';import CaretRightIcon from '@icon/system/regular/caret-right.svg';import PlusIcon from '@icon/system/regular/plus.svg';@@ -70,7 +69,8 @@ function DesktopAgentPicker(props: AgentPickerProps) {model(),catalog.models().find((option) => option.id === model())?.name);- const label = baseLabel;+ const label = () =>+ [baseLabel(), props.effortLabel].filter(Boolean).join(' · ');const choose = (agent: RosterAgent, model?: string) => {props.onSelect(agent, model);setOpen(false);@@ -84,13 +84,7 @@ function DesktopAgentPicker(props: AgentPickerProps) {setOpen(false);};return (- <Dropdown- open={open()}- onOpenChange={setOpen}- placement={macro() ? 'bottom-start' : 'top-end'}- gutter={macro() ? 8 : 4}- getAnchorRect={macro() ? composerMenuAnchorRect : undefined}- >+ <Dropdown open={open()} onOpenChange={setOpen} placement="top-end"><Dropdown.Triggervariant="ghost"aria-label="Agent"@@ -127,99 +121,62 @@ function DesktopAgentPicker(props: AgentPickerProps) {<Show when={rawModel()}><ModelIcon model={model()} class="size-[15px] shrink-0" /></Show>- <span class="min-w-0 truncate text-left leading-5">{baseLabel()}</span>- <CaretDownIcon class="size-4 shrink-0 text-ink-muted" />+ <span class="min-w-0 truncate text-left leading-5">{label()}</span>+ <CaretDownIcon class="size-[15px] shrink-0" /></Dropdown.Trigger><Dropdown.Content- class={cn(- macro()- ? 'w-[min(42rem,calc(100vw-2rem))]'- : 'w-70 max-w-[calc(100vw-1rem)]',- 'overflow-hidden rounded-2xl border-0'- )}- onCloseAutoFocus={props.onCloseAutoFocus}+ class="w-88 max-w-[calc(100vw-1rem)] overflow-hidden"onPointerDown={(event: PointerEvent) => event.stopPropagation()}onMouseDown={(event: MouseEvent) => event.stopPropagation()}>- <div class="grid max-h-[min(24rem,var(--kb-popper-content-available-height))] min-h-0 grid-cols-1 sm:grid-cols-[minmax(0,0.9fr)_minmax(0,1.1fr)]">- <Show when={macro()}>- <div- role="group"- aria-label="Models"- class="order-2 min-h-0 max-h-[min(24rem,var(--kb-popper-content-available-height))] min-w-0 overflow-y-auto overscroll-contain px-2 pb-2 sm:border-l sm:border-edge-divider"- >- <div class="px-3 pt-3 pb-1 text-xs font-medium text-ink-extra-muted">- Models- </div>- <Show when={macro()}>- {(agent) => (- <ModelCatalogMenu- fullCatalog- suggestedFirst- searchable={false}- value={- props.selected?.id === agent().id- ? (model() ?? null)- : null- }- disabled={Boolean(agent().unavailableReason)}- options={macroCatalog.models().map((option) => ({- id: option.id,- label: modelLabel(option.id, option.name),- description: option.description ?? undefined,- group: option.group ?? undefined,- }))}- onSelect={(id) => choose(agent(), id)}- modelRow={- props.onSelectEffort- ? (row) => (- <AgentModelMenuItem- {...row}- harness={agent().harness}- effortValue={- row.selected- ? props.effortSelection?.value- : undefined- }- onSelectEffort={(effort) =>- chooseEffort(agent(), row.option.id, effort)- }- />- )- : undefined- }- emptyMessage={macroCatalog.message()}- />- )}- </Show>- </div>- </Show>+ <div class="flex min-h-0 max-h-[min(28rem,var(--kb-popper-content-available-height))] flex-col"><div- role="group"- aria-label="Agents"- class="order-1 min-h-0 max-h-[min(24rem,var(--kb-popper-content-available-height))] min-w-0 space-y-1 overflow-y-auto overscroll-contain px-2 pb-2 pt-3"- classList={{ 'sm:col-span-2': !macro() }}+ class="min-h-0 space-y-1 overflow-y-auto overscroll-contain px-2 pb-2"+ classList={{ 'pt-2': !macro() }}><Show when={macro()}>- <div class="px-3 pb-1 text-xs font-medium text-ink-extra-muted">- Agents- </div>+ {(agent) => (+ <ModelCatalogMenu+ autoFocusSearch+ value={+ props.selected?.id === agent().id ? (model() ?? null) : null+ }+ disabled={Boolean(agent().unavailableReason)}+ options={macroCatalog.models().map((option) => ({+ id: option.id,+ label: modelLabel(option.id, option.name),+ description: option.description ?? undefined,+ group: option.group ?? undefined,+ }))}+ onSelect={(id) => choose(agent(), id)}+ modelRow={+ props.onSelectEffort+ ? (row) => (+ <AgentModelMenuItem+ {...row}+ harness={agent().harness}+ effortValue={+ row.selected+ ? props.effortSelection?.value+ : undefined+ }+ onSelectEffort={(effort) =>+ chooseEffort(agent(), row.option.id, effort)+ }+ />+ )+ : undefined+ }+ emptyMessage={macroCatalog.message()}+ />+ )}</Show><For each={groups()}>{(group) => (- <Dropdown.Group- class="bg-transparent py-0"- aria-label={- macro() && group.label === 'Your agents'- ? group.label- : undefined- }- >- <Show when={!macro() || group.label !== 'Your agents'}>- <Dropdown.GroupLabel class="h-6 font-medium text-ink-muted">- {group.label}- </Dropdown.GroupLabel>- </Show>+ <Dropdown.Group class="bg-transparent py-0">+ <Dropdown.GroupLabel class="h-6 font-medium text-ink-muted">+ {group.label}+ </Dropdown.GroupLabel><For each={group.agents}>{(agent) => (<AgentPickerRowdiff --git a/apps/web/src/features/agents-view/views/NewChatPage.test.tsx b/apps/web/src/features/agents-view/views/NewChatPage.test.tsxindex 46788d8c10..8378dd8364 100644--- a/apps/web/src/features/agents-view/views/NewChatPage.test.tsx+++ b/apps/web/src/features/agents-view/views/NewChatPage.test.tsx@@ -262,8 +262,6 @@ function page(function openAgents() {const trigger = screen.getByRole('button', { name: 'Agent' });fireEvent.keyDown(trigger, { key: 'Enter' });- const overview = screen.queryByRole('menuitem', { name: 'Choose model' });- if (overview) fireEvent.keyDown(overview, { key: 'Enter' });return trigger;}async function selectAgent(name: RegExp) {@@ -339,26 +337,6 @@ describe('agent-led new conversation', () => {motionStyles.remove();vi.unstubAllGlobals();});- it.each([390, 1024])(- 'keeps the touch picker as a single sheet at %ipx',- async (width) => {- vi.stubGlobal('innerWidth', width);- mocks.touch = true;- page();- fireEvent.click(screen.getByRole('button', { name: 'Agent' }));- const sheet = await screen.findByRole('dialog');- expect(- within(sheet).getByRole('textbox', { name: 'Search agents and models' })- ).toBeTruthy();- expect(screen.queryByRole('menu')).toBeNull();- expect(screen.queryByRole('group', { name: 'Agents' })).toBeNull();- expect(screen.queryByRole('group', { name: 'Models' })).toBeNull();- fireEvent.click(- within(sheet).getByRole('button', { name: 'Sonnet 5.5' })- );- await waitFor(() => expect(screen.queryByRole('dialog')).toBeNull());- }- );it('selects a coding model from the phone sheet without hover and preserves the draft', async () => {mocks.touch = true;const send = page(true, [], false, [], 'code');@@ -432,52 +410,18 @@ describe('agent-led new conversation', () => {});await waitFor(() => expect(document.activeElement).toBe(search));});- it('opens the full desktop catalog without search or a More step', async () => {+ it('focuses desktop search on opening and reopening the model selector', async () => {page();for (let attempt = 0; attempt < 2; attempt++) {openAgents();- expect(- screen.queryByRole('textbox', { name: 'Search models' })- ).toBeNull();- expect(- screen.queryByRole('menuitem', { name: 'More models' })- ).toBeNull();- expect(- within(screen.getByRole('group', { name: 'Suggested' })).getByTitle(- 'Sonnet 5.5'- )- ).toBeTruthy();- expect(screen.getByTitle('GLM 5.3 Flash')).toBeTruthy();- fireEvent.keyDown(screen.getByRole('menu'), { key: 'Escape' });+ const search = screen.getByRole('textbox', { name: 'Search models' });+ await waitFor(() => expect(document.activeElement).toBe(search));+ fireEvent.input(search, { target: { value: 'Sonnet' } });+ expect(screen.getByTitle('Sonnet 5.5')).toBeTruthy();+ fireEvent.keyDown(search, { key: 'Escape' });await waitFor(() => expect(screen.queryByRole('menu')).toBeNull());}});- it('separates the desktop agent and model choices into named groups', () => {- page();- openAgents();- const agents = screen.getByRole('group', { name: 'Agents' });- const models = screen.getByRole('group', { name: 'Models' });- expect(screen.queryByText('Your agents')).toBeNull();- expect(screen.queryByText('Suggested')).toBeNull();- const suggested = within(models).getByRole('group', { name: 'Suggested' });- const anthropic = within(models).getByRole('group', { name: 'Anthropic' });- expect(- suggested.compareDocumentPosition(anthropic) &- Node.DOCUMENT_POSITION_FOLLOWING- ).toBe(Node.DOCUMENT_POSITION_FOLLOWING);-- expect(- within(agents).getByRole('menuitem', { name: 'Create agent' })- ).toBeTruthy();- expect(- within(models).queryByRole('textbox', { name: 'Search models' })- ).toBeNull();- expect(- within(- within(models).getByRole('group', { name: 'Suggested' })- ).getByRole('menuitem', { name: 'Opus 5.5' })- ).toBeTruthy();- });it('starts in Chat and switches to Code from the composer', async () => {const send = page();expect(@@ -575,7 +519,7 @@ describe('agent-led new conversation', () => {).toBeTruthy();expect(screen.queryByRole('button', { name: 'Repository' })).toBeNull();openAgents();- expect(screen.getByRole('group', { name: 'Models' })).toBeTruthy();+ expect(screen.getByRole('group', { name: 'Suggested' })).toBeTruthy();expect(screen.queryByRole('menuitem', { name: /Cursor/ })).toBeNull();fireEvent.keyDown(document, { key: 'Escape' });await waitFor(() => expect(screen.queryByRole('menu')).toBeNull());@@ -950,9 +894,7 @@ describe('agent-led new conversation', () => {it('clears a temporary model choice when switching to Code', async () => {page();openAgents();- const model = within(- screen.getByRole('group', { name: 'Suggested' })- ).getByTitle('Sonnet 5.5');+ const model = screen.getByTitle('Sonnet 5.5');model.focus();fireEvent.keyDown(model, { key: 'Enter' });await waitFor(() => expect(screen.queryByRole('menu')).toBeNull());@@ -973,19 +915,34 @@ describe('agent-led new conversation', () => {},]);openAgents();- const models = within(screen.getByRole('group', { name: 'Models' }));- expect(screen.getByRole('group', { name: 'Your agents' })).toBeTruthy();+ const modelsGroup = screen.getByRole('group', { name: 'Suggested' });+ const agentsGroup = screen.getByRole('group', { name: 'Your agents' });+ expect(+ modelsGroup.compareDocumentPosition(agentsGroup) &+ Node.DOCUMENT_POSITION_FOLLOWING+ ).toBe(Node.DOCUMENT_POSITION_FOLLOWING);expect(screen.queryByRole('group', { name: 'Coding agents' })).toBeNull();- expect(screen.queryByRole('textbox', { name: 'Search models' })).toBeNull();- expect(screen.queryByRole('menuitem', { name: /More models/ })).toBeNull();- expect(models.getByRole('group', { name: 'Z.ai' })).toBeTruthy();- expect(models.getByTitle('GLM 5.3')).toBeTruthy();- expect(models.getByTitle('GLM 5.3 Flash')).toBeTruthy();+ const search = screen.getByRole('textbox', { name: 'Search models' });+ expect(screen.getByRole('menuitem', { name: /More models/ })).toBeTruthy();+ expect(screen.queryByRole('group', { name: 'Z.ai' })).toBeNull();+ fireEvent.input(search, { target: { value: 'GLM' } });+ expect(screen.getByTitle('GLM 5.3')).toBeTruthy();+ expect(screen.getByTitle('GLM 5.3 Flash')).toBeTruthy();+ fireEvent.input(search, { target: { value: '' } });expect(screen.queryByRole('menuitem', { name: /Cursor/ })).toBeNull();expect(screen.queryByRole('menuitem', { name: /^Macro/ })).toBeNull();- const sonnet = within(- models.getByRole('group', { name: 'Suggested' })- ).getByTitle('Sonnet 5.5');+ const models = within(screen.getByRole('group', { name: 'Suggested' }));+ expect(+ models.queryByRole('menuitem', { name: /Cursor default/ })+ ).toBeNull();+ expect(models.getAllByRole('menuitem').map((item) => item.title)).toEqual([+ 'Opus 5.5',+ 'Sonnet 5.5',+ 'GPT-5.6',+ 'GPT-6 Astra',+ 'Gemini 3.8 Flash',+ ]);+ const sonnet = models.getByTitle('Sonnet 5.5');expect(sonnet.querySelector('[data-ai-provider="anthropic"] svg')).toBeTruthy();@@ -1046,17 +1003,24 @@ describe('agent-led new conversation', () => {/>));openAgents();- const sonnet = within(- screen.getByRole('group', { name: 'Suggested' })- ).getByTitle('Sonnet 5.5');+ const sonnet = screen.getByTitle('Sonnet 5.5');expect(sonnet.getAttribute('aria-disabled')).toBe('true');fireEvent.click(sonnet);fireEvent.keyDown(sonnet, { key: 'Enter' });+ const search = screen.getByRole('textbox', { name: 'Search models' });+ fireEvent.input(search, { target: { value: 'GLM' } });const flash = screen.getByTitle('GLM 5.3 Flash');expect(flash.getAttribute('aria-disabled')).toBe('true');fireEvent.click(flash);- fireEvent.keyDown(flash, { key: 'Enter' });+ fireEvent.input(search, { target: { value: '' } });++ const more = screen.getByRole('menuitem', { name: 'More models' });+ more.focus();+ fireEvent.keyDown(more, { key: 'ArrowRight' });+ const extra = await screen.findByTitle('GLM 5.3 Flash');+ expect(extra.getAttribute('aria-disabled')).toBe('true');+ fireEvent.click(extra);expect(onSelect).not.toHaveBeenCalled();});it('restores a preferred Macro model on a fresh composer', () => {@@ -1077,9 +1041,7 @@ describe('agent-led new conversation', () => {await waitFor(() => expect(screen.getByRole('menu')).toBeTruthy());expect(screen.queryByTitle('Sonnet 5.5')).toBeNull();expect(- within(screen.getByRole('group', { name: 'Suggested' })).getByTitle(- 'Gemini 3.8 Flash'- )+ within(screen.getByRole('menu')).getByTitle('Gemini 3.8 Flash')).toBeTruthy();fireEvent.keyDown(screen.getByRole('menu'), { key: 'Escape' });fireEvent.click(screen.getByRole('button', { name: 'Send' }));@@ -1134,29 +1096,6 @@ describe('agent-led new conversation', () => {);});- it('sends the effort chosen with the separate speedometer slider', async () => {- const send = page(true, [], false, [], 'code');- const models = await hoverAgent('Cursor');- fireEvent.keyDown(models.getByRole('menuitem', { name: /^GPT-5/ }), {- key: 'Enter',- });- await waitFor(() => expect(screen.queryByRole('menu')).toBeNull());- fireEvent.keyDown(screen.getByRole('button', { name: /^Effort:/ }), {- key: 'Enter',- });- const slider = screen.getByRole('slider', { name: 'Reasoning effort' });- fireEvent.keyDown(slider, { key: 'ArrowRight' });- expect(slider.getAttribute('aria-valuetext')).toBe('Ultra');- fireEvent.keyDown(slider, { key: 'Escape' });- await waitFor(() => expect(screen.queryByRole('menu')).toBeNull());- fireEvent.click(screen.getByRole('button', { name: 'Send' }));- expect(send).toHaveBeenLastCalledWith(- expect.objectContaining({- modelOverride: 'gpt-5',- effortOverride: { configId: 'cursor_effort', value: 'ultra' },- })- );- });it('passes opaque effort and clears it with the model override after sending', async () => {const send = page(true, [], false, [], 'code');const models = await hoverAgent('Cursor');@@ -1170,9 +1109,8 @@ describe('agent-led new conversation', () => {await waitFor(() => expect(screen.queryByRole('menu')).toBeNull());mocks.capabilitiesPending = true;expect(screen.getByRole('button', { name: 'Agent' }).title).toContain(- 'GPT-5'+ 'GPT-5 · Ultra');- expect(screen.getByRole('button', { name: 'Effort: Ultra' })).toBeTruthy();fireEvent.click(screen.getByRole('button', { name: 'Send' }));expect(send).toHaveBeenLastCalledWith(expect.objectContaining({diff --git a/apps/web/src/features/block-agent/component/EffortSelector.test.tsx b/apps/web/src/features/block-agent/component/EffortSelector.test.tsxindex bea6fc4f39..13f7c710fe 100644--- a/apps/web/src/features/block-agent/component/EffortSelector.test.tsx+++ b/apps/web/src/features/block-agent/component/EffortSelector.test.tsx@@ -8,7 +8,6 @@ import {screen,waitFor,} from '@solidjs/testing-library';-import { createSignal } from 'solid-js';import { afterEach, beforeEach, expect, it, vi } from 'vitest';import type { SelectSessionConfigOption } from '../state/session-config';import { EffortSelector } from './EffortSelector';@@ -47,42 +46,43 @@ afterEach(() => {HTMLElement.prototype.scrollTo = originalScrollTo;vi.unstubAllGlobals();});-it('selects a named effort option and closes on touch', async () => {- const touch = true;- vi.mocked(isTouchDevice).mockReturnValue(touch);- const change = vi.fn();- const openChange = vi.fn();- render(() => (- <EffortSelector- config={config}- onChange={change}- onOpenChange={openChange}- />- ));- const trigger = screen.getByRole('button', { name: 'Effort: Low' });- if (touch) fireEvent.click(trigger);- else fireEvent.keyDown(trigger, { key: 'ArrowDown' });- expect(screen.queryByRole('slider')).toBeNull();- const high = await screen.findByRole(touch ? 'button' : 'menuitem', {- name: 'High',- });- if (touch) {- expect(- screen.getByRole('button', { name: 'Low' }).getAttribute('aria-pressed')- ).toBe('true');- expect(high.getAttribute('aria-pressed')).toBe('false');- fireEvent.click(high);- } else {- high.focus();- fireEvent.keyDown(high, { key: 'Enter' });+it.each([false, true])(+ 'selects a named effort option and closes (touch=%s)',+ async (touch) => {+ vi.mocked(isTouchDevice).mockReturnValue(touch);+ const change = vi.fn();+ const openChange = vi.fn();+ render(() => (+ <EffortSelector+ config={config}+ onChange={change}+ onOpenChange={openChange}+ />+ ));+ const trigger = screen.getByRole('button', { name: 'Effort: Low' });+ if (touch) fireEvent.click(trigger);+ else fireEvent.keyDown(trigger, { key: 'ArrowDown' });+ const high = await screen.findByRole(touch ? 'button' : 'menuitem', {+ name: 'High',+ });+ if (touch) {+ expect(+ screen.getByRole('button', { name: 'Low' }).getAttribute('aria-pressed')+ ).toBe('true');+ expect(high.getAttribute('aria-pressed')).toBe('false');+ fireEvent.click(high);+ } else {+ high.focus();+ fireEvent.keyDown(high, { key: 'Enter' });+ }+ expect(openChange).toHaveBeenLastCalledWith(false);+ expect(change).toHaveBeenCalledExactlyOnceWith({+ configId: 'effort',+ value: 'high',+ name: 'High',+ });}- expect(openChange).toHaveBeenLastCalledWith(false);- expect(change).toHaveBeenCalledExactlyOnceWith({- configId: 'effort',- value: 'high',- name: 'High',- });-});+);it('hides unsupported effort', () => {render(() => <EffortSelector onChange={vi.fn()} />);expect(screen.queryByRole('button')).toBeNull();@@ -116,88 +116,3 @@ it('returns focus to the composer when the mobile chooser closes', async () => {fireEvent.keyDown(low, { key: 'Escape' });await waitFor(() => expect(document.activeElement).toBe(input));});--it('stages desktop slider effort and commits it when the popup closes', async () => {- vi.mocked(isTouchDevice).mockReturnValue(false);- const change = vi.fn();- const openChange = vi.fn();- render(() => (- <EffortSelector- config={config}- onChange={change}- onOpenChange={openChange}- />- ));- fireEvent.keyDown(screen.getByRole('button', { name: 'Effort: Low' }), {- key: 'Enter',- });- const slider = await screen.findByRole('slider', {- name: 'Reasoning effort',- });- await waitFor(() => expect(document.activeElement).toBe(slider));- expect(screen.queryByRole('menuitem', { name: 'Choose model' })).toBeNull();- fireEvent.keyDown(slider, { key: 'ArrowRight' });- expect(change).not.toHaveBeenCalled();- expect(screen.getByRole('menu')).toBeTruthy();- expect(- screen.getByRole('button', { name: 'Effort: High', hidden: true })- ).toBeTruthy();- fireEvent.keyDown(slider, { key: 'Escape' });- await waitFor(() => expect(openChange).toHaveBeenLastCalledWith(false));- expect(change).toHaveBeenCalledExactlyOnceWith({- configId: 'effort',- value: 'high',- name: 'High',- });-});--it('does not commit when the desktop slider returns to the current effort', async () => {- vi.mocked(isTouchDevice).mockReturnValue(false);- const change = vi.fn();- const openChange = vi.fn();- render(() => (- <EffortSelector- config={config}- onChange={change}- onOpenChange={openChange}- />- ));- fireEvent.keyDown(screen.getByRole('button', { name: 'Effort: Low' }), {- key: 'Enter',- });- const slider = await screen.findByRole('slider', {- name: 'Reasoning effort',- });- await waitFor(() => expect(document.activeElement).toBe(slider));- fireEvent.keyDown(slider, { key: 'ArrowRight' });- fireEvent.keyDown(slider, { key: 'ArrowLeft' });- fireEvent.keyDown(slider, { key: 'Escape' });- await waitFor(() => expect(openChange).toHaveBeenLastCalledWith(false));- expect(change).not.toHaveBeenCalled();-});--it('drops a staged desktop effort when the config changes before close', async () => {- vi.mocked(isTouchDevice).mockReturnValue(false);- const change = vi.fn();- const openChange = vi.fn();- const [current, setCurrent] = createSignal(config);- render(() => (- <EffortSelector- config={current()}- onChange={change}- onOpenChange={openChange}- />- ));- fireEvent.keyDown(screen.getByRole('button', { name: 'Effort: Low' }), {- key: 'Enter',- });- const slider = await screen.findByRole('slider', {- name: 'Reasoning effort',- });- await waitFor(() => expect(document.activeElement).toBe(slider));- fireEvent.keyDown(slider, { key: 'ArrowRight' });- setCurrent({ ...config, id: 'other-effort' });- fireEvent.keyDown(slider, { key: 'Escape' });- await waitFor(() => expect(openChange).toHaveBeenLastCalledWith(false));- expect(change).not.toHaveBeenCalled();-});diff --git a/apps/web/src/features/block-agent/component/EffortSelector.tsx b/apps/web/src/features/block-agent/component/EffortSelector.tsxindex 5481989e8b..1d7b6bfec0 100644--- a/apps/web/src/features/block-agent/component/EffortSelector.tsx+++ b/apps/web/src/features/block-agent/component/EffortSelector.tsx@@ -1,5 +1,4 @@import { MobileDrawer } from '@components/app/mobile/MobileDrawer';-import { ModelEffortMenu } from '@core/component/AI/component/input/ModelEffortMenu';import { isTouchDevice } from '@core/mobile/isTouchDevice';import Check from '@icon/system/regular/check.svg';import { Button, Dropdown, Tooltip } from '@ui';@@ -19,28 +18,12 @@ export function EffortSelector(props: {onCloseAutoFocus?: (event: Event) => void;}) {const [open, setOpen] = createSignal(false);- // The desktop slider stages its choice here and commits it when the menu closes.- const [pending, setPending] = createSignal<EffortChoice>();- let content: HTMLElement | undefined;const changeOpen = (value: boolean) => {setOpen(value);- if (!value) {- const choice = pending();- setPending(undefined);- if (- choice &&- choice.configId === props.config?.id &&- choices().some((option) => option.value === choice.value) &&- choice.value !== committed() &&- !props.disabled- )- props.onChange(choice);- }props.onOpenChange?.(value);};const choices = () => props.config?.options ?? [];- const committed = () => props.value ?? props.config?.currentValue;- const value = () => pending()?.value ?? committed();+ const value = () => props.value ?? props.config?.currentValue;const index = () =>Math.max(0,@@ -106,35 +89,19 @@ export function EffortSelector(props: {{contents()}</Dropdown.Trigger></Tooltip>- <Dropdown.Content- ref={content}- onOpenAutoFocus={(event) => {- // This menu contains a slider rather than roving menu items.- event.preventDefault();- content?.querySelector<HTMLElement>('[role="slider"]')?.focus();- }}- class="w-64 rounded-2xl"- aria-label="Reasoning effort"- onCloseAutoFocus={props.onCloseAutoFocus}- >- <ModelEffortMenu- effortOnly- label="Reasoning effort"- config={props.config}- value={value()}- disabled={props.disabled}- onChange={(next) => {- const choice = choices().find(- (choice) => choice.value === next- );- if (props.config && choice)- setPending({- configId: props.config.id,- value: choice.value,- name: choice.name,- });- }}- />+ <Dropdown.Content class="w-48" aria-label="Reasoning effort">+ <Dropdown.Group>+ <For each={choices()}>+ {(choice) => (+ <Dropdown.Item+ disabled={props.disabled}+ onSelect={() => choose(choice)}+ >+ {optionLabel(choice)}+ </Dropdown.Item>+ )}+ </For>+ </Dropdown.Group></Dropdown.Content></Dropdown>}diff --git a/apps/web/src/features/block-agent/ui/AgentModelSelector.test.tsx b/apps/web/src/features/block-agent/ui/AgentModelSelector.test.tsxindex 41f60fb897..ebf08ee2c0 100644--- a/apps/web/src/features/block-agent/ui/AgentModelSelector.test.tsx+++ b/apps/web/src/features/block-agent/ui/AgentModelSelector.test.tsx@@ -184,19 +184,3 @@ it('keeps the touch picker visible while models load', async () => {expect(status.textContent).toContain('Waiting for the agent');expect(screen.getByRole('textbox', { name: 'Search models' })).toBeTruthy();});--it('preserves the current effort label in the mobile model trigger', () => {- device.touch = true;- render(() => (- <AgentModelSelector- model="gpt-5"- options={[{ id: 'gpt-5', name: 'GPT-5', group: null, description: null }]}- effortLabel="High"- onSelect={vi.fn()}- />- ));- expect(- screen.getByRole('button', { name: 'Agent model' }).textContent- ).toContain('GPT-5 · High');- expect(screen.queryByRole('slider')).toBeNull();-});diff --git a/apps/web/src/features/block-agent/ui/AgentModelSelector.tsx b/apps/web/src/features/block-agent/ui/AgentModelSelector.tsxindex 26cb3ba538..d2fe51bdd7 100644--- a/apps/web/src/features/block-agent/ui/AgentModelSelector.tsx+++ b/apps/web/src/features/block-agent/ui/AgentModelSelector.tsx@@ -6,66 +6,23 @@* projection of them. Names and logos still go through the house* `modelLabel` / `ModelIcon`, because a runtime that keeps no display name* for a model — the in-memory Macro Agent among them — reports the slug as- * its name. Renders nothing until the harness has advertised its models.- *- * Touch devices get a bottom sheet (`MobileDrawer`, the same chrome as the- * split title menu) listing every model with a check on the current one, and- * a compact searchable catalog with Suggested and More models. Desktop keeps- * a popover: a compact scrolling list for short catalogs, the searchable- * `ModelCatalogPicker` for long ones.- *- * Harnesses advertise as many models as they like, so the desktop list- * scrolls rather than growing without bound: it shows at most- * `MAX_VISIBLE_ROWS` (or fewer, when the popper has less room than that),- * leaving the next row half-cut under a gradient so the overflow is visible- * rather than merely scrollable.+ * its name. Renders nothing on desktop until the harness has advertised its+ * models. The list itself is the shared `ModelCatalogPicker`.*/-import { MobileDrawer } from '@components/app/mobile/MobileDrawer';import {ModelCatalogPicker,type ModelRowProps,} from '@core/component/AI/component/input/ModelCatalogPicker';-import {- buildModelCatalog,- type CatalogModelOption,- isLargeModelCatalog,- matchesModelQuery,-} from '@core/component/AI/component/input/modelCatalog';-import { ModelIcon } from '@core/component/AI/component/ProviderIcon';import { modelLabel } from '@core/component/AI/constant/model-label';-import { ScrollIndicators } from '@core/component/VerticalScrollIndicators';import { isTouchDevice } from '@core/mobile/isTouchDevice';-import ArrowLeft from '@icon/system/regular/arrow-left.svg';-import CaretDown from '@icon/system/regular/caret-down.svg?component-solid';-import CaretRight from '@icon/system/regular/caret-right.svg';-import Check from '@icon/system/regular/check.svg';-import SearchIcon from '@icon/system/regular/magnifying-glass.svg';-import SquaresFour from '@icon/system/regular/squares-four.svg';import type { ModelOption } from '@service-agent-fold/generated/types';-import { Button, cn, Dropdown } from '@ui';-import { type Component, createMemo, createSignal, For, Show } from 'solid-js';+import { type Component, createMemo, Show } from 'solid-js';import { withoutRedundantGroups } from './model-groups';-/** Compact ghost pill — same size as the short-list trigger and chat's selector. */+/** Compact ghost pill — the same trigger for every session composer. */const PILL_TRIGGER_CLASS =- 'h-6 w-auto max-w-[9rem] min-w-0 justify-start gap-1 rounded-full border-transparent bg-ink/5 px-2 text-left text-sm text-ink-subtle hover:bg-ink/10';--/** Height of one model row — `h-7` on the item, so the cap is exact. */-const ROW_HEIGHT_PX = 28;-/** Rows shown in full before the list starts scrolling. */-const MAX_VISIBLE_ROWS = 10;-/** The scroll container's own top padding, inside the capped window. */-const LIST_PADDING_PX = 6;--/**- * Ten whole rows plus half of the eleventh, clamped to the room the popper- * actually has (Kobalte's size middleware publishes that on the content- * element, so a short screen caps the list before the row count does).- */-const LIST_MAX_HEIGHT = `min(${- LIST_PADDING_PX + MAX_VISIBLE_ROWS * ROW_HEIGHT_PX + ROW_HEIGHT_PX / 2-}px, calc(var(--kb-popper-content-available-height, 100vh) - 4px))`;+ 'h-6 w-auto max-w-[9rem] min-w-0 justify-start gap-1 rounded-full border-transparent bg-ink/5 px-2 text-left text-sm text-ink-subtle hover:bg-ink/10 touch:h-8 touch:max-w-[60vw] touch:gap-1.5 touch:rounded-lg touch:bg-transparent touch:px-1.5 touch:hover:bg-hover';export interface AgentModelSelectorProps {/** Current model id, when the fold has learned it. */@@ -87,259 +44,45 @@ export interface AgentModelSelectorProps {}export function AgentModelSelector(props: AgentModelSelectorProps) {- const [listRef, setListRef] = createSignal<HTMLElement>();- const [sheetOpen, setSheetOpen] = createSignal(false);- const [query, setQuery] = createSignal('');- const [showAll, setShowAll] = createSignal(false);- let searchInput: HTMLInputElement | undefined;const shown = () => props.changingTo ?? props.model;- const baseLabel = () =>- modelLabel(- shown() ?? undefined,- props.options.find((option) => option.id === shown())?.name- );const label = () =>- isTouchDevice()- ? [baseLabel(), props.effortLabel].filter(Boolean).join(' · ')- : baseLabel();- const options = createMemo(() => withoutRedundantGroups(props.options));- const toCatalogOption = (option: ModelOption): CatalogModelOption => ({- id: option.id,- label: modelLabel(option.id, option.name),- description: option.description ?? undefined,- group: option.group ?? undefined,- });- const catalogOptions = () => options().map(toCatalogOption);- const useCatalog = () => isLargeModelCatalog(catalogOptions());- const catalog = createMemo(() => buildModelCatalog(catalogOptions(), true));- const groups = createMemo(() => {- const queryText = query().trim().toLowerCase();- const sections =- showAll() || queryText || catalog().frontier.length === 0- ? catalog().providers- : [{ label: 'Suggested', options: catalog().frontier }];- return sections- .map((section) => ({- ...section,- options: section.options.filter((option) =>- matchesModelQuery(option, queryText)- ),- }))- .filter((section) => section.options.length > 0);- });- const openSheet = (open: boolean) => {- setSheetOpen(open);- if (!open) {- setQuery('');- setShowAll(false);- }- };-- const pick = (id: string) => {- openSheet(false);- if (id !== props.model) props.onSelect(id);- };-- const sheet = (- <MobileDrawer- side="bottom"- open={sheetOpen()}- onOpenChange={openSheet}- restoreFocus={!!props.onCloseAutoFocus}- onFinalFocus={props.onCloseAutoFocus}- onInitialFocus={(event) => {- event.preventDefault();- searchInput?.focus();- }}- preventScroll={false}- preventScrollbarShift={false}- >- {/* Provider logo + text + caret, like the reference composer — no pill. */}- <MobileDrawer.Trigger- as={Button}- variant="ghost"- size="sm"- aria-label="Agent model"- disabled={props.disabled || props.changingTo !== undefined}- onPointerDown={(event: PointerEvent) => event.preventDefault()}- onMouseDown={(event: MouseEvent) => event.preventDefault()}- class="h-8 max-w-[60vw] min-w-0 justify-start gap-1.5 rounded-lg border-none bg-transparent px-1.5 text-left text-sm text-ink-subtle hover:bg-hover"- >- <ModelIcon model={shown()} />- <span class="min-w-0 truncate">{label()}</span>- <CaretDown class="size-3.5 shrink-0" />- </MobileDrawer.Trigger>- <MobileDrawer.Portal>- <MobileDrawer.Overlay />- <MobileDrawer.Content aria-label="Choose a model">- <MobileDrawer.Handle />- <div class="flex items-center gap-2 px-4 pb-3">- <Show when={showAll()}>- <Button- variant="ghost"- size="icon-md"- label="Back to Suggested"- onClick={() => {- setShowAll(false);- setQuery('');- searchInput?.focus();- }}- >- <ArrowLeft />- </Button>- </Show>- <MobileDrawer.Title class="min-w-0 flex-1 truncate font-medium">- {showAll() ? 'All models' : 'Choose a model'}- </MobileDrawer.Title>- </div>- <div class="mx-4 mb-2 flex h-9 shrink-0 items-center gap-2 px-3">- <SearchIcon class="size-4 shrink-0 text-ink-extra-muted" />- <input- ref={searchInput}- type="text"- aria-label="Search models"- placeholder="Search models"- value={query()}- onInput={(event) => setQuery(event.currentTarget.value)}- class="h-full min-w-0 w-full border-0 bg-transparent p-0 text-base outline-none placeholder:text-ink-extra-muted"- />- </div>- <MobileDrawer.ScrollBody class="gap-1">- <Show when={groups().length === 0}>- <div role="status" class="px-4 py-3 text-sm text-ink-muted">- {props.options.length === 0- ? 'Waiting for the agent to report its models.'- : 'No models match that search.'}- </div>- </Show>- <For each={groups()}>- {(group) => (- <>- <Show when={group.label}>- {(heading) => (- <MobileDrawer.Label class="px-4 pb-1 font-medium text-ink-muted">- {heading()}- </MobileDrawer.Label>- )}- </Show>- <MobileDrawer.Section- role="radiogroup"- aria-label={group.label ?? 'Models'}- class="rounded-none bg-transparent p-0"- >- <For each={group.options}>- {(option) => (- <MobileDrawer.Item- type="button"- role="radio"- aria-checked={option.id === shown()}- title={option.description ?? undefined}- onClick={() => pick(option.id)}- >- <ModelIcon model={option.id} />- <span class="min-w-0 flex-1 truncate">- {option.label}- </span>- <Show when={option.id === shown()}>- <Check class="size-3.5 shrink-0 text-accent" />- </Show>- </MobileDrawer.Item>- )}- </For>- </MobileDrawer.Section>- </>- )}- </For>- <Show- when={- !showAll() && !query().trim() && catalog().frontier.length > 0- }- >- <MobileDrawer.Section class="rounded-none bg-transparent p-0">- <MobileDrawer.Item- onClick={() => {- setShowAll(true);- searchInput?.focus();- }}- >- <SquaresFour class="size-4 shrink-0 text-ink-muted" />- <span class="flex-1">More models</span>- <CaretRight class="size-4" />- </MobileDrawer.Item>- </MobileDrawer.Section>- </Show>- </MobileDrawer.ScrollBody>- </MobileDrawer.Content>- </MobileDrawer.Portal>- </MobileDrawer>- );-- const shortList = (- <Dropdown placement="top-start">- <Dropdown.Trigger- variant="ghost"- size="sm"- class={PILL_TRIGGER_CLASS}- disabled={props.disabled}- >- <ModelIcon model={shown()} class="size-3.5" />- <span class="min-w-0 truncate">{label()}</span>- <CaretDown class="shrink-0" />- </Dropdown.Trigger>- <Dropdown.Content class="w-60 max-w-[calc(100vw-1rem)] overflow-hidden">- {/* The gradients anchor here, outside the scrolling box, and read- the menu background through `--color-surface`. */}- <div class="relative [--color-surface:var(--color-menu)]">- <Dropdown.Group- ref={setListRef}- class="overflow-y-auto overscroll-contain p-0"- style={{ 'max-height': LIST_MAX_HEIGHT }}- >- <div class="flex flex-col p-1.5">- <For each={options()}>- {(option) => (- <Dropdown.Item- class={cn(- 'h-7 shrink-0 gap-2',- option.id === shown() && 'text-ink font-medium'- )}- title={option.description ?? undefined}- onSelect={() => pick(option.id)}- >- <ModelIcon model={option.id} class="size-3.5" />- <span class="flex-1 truncate">- {modelLabel(option.id, option.name)}- </span>- </Dropdown.Item>- )}- </For>- </div>- </Dropdown.Group>- <ScrollIndicators scrollRef={listRef} appearance="gradient" />- </div>- </Dropdown.Content>- </Dropdown>+ [+ modelLabel(+ shown() ?? undefined,+ props.options.find((option) => option.id === shown())?.name+ ),+ props.effortLabel,+ ]+ .filter(Boolean)+ .join(' · ');+ const options = createMemo(() =>+ withoutRedundantGroups(props.options).map((option) => ({+ id: option.id,+ label: modelLabel(option.id, option.name),+ description: option.description ?? undefined,+ group: option.group ?? undefined,+ })));return (<Show when={isTouchDevice() || props.options.length > 0}>- <Show when={!isTouchDevice()} fallback={sheet}>- <Show when={useCatalog() || props.modelRow} fallback={shortList}>- <ModelCatalogPicker- value={shown()}- options={catalogOptions()}- onSelect={pick}- modelRow={props.modelRow}- triggerLabel={label()}- disabled={props.disabled}- ariaLabel="Agent model"- searchPlaceholder="Search models"- triggerClass={PILL_TRIGGER_CLASS}- contentClass="overflow-hidden"- placement="top-start"- />- </Show>- </Show>+ <ModelCatalogPicker+ value={shown()}+ options={options()}+ onSelect={(id) => {+ if (id !== props.model) props.onSelect(id);+ }}+ onCloseAutoFocus={props.onCloseAutoFocus}+ modelRow={props.modelRow}+ triggerLabel={label()}+ disabled={props.disabled}+ pending={isTouchDevice() && props.changingTo !== undefined}+ ariaLabel="Agent model"+ emptyMessage="Waiting for the agent to report its models."+ triggerClass={PILL_TRIGGER_CLASS}+ contentClass="overflow-hidden"+ placement="top-start"+ /></Show>);}diff --git a/apps/web/src/features/channel/Input/ComposerAddMenu.tsx b/apps/web/src/features/channel/Input/ComposerAddMenu.tsxindex ad2f2dd3f3..b454d6315c 100644--- a/apps/web/src/features/channel/Input/ComposerAddMenu.tsx+++ b/apps/web/src/features/channel/Input/ComposerAddMenu.tsx@@ -94,7 +94,6 @@ function AddDropdown(props: {return (<Dropdown placement={props.placement ?? 'top-start'} gutter={8}><Dropdown.Trigger- data-composer-menu-anchorvariant="ghost"size="icon-composer"class={cn('touch:size-6', props.class)}diff --git a/apps/web/src/features/settings/Agents.test.tsx b/apps/web/src/features/settings/Agents.test.tsxindex c293cdbe10..1b86958b14 100644--- a/apps/web/src/features/settings/Agents.test.tsx+++ b/apps/web/src/features/settings/Agents.test.tsx@@ -23,7 +23,12 @@ import { Suspense } from 'solid-js';import { createStore } from 'solid-js/store';import { beforeAll, beforeEach, describe, expect, it, vi } from 'vitest';import { Agents } from './Agents';-import { chooseSelectOption, selectOptions } from './tests/select-helpers';+import {+ chooseModelOption,+ chooseSelectOption,+ modelOptions,+ selectOptions,+} from './tests/select-helpers';const agentsPageProps = {onCursor: vi.fn(),@@ -1375,13 +1380,9 @@ describe('Agents', () => {expect(cursor).toHaveProperty('checked', true);const defaultModel = within(dialog).getByLabelText('Default model');- expect(selectOptions(defaultModel).getAllByRole('option')).toHaveLength(2);- expect(- selectOptions(defaultModel)- .getByRole('option', { name: 'Cursor Small' })- .getAttribute('aria-selected')- ).toBe('true');- chooseSelectOption(defaultModel, 'Cursor Large');+ expect(modelOptions(defaultModel).getAllByRole('menuitem')).toHaveLength(2);+ expect(defaultModel.textContent).toBe('Cursor Small');+ chooseModelOption(defaultModel, 'Cursor Large');expect(defaultModel.textContent).toBe('Cursor Large');fireEvent.input(within(dialog).getByLabelText('Name'), {target: { value: 'Coding agent' },@@ -1529,7 +1530,7 @@ describe('Agents', () => {render(() => <Agents {...agentsPageProps} />);fireEvent.click(screen.getByRole('button', { name: 'Add agent' }));const dialog = screen.getByRole('region', { name: /^(New|Edit) agent$/ });- expect(within(dialog).getByText('Claude Sonnet 4.5')).toBeTruthy();+ expect(within(dialog).getByText('Sonnet 5.5')).toBeTruthy();fireEvent.click(within(dialog).getByRole('radio', { name: 'In Cursor' }));expect(@@ -1577,7 +1578,7 @@ describe('Agents', () => {const defaultModel = within(dialog).getByLabelText('Default model');expect(defaultModel.tagName).toBe('BUTTON');expect(defaultModel).toHaveProperty('textContent', 'Codex');- expect(selectOptions(defaultModel).getAllByRole('option')).toHaveLength(2);+ expect(modelOptions(defaultModel).getAllByRole('menuitem')).toHaveLength(2);});it('falls back to the first advertised model when current is absent', () => {@@ -1623,7 +1624,7 @@ describe('Agents', () => {'provider-default (unavailable)');expect(- selectOptions(defaultModel).getByRole('option', {+ modelOptions(defaultModel).getByRole('menuitem', {name: 'provider-default (unavailable)',})).toBeTruthy();@@ -1739,9 +1740,13 @@ describe('Agents', () => {'textContent','retired-model (saved, unavailable)');+ fireEvent.keyDown(defaultModel, { key: 'Enter' });+ fireEvent.input(screen.getByRole('textbox', { name: 'Search models' }), {+ target: { value: 'retired' },+ });expect(- selectOptions(defaultModel).getByRole('option', {- name: 'retired-model (saved, unavailable)',+ screen.getByRole('menuitem', {+ name: /^retired-model \(saved, unavailable\)/,})).toBeTruthy();});diff --git a/apps/web/src/features/settings/Agents.tsx b/apps/web/src/features/settings/Agents.tsxindex 9e9106ab9b..2fb6dc80b7 100644--- a/apps/web/src/features/settings/Agents.tsx+++ b/apps/web/src/features/settings/Agents.tsx@@ -5,8 +5,8 @@ import {} from '@app/features/agents-view/core/agent-kind';import { AGENTS_TOUR } from '@app/features/agents-view/tour';import { ModelCatalogPicker } from '@core/component/AI/component/input/ModelCatalogPicker';-import { isLargeModelCatalog } from '@core/component/AI/component/input/modelCatalog';import { MODEL_PRETTYNAME, Model } from '@core/component/AI/constant/model';+import { modelLabel } from '@core/component/AI/constant/model-label';import { toast } from '@core/component/Toast/Toast';import { ENABLE_AGENT_DMS } from '@core/constant/featureFlags';import {@@ -713,12 +713,15 @@ function AgentEditorPage(props: {const selectedCatalogOptions = () =>selectedModelOptions().map((model) => ({id: model.id,- label: model.name,+ // The built-in runtime reports slugs as names; other runtimes name+ // their own models.+ label:+ harnessId() === IN_MEMORY_HARNESS.id+ ? modelLabel(model.id, model.name)+ : model.name,description: model.description ?? undefined,group: model.group ?? undefined,}));- const selectedHarnessUsesCatalog = () =>- isLargeModelCatalog(selectedCatalogOptions());const [channelMode, setChannelMode] = createSignal<ChannelMode>(props.agent?.channel_scope ?? 'all');@@ -818,12 +821,14 @@ function AgentEditorPage(props: {<Showwhen={!query.isPending}fallback={- <SettingsSelect- label="Default model"+ <ModelCatalogPicker+ value={null}options={[]}placeholder="Loading models…"- onChange={setDefaultModelId}- disabled+ onSelect={setDefaultModelId}+ ariaLabel="Default model"+ triggerClass="w-full justify-between"+ pending/>}>@@ -865,26 +870,15 @@ function AgentEditorPage(props: {</p>}>- <Show- when={selectedHarnessUsesCatalog()}- fallback={- <SettingsSelect- label="Default model"- options={selectedModelOptions()}- value={selectedDefaultModelId()}- onChange={setDefaultModelId}- />- }- >- <ModelCatalogPicker- value={selectedDefaultModelId()}- options={selectedCatalogOptions()}- onSelect={setDefaultModelId}- ariaLabel="Default model"- triggerClass="w-full justify-between"- contentClass="overflow-hidden"- />- </Show>+ <ModelCatalogPicker+ value={selectedDefaultModelId()}+ options={selectedCatalogOptions()}+ onSelect={setDefaultModelId}+ ariaLabel="Default model"+ triggerClass="w-full justify-between"+ contentClass="overflow-hidden"+ placement="bottom-start"+ /></Show></Show></Show>diff --git a/apps/web/src/features/settings/CursorConnectPage.test.tsx b/apps/web/src/features/settings/CursorConnectPage.test.tsxindex 38b33dbf77..6f3c2a88d3 100644--- a/apps/web/src/features/settings/CursorConnectPage.test.tsx+++ b/apps/web/src/features/settings/CursorConnectPage.test.tsx@@ -5,7 +5,7 @@import { fireEvent, render, screen, waitFor } from '@solidjs/testing-library';import { beforeAll, beforeEach, describe, expect, it, vi } from 'vitest';import { CursorConnectPage } from './CursorConnectPage';-import { chooseSelectOption } from './tests/select-helpers';+import { chooseModelOption } from './tests/select-helpers';vi.mock('@ui', async (importOriginal) => ({...(await importOriginal<typeof import('@ui')>()),@@ -142,7 +142,7 @@ describe('CursorConnectPage', () => {expect(screen.getByText('Connected')).toBeTruthy();expect(screen.queryByLabelText('API key')).toBeNull();- chooseSelectOption(screen.getByLabelText('Default model'), 'Composer');+ chooseModelOption(screen.getByLabelText('Default model'), 'Composer');await waitFor(() => {expect(mocks.setDefaultModel).toHaveBeenCalledWith('composer');expect(mocks.toastSuccess).toHaveBeenCalledWith('Default model updated');diff --git a/apps/web/src/features/settings/Harness.test.tsx b/apps/web/src/features/settings/Harness.test.tsxindex ecc7f8a76a..309969ff6d 100644--- a/apps/web/src/features/settings/Harness.test.tsx+++ b/apps/web/src/features/settings/Harness.test.tsx@@ -24,7 +24,7 @@ import {import { Suspense } from 'solid-js';import { beforeAll, beforeEach, describe, expect, it, vi } from 'vitest';import { Harness } from './Harness';-import { chooseSelectOption } from './tests/select-helpers';+import { chooseModelOption } from './tests/select-helpers';vi.mock('@ui', async (importOriginal) => ({...(await importOriginal<typeof import('@ui')>()),@@ -342,7 +342,7 @@ describe('Harness', () => {expect(screen.queryByLabelText('API key')).toBeNull();expect(screen.getByText(/does not revoke it in Cursor/)).toBeTruthy();- chooseSelectOption(screen.getByLabelText('Default model'), 'Another Model');+ chooseModelOption(screen.getByLabelText('Default model'), 'Another Model');await waitFor(() => {expect(mocks.setDefaultModel).toHaveBeenCalledWith('another-model');expect(mocks.toastSuccess).toHaveBeenCalledWith('Default model updated');diff --git a/apps/web/src/features/settings/components/cursor-default-model.tsx b/apps/web/src/features/settings/components/cursor-default-model.tsxindex 2f6c643ced..a483122bbd 100644--- a/apps/web/src/features/settings/components/cursor-default-model.tsx+++ b/apps/web/src/features/settings/components/cursor-default-model.tsx@@ -1,5 +1,4 @@import { ModelCatalogPicker } from '@core/component/AI/component/input/ModelCatalogPicker';-import { isLargeModelCatalog } from '@core/component/AI/component/input/modelCatalog';import { toast } from '@core/component/Toast/Toast';import { fireAndForget } from '@core/util/fireAndForget';import { ThrownResultError } from '@core/util/result';@@ -10,7 +9,6 @@ import {} from '@queries/auth/cursor-api-key';import { Button } from '@ui';import { Show } from 'solid-js';-import { SettingsSelect } from './settings-select';/*** The model new Cursor sessions start on. Saves on change; renders loading,@@ -73,13 +71,17 @@ export function CursorDefaultModel(props: { triggerClass?: string }) {<Showwhen={!cursorModels.isPending}fallback={- <SettingsSelect- label="Default model"+ <ModelCatalogPicker+ value={null}options={[]}placeholder="Loading models…"- triggerClass={props.triggerClass}- onChange={(id) => fireAndForget(changeModel(id), 'cursor-connect')}- disabled+ onSelect={(id) => fireAndForget(changeModel(id), 'cursor-connect')}+ ariaLabel="Default model"+ triggerClass={+ props.triggerClass ??+ 'h-9 w-full justify-between text-base [&>span]:flex-1'+ }+ pending/>}>@@ -109,36 +111,18 @@ export function CursorDefaultModel(props: { triggerClass?: string }) {</p>}>- <Show- when={isLargeModelCatalog(catalogOptions())}- fallback={- <SettingsSelect- label="Default model"- options={modelOptions()}- value={selectedModelId()}- triggerClass={props.triggerClass}- disabled={setDefaultModel.isPending}- onChange={(id) =>- fireAndForget(changeModel(id), 'cursor-connect')- }- />+ <ModelCatalogPicker+ value={selectedModelId()}+ options={catalogOptions()}+ onSelect={(id) => fireAndForget(changeModel(id), 'cursor-connect')}+ disabled={setDefaultModel.isPending}+ ariaLabel="Default model"+ triggerClass={+ props.triggerClass ??+ 'h-9 w-full justify-between text-base [&>span]:flex-1'}- >- <ModelCatalogPicker- value={selectedModelId()}- options={catalogOptions()}- onSelect={(id) =>- fireAndForget(changeModel(id), 'cursor-connect')- }- disabled={setDefaultModel.isPending}- ariaLabel="Default model"- triggerClass={- props.triggerClass ??- 'h-9 w-full justify-between text-base [&>span]:flex-1'- }- placement="bottom-start"- />- </Show>+ placement="bottom-start"+ /></Show></Show></Show>diff --git a/apps/web/src/features/settings/tests/select-helpers.ts b/apps/web/src/features/settings/tests/select-helpers.tsindex 0d95e89f16..b090d56068 100644--- a/apps/web/src/features/settings/tests/select-helpers.ts+++ b/apps/web/src/features/settings/tests/select-helpers.ts@@ -20,3 +20,26 @@ export function chooseSelectOption(trigger: HTMLElement, name: string) {const listbox = openSelect(trigger);fireEvent.click(within(listbox).getByRole('option', { name }));}++function openModelMenu(trigger: HTMLElement) {+ fireEvent.keyDown(trigger, { key: 'Enter' });+ const menu = screen+ .getAllByRole('menu')+ .find((element) => element.getAttribute('aria-labelledby') === trigger.id);+ if (!menu) throw new Error('No model menu labelled by the picker trigger');+ return menu;+}++/** Inspect a model picker's rows, then close it without changing it. */+export function modelOptions(trigger: HTMLElement) {+ const menu = openModelMenu(trigger);+ fireEvent.keyDown(menu, { key: 'Escape' });+ return within(menu);+}++export function chooseModelOption(trigger: HTMLElement, name: string) {+ const menu = openModelMenu(trigger);+ const item = within(menu).getByRole('menuitem', { name });+ item.focus();+ fireEvent.keyDown(item, { key: 'Enter' });+}diff --git a/apps/web/src/lib/core/component/AI/component/input/ChatInput.model.test.tsx b/apps/web/src/lib/core/component/AI/component/input/ChatInput.model.test.tsxindex fd3f8fcca3..552526a7ee 100644--- a/apps/web/src/lib/core/component/AI/component/input/ChatInput.model.test.tsx+++ b/apps/web/src/lib/core/component/AI/component/input/ChatInput.model.test.tsx@@ -215,9 +215,12 @@ it('preserves a real soup composer selection when creating and opening its firstfireEvent.click(screen.getByRole('button', { name: 'Choose model, Sonnet 5.5' }));- const dialog = await screen.findByRole('dialog', { name: 'Select model' });- fireEvent.click(within(dialog).getByRole('button', { name: 'GPT-5.6' }));- fireEvent.click(within(dialog).getByRole('button', { name: 'Done' }));+ const dialog = await screen.findByRole('dialog', { name: 'Choose a model' });+ fireEvent.input(+ within(dialog).getByRole('textbox', { name: 'Search models' }),+ { target: { value: 'GPT-5.6' } }+ );+ fireEvent.click(within(dialog).getByRole('radio', { name: 'GPT-5.6' }));await waitFor(() => expect(screen.queryByRole('dialog')).toBeNull());expect(screen.getByRole('button', { name: 'Choose model, GPT-5.6' })@@ -318,23 +321,31 @@ it.each([true, false])(<ChatInput variant="default" editor={editor} onSend={onSend} /></ChatInputProvider>));- const trigger = mobile- ? screen.getByRole('button', { name: 'Choose model, Sonnet 5.5' })- : screen.getByRole('button', { name: 'Sonnet 5.5' });+ const trigger = screen.getByRole('button', {+ name: 'Choose model, Sonnet 5.5',+ });if (mobile) fireEvent.click(trigger);else fireEvent.keyDown(trigger, { key: 'ArrowDown' });if (mobile) {const dialog = await screen.findByRole('dialog', {- name: 'Select model',+ name: 'Choose a model',});- fireEvent.click(within(dialog).getByRole('button', { name: 'GPT-5.6' }));- expect(screen.getByTestId('model').textContent).toBe(Model.gpt56);- fireEvent.click(within(dialog).getByRole('button', { name: 'Done' }));+ fireEvent.input(+ within(dialog).getByRole('textbox', { name: 'Search models' }),+ { target: { value: 'GPT-5.6' } }+ );+ fireEvent.click(within(dialog).getByRole('radio', { name: 'GPT-5.6' }));await waitFor(() => expect(screen.queryByRole('dialog')).toBeNull());} else {+ fireEvent.input(+ await screen.findByRole('textbox', { name: 'Search models' }),+ { target: { value: 'GPT-5.6' } }+ );fireEvent.keyDown(- await screen.findByRole('menuitem', { name: 'GPT-5.6' }),- { key: 'Enter' }+ screen.getByRole('menuitem', { name: /^GPT-5\.6 OpenAI$/ }),+ {+ key: 'Enter',+ });await waitFor(() => expect(screen.queryByRole('menu')).toBeNull());}diff --git a/apps/web/src/lib/core/component/AI/component/input/ModelCatalogPicker.tsx b/apps/web/src/lib/core/component/AI/component/input/ModelCatalogPicker.tsxindex f9108c5763..9a344cc826 100644--- a/apps/web/src/lib/core/component/AI/component/input/ModelCatalogPicker.tsx+++ b/apps/web/src/lib/core/component/AI/component/input/ModelCatalogPicker.tsx@@ -1,10 +1,14 @@+import { MobileDrawer } from '@components/app/mobile/MobileDrawer';+import { isTouchDevice } from '@core/mobile/isTouchDevice';import { isMobileWidth } from '@core/mobile/mobileWidth';+import ArrowLeft from '@icon/system/regular/arrow-left.svg';import CaretDown from '@icon/system/regular/caret-left.svg';import CaretRight from '@icon/system/regular/caret-right.svg';import CheckIcon from '@icon/system/regular/check.svg';+import LockIcon from '@icon/system/regular/lock-simple.svg';import MagnifyingGlassIcon from '@icon/system/regular/magnifying-glass.svg';import SquaresFour from '@icon/system/regular/squares-four.svg';-import { cn, Dropdown } from '@ui';+import { Button, cn, Dropdown } from '@ui';import {type Component,createMemo,@@ -27,22 +31,22 @@ type ModelCatalogPickerProps = {value: string | null;options: CatalogModelOption[];onSelect: (id: string) => void;+ /** Called instead of `onSelect` for a `locked` option, e.g. to open the paywall. */+ onLocked?: (id: string) => void;onCloseAutoFocus?: (event: Event) => void;modelRow?: Component<ModelRowProps>;disabled?: boolean;+ /** Show only the selected model's logo in the trigger. */+ compact?: boolean;pending?: boolean;triggerLabel?: JSX.Element;children?: JSX.Element;- /** Optional overview that can reveal the complete catalog. */- menu?: (catalog: JSX.Element) => JSX.Element;emptyMessage?: string;triggerClass?: string;contentClass?: string;placeholder?: string;searchPlaceholder?: string;ariaLabel?: string;- getAnchorRect?: (anchor?: HTMLElement) => DOMRect | undefined;- gutter?: number;placement?: 'top-start' | 'top-end' | 'bottom-start' | 'bottom-end';};@@ -61,8 +65,17 @@ export function ModelRow(props: ModelRowProps) {<Dropdown.ItemcloseOnSelectdisabled={props.disabled}- class={cn('h-8 gap-2', props.selected && 'bg-ink/5 text-ink font-medium')}+ class={cn(+ 'h-8 gap-2',+ props.selected && 'bg-ink/5 text-ink font-medium',+ props.option.locked && 'opacity-50'+ )}title={props.option.description ?? props.option.label}+ aria-label={+ props.option.locked+ ? `${props.option.label}, upgrade required`+ : undefined+ }onSelect={props.onSelect}><ModelIcon model={props.option.id} />@@ -70,6 +83,9 @@ export function ModelRow(props: ModelRowProps) {<Show when={props.hint}><span class="shrink-0 text-xs text-ink-extra-muted">{props.hint}</span></Show>+ <Show when={props.option.locked}>+ <LockIcon class="size-3.5 shrink-0 text-ink-extra-muted" />+ </Show><Show when={props.selected}><CheckIcon class="size-3.5 shrink-0 text-accent" /></Show>@@ -80,7 +96,6 @@ export function ModelRow(props: ModelRowProps) {/** One model section, shared by the frontier shortlist and provider groups. */function ModelList(props: {label: string;- hideLabel?: boolean;options: CatalogModelOption[];value: string | null;disabled?: boolean;@@ -90,15 +105,10 @@ function ModelList(props: {}) {const Row = props.row;return (- <Dropdown.Group- class="bg-transparent py-0"- aria-label={props.hideLabel ? props.label : undefined}- >- <Show when={!props.hideLabel}>- <Dropdown.GroupLabel class="h-6 font-medium text-ink-muted">- {props.label}- </Dropdown.GroupLabel>- </Show>+ <Dropdown.Group class="bg-transparent py-0">+ <Dropdown.GroupLabel class="h-6 font-medium text-ink-muted">+ {props.label}+ </Dropdown.GroupLabel><For each={props.options}>{(option) => (<Row@@ -182,6 +192,11 @@ function keepSearchFocused(input: () => HTMLInputElement | undefined) {});}+/**+ * The one model selector: a searchable popover on desktop and a bottom sheet+ * on touch devices, with Suggested first and the complete catalog behind+ * More models. Composers, sessions, and settings all render this.+ */export function ModelCatalogPicker(props: ModelCatalogPickerProps) {const [open, setOpen] = createSignal(false);let searchRef: HTMLInputElement | undefined;@@ -189,74 +204,276 @@ export function ModelCatalogPicker(props: ModelCatalogPickerProps) {const selected = () =>props.options.find((option) => option.id === props.value) ?? null;const displayValue = () => selected()?.label ?? props.placeholder ?? 'Model';- const catalog = () => (- <ModelCatalogMenu- value={props.value}- options={props.options}- disabled={props.disabled || props.pending}- onSelect={(id) => {- props.onSelect(id);- setOpen(false);- }}- onClose={() => setOpen(false)}- modelRow={props.modelRow}- emptyMessage={props.emptyMessage}- searchPlaceholder={props.searchPlaceholder}- autoFocusSearch- searchRef={(element) => {- searchRef = element;- }}+ const title = () =>+ typeof props.triggerLabel === 'string'+ ? props.triggerLabel+ : displayValue();+ const choose = (id: string) => {+ setOpen(false);+ if (props.options.find((option) => option.id === id)?.locked)+ props.onLocked?.(id);+ else props.onSelect(id);+ };+ const triggerContents = () => (+ <>+ <ModelIcon model={props.value} />+ <Show when={!props.compact}>+ <span class="min-w-0 flex-1 truncate text-left">+ {props.triggerLabel ?? displayValue()}+ </span>+ <CaretDown class="size-3.5 shrink-0 rotate-[-90deg] opacity-70" />+ </Show>+ </>+ );+ const triggerClass = () =>+ cn(+ 'h-9 justify-between border border-edge-muted bg-transparent px-3 text-left text-sm text-ink hover:bg-ink/3',+ props.triggerClass+ );++ return (+ <Show+ when={!isTouchDevice()}+ fallback={+ <ModelCatalogSheet+ {...props}+ open={open()}+ onOpenChange={setOpen}+ onChoose={choose}+ trigger={triggerContents()}+ triggerClass={triggerClass()}+ title={title()}+ />+ }>- {props.children}- </ModelCatalogMenu>+ <Dropdown+ open={open()}+ onOpenChange={setOpen}+ placement={props.placement ?? 'top-start'}+ >+ <Dropdown.Trigger+ variant="ghost"+ size="sm"+ class={triggerClass()}+ aria-label={props.ariaLabel}+ aria-busy={props.pending || undefined}+ title={title()}+ disabled={props.disabled || props.pending}+ >+ {triggerContents()}+ </Dropdown.Trigger>+ <Dropdown.Content+ onCloseAutoFocus={props.onCloseAutoFocus}+ onPointerDown={(event: PointerEvent) => event.stopPropagation()}+ onMouseDown={(event: MouseEvent) => event.stopPropagation()}+ class={cn(+ 'w-72 max-w-[calc(100vw-1rem)] max-h-[min(28rem,var(--kb-popper-content-available-height))] overflow-y-auto overscroll-contain',+ props.contentClass+ )}+ onOpenAutoFocus={(event) => {+ event.preventDefault();+ focusSearchAfterMenuOpen(() => searchRef);+ }}+ >+ <ModelCatalogMenu+ value={props.value}+ options={props.options}+ disabled={props.disabled || props.pending}+ onSelect={choose}+ onClose={() => setOpen(false)}+ modelRow={props.modelRow}+ emptyMessage={props.emptyMessage}+ searchPlaceholder={props.searchPlaceholder}+ searchRef={(element) => {+ searchRef = element;+ }}+ >+ {props.children}+ </ModelCatalogMenu>+ </Dropdown.Content>+ </Dropdown>+ </Show>);+}++/** Touch devices: the same catalog as a searchable bottom sheet. */+function ModelCatalogSheet(+ props: ModelCatalogPickerProps & {+ open: boolean;+ onOpenChange: (open: boolean) => void;+ onChoose: (id: string) => void;+ trigger: JSX.Element;+ triggerClass: string;+ title: string;+ }+) {+ const [query, setQuery] = createSignal('');+ const [showAll, setShowAll] = createSignal(false);+ let searchInput: HTMLInputElement | undefined;+ const catalog = createMemo(() => buildModelCatalog(props.options, true));+ const groups = createMemo(() => {+ const queryText = query().trim().toLowerCase();+ const sections =+ showAll() || queryText || catalog().frontier.length === 0+ ? catalog().providers+ : [{ label: 'Suggested', options: catalog().frontier }];+ return sections+ .map((section) => ({+ ...section,+ options: section.options.filter((option) =>+ matchesModelQuery(option, queryText)+ ),+ }))+ .filter((section) => section.options.length > 0);+ });+ const changeOpen = (open: boolean) => {+ props.onOpenChange(open);+ if (!open) {+ setQuery('');+ setShowAll(false);+ }+ };return (- <Dropdown- open={open()}- onOpenChange={setOpen}- placement={props.placement ?? 'top-start'}- getAnchorRect={props.getAnchorRect}- gutter={props.gutter ?? 4}+ <MobileDrawer+ side="bottom"+ open={props.open}+ onOpenChange={changeOpen}+ restoreFocus={!!props.onCloseAutoFocus}+ onFinalFocus={props.onCloseAutoFocus}+ onInitialFocus={(event) => {+ event.preventDefault();+ searchInput?.focus();+ }}+ preventScroll={false}+ preventScrollbarShift={false}>- <Dropdown.Trigger+ <MobileDrawer.Trigger+ as={Button}variant="ghost"size="sm"- class={cn(- 'h-9 justify-between border border-edge-muted bg-transparent px-3 text-left text-sm text-ink hover:bg-ink/3',- props.triggerClass- )}aria-label={props.ariaLabel}aria-busy={props.pending || undefined}- title={- typeof props.triggerLabel === 'string'- ? props.triggerLabel- : displayValue()- }+ title={props.title}disabled={props.disabled || props.pending}+ // Keep the editor focused (and the keyboard up) until the tap lands.+ onPointerDown={(event: PointerEvent) => event.preventDefault()}+ onMouseDown={(event: MouseEvent) => event.preventDefault()}+ class={props.triggerClass}>- <ModelIcon model={props.value} />- <span class="min-w-0 flex-1 truncate text-left">- {props.triggerLabel ?? displayValue()}- </span>- <CaretDown class="size-3.5 shrink-0 rotate-[-90deg] opacity-70" />- </Dropdown.Trigger>- <Dropdown.Content- onCloseAutoFocus={props.onCloseAutoFocus}- onPointerDown={(event: PointerEvent) => event.stopPropagation()}- onMouseDown={(event: MouseEvent) => event.stopPropagation()}- class={cn(- 'w-72 max-w-[calc(100vw-1rem)] max-h-[min(28rem,var(--kb-popper-content-available-height))] overflow-y-auto overscroll-contain',- props.contentClass- )}- onOpenAutoFocus={(event) => {- event.preventDefault();- focusSearchAfterMenuOpen(() => searchRef);- }}- >- {props.menu ? props.menu(catalog()) : catalog()}- </Dropdown.Content>- </Dropdown>+ {props.trigger}+ </MobileDrawer.Trigger>+ <MobileDrawer.Portal>+ <MobileDrawer.Overlay />+ <MobileDrawer.Content aria-label="Choose a model">+ <MobileDrawer.Handle />+ <div class="flex items-center gap-2 px-4 pb-3">+ <Show when={showAll()}>+ <Button+ variant="ghost"+ size="icon-md"+ label="Back to Suggested"+ onClick={() => {+ setShowAll(false);+ setQuery('');+ searchInput?.focus();+ }}+ >+ <ArrowLeft />+ </Button>+ </Show>+ <MobileDrawer.Title class="min-w-0 flex-1 truncate font-medium">+ {showAll() ? 'All models' : 'Choose a model'}+ </MobileDrawer.Title>+ </div>+ <div class="mx-4 mb-2 flex h-9 shrink-0 items-center gap-2 px-3">+ <MagnifyingGlassIcon class="size-4 shrink-0 text-ink-extra-muted" />+ <input+ ref={searchInput}+ type="text"+ aria-label={props.searchPlaceholder ?? 'Search models'}+ placeholder={props.searchPlaceholder ?? 'Search models'}+ value={query()}+ onInput={(event) => setQuery(event.currentTarget.value)}+ class="h-full min-w-0 w-full border-0 bg-transparent p-0 text-base outline-none placeholder:text-ink-extra-muted"+ />+ </div>+ <MobileDrawer.ScrollBody class="gap-1">+ <Show when={groups().length === 0}>+ <div role="status" class="px-4 py-3 text-sm text-ink-muted">+ {props.options.length === 0+ ? (props.emptyMessage ?? 'No models available.')+ : 'No models match that search.'}+ </div>+ </Show>+ <For each={groups()}>+ {(group) => (+ <>+ <MobileDrawer.Label class="px-4 pb-1 font-medium text-ink-muted">+ {group.label}+ </MobileDrawer.Label>+ <MobileDrawer.Section+ role="radiogroup"+ aria-label={group.label}+ class="rounded-none bg-transparent p-0"+ >+ <For each={group.options}>+ {(option) => (+ <MobileDrawer.Item+ type="button"+ role="radio"+ aria-checked={option.id === props.value}+ aria-label={+ option.locked+ ? `${option.label}, upgrade required`+ : undefined+ }+ aria-disabled={props.disabled || undefined}+ title={option.description}+ class={cn(option.locked && 'opacity-50')}+ onClick={() => {+ if (!props.disabled) props.onChoose(option.id);+ }}+ >+ <ModelIcon model={option.id} />+ <span class="min-w-0 flex-1 truncate">+ {option.label}+ </span>+ <Show when={option.locked}>+ <LockIcon class="size-3.5 shrink-0 text-ink-muted" />+ </Show>+ <Show when={option.id === props.value}>+ <CheckIcon class="size-3.5 shrink-0 text-accent" />+ </Show>+ </MobileDrawer.Item>+ )}+ </For>+ </MobileDrawer.Section>+ </>+ )}+ </For>+ <Show+ when={+ !showAll() && !query().trim() && catalog().frontier.length > 0+ }+ >+ <MobileDrawer.Section class="rounded-none bg-transparent p-0">+ <MobileDrawer.Item+ onClick={() => {+ setShowAll(true);+ searchInput?.focus();+ }}+ >+ <SquaresFour class="size-4 shrink-0 text-ink-muted" />+ <span class="flex-1">More models</span>+ <CaretRight class="size-4" />+ </MobileDrawer.Item>+ </MobileDrawer.Section>+ </Show>+ </MobileDrawer.ScrollBody>+ </MobileDrawer.Content>+ </MobileDrawer.Portal>+ </MobileDrawer>);}@@ -280,8 +497,6 @@ export function ModelCatalogMenu(*/autoFocusSearch?: boolean;fullCatalog?: boolean;- suggestedFirst?: boolean;- searchable?: boolean;onClose?: () => void;}) {@@ -290,8 +505,7 @@ export function ModelCatalogMenu(const [query, setQuery] = createSignal('');const [showAll, setShowAll] = createSignal(false);onMount(() => {- if (props.autoFocusSearch && props.searchable !== false)- keepSearchFocused(() => searchEl);+ if (props.autoFocusSearch) keepSearchFocused(() => searchEl);});const normalizedQuery = () => query().trim().toLowerCase();const filtered = createMemo(() => {@@ -305,35 +519,33 @@ export function ModelCatalogMenu(return (<>- <Show when={props.searchable !== false}>- <div class="sticky top-0 z-10 bg-menu py-1">- <div class="flex h-8 items-center gap-2 px-3">- <MagnifyingGlassIcon- aria-hidden="true"- class="size-4 shrink-0 text-ink-extra-muted"- />- <input- ref={(element) => {- searchEl = element;- props.searchRef?.(element);- }}- aria-label={props.searchPlaceholder ?? 'Search models'}- placeholder={props.searchPlaceholder ?? 'Search models'}- value={query()}- onInput={(event) => setQuery(event.currentTarget.value)}- onMouseDown={(event: MouseEvent) => event.stopPropagation()}- onClick={(event) => event.stopPropagation()}- onKeyDown={(event) => {- if (event.key !== 'Escape') event.stopPropagation();- }}- onKeyUp={(event) => {- if (event.key !== 'Escape') event.stopPropagation();- }}- class="min-w-0 h-full w-full border-0 bg-transparent p-0 text-sm text-ink outline-none placeholder:text-ink-extra-muted"- />- </div>+ <div class="sticky top-0 z-10 bg-menu py-1">+ <div class="flex h-8 items-center gap-2 px-3">+ <MagnifyingGlassIcon+ aria-hidden="true"+ class="size-4 shrink-0 text-ink-extra-muted"+ />+ <input+ ref={(element) => {+ searchEl = element;+ props.searchRef?.(element);+ }}+ aria-label={props.searchPlaceholder ?? 'Search models'}+ placeholder={props.searchPlaceholder ?? 'Search models'}+ value={query()}+ onInput={(event) => setQuery(event.currentTarget.value)}+ onMouseDown={(event: MouseEvent) => event.stopPropagation()}+ onClick={(event) => event.stopPropagation()}+ onKeyDown={(event) => {+ if (event.key !== 'Escape') event.stopPropagation();+ }}+ onKeyUp={(event) => {+ if (event.key !== 'Escape') event.stopPropagation();+ }}+ class="min-w-0 h-full w-full border-0 bg-transparent p-0 text-sm text-ink outline-none placeholder:text-ink-extra-muted"+ /></div>- </Show>+ </div>{props.children}<Show when={props.options.length === 0}>@@ -347,14 +559,13 @@ export function ModelCatalogMenu(<div class="space-y-1"><Showwhen={- (!props.fullCatalog || props.suggestedFirst) &&+ !props.fullCatalog &&!showAll() &&catalog().frontier.length > 0}><ModelListlabel="Suggested"- hideLabel={props.suggestedFirst}options={catalog().frontier}value={props.value}disabled={props.disabled}diff --git a/apps/web/src/lib/core/component/AI/component/input/ModelEffortMenu.test.tsx b/apps/web/src/lib/core/component/AI/component/input/ModelEffortMenu.test.tsxdeleted file mode 100644index de07a4c256..0000000000--- a/apps/web/src/lib/core/component/AI/component/input/ModelEffortMenu.test.tsx+++ /dev/null@@ -1,219 +0,0 @@-/** @vitest-environment jsdom */-import {- cleanup,- fireEvent,- render,- screen,- waitFor,-} from '@solidjs/testing-library';-import { Dropdown } from '@ui';-import { createSignal } from 'solid-js';-import { afterEach, beforeEach, expect, it, vi } from 'vitest';-import { type ModelEffortConfig, ModelEffortMenu } from './ModelEffortMenu';--const config: ModelEffortConfig = {- id: 'runtime-effort',- name: 'Power',- category: 'thought_level',- type: 'select',- description: null,- currentValue: 'low',- options: [- { name: 'Low', value: 'low', group: null, description: null },- { name: 'High', value: 'high', group: null, description: null },- { name: 'Max', value: 'max', group: null, description: null },- ],-};-beforeEach(() => {- vi.stubGlobal(- 'ResizeObserver',- class {- observe() {}- unobserve() {}- disconnect() {}- }- );- vi.stubGlobal('scrollTo', vi.fn());-});-afterEach(() => {- cleanup();- vi.unstubAllGlobals();-});--function setup(disabled = false, effortConfig = config) {- const change = vi.fn();- const [value, setValue] = createSignal(effortConfig.currentValue);- render(() => (- <>- <style>- {'[role="menu"] { animation-name: none; transition-duration: 0s; }'}- </style>- <Dropdown>- <Dropdown.Trigger>Model settings</Dropdown.Trigger>- <Dropdown.Content>- <ModelEffortMenu- model="gpt-5"- label="GPT-5"- config={effortConfig}- value={value()}- disabled={disabled}- onChange={(next) => {- change(next);- setValue(next);- }}- >- <Dropdown.Item onSelect={() => change('other-model')}>- Other model- </Dropdown.Item>- </ModelEffortMenu>- </Dropdown.Content>- </Dropdown>- </>- ));- fireEvent.keyDown(screen.getByRole('button', { name: 'Model settings' }), {- key: 'Enter',- });- return change;-}--it('adjusts named effort stops with the keyboard without dismissing the menu', async () => {- const change = setup();- const slider = await screen.findByRole('slider', {- name: 'Reasoning effort',- });- slider.focus();- expect(slider.getAttribute('aria-valuetext')).toBe('Low');- fireEvent.keyDown(slider, { key: 'ArrowRight' });- expect(change).toHaveBeenLastCalledWith('high');- expect(slider.getAttribute('aria-valuetext')).toBe('High');- expect(screen.getByRole('menu')).toBeTruthy();- fireEvent.keyDown(slider, { key: 'ArrowRight' });- expect(change).toHaveBeenLastCalledWith('max');- fireEvent.keyDown(slider, { key: 'ArrowRight' });- expect(change).toHaveBeenLastCalledWith('max');- fireEvent.keyDown(slider, { key: 'ArrowLeft' });- fireEvent.keyDown(slider, { key: 'ArrowLeft' });- expect(change).toHaveBeenLastCalledWith('low');-});--it('tracks a captured thumb drag immediately and commits only on release', () => {- const change = setup();- const slider = screen.getByRole('slider', { name: 'Reasoning effort' });- const track = slider.parentElement!;- vi.spyOn(track, 'getBoundingClientRect').mockReturnValue(- new DOMRect(0, 0, 200, 24)- );- let captured = false;- slider.setPointerCapture = () => {- captured = true;- };- slider.hasPointerCapture = () => captured;- slider.releasePointerCapture = () => {- captured = false;- };- fireEvent(- slider,- Object.assign(- new MouseEvent('pointerdown', { bubbles: true, clientX: 0 }),- {- pointerId: 1,- pointerType: 'mouse',- }- )- );- fireEvent(- slider,- Object.assign(- new MouseEvent('pointermove', { bubbles: true, clientX: 100 }),- {- pointerId: 1,- pointerType: 'mouse',- }- )- );- expect(slider.getAttribute('aria-valuetext')).toBe('High');- expect(slider.closest('[data-scrubbing]')).not.toBeNull();- expect(change).not.toHaveBeenCalled();- fireEvent(- slider,- Object.assign(- new MouseEvent('pointerup', { bubbles: true, clientX: 100 }),- {- pointerId: 1,- pointerType: 'mouse',- }- )- );- expect(change).toHaveBeenCalledExactlyOnceWith('high');- expect(slider.closest('[data-scrubbing]')).toBeNull();- expect(screen.getByRole('menu')).toBeTruthy();-});--it('opens the catalog, returns to effort, and dismisses with Escape', async () => {- setup();- fireEvent.keyDown(screen.getByRole('menuitem', { name: 'Choose model' }), {- key: 'Enter',- });- expect(screen.getByRole('menuitem', { name: 'Other model' })).toBeTruthy();- expect(screen.queryByRole('slider', { name: 'Reasoning effort' })).toBeNull();- fireEvent.keyDown(- screen.getByRole('menuitem', { name: 'Model and effort' }),- { key: 'Enter' }- );- const slider = screen.getByRole('slider', { name: 'Reasoning effort' });- await waitFor(() =>- expect(document.activeElement).toBe(- screen.getByRole('menuitem', { name: 'Choose model' })- )- );- fireEvent.keyDown(slider, { key: 'Escape' });- await waitFor(() => expect(screen.queryByRole('menu')).toBeNull());-});--it('does not change a disabled effort control', () => {- const change = setup(true);- fireEvent.keyDown(screen.getByRole('slider', { name: 'Reasoning effort' }), {- key: 'ArrowRight',- });- expect(change).not.toHaveBeenCalled();-});--it('preserves the inherited default until a specific effort is selected', () => {- const change = setup(false, {- ...config,- id: 'reasoning_effort',- currentValue: 'default',- options: [- { name: 'Default', value: 'default', group: null, description: null },- config.options[0],- { name: 'Medium', value: 'medium', group: null, description: null },- config.options[1],- ],- });- const slider = screen.getByRole('slider', { name: 'Reasoning effort' });- expect(slider.getAttribute('aria-valuetext')).toBe('Default');- slider.focus();- fireEvent.keyDown(slider, { key: 'ArrowRight' });- expect(change).toHaveBeenLastCalledWith('low');- expect(slider.getAttribute('aria-valuetext')).toBe('Low');- fireEvent.keyDown(slider, { key: 'ArrowRight' });- expect(change).toHaveBeenLastCalledWith('medium');-});--it('shows the catalog directly for a model with no effort configuration', () => {- render(() => (- <Dropdown>- <Dropdown.Trigger>Model settings</Dropdown.Trigger>- <Dropdown.Content>- <ModelEffortMenu label="Basic model">- <Dropdown.Item>Basic model</Dropdown.Item>- </ModelEffortMenu>- </Dropdown.Content>- </Dropdown>- ));- fireEvent.keyDown(screen.getByRole('button', { name: 'Model settings' }), {- key: 'Enter',- });- expect(screen.getByRole('menuitem', { name: 'Basic model' })).toBeTruthy();- expect(screen.queryByRole('slider')).toBeNull();-});diff --git a/apps/web/src/lib/core/component/AI/component/input/ModelEffortMenu.tsx b/apps/web/src/lib/core/component/AI/component/input/ModelEffortMenu.tsxdeleted file mode 100644index e888966faa..0000000000--- a/apps/web/src/lib/core/component/AI/component/input/ModelEffortMenu.tsx+++ /dev/null@@ -1,196 +0,0 @@-import CaretLeft from '@icon/system/regular/caret-left.svg';-import CaretRight from '@icon/system/regular/caret-right.svg';-import type { SessionConfigOption } from '@service-agent-fold/generated/types';-import { Dropdown, Slider } from '@ui';-import { createSignal, For, type JSX, Show } from 'solid-js';-import { ModelIcon } from '../ProviderIcon';--export type ModelEffortConfig = Extract<- SessionConfigOption,- { type: 'select' }->;--/** A compact model overview; browsing retains the complete model/agent catalog. */-export function ModelEffortMenu(props: {- model?: string | null;- label: string;- config?: ModelEffortConfig;- value?: string;- disabled?: boolean;- onChange?: (value: string) => void;- effortOnly?: boolean;- children?: JSX.Element;-}) {- const [browsing, setBrowsing] = createSignal(false);- let overview: HTMLElement | undefined;- const choices = () => props.config?.options ?? [];- const available = () => choices().length > 1 && !!props.onChange;- const [dragIndex, setDragIndex] = createSignal<number>();- const [dragging, setDragging] = createSignal(false);- const [scrubbing, setScrubbing] = createSignal(false);- const value = () => props.value ?? props.config?.currentValue;- const index = () =>- dragIndex() ??- Math.max(- 0,- choices().findIndex((choice) => choice.value === value())- );- const label = () => choices()[index()]?.name;- const commit = (next: number) => {- const choice = choices()[next];- if (choice && !props.disabled) props.onChange?.(choice.value);- };-- return (- <Show- when={available() && (!browsing() || props.effortOnly)}- fallback={- <>- <Show when={available()}>- <Dropdown.Item- closeOnSelect={false}- onSelect={() => {- setBrowsing(false);- queueMicrotask(() => overview?.focus());- }}- >- <CaretLeft class="size-4" />- Model and effort- </Dropdown.Item>- </Show>- {props.children}- </>- }- >- <div class="px-3 pb-3 pt-1">- <Show- when={!props.effortOnly}- fallback={- <div class="mb-2 flex h-9 items-center justify-between gap-2 text-sm">- <span class="text-ink-muted">Reasoning effort</span>- <span class="font-medium">{label()}</span>- </div>- }- >- <Dropdown.Item- ref={overview}- closeOnSelect={false}- aria-label="Choose model"- class="mb-2 h-9 gap-2 rounded-xl px-0 hover:bg-transparent"- onSelect={() => setBrowsing(true)}- >- <ModelIcon- model={props.model}- class="size-4 shrink-0 text-ink-muted"- />- <span class="flex min-w-0 flex-1 items-center justify-center gap-1">- <span class="truncate text-base font-medium">{props.label}</span>- <span class="shrink-0 text-base font-normal text-ink-muted">- {label()}- </span>- <CaretRight class="size-3 shrink-0 text-ink-muted" />- </span>- </Dropdown.Item>- </Show>- <Slider- class="group/effort px-3.5"- data-dragging={dragging() || undefined}- data-scrubbing={scrubbing() || undefined}- onPointerMove={() => {- if (dragging()) setScrubbing(true);- }}- aria-label="Reasoning effort"- minValue={0}- maxValue={Math.max(1, choices().length - 1)}- step={1}- value={[index()]}- getValueLabel={() => label() ?? ''}- disabled={props.disabled}- onChange={([next]) => {- if (dragging()) setDragIndex(next);- else commit(next);- }}- onChangeEnd={([next]) => {- if (!dragging()) return;- setDragging(false);- setScrubbing(false);- commit(next);- setDragIndex(undefined);- }}- onKeyDown={(event: KeyboardEvent) => {- // Arrow keys belong to the slider, not the menu's roving focus.- if (- [- 'ArrowLeft',- 'ArrowRight',- 'ArrowUp',- 'ArrowDown',- 'Home',- 'End',- ].includes(event.key)- )- event.stopPropagation();- }}- >- <Slider.Track- class="my-0 h-6 bg-transparent"- onPointerDown={() => {- setDragging(true);- }}- onPointerCancel={() => {- setDragging(false);- setScrubbing(false);- setDragIndex(undefined);- }}- >- <div- aria-hidden="true"- class="pointer-events-none absolute -inset-x-3.5 inset-y-0 rounded-full bg-ink/10 shadow-[inset_0_0_0_0.5px_color-mix(in_srgb,var(--color-ink)_10%,transparent)]"- />- <Slider.Fill- class="bg-blue transition-[left,right] duration-300 ease-[cubic-bezier(0.2,1.3,0.35,1)] group-data-[scrubbing]/effort:transition-none motion-reduce:transition-none"- style={{- left: '-14px',- display: index() === 0 ? 'none' : undefined,- }}- />- <div- aria-hidden="true"- class="pointer-events-none absolute inset-x-0 inset-y-0 flex items-center justify-between"- >- <For each={choices()}>- {(_, i) => (- <span- class="size-1 rounded-full"- classList={{- 'bg-panel/40': i() <= index(),- 'bg-ink-muted/50': i() > index(),- }}- />- )}- </For>- </div>- <Slider.Thumb- onPointerMove={() => {- if (dragging()) setScrubbing(true);- }}- onPointerDown={() => {- setDragging(true);- }}- onPointerCancel={() => {- setDragging(false);- setScrubbing(false);- setDragIndex(undefined);- }}- aria-label="Reasoning effort"- aria-valuetext={label()}- class="size-7 cursor-grab group-data-[dragging]/effort:cursor-grabbing data-[disabled]:cursor-default border-ink/15 bg-composer-action shadow-[0_0_2px_0_color-mix(in_srgb,var(--color-ink)_10%,transparent)] light-mode:bg-panel focus-visible:ring-blue focus-visible:ring-offset-0 transition-[left,right,scale] duration-300 ease-[cubic-bezier(0.2,1.3,0.35,1)] group-data-[scrubbing]/effort:transition-[scale] motion-safe:group-data-[dragging]/effort:scale-105 motion-reduce:transition-none"- >- <Slider.Input />- </Slider.Thumb>- </Slider.Track>- </Slider>- </div>- </Show>- );-}diff --git a/apps/web/src/lib/core/component/AI/component/input/ModelSelector.tsx b/apps/web/src/lib/core/component/AI/component/input/ModelSelector.tsxindex 3ffa8629db..e0494cbbea 100644--- a/apps/web/src/lib/core/component/AI/component/input/ModelSelector.tsx+++ b/apps/web/src/lib/core/component/AI/component/input/ModelSelector.tsx@@ -1,21 +1,14 @@-import { MobileDrawer } from '@components/app/mobile/MobileDrawer';import {DEFAULT_MODEL,MODEL_PRETTYNAME,- MODEL_PROVIDER_ICON,Model,PAID_MODELS,} from '@core/component/AI/constant';import type { TModel } from '@core/component/AI/types';import { isMobile } from '@core/mobile/isMobile';import { virtualKeyboardVisible } from '@core/mobile/virtualKeyboard';-import CaretDown from '@icon/system/regular/caret-down.svg?component-solid';-import CheckIcon from '@icon/system/regular/check.svg';-import LockIcon from '@icon/system/regular/lock-simple.svg?component-solid';-import CloseIcon from '@icon/system/regular/x.svg';-import { Button, cn, Dropdown } from '@ui';-import { createSignal, For, Show } from 'solid-js';-import { Dynamic } from 'solid-js/web';+import { cn } from '@ui';+import { ModelCatalogPicker } from './ModelCatalogPicker';/** A model and whether the current user may select it. */export type ModelOption = { id: TModel; available: boolean };@@ -47,173 +40,44 @@ const MODEL_DESCRIPTION: Record<TModel, string> = {[Model.gemini38Flash]: 'Fast answers over data and documents',};+const isModel = (id: string): id is TModel =>+ PAID_MODELS.some((model) => model === id);++/** Chat's model selector: the shared catalog over the chat-routable models. */export function ModelSelector(props: ModelSelectorProps) {- const [open, setOpen] = createSignal(false);const model = () => props.selectedModel ?? DEFAULT_MODEL;const options = () =>- props.models && props.models.length > 0 ? props.models : ALL_AVAILABLE;-- const handleSelect = (option: ModelOption) => {- if (option.available) {- props.onSelect(option.id);- } else {- props.onLocked?.(option.id);- }- };+ (props.models && props.models.length > 0+ ? props.models+ : ALL_AVAILABLE+ ).map((option) => ({+ id: option.id,+ label: MODEL_PRETTYNAME[option.id],+ description: MODEL_DESCRIPTION[option.id],+ locked: !option.available,+ }));return (- <Show- when={isMobile()}- fallback={- <Dropdown placement="top-end">- <Dropdown.Trigger- variant="ghost"- size={props.compact ? 'icon-sm' : 'sm'}- class={cn(- 'text-sm text-ink-subtle',- !props.compact && 'gap-1.5',- 'not-touch:h-[33.75px] not-touch:text-base not-touch:gap-[5.625px] not-touch:px-[7.5px] not-touch:[&_svg]:size-[15px] not-touch:light-mode:text-composer-placeholder not-touch:light-mode:font-normal',- props.compact && 'not-touch:p-[3.75px]'- )}- label={props.compact ? MODEL_PRETTYNAME[model()] : undefined}- >- <Dynamic component={MODEL_PROVIDER_ICON[model()]} />- <Show when={!props.compact}>- {MODEL_PRETTYNAME[model()]}- <CaretDown />- </Show>- </Dropdown.Trigger>- <Dropdown.Content class="w-60 max-w-[calc(100vw-1rem)]">- <Dropdown.Group>- <For each={options()}>- {(option) => (- // Unavailable items stay clickable (not Kobalte-disabled) so the- // click can open the paywall; they're just visually dimmed.- <Dropdown.Item- class={cn('gap-2', !option.available && 'opacity-50')}- onSelect={() => handleSelect(option)}- >- <Dynamic- component={MODEL_PROVIDER_ICON[option.id]}- class="size-4 shrink-0"- />- <span class="flex-1 truncate">- {MODEL_PRETTYNAME[option.id]}- </span>- <Show when={!option.available}>- <LockIcon class="size-3.5 shrink-0 text-ink-extra-muted" />- </Show>- </Dropdown.Item>- )}- </For>- </Dropdown.Group>- </Dropdown.Content>- </Dropdown>- }- >- <MobileDrawer- side="bottom"- open={open()}- onOpenChange={setOpen}- preventScroll={false}- preventScrollbarShift={false}- >- {/* Keep the drawer mounted when opening it dismisses the keyboard. */}- <MobileDrawer.Trigger- as={Button}- variant="ghost"- size="icon-sm"- // Prevent compatibility mouse focus from hiding the trigger before- // click. Leave pointerdown uncancelled so WebKit emits the tap click.- onMouseDown={(event) => {- if (event.button === 0) event.preventDefault();- }}- aria-label={`Choose model, ${MODEL_PRETTYNAME[model()]}`}- class={cn(- 'touch:min-h-11 touch:min-w-11 rounded-full text-sm text-ink-subtle',- !virtualKeyboardVisible() && 'hidden'- )}- >- <Dynamic component={MODEL_PROVIDER_ICON[model()]} />- </MobileDrawer.Trigger>- <MobileDrawer.Portal>- <MobileDrawer.Overlay />- <MobileDrawer.Content- aria-label="Select model"- class="overflow-hidden"- >- <MobileDrawer.Handle class="pb-1" />- <div class="flex shrink-0 items-center justify-between gap-3 px-6 pb-4">- <h2 class="text-lg font-semibold text-ink">Select model</h2>- <MobileDrawer.Close- as={Button}- variant="ghost"- size="icon-sm"- aria-label="Close model picker"- class="size-11 shrink-0 rounded-full bg-ink/6"- >- <CloseIcon class="size-5" />- </MobileDrawer.Close>- </div>- <MobileDrawer.ScrollBody>- <MobileDrawer.Section role="group" aria-label="Models">- <For each={options()}>- {(option) => (- <MobileDrawer.Item- aria-label={`${MODEL_PRETTYNAME[option.id]}${option.available ? '' : ', upgrade required'}`}- aria-pressed={model() === option.id}- class={cn(- 'min-h-19 gap-3 px-4 py-4',- !option.available && 'opacity-50'- )}- onClick={() => {- if (!option.available) setOpen(false);- handleSelect(option);- }}- >- <Dynamic- component={MODEL_PROVIDER_ICON[option.id]}- class="size-6 shrink-0 text-ink-muted"- />- <span class="flex min-w-0 flex-1 flex-col gap-1">- <span class="text-base font-medium leading-5">- {MODEL_PRETTYNAME[option.id]}- </span>- <span class="text-[13px] leading-[18px] text-ink-muted">- {MODEL_DESCRIPTION[option.id]}- </span>- </span>- <span class="flex size-5 shrink-0 items-center justify-center">- <Show- when={!option.available}- fallback={- <Show when={model() === option.id}>- <CheckIcon class="size-5 text-accent" />- </Show>- }- >- <LockIcon class="size-4 text-ink-muted" />- </Show>- </span>- </MobileDrawer.Item>- )}- </For>- </MobileDrawer.Section>- <div class="px-6 pt-5 pb-2">- <MobileDrawer.Close- as={Button}- variant="cta"- size="xl"- aria-label="Done"- class="w-full rounded-full text-base"- >- Done- </MobileDrawer.Close>- </div>- </MobileDrawer.ScrollBody>- </MobileDrawer.Content>- </MobileDrawer.Portal>- </MobileDrawer>- </Show>+ <ModelCatalogPicker+ value={model()}+ options={options()}+ onSelect={(id) => {+ if (isModel(id)) props.onSelect(id);+ }}+ onLocked={(id) => {+ if (isModel(id)) props.onLocked?.(id);+ }}+ compact={props.compact || isMobile()}+ ariaLabel={`Choose model, ${MODEL_PRETTYNAME[model()]}`}+ placement="top-end"+ triggerClass={cn(+ 'h-8 w-auto gap-1.5 border-0 px-2 text-sm text-ink-subtle hover:bg-hover',+ 'not-touch:h-[33.75px] not-touch:text-base not-touch:gap-[5.625px] not-touch:px-[7.5px] not-touch:[&_svg]:size-[15px] not-touch:light-mode:text-composer-placeholder not-touch:light-mode:font-normal',+ props.compact && 'not-touch:p-[3.75px]',+ isMobile() &&+ 'touch:min-h-11 touch:min-w-11 justify-center rounded-full',+ isMobile() && !virtualKeyboardVisible() && 'hidden'+ )}+ />);}diff --git a/apps/web/src/lib/core/component/AI/component/input/modelCatalog.ts b/apps/web/src/lib/core/component/AI/component/input/modelCatalog.tsindex edce131b99..b5c5ca6772 100644--- a/apps/web/src/lib/core/component/AI/component/input/modelCatalog.ts+++ b/apps/web/src/lib/core/component/AI/component/input/modelCatalog.ts@@ -9,6 +9,8 @@ export type CatalogModelOption = {* name), also available as a search term.*/group?: string;+ /** Listed but not selectable on the user's plan; choosing it calls `onLocked`. */+ locked?: boolean;};export type ModelProviderGroup = {@@ -21,11 +23,6 @@ export type ModelCatalog = {providers: ModelProviderGroup[];};-/** Large third-party catalogs need structure rather than one long flat list. */-export function isLargeModelCatalog(options: readonly CatalogModelOption[]) {- return options.length > 10;-}-/*** A version-looking token: alphanumerics and dots with a digit first or* second (`4.6`, `5`, `K3`, `o3`, `R1`), but not `GPT`, `Sol`, or `Mini`.diff --git a/apps/web/src/lib/core/util/composerMenuAnchor.test.ts b/apps/web/src/lib/core/util/composerMenuAnchor.test.tsdeleted file mode 100644index 2fa1a189b2..0000000000--- a/apps/web/src/lib/core/util/composerMenuAnchor.test.ts+++ /dev/null@@ -1,25 +0,0 @@-/** @vitest-environment jsdom */-import { afterEach, expect, it, vi } from 'vitest';-import { composerMenuAnchorRect } from './composerMenuAnchor';--afterEach(() => {- document.body.replaceChildren();-});--it('anchors to the Add button in the same composer', () => {- document.body.innerHTML = `<div data-agent-composer><button data-composer-menu-anchor></button></div><div data-agent-composer><button data-composer-menu-anchor></button><button id="model"></button></div>`;- const add = document.querySelectorAll<HTMLElement>(- '[data-composer-menu-anchor]'- )[1];- const rect = new DOMRect(40, 100, 36, 36);- vi.spyOn(add, 'getBoundingClientRect').mockReturnValue(rect);- expect(composerMenuAnchorRect(document.getElementById('model')!)).toBe(rect);-});--it('uses the trigger when rendered outside a composer', () => {- const trigger = document.createElement('button');- const rect = new DOMRect(200, 50, 100, 36);- vi.spyOn(trigger, 'getBoundingClientRect').mockReturnValue(rect);- expect(composerMenuAnchorRect(trigger)).toBe(rect);- expect(composerMenuAnchorRect()).toBeUndefined();-});diff --git a/apps/web/src/lib/core/util/composerMenuAnchor.ts b/apps/web/src/lib/core/util/composerMenuAnchor.tsdeleted file mode 100644index 245133ea08..0000000000--- a/apps/web/src/lib/core/util/composerMenuAnchor.ts+++ /dev/null@@ -1,7 +0,0 @@-/** Align composer menus with the Add button, regardless of their trigger. */-export function composerMenuAnchorRect(trigger?: HTMLElement) {- const anchor = trigger- ?.closest('[data-agent-composer]')- ?.querySelector<HTMLElement>('[data-composer-menu-anchor]');- return (anchor ?? trigger)?.getBoundingClientRect();-}diff --git a/docs/agent-guide/ai-chat.md b/docs/agent-guide/ai-chat.mdindex 0de6d363f3..4927c980c9 100644--- a/docs/agent-guide/ai-chat.md+++ b/docs/agent-guide/ai-chat.md@@ -421,15 +421,14 @@ the shimmer.keeps the saved model name visible in its picker, including unavailable models.- The agent dropdown includes saved agents of the selected mode regardless ofruntime, plus Cursor in Code mode.- In Chat mode, the desktop picker uses a wide, height-limited layout with- agents on the left without a redundant Your agents subheading. The models- column starts with unlabeled suggested choices, followed by the complete- catalog grouped by provider. There is no search box or More step; each column scrolls independently.- It shares the Plus menu's width and below-composer anchor. Code mode keeps its- compact agent dropdown above the selector. Phones retain their single-column- searchable sheet, Suggested choices, and More models action. Model-specific- submenus also retain search. Choosing a model does not reorder the sections.- The separate speedometer controls effort. The catalog's opaque header+ Macro's models use the same searchable catalog as running sessions:+ **Suggested** lists **Opus 5.5**, **Sonnet 5.5**, **GPT-5.6** (Sol in+ runtime catalogs), **GPT-6 Astra**, and **Gemini**, when available, in that order. The+ **More models** submenu contains the complete catalog grouped by provider,+ including the Suggested choices and effort/speed variants. Your agents+ follow Suggested and More models in the root menu. Choosing a model+ does not reorder the sections. Search matches names, IDs, and provider names. The compact borderless search+ field receives focus when the selector opens or reopens. Its opaque headermeets the top of the scroll area so rows cannot show through above it.**Built-in**, **Your agents**, and **Needs connection** groups follow whenthey have entries. Each agent row shows its runtime and model, or its setup@@ -449,7 +448,7 @@ the shimmer.default for Macro's in-memory agent until another model entry is picked.The built-in Macro agent is the only agent excluded from these sections; its models remain available.Unavailable paired agents stay visible with a reason.- If Macro is unavailable, its catalog stays visible but+ If Macro is unavailable, its catalog stays searchable butmodel choices are disabled in every list. Model discovery uses theselected runtime. Every coding agent shows repositorycontrols; chat agents hide those controls but keep the mode bar. Repository/branch overrides are currently applied@@ -532,14 +531,7 @@ the shimmer.provider icons, search, **Suggested** first, and **More models** for thecomplete provider catalog. Desktop opens a submenu; phone widths showthe catalog in place with a Back action. Search includes every model.-- Desktop keeps the model selector and speedometer as separate controls. The- speedometer opens a slider with a stop for each advertised effort level. Arrow keys- and drags preview the level; it is applied once, when the popover closes, and- only if it differs from the current level. The popover stays open, and- the model selector opens the full catalog independently. On mobile, the **speedometer-style- effort** button opens its own sheet after the input expands. Choosing a level- applies it and closes the sheet. Models with fewer than two effort choices- omit the effort button.+- A compact **speedometer-style effort** button with a simple arc and needle beside the model selector opens a simple list of effort levels with a check beside the current choice: a popover centered below the button on desktop, or its own bottom sheet on mobile. Choosing a level applies it and closes the menu. Mobile shows it alongside the model control after the input expands. It is hidden when the model has fewer than two effort choices.Model-specific effort choices remain available in desktop model submenus.Free and Pro users start new conversations at the lowest advertised level,unless they explicitly choose another. Existing sessions keep their current setting.@@ -628,9 +620,9 @@ the shimmer.hourly, plus any recovery backlog. Normal completion handling remains immediate.The agent form retains sharing, name, `@tag`, runtime, default model, connections,channels, instructions, and permission policy.- Runtime and short model lists use styled dropdown buttons: open the field and- choose an option (or use arrow keys and Enter). Escape dismisses the menu.- Large model lists retain the searchable model picker.+ The runtime list uses a styled dropdown button: open the field and choose an+ option (or use arrow keys and Enter). Escape dismisses the menu. Default model+ uses the shared searchable model picker for every runtime, whatever its size.- **Session**: the header has the sidebar reopen control, a linked PR status chip,favorite, Share, and Side panel. The top-left title uses the same provider icon,saved-title precedence, and title menu as `/app/agent/<id>`; click the caret@@ -1830,14 +1822,15 @@ slide and fade. On touch devices, messages lift into place with a gentle settle;the text reaches full opacity early and keeps its final size. History andremounted messages stay still; reduced-motion preferences disable the transition.-On phones, the chat model control appears as a provider icon while the software-keyboard is open. Its accessible name is `Choose model, <model name>`. It opens-a `Select model` sheet with descriptions, a checkmark for the current choice,-and a **Done** button. Selecting an available model updates the selection;-locked models open the upgrade flow. The sheet stays open when the keyboard closes.+Every model control — production chat, the agent composer, running sessions,+and the default-model fields in Settings — is the same `ModelCatalogPicker`: a+searchable popover on desktop and a searchable `Choose a model` bottom sheet on+touch devices, both with **Suggested** first and the complete provider catalog+behind **More models**. Tapping or choosing a model applies it and closes the+menu. Locked models stay listed, dimmed with a lock, and open the upgrade flow.-The compact model menus use the standard menu text size and a 240px width-(capped to the viewport), consistently in production chat and the agent input.+On phones, the chat model control appears as a provider icon while the software+keyboard is open. Its accessible name is `Choose model, <model name>`.Chat title icons follow the selected model's provider, including the agentsystem's live model. Soup rows use the model included in the list data, with a@@ -1876,15 +1869,12 @@ There is no periodic PR lookup polling.### Agent reasoning effort-On desktop, open the speedometer beside the model selector to adjust the-current model with the **Reasoning effort** slider. The header and accessible value announce the-selected level. Arrow keys move between supported levels; the menu stays open-until dismissed, and the chosen level is applied when it closes. The model selector opens the full catalog independently; other-models still offer their own effort submenu with Right Arrow. On mobile, tap a model-to select it, then use the adjacent effort button to adjust effort.+Open the model selector and hover a model to choose its reasoning effort in the+submenu on desktop, opened with Right Arrow. On mobile, tap a model to select it,+then use the adjacent effort button to adjust effort.Cursor and Macro's in-memory agent load the hovered model's own advertised-choices. The model trigger shows the model name; the speedometer announces the effort.-Models without effort+choices. The selected label includes the effort, such as `Sonnet 5.5 · High`;+the composer also offers a separate effort button for the selected model. Models without effortsupport remain selectable through `Use <model>` (or a desktop click/Enter).Default keeps the model's existing behavior.@@ -2130,15 +2120,12 @@ that chat remains usable, and that another account cannot submit. Sending an emacreating an event is a real action, including from a local app connected to dev.## Agent reasoning effort-On desktop, open the speedometer beside the model selector to adjust the-current model with the **Reasoning effort** slider. The header and accessible value announce the-selected level. Arrow keys move between supported levels; the menu stays open-until dismissed, and the chosen level is applied when it closes. The model selector opens the full catalog independently; other-models still offer their own effort submenu with Right Arrow. On mobile, tap a model-to select it, then use the adjacent effort button to adjust effort.+Open the model selector and hover a model to choose its reasoning effort in the+submenu on desktop, opened with Right Arrow. On mobile, tap a model to select it,+then use the adjacent effort button to adjust effort.Cursor and Macro's in-memory agent load the hovered model's own advertised-choices. The model trigger shows the model name; the speedometer announces the effort.-Models without effort+choices. The selected label includes the effort, such as `Sonnet 5.5 · High`;+the composer also offers a separate effort button for the selected model. Models without effortsupport remain selectable through `Use <model>` (or a desktop click/Enter).Default keeps the model's existing behavior.diff --git a/docs/architecture/agent-effort.md b/docs/architecture/agent-effort.mdindex 85f5b08cfd..dffc8792b6 100644--- a/docs/architecture/agent-effort.md+++ b/docs/architecture/agent-effort.md@@ -92,17 +92,14 @@ an external harness result.## Model menu interaction-Desktop new-chat and running-session model selectors open the full model catalog.-The adjacent speedometer opens a discrete **Reasoning effort** slider. Slider-stops come directly from the runtime's advertised choices and retain their opaque-values, including Default when advertised. Arrow keys change one level at a time;-pointer drags commit on release. The menu stays open while its accessible value-updates. Mobile retains the dedicated effort sheet.+The selected model also has a **speedometer-style effort** button beside its model selector+in new-chat and running-session composers. It opens a compact desktop popover+or a dedicated bottom sheet on mobile. Its needle reflects the selected level. A simple list shows the supported effort levels and checks the current choice. Selecting a level applies it and closes the menu; models with fewer than two choices hide the button.On desktop, effort remains available in each model’s submenu.Discovery runs when the submenu opens, scoped to that model and harness;the current session's advertised options take precedence for its selected model.-The model trigger displays the model; the adjacent speedometer shows effort. Keyboard Right Arrow+The trigger displays the model and selected effort together. Keyboard Right Arrowopens the submenu. On mobile, tapping a model selects it directly; use the adjacenteffort button to adjust its supported effort levels. Loading, discovery errors, and models withno effort options keep ordinary model selection available.