Skip to content

armgit / macro

Public Imported from GitHub
0

Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.

feat(agents): unify composer controls and model selection

Wolf Mermelstein057e055ce9b4
diff --git a/apps/web/src/components/app/mobile/MobilePageActionRow.tsx b/apps/web/src/components/app/mobile/MobilePageActionRow.tsx
index 6b17d7ab41..3269d7b99d 100644
--- a/apps/web/src/components/app/mobile/MobilePageActionRow.tsx
+++ b/apps/web/src/components/app/mobile/MobilePageActionRow.tsx
@@ -33,9 +33,11 @@ export function MobilePageActionRow() {
return (
// Screen composers (0) and search scopes (100) take precedence.
<FloatRegion region="accessory" priority={-1} active={isAvailable}>
- <div class="flex items-end justify-end gap-(--mobile-chrome-gutter) px-(--mobile-chrome-gutter)">
+ <div class="group/mobile-composer flex items-end justify-end gap-(--mobile-chrome-gutter) px-(--mobile-chrome-gutter)">
{composer}
- <MobilePageCreateButton />
+ <div class="shrink-0 empty:hidden group-has-[[data-composer-expanded=true]]/mobile-composer:hidden">
+ <MobilePageCreateButton />
+ </div>
</div>
</FloatRegion>
);
diff --git a/apps/web/src/features/agents-view/agents-view-skeleton.tsx b/apps/web/src/features/agents-view/agents-view-skeleton.tsx
index f2df76d1ef..0e38b8669a 100644
--- a/apps/web/src/features/agents-view/agents-view-skeleton.tsx
+++ b/apps/web/src/features/agents-view/agents-view-skeleton.tsx
@@ -8,8 +8,8 @@ export function AgentsViewSkeleton() {
aside={{ min: 224, max: 380, preserveDuringResize: false }}
main={{ min: 280, preferredWidth: 640 }}
>
- <ViewSkeleton.Sidebar title="Agents" createLabel="New conversation" />
- <ViewSkeleton.Main title="New conversation">
+ <ViewSkeleton.Sidebar title="Agents" />
+ <ViewSkeleton.Main>
<div class="flex-1" />
</ViewSkeleton.Main>
</ViewSkeleton.Root>
diff --git a/apps/web/src/features/agents-view/agents-view.css b/apps/web/src/features/agents-view/agents-view.css
index cb8f3425de..13e678d6ff 100644
--- a/apps/web/src/features/agents-view/agents-view.css
+++ b/apps/web/src/features/agents-view/agents-view.css
@@ -348,7 +348,7 @@
background: color-mix(in oklch, var(--surface-1) 40%, var(--surface-2));
opacity: 0;
visibility: hidden;
- transition: grid-template-rows 200ms cubic-bezier(0.77, 0, 0.175, 1), opacity 200ms cubic-bezier(0.23, 1, 0.32, 1), visibility 200ms;
+ transition: grid-template-rows 100ms cubic-bezier(0.77, 0, 0.175, 1), opacity 100ms cubic-bezier(0.23, 1, 0.32, 1), visibility 100ms;
}
:where(.agents-view, .agents-view-portal) .composer-drawer::before {
@@ -361,7 +361,7 @@
pointer-events: none;
}
- /* Continue the footer behind the input's rounded bottom corners. */
+ /* Continue the repository bar behind the input's adjacent rounded corners. */
:where(.agents-view, .agents-view-portal) .composer-drawer::after {
content: '';
position: absolute;
@@ -388,9 +388,29 @@
:where(.agents-view, .agents-view-portal) .composer-drawer-content {
display: flex;
align-items: center;
- padding: 2px 10px;
+ min-height: 44px;
+ padding: 4px 10px;
transform: translateY(-12px);
- transition: transform 200ms cubic-bezier(0.77, 0, 0.175, 1);
+ transition: transform 100ms cubic-bezier(0.77, 0, 0.175, 1);
+ }
+
+ :where(.agents-view, .agents-view-portal) .composer-drawer[data-placement="top"] {
+ border-radius: 0;
+ background: transparent;
+ }
+
+ :where(.agents-view, .agents-view-portal) .composer-drawer[data-placement="top"]::before {
+ content: none;
+ }
+
+ :where(.agents-view, .agents-view-portal) .composer-drawer[data-placement="top"]::after {
+ content: none;
+ }
+
+ :where(.agents-view, .agents-view-portal) .composer-drawer[data-placement="top"] .composer-drawer-content {
+ min-height: 46px;
+ padding: 6px 12px 4px;
+ transform: translateY(12px);
}
:where(.agents-view, .agents-view-portal) .composer-drawer[data-open] .composer-drawer-content {
diff --git a/apps/web/src/features/agents-view/components/AgentPickerIdentity.tsx b/apps/web/src/features/agents-view/components/AgentPickerIdentity.tsx
new file mode 100644
index 0000000000..1c95994140
--- /dev/null
+++ b/apps/web/src/features/agents-view/components/AgentPickerIdentity.tsx
@@ -0,0 +1,50 @@
+import { modelLabel } from '@core/component/AI/constant/model-label';
+import Check from '@phosphor/check.svg';
+import { Show } from 'solid-js';
+import type { RosterAgent } from '../core/roster';
+import { AgentIcon } from './AgentGlyph';
+
+/** Consistent identity and availability details in desktop and mobile pickers. */
+export function AgentPickerIdentity(props: {
+ agent: RosterAgent;
+ selected: boolean;
+ model?: string;
+}) {
+ const detail = () => {
+ if (props.agent.unavailableReason)
+ return props.agent.connectLabel ?? props.agent.unavailableReason;
+ const model = props.model ?? props.agent.defaultModel;
+ return [
+ props.agent.share === 'system' && model
+ ? undefined
+ : props.agent.runtime.label,
+ model && modelLabel(model),
+ ]
+ .filter(Boolean)
+ .join(' · ');
+ };
+ return (
+ <>
+ <span class="flex size-8 shrink-0 items-center justify-center rounded-lg bg-ink/5">
+ <AgentIcon agent={props.agent} class="size-[18px]" />
+ </span>
+ <span class="min-w-0 flex-1 text-left">
+ <span
+ class="block truncate text-sm font-medium leading-5"
+ title={props.agent.name}
+ >
+ {props.agent.name}
+ </span>
+ <span
+ class="block truncate text-xs leading-4 text-ink-muted"
+ title={`${props.agent.name} · ${detail()}`}
+ >
+ {detail()}
+ </span>
+ </span>
+ <Show when={props.selected}>
+ <Check class="size-4 shrink-0 text-accent" />
+ </Show>
+ </>
+ );
+}
diff --git a/apps/web/src/features/agents-view/components/AgentsSidebar.test.tsx b/apps/web/src/features/agents-view/components/AgentsSidebar.test.tsx
index 82ffa30e27..8573c21177 100644
--- a/apps/web/src/features/agents-view/components/AgentsSidebar.test.tsx
+++ b/apps/web/src/features/agents-view/components/AgentsSidebar.test.tsx
@@ -8,7 +8,10 @@ import {
} from '@solidjs/testing-library';
import { createSignal, type JSX } from 'solid-js';
import { afterEach, describe, expect, it, vi } from 'vitest';
-import type { AgentsMode } from '../core/mode';
+import {
+ type ConversationFilters,
+ EMPTY_CONVERSATION_FILTERS,
+} from '../core/conversation-filters';
import {
type AgentConversationEntity,
partitionArchived,
@@ -105,14 +108,9 @@ vi.mock('@app/features/soup', () => ({
vi.mock('@components/app/split-panel', () => ({
SplitPanel: { CloseButton: () => null },
}));
-vi.mock('@app/components/view-shell/SidebarCreateButton', () => ({
- SidebarCreateButton: (props: { label: string; onCreate: () => void }) => (
- <button onClick={props.onCreate}>{props.label}</button>
- ),
-}));
describe('mixed Agents sidebar', () => {
- it('lists only the conversations of the chosen mode and switches between Work and Code', async () => {
+ it('lists chat and code conversations together until a filter narrows them', async () => {
const conversations: AgentConversationEntity[] = [
{
type: 'agent_session',
@@ -122,6 +120,7 @@ describe('mixed Agents sidebar', () => {
isArchived: false,
botId: 'cursor',
status: 'acp_ready',
+ turnState: 'blocked',
},
{ type: 'chat', id: 'chat', name: 'Plan launch', ownerId: 'me' },
{
@@ -134,15 +133,18 @@ describe('mixed Agents sidebar', () => {
status: 'disconnected',
},
];
- const [mode, setMode] = createSignal<AgentsMode>('chat');
- const changeMode = vi.fn(setMode);
+ const [filters, setFilters] = createSignal<ConversationFilters>(
+ EMPTY_CONVERSATION_FILTERS
+ );
const open = vi.fn();
- const create = vi.fn();
const openPage = vi.fn();
render(() => (
<AgentsSidebar
- mode={mode()}
- onModeChange={changeMode}
+ filters={filters()}
+ grouping="status"
+ onFilterChange={vi.fn()}
+ onClearFilters={vi.fn()}
+ onGroupingChange={vi.fn()}
activePage="new"
onOpenPage={openPage}
{...partitionArchived(conversations)}
@@ -155,7 +157,6 @@ describe('mixed Agents sidebar', () => {
error={false}
hasNextPage={false}
loadingNextPage={false}
- onNewConversation={create}
onSearchChange={vi.fn()}
onOpenConversation={open}
onRetry={vi.fn()}
@@ -167,40 +168,50 @@ describe('mixed Agents sidebar', () => {
expect(openPage).toHaveBeenLastCalledWith(label.toLowerCase());
}
- const work = screen.getByRole('radio', {
- name: 'Work',
- }) as HTMLInputElement;
- expect(work.checked).toBe(true);
+ expect(screen.queryByRole('radio', { name: 'Work' })).toBeNull();
+ expect(
+ screen
+ .getAllByRole('heading', { level: 3 })
+ .map((heading) => heading.textContent)
+ ).toEqual(['Needs you1', 'Recent1', 'Archived']);
const chat = screen.getByRole('button', { name: /Plan launch/ });
expect(chat.getAttribute('data-kind')).toBe('chat');
expect(chat.getAttribute('aria-current')).toBe('page');
- expect(screen.queryByRole('button', { name: /Fix build/ })).toBeNull();
- expect(screen.queryByText('Archived')).toBeNull();
+ expect(screen.getByRole('button', { name: /Fix build/ })).toBeTruthy();
fireEvent.click(chat);
expect(open).toHaveBeenLastCalledWith(conversations[1], expect.anything());
- fireEvent.click(screen.getByRole('radio', { name: 'Code' }));
- expect(changeMode).toHaveBeenCalledWith('code');
+ setFilters({ ...EMPTY_CONVERSATION_FILTERS, type: ['code'] });
const code = await screen.findByRole('button', { name: /Fix build/ });
expect(code.closest('[data-kind]')?.getAttribute('data-kind')).toBe('code');
expect(screen.queryByRole('button', { name: /Plan launch/ })).toBeNull();
- expect(screen.getByText('Archived')).toBeTruthy();
expect(screen.getByRole('button', { name: /Old spike/ })).toBeTruthy();
fireEvent.click(code, { shiftKey: true });
expect(open).toHaveBeenLastCalledWith(
conversations[0],
expect.objectContaining({ shiftKey: true })
);
- fireEvent.click(screen.getByRole('button', { name: 'New conversation' }));
- expect(create).toHaveBeenCalledOnce();
+
+ setFilters({ ...EMPTY_CONVERSATION_FILTERS, status: ['waiting'] });
+ expect(screen.getByRole('button', { name: /Fix build/ })).toBeTruthy();
+ expect(screen.queryByRole('button', { name: /Plan launch/ })).toBeNull();
+ expect(screen.queryByText('Archived')).toBeNull();
+
+ expect(
+ screen.queryByRole('button', { name: 'New conversation' })
+ ).toBeNull();
});
- it('keeps paging while the chosen mode has too few conversations to scroll', () => {
+ it('keeps paging while filters leave too few conversations to scroll', () => {
const loadMore = vi.fn();
+ const clear = vi.fn();
render(() => (
<AgentsSidebar
- mode="code"
- onModeChange={vi.fn()}
+ filters={{ ...EMPTY_CONVERSATION_FILTERS, type: ['code'] }}
+ grouping="none"
+ onFilterChange={vi.fn()}
+ onClearFilters={clear}
+ onGroupingChange={vi.fn()}
activePage="new"
onOpenPage={vi.fn()}
conversations={[
@@ -214,7 +225,6 @@ describe('mixed Agents sidebar', () => {
error={false}
hasNextPage
loadingNextPage={false}
- onNewConversation={vi.fn()}
onSearchChange={vi.fn()}
onOpenConversation={vi.fn()}
onRetry={vi.fn()}
@@ -222,14 +232,21 @@ describe('mixed Agents sidebar', () => {
/>
));
expect(loadMore).toHaveBeenCalledOnce();
- expect(screen.getByText('No coding conversations yet.')).toBeTruthy();
+ expect(
+ screen.getByText('No conversations match these filters.')
+ ).toBeTruthy();
+ fireEvent.click(screen.getByRole('button', { name: 'Clear filters' }));
+ expect(clear).toHaveBeenCalledOnce();
});
it('opens rename and delete on a session or chat right-click', async () => {
render(() => (
<AgentsSidebar
- mode="chat"
- onModeChange={vi.fn()}
+ filters={EMPTY_CONVERSATION_FILTERS}
+ grouping="none"
+ onFilterChange={vi.fn()}
+ onClearFilters={vi.fn()}
+ onGroupingChange={vi.fn()}
activePage="new"
onOpenPage={vi.fn()}
{...partitionArchived([
@@ -260,7 +277,6 @@ describe('mixed Agents sidebar', () => {
error={false}
hasNextPage={false}
loadingNextPage={false}
- onNewConversation={vi.fn()}
onSearchChange={vi.fn()}
onOpenConversation={vi.fn()}
onRetry={vi.fn()}
@@ -330,8 +346,11 @@ describe.each(['home', 'sidebar'] as const)('%s agent rows', (surface) => {
/>
) : (
<AgentsSidebar
- mode="code"
- onModeChange={vi.fn()}
+ filters={EMPTY_CONVERSATION_FILTERS}
+ grouping="none"
+ onFilterChange={vi.fn()}
+ onClearFilters={vi.fn()}
+ onGroupingChange={vi.fn()}
activePage="new"
onOpenPage={vi.fn()}
conversations={[entity()]}
@@ -343,7 +362,6 @@ describe.each(['home', 'sidebar'] as const)('%s agent rows', (surface) => {
error={false}
hasNextPage={false}
loadingNextPage={false}
- onNewConversation={vi.fn()}
onSearchChange={vi.fn()}
onOpenConversation={open}
onRetry={vi.fn()}
diff --git a/apps/web/src/features/agents-view/components/AgentsSidebar.tsx b/apps/web/src/features/agents-view/components/AgentsSidebar.tsx
index 6b1514653e..2424a7ccdc 100644
--- a/apps/web/src/features/agents-view/components/AgentsSidebar.tsx
+++ b/apps/web/src/features/agents-view/components/AgentsSidebar.tsx
@@ -5,7 +5,6 @@ import {
useViewControlHotkeys,
ViewSidebar,
} from '@app/components/view-shell';
-import { SidebarCreateButton } from '@app/components/view-shell/SidebarCreateButton';
import { changeSessionArchiveState } from '@app/features/block-agent/queries/change-session-archive-state';
import {
type EntityActionListState,
@@ -27,11 +26,19 @@ import PlugIcon from '@phosphor/plugs-connected.svg';
import AgentIcon from '@phosphor/sparkle.svg';
import TrayIcon from '@phosphor/tray.svg';
import { Key } from '@solid-primitives/keyed';
-import { cn, Tabs } from '@ui';
+import { cn } from '@ui';
import { tourTarget } from '@ui/components/Tour';
import { createEffect, createSignal, type JSX, Show } from 'solid-js';
+import {
+ activeFilterCount,
+ type ConversationFilters,
+ type ConversationGrouping,
+ conversationFacts,
+ conversationMatchesFilters,
+ groupConversations,
+} from '../core/conversation-filters';
import { compactAge } from '../core/format-age';
-import { type AgentsMode, agentsModeLabel } from '../core/mode';
+import type { AgentsMode } from '../core/mode';
import type { AgentsPage } from '../core/pages';
import {
type AgentConversationEntity,
@@ -40,9 +47,13 @@ import {
import { AGENTS_TOUR } from '../tour';
import { AgentSessionListItem } from '../views/AgentSessionListItem';
import { AgentSessionListSkeleton } from './AgentSessionListSkeleton';
+import {
+ ConversationListControls,
+ type ConversationListControlsProps,
+} from './ConversationListControls';
-/** Rows a mode should fill before paging stops waiting for a scroll. */
-const MODE_PAGE_FILL = 20;
+/** Rows the filtered list should fill before paging stops waiting for a scroll. */
+const FILTERED_PAGE_FILL = 20;
const AGENTS_ACTION_VIEW_CONTEXT: EntityActionViewContext = {
supportsMarkDone: false,
@@ -50,10 +61,13 @@ const AGENTS_ACTION_VIEW_CONTEXT: EntityActionViewContext = {
senderBucket: undefined,
};
-export type AgentsSidebarProps = {
- /** Only conversations of this mode are listed. */
- mode: AgentsMode;
- onModeChange: (mode: AgentsMode) => void;
+export type AgentsSidebarProps = Omit<
+ ConversationListControlsProps,
+ 'filters' | 'grouping'
+> & {
+ /** Only conversations matching these are listed. */
+ filters: ConversationFilters;
+ grouping: ConversationGrouping;
activePage: AgentsPage | undefined;
onOpenPage: (page: AgentsPage) => void;
modeForConversation: (conversation: AgentConversationEntity) => AgentsMode;
@@ -65,7 +79,6 @@ export type AgentsSidebarProps = {
error: boolean;
hasNextPage: boolean;
loadingNextPage: boolean;
- onNewConversation: () => void;
onSearchChange: (search: string) => void;
onOpenConversation: (
conversation: AgentConversationEntity,
@@ -163,12 +176,21 @@ export function AgentsSidebar(props: AgentsSidebarProps) {
const [searchOpen, setSearchOpen] = createSignal(false);
const [conversationsOpen, setConversationsOpen] = createSignal(true);
let searchInput: HTMLInputElement | undefined;
- const inMode = (conversations: AgentConversationEntity[]) =>
- conversations.filter(
- (conversation) => props.modeForConversation(conversation) === props.mode
+ const factsOf = (conversation: AgentConversationEntity) =>
+ conversationFacts(
+ conversation,
+ props.modeForConversation(conversation),
+ unreadFilterFn(conversation)
);
- const conversations = () => inMode(props.conversations);
- const archived = () => inMode(props.archived);
+ const matching = (conversations: AgentConversationEntity[]) =>
+ conversations.filter((conversation) =>
+ conversationMatchesFilters(factsOf(conversation), props.filters)
+ );
+ const conversations = () => matching(props.conversations);
+ const archived = () => matching(props.archived);
+ const groups = () =>
+ groupConversations(conversations(), factsOf, props.grouping);
+ const filtering = () => activeFilterCount(props.filters) > 0;
const actionController = createListController({
items: () => [...conversations(), ...archived()],
getKey: (conversation) => conversation.id,
@@ -179,11 +201,11 @@ export function AgentsSidebar(props: AgentsSidebarProps) {
getEntity: (conversation) => conversation,
});
const total = () => conversations().length + archived().length;
- // Both modes page through one mixed query, so a short filtered list never
- // scrolls far enough to ask for more; keep paging until it fills.
+ // Filters apply to one mixed query, so a short filtered list never scrolls
+ // far enough to ask for more; keep paging until it fills.
createEffect(() => {
if (
- total() < MODE_PAGE_FILL &&
+ total() < FILTERED_PAGE_FILL &&
props.hasNextPage &&
!props.loading &&
!props.loadingNextPage &&
@@ -252,34 +274,6 @@ export function AgentsSidebar(props: AgentsSidebarProps) {
</ViewSidebar.Header>
</Show>
- <div
- ref={tourTarget(AGENTS_TOUR.modeSwitch)}
- class="px-(--sidebar-gutter) pt-1 touch:pt-0"
- >
- <Tabs
- aria-label="Agents mode"
- fullWidth
- list={(['chat', 'code'] as const).map((mode) => ({
- value: mode,
- label: agentsModeLabel(mode),
- }))}
- value={props.mode}
- onChange={(value) =>
- props.onModeChange(value === 'code' ? 'code' : 'chat')
- }
- />
- </div>
-
- <Show when={!isTouchDevice()}>
- <div class="px-(--sidebar-gutter) pt-2">
- <SidebarCreateButton
- label="New conversation"
- onCreate={props.onNewConversation}
- ref={tourTarget(AGENTS_TOUR.newChat)}
- />
- </div>
- </Show>
-
<ViewSidebar.Content class="gap-2 overflow-hidden pt-2">
<Show when={!isTouchDevice()}>
<ViewSidebar.Nav aria-label="Agent tools">
@@ -326,6 +320,13 @@ export function AgentsSidebar(props: AgentsSidebarProps) {
<span class="min-w-0 truncate">Conversations</span>
<CollapsibleSection.Indicator />
</CollapsibleSection.Trigger>
+ <ConversationListControls
+ filters={props.filters}
+ grouping={props.grouping}
+ onFilterChange={props.onFilterChange}
+ onClearFilters={props.onClearFilters}
+ onGroupingChange={props.onGroupingChange}
+ />
<CollapsibleSection.Action
label="Search conversations"
aria-pressed={searchOpen()}
@@ -355,7 +356,23 @@ export function AgentsSidebar(props: AgentsSidebarProps) {
aria-busy={props.loading || props.loadingNextPage}
onScroll={loadMoreNearEnd}
>
- {rows(conversations)}
+ <Key each={groups()} by="id">
+ {(group) => (
+ <>
+ <Show when={group().label}>
+ {(label) => (
+ <h3 class="flex shrink-0 items-center gap-1.5 px-(--sidebar-item-inset) pt-2 pb-1 text-xs font-medium text-ink-muted">
+ {label()}
+ <span class="text-ink-extra-muted tabular-nums">
+ {group().items.length}
+ </span>
+ </h3>
+ )}
+ </Show>
+ {rows(() => group().items)}
+ </>
+ )}
+ </Key>
<Show when={props.loading && total() === 0}>
<AgentSessionListSkeleton />
</Show>
@@ -369,10 +386,16 @@ export function AgentsSidebar(props: AgentsSidebarProps) {
<p class="px-(--sidebar-item-inset) py-2 text-xs text-ink-muted">
{props.search.trim()
? `No results for "${props.search.trim()}"`
- : props.mode === 'code'
- ? 'No coding conversations yet.'
+ : filtering()
+ ? 'No conversations match these filters.'
: 'No conversations yet.'}
</p>
+ <Show when={filtering()}>
+ <ViewSidebar.Item onClick={props.onClearFilters}>
+ <ViewSidebar.Icon />
+ <span class="truncate">Clear filters</span>
+ </ViewSidebar.Item>
+ </Show>
</Show>
<Show when={props.loadingNextPage}>
<AgentSessionListSkeleton loadingMore />
diff --git a/apps/web/src/features/agents-view/components/ChatComposer.test.tsx b/apps/web/src/features/agents-view/components/ChatComposer.test.tsx
index 316dbd30b2..06c847132c 100644
--- a/apps/web/src/features/agents-view/components/ChatComposer.test.tsx
+++ b/apps/web/src/features/agents-view/components/ChatComposer.test.tsx
@@ -369,41 +369,47 @@ describe('Chat session input', () => {
expect(screen.getByRole('button', { name: 'Agent' })).toBeTruthy();
expect(screen.queryByRole('button', { name: 'Model' })).toBeNull();
});
- it('expands coding mode with repository settings after the input without remounting the editor', () => {
- const [mode, setMode] = createSignal('chat');
- const { container } = render(() => (
- <ChatComposer
- draft="Shared draft"
- onDraftChange={vi.fn()}
- selector={<button>Agent</button>}
- drawer={<button>Repository</button>}
- drawerOpen={mode() === 'code'}
- onSend={vi.fn()}
- />
- ));
- const input = screen.getByTestId('editor');
- const drawer = container.querySelector('.composer-drawer');
- const layout = container.querySelector('[data-composer-compact]');
- expect(layout?.getAttribute('data-composer-compact')).toBe('true');
- expect(
- (drawer?.compareDocumentPosition(input) ?? 0) &
- Node.DOCUMENT_POSITION_PRECEDING
- ).toBeTruthy();
- expect((drawer as HTMLElement).inert).toBe(true);
- expect(drawer?.getAttribute('aria-hidden')).toBe('true');
- setMode('code');
- expect(screen.getByTestId('editor')).toBe(input);
- expect((drawer as HTMLElement).inert).toBe(false);
- expect(drawer?.hasAttribute('data-open')).toBe(true);
- expect(layout?.getAttribute('data-composer-compact')).toBe('false');
- expect(editor.clear).not.toHaveBeenCalled();
- setMode('chat');
- expect(layout?.getAttribute('data-composer-compact')).toBe('true');
- expect(screen.getByTestId('editor')).toBe(input);
- expect((drawer as HTMLElement).inert).toBe(true);
- const settings = screen.getByRole('group', { name: 'Composer settings' });
- expect(settings.textContent).toBe('Agent');
- });
+ it.each([false, true])(
+ 'places repository settings below desktop and above touch input without remounting the editor (touch: %s)',
+ (touch) => {
+ vi.mocked(isTouchDevice).mockReturnValue(touch);
+ const [mode, setMode] = createSignal('chat');
+ const { container } = render(() => (
+ <ChatComposer
+ draft="Shared draft"
+ onDraftChange={vi.fn()}
+ selector={<button>Agent</button>}
+ drawer={<button>Repository</button>}
+ drawerOpen={mode() === 'code'}
+ onSend={vi.fn()}
+ />
+ ));
+ const input = screen.getByTestId('editor');
+ const drawer = container.querySelector('.composer-drawer');
+ const layout = container.querySelector('[data-composer-compact]');
+ expect(layout?.getAttribute('data-composer-compact')).toBe('true');
+ expect(
+ (drawer?.compareDocumentPosition(input) ?? 0) &
+ (touch
+ ? Node.DOCUMENT_POSITION_FOLLOWING
+ : Node.DOCUMENT_POSITION_PRECEDING)
+ ).toBeTruthy();
+ expect((drawer as HTMLElement).inert).toBe(true);
+ expect(drawer?.getAttribute('aria-hidden')).toBe('true');
+ setMode('code');
+ expect(screen.getByTestId('editor')).toBe(input);
+ expect((drawer as HTMLElement).inert).toBe(false);
+ expect(drawer?.hasAttribute('data-open')).toBe(true);
+ expect(layout?.getAttribute('data-composer-compact')).toBe('false');
+ expect(editor.clear).not.toHaveBeenCalled();
+ setMode('chat');
+ expect(layout?.getAttribute('data-composer-compact')).toBe('true');
+ expect(screen.getByTestId('editor')).toBe(input);
+ expect((drawer as HTMLElement).inert).toBe(true);
+ const settings = screen.getByRole('group', { name: 'Composer settings' });
+ expect(settings.textContent).toBe('Agent');
+ }
+ );
it('does not grow the surface from zero after mounting offscreen', () => {
render(() => (
<ChatComposer
@@ -560,7 +566,7 @@ it('keeps the paperclip visible while the session is unavailable', () => {
});
it.each([undefined, 'Describe what you want to build'])(
- 'leaves the mobile editor blank instead of showing placeholder %s',
+ 'uses a short mobile placeholder instead of the desktop prompt %s',
(placeholder) => {
vi.mocked(isTouchDevice).mockReturnValue(true);
render(() => (
@@ -572,11 +578,11 @@ it.each([undefined, 'Describe what you want to build'])(
selector={<button>Model</button>}
/>
));
- expect(screen.getByTestId('editor').textContent).toBe('');
+ expect(screen.getByTestId('editor').textContent).toBe('Message Macro AI');
}
);
-it('expands Home controls on focus without replacing the editor or model picker', () => {
+it('expands mobile controls on focus without replacing the editor or model picker', () => {
vi.mocked(isTouchDevice).mockReturnValue(true);
const { container } = render(() => (
<ChatComposer
@@ -594,26 +600,80 @@ it('expands Home controls on focus without replacing the editor or model picker'
const model = screen.getByRole('button', { name: 'Model' });
const attach = screen.getByRole('button', { name: 'Attach files' });
const repository = container.querySelector('.composer-drawer');
+ const surface = container.querySelector('[data-agent-composer]');
const compact = () => input.closest('[data-composer-compact]');
expect(compact()?.getAttribute('data-composer-compact')).toBe('true');
- expect(model.parentElement?.classList.contains('hidden')).toBe(false);
+ expect(model.parentElement?.classList.contains('hidden')).toBe(true);
expect(attach.parentElement?.classList.contains('hidden')).toBe(true);
expect(repository?.getAttribute('aria-hidden')).toBe('true');
+ expect(surface?.hasAttribute('data-composer-expanded')).toBe(false);
fireEvent.focusIn(input);
expect(compact()?.getAttribute('data-composer-compact')).toBe('false');
expect(model.parentElement?.classList.contains('hidden')).toBe(false);
expect(attach.parentElement?.classList.contains('hidden')).toBe(false);
expect(repository?.getAttribute('aria-hidden')).toBe('false');
+ expect(surface?.getAttribute('data-composer-expanded')).toBe('true');
fireEvent.pointerDown(document.body);
expect(compact()?.getAttribute('data-composer-compact')).toBe('true');
expect(repository?.getAttribute('aria-hidden')).toBe('true');
+ expect(surface?.hasAttribute('data-composer-expanded')).toBe(false);
expect(screen.getByTestId('editor')).toBe(input);
expect(screen.getByRole('button', { name: 'Model' })).toBe(model);
});
+it('expands a short mobile session draft on focus and keeps the editor mounted', () => {
+ vi.mocked(isTouchDevice).mockReturnValue(true);
+ render(() => (
+ <ChatSessionInput
+ initialInput="Keep this draft"
+ onSend={() => {}}
+ modelControl={<button>Model</button>}
+ />
+ ));
+ const input = screen.getByTestId('editor');
+ const compact = () =>
+ input
+ .closest('[data-composer-compact]')
+ ?.getAttribute('data-composer-compact');
+
+ expect(compact()).toBe('true');
+ fireEvent.focusIn(input);
+ expect(compact()).toBe('false');
+ fireEvent.focusOut(input, { relatedTarget: document.body });
+ expect(compact()).toBe('true');
+ expect(screen.getByTestId('editor')).toBe(input);
+ expect(editor.clear).not.toHaveBeenCalled();
+});
+
+it('reveals the mobile model trigger after focusing the input', () => {
+ vi.mocked(isTouchDevice).mockReturnValue(true);
+ const open = vi.fn();
+ render(() => (
+ <ChatComposer
+ collapseOnBlur
+ draft=""
+ onDraftChange={() => {}}
+ onSend={() => {}}
+ selector={<button onClick={open}>Model</button>}
+ />
+ ));
+ const trigger = screen.getByRole('button', { name: 'Model' });
+ const compact = screen
+ .getByTestId('editor')
+ .closest('[data-composer-compact]');
+
+ expect(trigger.parentElement?.classList.contains('hidden')).toBe(true);
+ fireEvent.focusIn(screen.getByTestId('editor'));
+ expect(trigger.parentElement?.classList.contains('hidden')).toBe(false);
+ expect(compact?.getAttribute('data-composer-compact')).toBe('false');
+ fireEvent.click(trigger);
+ expect(open).toHaveBeenCalledOnce();
+ expect(preloadAgentFold).toHaveBeenCalled();
+});
+
it.each(['Send', 'Attach files', 'Model'])(
'keeps the expanded Home composer stable through an iOS %s tap',
(control) => {
diff --git a/apps/web/src/features/agents-view/components/ChatComposer.tsx b/apps/web/src/features/agents-view/components/ChatComposer.tsx
index 78ab78b62f..3c67543e93 100644
--- a/apps/web/src/features/agents-view/components/ChatComposer.tsx
+++ b/apps/web/src/features/agents-view/components/ChatComposer.tsx
@@ -57,7 +57,8 @@ export function ChatComposer(props: {
placeholder?: string;
}) {
const tip = createChatComposerTip(
- () => props.draft.trim().length === 0,
+ () =>
+ props.draft.trim().length === 0 && !isTouchDevice() && !props.placeholder,
!props.session
);
const attachments = () => props.attachments ?? [];
@@ -96,6 +97,7 @@ export function ChatComposer(props: {
});
let container: HTMLDivElement | undefined;
const [focused, setFocused] = createSignal(false);
+ const [hasFocused, setHasFocused] = createSignal(false);
const collapsed = () =>
isTouchDevice() &&
props.collapseOnBlur &&
@@ -162,7 +164,7 @@ export function ChatComposer(props: {
mode: () =>
collapsed()
? 'collapsed'
- : isTouchDevice() && props.collapseOnBlur
+ : isTouchDevice() && (props.collapseOnBlur || focused())
? 'expanded'
: 'auto',
});
@@ -230,6 +232,55 @@ export function ChatComposer(props: {
if (event.type === 'pointerdown') editor.controls.focus();
};
+ const editorRow = () => (
+ <div
+ classList={{
+ 'max-h-6 overflow-hidden': !!collapsed(),
+ 'max-h-[min(15rem,30dvh)]': !collapsed(),
+ }}
+ class="min-w-0 flex-1 self-center overflow-y-auto px-[9.375px] group-data-[composer-compact=true]/composer:px-0 group-data-[composer-coding=true]/composer:min-h-[58px] touch:group-data-[composer-compact=false]/composer:min-h-18 group-data-[composer-compact=false]/composer:flex-none group-data-[composer-compact=false]/composer:basis-full"
+ >
+ <MarkdownShell
+ class="h-auto min-h-6 text-base leading-6 [&_[data-markdown-editable]]:min-h-6 [&_[data-markdown-editable]]:outline-none [&_[data-markdown-editable]>.md-p]:my-0 [&_[data-markdown-placeholder]]:max-w-full [&_[data-markdown-placeholder]>p]:m-0 [&_[data-markdown-placeholder]>p]:truncate"
+ config={editor}
+ initialValue={props.draft}
+ placeholder={
+ isTouchDevice()
+ ? // Phones are too narrow for the longer prompts and rotating tips.
+ 'Message Macro AI'
+ : (props.placeholder ?? tip())
+ }
+ ariaLabel="Message the agent"
+ autofocus={
+ !isTouchDevice() &&
+ (props.autoFocus ?? props.session?.autofocus ?? true)
+ }
+ />
+ </div>
+ );
+
+ const repositoryDrawer = () => (
+ <Show when={props.drawer}>
+ <div
+ class="composer-drawer"
+ data-placement={isTouchDevice() ? 'top' : 'bottom'}
+ data-open={drawerOpen() ? '' : undefined}
+ aria-hidden={!drawerOpen()}
+ inert={!drawerOpen()}
+ >
+ <div class="composer-drawer-inner">
+ <div
+ class="composer-drawer-content"
+ role="group"
+ aria-label="Conversation settings"
+ >
+ {props.drawer}
+ </div>
+ </div>
+ </div>
+ </Show>
+ );
+
return (
<InputProvider
value={{
@@ -245,9 +296,19 @@ export function ChatComposer(props: {
<div
ref={container}
data-keep-keyboard
- class="min-w-0"
- onFocusIn={() => {
+ class="relative w-full min-w-0 touch:island touch:rounded-[32px]"
+ onFocusIn={(event) => {
+ // Focusing a control before its click must not move it into the
+ // expanded layout midway through a tap.
+ if (
+ event.target instanceof Element &&
+ event.target.closest(
+ '[data-composer-controls], button, input, select, a'
+ )
+ )
+ return;
setFocused(true);
+ setHasFocused(true);
fireAndForget(preloadAgentFold(), 'agents-view');
}}
onFocusOut={(event) => {
@@ -260,10 +321,14 @@ export function ChatComposer(props: {
setFocused(false);
}}
>
+ <Show when={isTouchDevice()}>{repositoryDrawer()}</Show>
<ComposerSurface
as="div"
data-agent-composer="chat"
- class="relative z-10 min-w-0 rounded-[32px] touch:island touch:bg-chrome transition-[height] duration-200 ease-[cubic-bezier(0.77,0,0.175,1)] motion-reduce:transition-none"
+ data-composer-expanded={
+ (isTouchDevice() && !collapsed()) || undefined
+ }
+ class="relative z-10 min-w-0 rounded-[32px] transition-[height] duration-200 ease-[cubic-bezier(0.77,0,0.175,1)] motion-reduce:transition-none"
style={{
height: height() === undefined ? undefined : `${height()}px`,
}}
@@ -311,29 +376,7 @@ export function ChatComposer(props: {
</Input.AttachFilesAction>
</div>
</Show>
- <div
- classList={{
- 'max-h-6 overflow-hidden': !!collapsed(),
- 'max-h-[min(15rem,30dvh)]': !collapsed(),
- }}
- class="min-w-0 flex-1 self-center group-data-[composer-compact=false]/composer:flex-none group-data-[composer-compact=false]/composer:basis-full overflow-y-auto px-[9.375px] group-data-[composer-compact=true]/composer:px-0 group-data-[composer-coding=true]/composer:min-h-[58px]"
- >
- <MarkdownShell
- class="h-auto min-h-6 text-base leading-6 [&_[data-markdown-editable]]:min-h-6 [&_[data-markdown-editable]]:outline-none [&_[data-markdown-editable]>.md-p]:my-0 [&_[data-markdown-placeholder]]:max-w-full [&_[data-markdown-placeholder]>p]:m-0 [&_[data-markdown-placeholder]>p]:truncate"
- config={editor}
- initialValue={props.draft}
- placeholder={
- isTouchDevice() ? '' : (props.placeholder ?? tip())
- }
- refFn={(element) =>
- element.setAttribute('aria-label', 'Message the agent')
- }
- autofocus={
- !isTouchDevice() &&
- (props.autoFocus ?? props.session?.autofocus ?? true)
- }
- />
- </div>
+ {editorRow()}
<div
data-composer-controls
class="order-2 flex min-w-0 max-w-[55%] group-data-[composer-compact=false]/composer:max-w-none group-data-[composer-compact=false]/composer:flex-1 shrink-0 items-center gap-2"
@@ -341,7 +384,13 @@ export function ChatComposer(props: {
aria-label="Composer settings"
>
<div class="ml-auto flex min-w-0 max-w-full items-center gap-2 [&_.menu]:right-0 [&_.menu]:left-auto [&_.menu-anchor]:min-w-0 [&_.pill]:max-w-full">
- <div class="flex min-w-0 items-center gap-2">
+ <div
+ class={
+ collapsed() || (isTouchDevice() && !hasFocused())
+ ? 'hidden'
+ : 'flex min-w-0 items-center gap-2'
+ }
+ >
{props.selector}
<div class={collapsed() ? 'hidden' : 'contents'}>
<DictationButton
@@ -359,6 +408,7 @@ export function ChatComposer(props: {
fallback={
<SendButton
appearance="composer"
+ class="touch:bg-transparent touch:text-ink touch:data-disabled:bg-transparent"
aria-label="Send"
title={props.blockedReason}
disabled={
@@ -376,6 +426,7 @@ export function ChatComposer(props: {
fallback={
<Button
variant="strong"
+ class="touch:glass touch:bg-chrome touch:text-ink touch:data-disabled:bg-chrome"
size="icon-composer"
label="Stop"
disabled={disabled()}
@@ -387,6 +438,7 @@ export function ChatComposer(props: {
>
<SendButton
appearance="composer"
+ class="touch:bg-transparent touch:text-ink touch:data-disabled:bg-transparent"
intent="flush"
aria-label="Flush queued messages"
tooltip="Flush queued messages"
@@ -407,25 +459,8 @@ export function ChatComposer(props: {
{IMAGE_INPUT_WARNING}
</p>
</Show>
+ <Show when={!isTouchDevice()}>{repositoryDrawer()}</Show>
<DictationFeedback dictation={dictation} />
- <Show when={props.drawer}>
- <div
- class="composer-drawer"
- data-open={drawerOpen() ? '' : undefined}
- aria-hidden={!drawerOpen()}
- inert={!drawerOpen()}
- >
- <div class="composer-drawer-inner">
- <div
- class="composer-drawer-content"
- role="group"
- aria-label="Repository settings"
- >
- {props.drawer}
- </div>
- </div>
- </div>
- </Show>
</div>
</InputProvider>
);
diff --git a/apps/web/src/features/agents-view/components/ConversationListControls.tsx b/apps/web/src/features/agents-view/components/ConversationListControls.tsx
new file mode 100644
index 0000000000..0ccb6db4db
--- /dev/null
+++ b/apps/web/src/features/agents-view/components/ConversationListControls.tsx
@@ -0,0 +1,141 @@
+import {
+ type ListControlOption,
+ ListFilterDropdown,
+ type ListFilterGroup,
+ ListGroupDropdown,
+} from '@app/components/view-shell';
+import ChatIcon from '@phosphor/chat-circle.svg';
+import CodeIcon from '@phosphor/code.svg';
+import GitMergeIcon from '@phosphor/git-merge.svg';
+import GitPullRequestIcon from '@phosphor/git-pull-request.svg';
+import { cn } from '@ui';
+import { Show } from 'solid-js';
+import {
+ activeFilterCount,
+ type ConversationFilterCategory,
+ type ConversationFilters,
+ type ConversationGrouping,
+ type PullRequestFilter,
+ type StatusFilter,
+} from '../core/conversation-filters';
+import type { AgentsMode } from '../core/mode';
+
+type FilterValue = AgentsMode | StatusFilter | PullRequestFilter;
+
+const statusDot = (class_: string) => () => (
+ <span class={cn('size-1.5 rounded-full', class_)} />
+);
+
+const pullRequestIcon =
+ (class_: string, merged = false) =>
+ () =>
+ merged ? (
+ <GitMergeIcon class={cn('size-3.5', class_)} />
+ ) : (
+ <GitPullRequestIcon class={cn('size-3.5', class_)} />
+ );
+
+const TYPE_OPTIONS: ListControlOption<AgentsMode>[] = [
+ {
+ id: 'chat',
+ label: 'Chat',
+ icon: () => <ChatIcon class="size-3.5 text-ink-muted" />,
+ },
+ {
+ id: 'code',
+ label: 'Code',
+ icon: () => <CodeIcon class="size-3.5 text-ink-muted" />,
+ },
+];
+
+const STATUS_OPTIONS: ListControlOption<StatusFilter>[] = [
+ { id: 'waiting', label: 'Waiting for you', icon: statusDot('bg-warning') },
+ { id: 'working', label: 'Working', icon: statusDot('bg-accent') },
+ { id: 'unread', label: 'Unread', icon: statusDot('bg-accent') },
+ {
+ id: 'idle',
+ label: 'Idle',
+ icon: () => (
+ <span class="size-1.5 rounded-full border border-ink-extra-muted" />
+ ),
+ },
+];
+
+const PULL_REQUEST_OPTIONS: ListControlOption<PullRequestFilter>[] = [
+ { id: 'open', label: 'Open', icon: pullRequestIcon('text-success') },
+ {
+ id: 'draft',
+ label: 'Draft',
+ icon: pullRequestIcon('text-ink-extra-muted'),
+ },
+ { id: 'merged', label: 'Merged', icon: pullRequestIcon('text-note', true) },
+ { id: 'closed', label: 'Closed', icon: pullRequestIcon('text-failure') },
+ {
+ id: 'none',
+ label: 'No pull request',
+ icon: pullRequestIcon('text-ink-extra-muted'),
+ },
+];
+
+const FILTER_GROUPS: ListFilterGroup<
+ ConversationFilterCategory,
+ FilterValue
+>[] = [
+ { id: 'type', label: 'Type', options: TYPE_OPTIONS },
+ { id: 'status', label: 'Status', options: STATUS_OPTIONS },
+ { id: 'pullRequest', label: 'Pull request', options: PULL_REQUEST_OPTIONS },
+];
+
+const GROUPING_OPTIONS: ListControlOption<ConversationGrouping>[] = [
+ { id: 'none', label: 'None' },
+ { id: 'status', label: 'Status' },
+ { id: 'type', label: 'Type' },
+];
+
+export type ConversationListControlsProps = {
+ filters: ConversationFilters;
+ grouping: ConversationGrouping;
+ onFilterChange: (
+ category: ConversationFilterCategory,
+ value: FilterValue,
+ selected: boolean
+ ) => void;
+ onClearFilters: () => void;
+ onGroupingChange: (grouping: ConversationGrouping) => void;
+};
+
+/** The Tasks-style Group and Filter menus for the conversation list. */
+export function ConversationListControls(props: ConversationListControlsProps) {
+ const isSelected = (
+ category: ConversationFilterCategory,
+ value: FilterValue
+ ) => (props.filters[category] as readonly FilterValue[]).includes(value);
+ const activeCount = () => activeFilterCount(props.filters);
+
+ return (
+ <div class="flex shrink-0 items-center">
+ <ListGroupDropdown
+ label="Group conversations"
+ class="size-(--sidebar-control-size)"
+ value={props.grouping}
+ options={GROUPING_OPTIONS}
+ onChange={props.onGroupingChange}
+ />
+ <div class="relative shrink-0">
+ <ListFilterDropdown
+ label="Filter conversations"
+ class="size-(--sidebar-control-size)"
+ groups={FILTER_GROUPS}
+ isSelected={isSelected}
+ onSelectionChange={props.onFilterChange}
+ onClear={props.onClearFilters}
+ />
+ <Show when={activeCount() > 0}>
+ <span class="pointer-events-none absolute -top-0.5 right-0 z-10 flex size-4 translate-x-1/2 items-center justify-center rounded-full bg-accent text-xxs font-medium leading-none text-surface">
+ {activeCount()}
+ </span>
+ </Show>
+ </div>
+ </div>
+ );
+}
diff --git a/apps/web/src/features/agents-view/components/ModelSelector.test.tsx b/apps/web/src/features/agents-view/components/ModelSelector.test.tsx
index 78ddf3f02f..3dc16cc4bb 100644
--- a/apps/web/src/features/agents-view/components/ModelSelector.test.tsx
+++ b/apps/web/src/features/agents-view/components/ModelSelector.test.tsx
@@ -100,9 +100,7 @@ describe('shared model selector', () => {
expect(trigger.textContent).toBe('Sonnet 5.5');
expect(trigger.title).toBe('Sonnet 5.5');
fireEvent.keyDown(trigger, { key: 'Enter' });
- expect(
- screen.getByRole('menuitem', { name: /^GPT-5.6 mini/ })
- ).toBeTruthy();
+ expect(screen.getByRole('menuitem', { name: 'More models' })).toBeTruthy();
expect(screen.queryByText(ids[0])).toBeNull();
fireEvent.keyDown(screen.getByRole('menuitem', { name: /^Opus 5.5/ }), {
key: 'Enter',
@@ -141,7 +139,7 @@ describe('shared model selector', () => {
await waitFor(() => expect(screen.queryByRole('menu')).toBeNull());
});
- it('shortlists a large catalog and searches every model with provider icons', async () => {
+ it('groups a large catalog by provider and searches every model with provider icons', async () => {
const select = vi.fn();
render(() => (
<ModelSelector
@@ -158,8 +156,10 @@ describe('shared model selector', () => {
fireEvent.keyDown(screen.getByRole('button', { name: 'Model' }), {
key: 'Enter',
});
- expect(screen.getAllByRole('menuitem').length).toBeLessThanOrEqual(6);
- expect(screen.getByRole('menuitem', { name: /More models/ })).toBeTruthy();
+ expect(screen.getAllByRole('menuitem')).toHaveLength(60);
+ expect(screen.queryByRole('menuitem', { name: /More models/ })).toBeNull();
+ expect(screen.getByRole('group', { name: 'OpenAI' })).toBeTruthy();
+ expect(screen.queryByRole('group', { name: 'Suggested' })).toBeNull();
fireEvent.input(screen.getByRole('textbox', { name: 'Search models' }), {
target: { value: 'variant 59' },
});
diff --git a/apps/web/src/features/agents-view/components/ModelSelector.tsx b/apps/web/src/features/agents-view/components/ModelSelector.tsx
index 35f0262497..07918777a8 100644
--- a/apps/web/src/features/agents-view/components/ModelSelector.tsx
+++ b/apps/web/src/features/agents-view/components/ModelSelector.tsx
@@ -1,10 +1,15 @@
-import type { AgentModelSelectorProps } from '@app/features/block-agent/ui/AgentModelSelector';
+import {
+ AgentModelSelector,
+ 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 type { Component, JSX } from 'solid-js';
+import { Show } from 'solid-js';
export type ModelChoice = {
id: string;
@@ -22,11 +27,13 @@ export function ModelSelector(props: {
modelRow?: Component<ModelRowProps>;
pending?: boolean;
onSelect: (id: string) => void;
+ onCloseAutoFocus?: (event: Event) => void;
children?: JSX.Element;
emptyMessage?: string;
}) {
return (
<ModelCatalogPicker
+ onCloseAutoFocus={props.onCloseAutoFocus}
value={props.model ?? null}
options={props.options.map((option) => ({
id: option.id,
@@ -56,29 +63,32 @@ export function ModelSelector(props: {
export function SessionModelSelector(props: AgentModelSelectorProps) {
const shown = () => props.changingTo ?? props.model ?? undefined;
return (
- <ModelSelector
- model={shown()}
- label={[
- modelLabel(
- shown(),
- props.options.find((option) => option.id === shown())?.name
- ),
- 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);
- }}
- />
+ <Show when={!isTouchDevice()} fallback={<AgentModelSelector {...props} />}>
+ <ModelSelector
+ onCloseAutoFocus={props.onCloseAutoFocus}
+ model={shown()}
+ label={[
+ modelLabel(
+ shown(),
+ props.options.find((option) => option.id === shown())?.name
+ ),
+ 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);
+ }}
+ />
+ </Show>
);
}
diff --git a/apps/web/src/features/agents-view/components/Topbar.test.tsx b/apps/web/src/features/agents-view/components/Topbar.test.tsx
index 5fed6c2a14..66c50831af 100644
--- a/apps/web/src/features/agents-view/components/Topbar.test.tsx
+++ b/apps/web/src/features/agents-view/components/Topbar.test.tsx
@@ -37,3 +37,8 @@ it('keeps the plain heading for the new conversation page', () => {
expect(screen.queryByRole('button', { name: 'Share' })).toBeNull();
expect(screen.queryByRole('button', { name: 'Side panel' })).toBeNull();
});
+
+it('omits the heading on an untitled composer page', () => {
+ render(() => <Topbar />);
+ expect(screen.queryByRole('heading')).toBeNull();
+});
diff --git a/apps/web/src/features/agents-view/components/Topbar.tsx b/apps/web/src/features/agents-view/components/Topbar.tsx
index 56a460b7d9..47e1ab2d83 100644
--- a/apps/web/src/features/agents-view/components/Topbar.tsx
+++ b/apps/web/src/features/agents-view/components/Topbar.tsx
@@ -6,7 +6,7 @@ import { type JSX, Show } from 'solid-js';
/** Shared workspace chrome for conversation and new-session pages. */
export function Topbar(props: {
- title: string;
+ title?: string;
onBack?: () => void;
titleContent?: JSX.Element;
children?: JSX.Element;
@@ -30,9 +30,11 @@ export function Topbar(props: {
</Show>
<div class="flex min-w-0 items-center gap-1">
{props.titleContent ?? (
- <h1 class="min-w-0 truncate text-sm font-semibold tracking-[-0.03em] text-ink">
- {props.title}
- </h1>
+ <Show when={props.title}>
+ <h1 class="min-w-0 truncate text-sm font-semibold tracking-[-0.03em] text-ink">
+ {props.title}
+ </h1>
+ </Show>
)}
</div>
<div class="header-actions ml-auto flex shrink-0 items-center gap-1">
diff --git a/apps/web/src/features/agents-view/core/agent-picker-groups.ts b/apps/web/src/features/agents-view/core/agent-picker-groups.ts
new file mode 100644
index 0000000000..0ffa4b4702
--- /dev/null
+++ b/apps/web/src/features/agents-view/core/agent-picker-groups.ts
@@ -0,0 +1,24 @@
+import { type RosterAgent, rosterForAgentPicker } from './roster';
+
+/** Keep ready-to-use choices ahead of agents that need setup. */
+export function agentPickerGroups(roster: readonly RosterAgent[]) {
+ const agents = rosterForAgentPicker(roster);
+ return [
+ {
+ label: 'Built-in',
+ agents: agents.filter(
+ (agent) => !agent.unavailableReason && agent.share === 'system'
+ ),
+ },
+ {
+ label: 'Your agents',
+ agents: agents.filter(
+ (agent) => !agent.unavailableReason && agent.share !== 'system'
+ ),
+ },
+ {
+ label: 'Needs connection',
+ agents: agents.filter((agent) => agent.unavailableReason),
+ },
+ ].filter((group) => group.agents.length > 0);
+}
diff --git a/apps/web/src/features/agents-view/core/conversation-filters.test.ts b/apps/web/src/features/agents-view/core/conversation-filters.test.ts
new file mode 100644
index 0000000000..c9bb01a06e
--- /dev/null
+++ b/apps/web/src/features/agents-view/core/conversation-filters.test.ts
@@ -0,0 +1,115 @@
+import { describe, expect, it } from 'vitest';
+import {
+ type ConversationFacts,
+ conversationMatchesFilters,
+ EMPTY_CONVERSATION_FILTERS,
+ groupConversations,
+} from './conversation-filters';
+
+const reviewFix: ConversationFacts = {
+ mode: 'code',
+ state: 'waiting',
+ unread: true,
+ pullRequest: 'open',
+};
+const hiringPlan: ConversationFacts = {
+ mode: 'chat',
+ state: 'working',
+ unread: false,
+ pullRequest: null,
+};
+const kanbanDrag: ConversationFacts = {
+ mode: 'code',
+ state: 'dormant',
+ unread: false,
+ pullRequest: null,
+};
+
+describe('conversationMatchesFilters', () => {
+ it('keeps everything when nothing is selected', () => {
+ expect(
+ [reviewFix, hiringPlan, kanbanDrag].map((facts) =>
+ conversationMatchesFilters(facts, EMPTY_CONVERSATION_FILTERS)
+ )
+ ).toEqual([true, true, true]);
+ });
+
+ it('ORs values inside a category and ANDs across categories', () => {
+ const filters = {
+ ...EMPTY_CONVERSATION_FILTERS,
+ type: ['code' as const],
+ status: ['waiting' as const, 'idle' as const],
+ };
+ expect(conversationMatchesFilters(reviewFix, filters)).toBe(true);
+ expect(conversationMatchesFilters(kanbanDrag, filters)).toBe(true);
+ expect(conversationMatchesFilters(hiringPlan, filters)).toBe(false);
+ });
+
+ it('treats unread as a status a conversation has alongside its turn', () => {
+ const filters = {
+ ...EMPTY_CONVERSATION_FILTERS,
+ status: ['unread' as const],
+ };
+ expect(conversationMatchesFilters(reviewFix, filters)).toBe(true);
+ expect(conversationMatchesFilters(hiringPlan, filters)).toBe(false);
+ });
+
+ it('counts a starting session as working', () => {
+ const filters = {
+ ...EMPTY_CONVERSATION_FILTERS,
+ status: ['working' as const],
+ };
+ expect(
+ conversationMatchesFilters({ ...kanbanDrag, state: 'starting' }, filters)
+ ).toBe(true);
+ });
+
+ it('only offers "no pull request" for code conversations', () => {
+ const filters = {
+ ...EMPTY_CONVERSATION_FILTERS,
+ pullRequest: ['none' as const],
+ };
+ expect(conversationMatchesFilters(kanbanDrag, filters)).toBe(true);
+ expect(conversationMatchesFilters(hiringPlan, filters)).toBe(false);
+ expect(conversationMatchesFilters(reviewFix, filters)).toBe(false);
+ });
+});
+
+describe('groupConversations', () => {
+ const items = [
+ { id: 'kanban', facts: kanbanDrag },
+ { id: 'review', facts: reviewFix },
+ { id: 'hiring', facts: hiringPlan },
+ ];
+
+ it('returns one unlabeled group when grouping is off', () => {
+ expect(groupConversations(items, (item) => item.facts, 'none')).toEqual([
+ { id: 'all', label: undefined, items },
+ ]);
+ });
+
+ it('puts conversations waiting on you first when grouping by status', () => {
+ expect(
+ groupConversations(items, (item) => item.facts, 'status').map((group) => [
+ group.label,
+ group.items.map((item) => item.id),
+ ])
+ ).toEqual([
+ ['Needs you', ['review']],
+ ['Working', ['hiring']],
+ ['Recent', ['kanban']],
+ ]);
+ });
+
+ it('drops empty groups and keeps the incoming order inside a group', () => {
+ expect(
+ groupConversations(items, (item) => item.facts, 'type').map((group) => [
+ group.label,
+ group.items.map((item) => item.id),
+ ])
+ ).toEqual([
+ ['Chat', ['hiring']],
+ ['Code', ['kanban', 'review']],
+ ]);
+ });
+});
diff --git a/apps/web/src/features/agents-view/core/conversation-filters.ts b/apps/web/src/features/agents-view/core/conversation-filters.ts
new file mode 100644
index 0000000000..c76e34c17b
--- /dev/null
+++ b/apps/web/src/features/agents-view/core/conversation-filters.ts
@@ -0,0 +1,155 @@
+import { match } from 'ts-pattern';
+import {
+ type ConversationState,
+ conversationState,
+} from './conversation-state';
+import { type AgentsMode, agentsModeLabel } from './mode';
+import type { AgentConversationEntity } from './recent-conversations';
+
+export type StatusFilter = 'waiting' | 'working' | 'unread' | 'idle';
+export type PullRequestFilter = 'open' | 'draft' | 'merged' | 'closed' | 'none';
+export type ConversationGrouping = 'none' | 'status' | 'type';
+
+/** Values are ORed inside a category and categories are ANDed. */
+export type ConversationFilters = {
+ type: AgentsMode[];
+ status: StatusFilter[];
+ pullRequest: PullRequestFilter[];
+};
+
+export type ConversationFilterCategory = keyof ConversationFilters;
+
+export const EMPTY_CONVERSATION_FILTERS: ConversationFilters = {
+ type: [],
+ status: [],
+ pullRequest: [],
+};
+
+/** What the sidebar knows about a row, independent of its entity shape. */
+export type ConversationFacts = {
+ mode: AgentsMode;
+ state: ConversationState;
+ unread: boolean;
+ pullRequest: Exclude<PullRequestFilter, 'none'> | null;
+};
+
+export function conversationFacts(
+ conversation: AgentConversationEntity,
+ mode: AgentsMode,
+ unread: boolean
+): ConversationFacts {
+ if (conversation.type !== 'agent_session')
+ return { mode, state: 'dormant', unread, pullRequest: null };
+ return {
+ mode,
+ state: conversationState(conversation.status, conversation.turnState),
+ unread,
+ pullRequest: conversation.pullRequestState ?? null,
+ };
+}
+
+function hasStatus(facts: ConversationFacts, status: StatusFilter): boolean {
+ return match(status)
+ .with('waiting', () => facts.state === 'waiting')
+ .with(
+ 'working',
+ () => facts.state === 'working' || facts.state === 'starting'
+ )
+ .with('idle', () => facts.state === 'dormant')
+ .with('unread', () => facts.unread)
+ .exhaustive();
+}
+
+function hasPullRequest(
+ facts: ConversationFacts,
+ pullRequest: PullRequestFilter
+): boolean {
+ // Chats never open pull requests, so "none" means a code session without one.
+ if (pullRequest === 'none')
+ return facts.mode === 'code' && facts.pullRequest === null;
+ return facts.pullRequest === pullRequest;
+}
+
+function matchesCategory<Value>(
+ selected: readonly Value[],
+ test: (value: Value) => boolean
+): boolean {
+ return selected.length === 0 || selected.some(test);
+}
+
+export function conversationMatchesFilters(
+ facts: ConversationFacts,
+ filters: ConversationFilters
+): boolean {
+ return (
+ matchesCategory(filters.type, (mode) => facts.mode === mode) &&
+ matchesCategory(filters.status, (status) => hasStatus(facts, status)) &&
+ matchesCategory(filters.pullRequest, (pullRequest) =>
+ hasPullRequest(facts, pullRequest)
+ )
+ );
+}
+
+export function activeFilterCount(filters: ConversationFilters): number {
+ return (
+ filters.type.length + filters.status.length + filters.pullRequest.length
+ );
+}
+
+export type ConversationGroup<Item> = {
+ id: string;
+ /** Undefined when the list is not grouped and needs no heading. */
+ label: string | undefined;
+ items: Item[];
+};
+
+type GroupDefinition = {
+ id: string;
+ label: string;
+ contains: (facts: ConversationFacts) => boolean;
+};
+
+const STATUS_GROUPS: GroupDefinition[] = [
+ {
+ id: 'waiting',
+ label: 'Needs you',
+ contains: (facts) => facts.state === 'waiting',
+ },
+ {
+ id: 'working',
+ label: 'Working',
+ contains: (facts) =>
+ facts.state === 'working' || facts.state === 'starting',
+ },
+ {
+ id: 'recent',
+ label: 'Recent',
+ contains: (facts) => facts.state === 'dormant',
+ },
+];
+
+const TYPE_GROUPS: GroupDefinition[] = (['chat', 'code'] as const).map(
+ (mode) => ({
+ id: mode,
+ label: agentsModeLabel(mode),
+ contains: (facts) => facts.mode === mode,
+ })
+);
+
+/** Splits an ordered list into headed sections, dropping empty ones. */
+export function groupConversations<Item>(
+ items: readonly Item[],
+ factsOf: (item: Item) => ConversationFacts,
+ grouping: ConversationGrouping
+): ConversationGroup<Item>[] {
+ if (grouping === 'none')
+ return [{ id: 'all', label: undefined, items: [...items] }];
+ const definitions = grouping === 'status' ? STATUS_GROUPS : TYPE_GROUPS;
+ return definitions
+ .map((definition) => ({
+ id: definition.id,
+ label: definition.label,
+ items: items.filter((item) => definition.contains(factsOf(item))),
+ }))
+ .filter((group) => group.items.length > 0);
+}
diff --git a/apps/web/src/features/agents-view/core/mode.ts b/apps/web/src/features/agents-view/core/mode.ts
index 213815b18f..e4a52d02a1 100644
--- a/apps/web/src/features/agents-view/core/mode.ts
+++ b/apps/web/src/features/agents-view/core/mode.ts
@@ -1,7 +1,7 @@
/** Session kind used for routes and the agent workspace's presentation. */
export type AgentsMode = 'chat' | 'code';
-/** The workspace switch calls chat agents "Work" and coding agents "Code". */
+/** The composer's mode switch calls chat agents "Chat" and coding agents "Code". */
export function agentsModeLabel(mode: AgentsMode): string {
- return mode === 'code' ? 'Code' : 'Work';
+ return mode === 'code' ? 'Code' : 'Chat';
}
diff --git a/apps/web/src/features/agents-view/core/roster.ts b/apps/web/src/features/agents-view/core/roster.ts
index cc1f3b3df0..2ca792ed14 100644
--- a/apps/web/src/features/agents-view/core/roster.ts
+++ b/apps/web/src/features/agents-view/core/roster.ts
@@ -94,6 +94,8 @@ export function runtimeLabel(
return MACRO_HARNESS_NAME;
case 'cursor':
return 'Cursor';
+ case 'claude-cloud':
+ return 'Claude Cloud';
case 'macrod':
return (
runtimes.find((runtime) => runtime.id === harnessId)?.name ??
diff --git a/apps/web/src/features/agents-view/primitives/chat-composer-tip.test.ts b/apps/web/src/features/agents-view/primitives/chat-composer-tip.test.ts
index 4dd9ff7423..f6c674b9dc 100644
--- a/apps/web/src/features/agents-view/primitives/chat-composer-tip.test.ts
+++ b/apps/web/src/features/agents-view/primitives/chat-composer-tip.test.ts
@@ -1,52 +1,87 @@
import { cleanup, renderHook } from '@solidjs/testing-library';
-import { createSignal } from 'solid-js';
+import { type Accessor, createSignal } from 'solid-js';
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
import { createChatComposerTip } from './chat-composer-tip';
-beforeEach(() => vi.useFakeTimers());
+beforeEach(() => {
+ vi.useFakeTimers();
+});
afterEach(() => {
cleanup();
vi.useRealTimers();
});
+/** Follow timer-driven text until a complete hint is visible. */
+function readHint(tip: Accessor<string>, expected: string) {
+ for (let step = 0; step < 300 && tip() !== expected; step++)
+ vi.advanceTimersToNextTimer();
+ expect(tip()).toBe(expected);
+}
+
+const CONNECT = 'Connect your apps in Agents → Connections';
+
describe('Chat composer tips', () => {
- it('omits the agent-selection tip inside a session', () => {
- const { result: tip } = renderHook(() =>
- createChatComposerTip(() => true, false)
- );
- const first = tip();
- vi.advanceTimersByTime(6000);
- expect(tip()).toContain('skill');
- vi.advanceTimersByTime(6000);
- expect(tip()).toContain('@');
- vi.advanceTimersByTime(6000);
- expect(tip()).toBe(first);
+ it('types progressively, pauses, quickly erases and types the next hint', () => {
+ const { result: tip } = renderHook(() => createChatComposerTip(() => true));
+ expect(tip()).toBe('');
+ vi.advanceTimersToNextTimer();
+ expect(tip()).toBe('C');
+ const typedAt = Date.now();
+ vi.advanceTimersToNextTimer();
+ expect(tip()).toBe('Co');
+ const typingTime = Date.now() - typedAt;
+ readHint(tip, CONNECT);
+ vi.advanceTimersByTime(2000);
+ expect(tip()).toBe(CONNECT);
+ vi.advanceTimersToNextTimer();
+ expect(CONNECT.startsWith(tip())).toBe(true);
+ expect(tip().length).toBeLessThan(CONNECT.length);
+ const deletingAt = Date.now();
+ vi.advanceTimersToNextTimer();
+ expect(Date.now() - deletingAt).toBeLessThan(typingTime);
+ readHint(tip, '');
+ vi.advanceTimersToNextTimer();
+ expect(tip()).toBe('T');
+ readHint(tip, 'Type / to add a skill');
});
it('cycles through connectors, skills, mentions and agents, then repeats', () => {
const { result: tip } = renderHook(() => createChatComposerTip(() => true));
- const first = tip();
- expect(first).toContain('Connections');
- vi.advanceTimersByTime(6000);
- expect(tip()).toContain('skill');
- vi.advanceTimersByTime(6000);
- expect(tip()).toContain('@');
- vi.advanceTimersByTime(6000);
- expect(tip()).toContain('agent');
- vi.advanceTimersByTime(6000);
- expect(tip()).toBe(first);
+ for (const hint of [
+ CONNECT,
+ 'Type / to add a skill',
+ 'Type @ to mention docs, people, or channels',
+ 'Choose an agent to change who helps',
+ CONNECT,
+ ])
+ readHint(tip, hint);
});
- it('pauses while writing and resumes when the draft is cleared', () => {
+ it('omits the agent-selection tip inside a session', () => {
+ const { result: tip } = renderHook(() =>
+ createChatComposerTip(() => true, false)
+ );
+ for (const hint of [
+ CONNECT,
+ 'Use @ to reference a skill document',
+ 'Type @ to mention docs, people, or channels',
+ CONNECT,
+ ])
+ readHint(tip, hint);
+ });
+
+ it('stops while writing and resumes the same hint when the draft is cleared', () => {
const [empty, setEmpty] = createSignal(true);
const { result: tip } = renderHook(() => createChatComposerTip(empty));
- const first = tip();
+ vi.advanceTimersToNextTimer();
+ expect(tip()).toBe('C');
setEmpty(false);
+ expect(vi.getTimerCount()).toBe(0);
vi.advanceTimersByTime(18000);
- expect(tip()).toBe(first);
+ expect(tip()).toBe('C');
setEmpty(true);
- vi.advanceTimersByTime(6000);
- expect(tip()).toContain('skill');
+ vi.advanceTimersToNextTimer();
+ expect(tip()).toBe('Co');
});
it('stops its timer when the composer is removed', () => {
diff --git a/apps/web/src/features/agents-view/primitives/chat-composer-tip.ts b/apps/web/src/features/agents-view/primitives/chat-composer-tip.ts
index eff2e319e4..1b74124367 100644
--- a/apps/web/src/features/agents-view/primitives/chat-composer-tip.ts
+++ b/apps/web/src/features/agents-view/primitives/chat-composer-tip.ts
@@ -1,4 +1,10 @@
-import { type Accessor, createSignal, onCleanup, onMount } from 'solid-js';
+import {
+ type Accessor,
+ createEffect,
+ createSignal,
+ on,
+ onCleanup,
+} from 'solid-js';
const TIPS = [
'Connect your apps in Agents → Connections',
@@ -7,7 +13,7 @@ const TIPS = [
'Choose an agent to change who helps',
];
-/** Cycle one hint at a time, pausing while the user has a draft. */
+/** Type each hint, pause to read it, then erase quickly before the next hint. */
export function createChatComposerTip(
empty: Accessor<boolean>,
canChooseAgent = true
@@ -15,12 +21,43 @@ export function createChatComposerTip(
const tips = canChooseAgent
? TIPS
: [TIPS[0], 'Use @ to reference a skill document', TIPS[2]];
- const [index, setIndex] = createSignal(0);
- onMount(() => {
- const interval = setInterval(() => {
- if (empty()) setIndex((current) => (current + 1) % tips.length);
- }, 6000);
- onCleanup(() => clearInterval(interval));
- });
- return () => tips[index()];
+ const [text, setText] = createSignal('');
+ let index = 0;
+ let length = 0;
+ let deleting = false;
+ let delay = 300;
+
+ // A timer is external state: start and stop it with the visible empty input.
+ createEffect(
+ on(empty, (isEmpty) => {
+ if (!isEmpty) return;
+ let timer: ReturnType<typeof setTimeout>;
+ const schedule = (nextDelay: number) => {
+ delay = nextDelay;
+ timer = setTimeout(advance, delay);
+ };
+ const advance = () => {
+ const tip = tips[index];
+ if (deleting) {
+ length = Math.max(0, length - 2);
+ setText(tip.slice(0, length));
+ if (length === 0) {
+ index = (index + 1) % tips.length;
+ deleting = false;
+ schedule(300);
+ } else schedule(12);
+ } else {
+ length += 1;
+ setText(tip.slice(0, length));
+ if (length === tip.length) {
+ deleting = true;
+ schedule(2200);
+ } else schedule(32);
+ }
+ };
+ schedule(delay);
+ onCleanup(() => clearTimeout(timer));
+ })
+ );
+ return text;
}
diff --git a/apps/web/src/features/agents-view/primitives/conversation-list-view.ts b/apps/web/src/features/agents-view/primitives/conversation-list-view.ts
new file mode 100644
index 0000000000..333a7db83f
--- /dev/null
+++ b/apps/web/src/features/agents-view/primitives/conversation-list-view.ts
@@ -0,0 +1,102 @@
+import { makePersistedState } from '@app/lib/persistence';
+import { createUserScopedStorage } from '@core/util/userScopedStorage';
+import { createSignal } from 'solid-js';
+import {
+ type ConversationFilterCategory,
+ type ConversationFilters,
+ type ConversationGrouping,
+ EMPTY_CONVERSATION_FILTERS,
+} from '../core/conversation-filters';
+
+type ConversationListViewState = {
+ filters: ConversationFilters;
+ grouping: ConversationGrouping;
+};
+
+const DEFAULT_VIEW: ConversationListViewState = {
+ filters: EMPTY_CONVERSATION_FILTERS,
+ grouping: 'status',
+};
+
+const GROUPINGS: readonly ConversationGrouping[] = ['none', 'status', 'type'];
+
+function stringsOf<Value extends string>(
+ value: unknown,
+ allowed: readonly Value[]
+): Value[] {
+ if (!Array.isArray(value)) return [];
+ return allowed.filter((option) => value.includes(option));
+}
+
+function parseView(raw: string | null): ConversationListViewState | undefined {
+ if (!raw) return;
+ let parsed: unknown;
+ try {
+ parsed = JSON.parse(raw);
+ } catch {
+ return;
+ }
+ if (typeof parsed !== 'object' || parsed === null) return;
+ const view = parsed as {
+ filters?: Record<string, unknown>;
+ grouping?: unknown;
+ };
+ const grouping = GROUPINGS.find((option) => option === view.grouping);
+ return {
+ grouping: grouping ?? DEFAULT_VIEW.grouping,
+ filters: {
+ type: stringsOf(view.filters?.type, ['chat', 'code'] as const),
+ status: stringsOf(view.filters?.status, [
+ 'waiting',
+ 'working',
+ 'unread',
+ 'idle',
+ ] as const),
+ pullRequest: stringsOf(view.filters?.pullRequest, [
+ 'open',
+ 'draft',
+ 'merged',
+ 'closed',
+ 'none',
+ ] as const),
+ },
+ };
+}
+
+/** The Agents sidebar's filters and grouping, remembered per user. */
+export function createConversationListView(userId: string | undefined) {
+ const storage = createUserScopedStorage('agents-conversation-list-view-v1');
+ const [view, setView] = makePersistedState(
+ createSignal<ConversationListViewState>(DEFAULT_VIEW),
+ {
+ storages: {
+ restore: () => (userId ? parseView(storage.read(userId)) : undefined),
+ write: (value) => {
+ if (userId) storage.write(userId, JSON.stringify(value));
+ },
+ },
+ }
+ );
+ const setSelected = <Category extends ConversationFilterCategory>(
+ category: Category,
+ value: ConversationFilters[Category][number],
+ selected: boolean
+ ) => {
+ const current = view().filters[category] as string[];
+ const next = selected
+ ? [...new Set([...current, value])]
+ : current.filter((existing) => existing !== value);
+ setView({
+ ...view(),
+ filters: { ...view().filters, [category]: next },
+ });
+ };
+ return {
+ filters: () => view().filters,
+ grouping: () => view().grouping,
+ setSelected,
+ setGrouping: (grouping: ConversationGrouping) =>
+ setView({ ...view(), grouping }),
+ clear: () => setView({ ...view(), filters: EMPTY_CONVERSATION_FILTERS }),
+ };
+}
diff --git a/apps/web/src/features/agents-view/primitives/workspace-mode.test.ts b/apps/web/src/features/agents-view/primitives/workspace-mode.test.ts
index 30613e4832..2635fb166f 100644
--- a/apps/web/src/features/agents-view/primitives/workspace-mode.test.ts
+++ b/apps/web/src/features/agents-view/primitives/workspace-mode.test.ts
@@ -5,7 +5,7 @@ import { createWorkspaceMode } from './workspace-mode';
beforeEach(() => window.localStorage.clear());
describe('workspace mode', () => {
- it('starts in Work and remembers Code per user', () => {
+ it('starts in Chat and remembers Code per user', () => {
createRoot((dispose) => {
const workspace = createWorkspaceMode('user-a');
expect(workspace.mode()).toBe('chat');
diff --git a/apps/web/src/features/agents-view/primitives/workspace-mode.ts b/apps/web/src/features/agents-view/primitives/workspace-mode.ts
index b4174f3d40..a0a6366567 100644
--- a/apps/web/src/features/agents-view/primitives/workspace-mode.ts
+++ b/apps/web/src/features/agents-view/primitives/workspace-mode.ts
@@ -4,8 +4,8 @@ import { createSignal } from 'solid-js';
import type { AgentsMode } from '../core/mode';
/**
- * Whether the Agents workspace shows chat agents (Work) or coding agents
- * (Code). Scoped to the signed-in user; a new person starts in Work.
+ * Whether the new-conversation composer starts chat agents (Chat) or coding
+ * agents (Code). Scoped to the signed-in user; a new person starts in Chat.
*/
export function createWorkspaceMode(userId: string | undefined) {
const storage = createUserScopedStorage('agents-view-mode-v1');
diff --git a/apps/web/src/features/agents-view/tour.ts b/apps/web/src/features/agents-view/tour.ts
index f60be9ebe0..9e37c3db59 100644
--- a/apps/web/src/features/agents-view/tour.ts
+++ b/apps/web/src/features/agents-view/tour.ts
@@ -5,7 +5,6 @@ import { defineTourTargets } from '@ui/components/Tour';
export const AGENTS_TOUR = defineTourTargets('agents', [
'modeSwitch',
- 'newChat',
'rosterNav',
'picker',
'composer',
@@ -24,19 +23,19 @@ export const agentsTour = defineViewTour({
steps: [
{
target: AGENTS_TOUR.modeSwitch,
- entry: [VIEW_SHELL_TOUR.sidebarToggle],
- entryLabel: 'Open the sidebar to continue',
- title: 'Switch between Work and Code',
+ entry: APP_TOUR.createMenu,
+ entryLabel: 'Choose Create → Agent to start a conversation',
+ title: 'Choose Chat or Code',
description:
- 'Work shows your chat agents and their conversations. Code shows your coding agents, their sessions, and the repository each one works in.',
+ 'Chat starts a conversation with an agent that works with your documents and apps. Code starts a coding agent on a repository. Filter the sidebar to find either kind.',
},
{
target: AGENTS_TOUR.picker,
- entry: [AGENTS_TOUR.newChat, VIEW_SHELL_TOUR.sidebarToggle],
- entryLabel: 'Start a new conversation to continue',
+ entry: APP_TOUR.createMenu,
+ entryLabel: 'Choose Create → Agent to start a conversation',
title: 'Choose your agent and model',
description:
- 'Open this picker to choose an agent for the current mode. In Work, Macro’s models are listed here too; each agent’s submenu lets you choose a model for that conversation.',
+ 'Open this picker to choose an agent for the current mode. In Chat, Macro’s models are listed here too; each agent’s submenu lets you choose a model for that conversation.',
},
{
target: AGENTS_TOUR.agentList,
diff --git a/apps/web/src/features/agents-view/views/AgentPicker.tsx b/apps/web/src/features/agents-view/views/AgentPicker.tsx
index 644caefe60..84d9af7cd5 100644
--- a/apps/web/src/features/agents-view/views/AgentPicker.tsx
+++ b/apps/web/src/features/agents-view/views/AgentPicker.tsx
@@ -1,13 +1,11 @@
import { ModelCatalogMenu } from '@core/component/AI/component/input/ModelCatalogPicker';
-import { ProviderIcon } from '@core/component/AI/component/ProviderIcon';
+import { ModelIcon } from '@core/component/AI/component/ProviderIcon';
import { modelLabel } from '@core/component/AI/constant/model-label';
import { isTouchDevice } from '@core/mobile/isTouchDevice';
import CaretDownIcon from '@phosphor/caret-down.svg';
import CaretRightIcon from '@phosphor/caret-right.svg';
-import CheckIcon from '@phosphor/check.svg';
-import CodeIcon from '@phosphor/code.svg';
import PlusIcon from '@phosphor/plus.svg';
-import { cn, Dropdown } from '@ui';
+import { buttonClasses, cn, Dropdown } from '@ui';
import { tourTarget } from '@ui/components/Tour';
import { createSignal, For, Show } from 'solid-js';
import { AgentModelMenuItem } from '../../block-agent/component/AgentModelMenuItem';
@@ -16,11 +14,9 @@ import type {
EffortSelection,
} from '../../block-agent/state/session-config';
import { AgentIcon } from '../components/AgentGlyph';
-import {
- MACRO_PERSONA_ID,
- type RosterAgent,
- rosterForAgentPicker,
-} from '../core/roster';
+import { AgentPickerIdentity } from '../components/AgentPickerIdentity';
+import { agentPickerGroups } from '../core/agent-picker-groups';
+import { MACRO_PERSONA_ID, type RosterAgent } from '../core/roster';
import { createComposerModels } from '../queries/composer-models';
import { AGENTS_TOUR } from '../tour';
import { MobileAgentPicker } from './MobileAgentPicker';
@@ -32,6 +28,8 @@ export type AgentPickerProps = {
modelOverride?: string;
loading: boolean;
triggerClass?: string;
+ /** Configuration forms also show the saved model name on mobile. */
+ showModelLabel?: boolean;
effortLabel?: string;
effortSelection?: EffortSelection;
onSelect: (agent: RosterAgent, model?: string) => void;
@@ -43,6 +41,7 @@ export type AgentPickerProps = {
) => void;
onConnect: (agent: RosterAgent) => void;
onCreate: () => void;
+ onCloseAutoFocus?: (event: Event) => void;
};
export function AgentPicker(props: AgentPickerProps) {
@@ -59,7 +58,7 @@ function DesktopAgentPicker(props: AgentPickerProps) {
const macro = () =>
props.agents.find((agent) => agent.id === MACRO_PERSONA_ID);
const macroCatalog = createComposerModels(macro);
- const agents = () => rosterForAgentPicker(props.agents);
+ const groups = () => agentPickerGroups(props.agents);
const rawModel = () => props.selected?.id === MACRO_PERSONA_ID;
const model = () =>
props.modelOverride ??
@@ -100,47 +99,48 @@ function DesktopAgentPicker(props: AgentPickerProps) {
props.triggerClass
)}
>
- <Show
- when={rawModel()}
- fallback={
- <Show when={props.selected}>
- {(agent) => (
- <AgentIcon agent={agent()} class="size-[15px] shrink-0" />
- )}
- </Show>
- }
- >
- <ProviderIcon model={model()} class="size-[15px]" />
- </Show>
- <span class="min-w-0 truncate text-left leading-5">
+ <Show when={!rawModel()}>
<Show
- when={rawModel()}
+ when={props.selected}
fallback={
- <>
- {props.selected?.name ?? 'Choose agent'}
- <span> · {label()}</span>
- </>
+ <span class="min-w-0 truncate text-left leading-5">
+ Choose agent
+ </span>
}
>
- {label()}
+ {(agent) => (
+ <>
+ <AgentIcon agent={agent()} class="size-[15px] shrink-0" />
+ <span class="min-w-0 truncate text-left leading-5">
+ {agent().name}
+ </span>
+ </>
+ )}
</Show>
- </span>
+ </Show>
+ <Show when={rawModel()}>
+ <ModelIcon model={model()} class="size-[15px] shrink-0" />
+ </Show>
+ <span class="min-w-0 truncate text-left leading-5">{label()}</span>
<CaretDownIcon class="size-[15px] shrink-0" />
</Dropdown.Trigger>
<Dropdown.Content
- class="w-80 max-w-[calc(100vw-1rem)] overflow-hidden"
+ class="w-88 max-w-[calc(100vw-1rem)] overflow-hidden"
onPointerDown={(event: PointerEvent) => event.stopPropagation()}
onMouseDown={(event: MouseEvent) => event.stopPropagation()}
>
<div class="flex min-h-0 max-h-[min(28rem,var(--kb-popper-content-available-height))] flex-col">
- <div class="min-h-0 overflow-y-auto overscroll-contain">
+ <div
+ class="min-h-0 space-y-1 overflow-y-auto overscroll-contain px-2 pb-2"
+ classList={{ 'pt-2': !macro() }}
+ >
<Show when={macro()}>
{(agent) => (
<ModelCatalogMenu
+ autoFocusSearch
value={
props.selected?.id === agent().id ? (model() ?? null) : null
}
- recommendedId={macroCatalog.currentModel()}
disabled={Boolean(agent().unavailableReason)}
options={macroCatalog.models().map((option) => ({
id: option.id,
@@ -171,46 +171,49 @@ function DesktopAgentPicker(props: AgentPickerProps) {
/>
)}
</Show>
- <For each={['agent', 'coder'] as const}>
- {(kind) => (
- <Show when={agents().some((agent) => agent.kind === kind)}>
- <Dropdown.Group>
- <Dropdown.GroupLabel>
- {kind === 'coder' ? 'Coding agents' : 'Agents'}
- </Dropdown.GroupLabel>
- <For each={agents().filter((agent) => agent.kind === kind)}>
- {(agent) => (
- <AgentPickerRow
- agent={agent}
- selected={agent.id === props.selected?.id}
- modelOverride={
- agent.id === props.selected?.id
- ? props.modelOverride
- : undefined
- }
- effortSelection={
- agent.id === props.selected?.id
- ? props.effortSelection
- : undefined
- }
- onSelect={(model) => choose(agent, model)}
- onSelectEffort={
- props.onSelectEffort
- ? (model, effort) =>
- chooseEffort(agent, model, effort)
- : undefined
- }
- onConnect={() => {
- setOpen(false);
- props.onConnect(agent);
- }}
- />
- )}
- </For>
- </Dropdown.Group>
- </Show>
+ <For each={groups()}>
+ {(group) => (
+ <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) => (
+ <AgentPickerRow
+ agent={agent}
+ selected={agent.id === props.selected?.id}
+ modelOverride={
+ agent.id === props.selected?.id
+ ? props.modelOverride
+ : undefined
+ }
+ effortSelection={
+ agent.id === props.selected?.id
+ ? props.effortSelection
+ : undefined
+ }
+ onSelect={(model) => choose(agent, model)}
+ onSelectEffort={
+ props.onSelectEffort
+ ? (model, effort) =>
+ chooseEffort(agent, model, effort)
+ : undefined
+ }
+ onConnect={() => {
+ setOpen(false);
+ props.onConnect(agent);
+ }}
+ />
+ )}
+ </For>
+ </Dropdown.Group>
)}
</For>
+ <Show when={!props.loading && !macro() && groups().length === 0}>
+ <p role="status" class="px-3 py-2 text-sm text-ink-muted">
+ No agents available
+ </p>
+ </Show>
<Show when={props.loading}>
<div
role="status"
@@ -219,19 +222,25 @@ function DesktopAgentPicker(props: AgentPickerProps) {
Loading agents…
</div>
</Show>
+ <Dropdown.Group class="items-end bg-transparent px-1.5 pt-1 pb-0">
+ <Dropdown.Item
+ closeOnSelect
+ class={buttonClasses({
+ variant: 'strong',
+ size: 'sm',
+ glass: false,
+ class: 'w-auto gap-1.5 data-highlighted:overlay-hover',
+ })}
+ onSelect={() => {
+ setOpen(false);
+ props.onCreate();
+ }}
+ >
+ <PlusIcon class="size-4" />
+ Create agent
+ </Dropdown.Item>
+ </Dropdown.Group>
</div>
- <Dropdown.Group class="shrink-0 border-t border-edge-muted">
- <Dropdown.Item
- closeOnSelect
- onSelect={() => {
- setOpen(false);
- props.onCreate();
- }}
- >
- <PlusIcon class="size-4" />
- Create agent
- </Dropdown.Item>
- </Dropdown.Group>
</div>
</Dropdown.Content>
</Dropdown>
@@ -249,19 +258,11 @@ function AgentPickerRow(props: {
}) {
const [open, setOpen] = createSignal(false);
const identity = () => (
- <>
- <AgentIcon agent={props.agent} class="size-5 shrink-0" />
- <span class="min-w-0 flex-1 truncate">{props.agent.name}</span>
- <Show when={props.agent.kind === 'coder'}>
- <CodeIcon
- class="size-3.5 shrink-0 text-ink-muted"
- aria-label="Coding agent"
- />
- </Show>
- <Show when={props.selected}>
- <CheckIcon class="size-3.5 shrink-0 text-accent" />
- </Show>
- </>
+ <AgentPickerIdentity
+ agent={props.agent}
+ selected={props.selected}
+ model={props.modelOverride}
+ />
);
return (
<div class="flex min-w-0 items-center gap-1">
@@ -270,21 +271,18 @@ function AgentPickerRow(props: {
fallback={
<Dropdown.Item
closeOnSelect
- class="min-w-0 flex-1"
+ class="min-w-0 flex-1 gap-3 py-2"
disabled={!props.agent.connectLabel}
title={props.agent.unavailableReason}
onSelect={props.onConnect}
>
{identity()}
- <span class="text-xs text-ink-muted">
- {props.agent.connectLabel ?? props.agent.unavailableReason}
- </span>
</Dropdown.Item>
}
>
<Dropdown.Sub open={open()} onOpenChange={setOpen} overlap>
<Dropdown.SubTrigger
- class="min-w-0 flex-1 gap-2"
+ class="min-w-0 flex-1 gap-3 py-2"
textValue={props.agent.name}
onClick={() => {
if (!isTouchDevice()) props.onSelect();
diff --git a/apps/web/src/features/agents-view/views/AgentsView.tsx b/apps/web/src/features/agents-view/views/AgentsView.tsx
index 7734acc269..6074ba5f27 100644
--- a/apps/web/src/features/agents-view/views/AgentsView.tsx
+++ b/apps/web/src/features/agents-view/views/AgentsView.tsx
@@ -43,7 +43,7 @@ import { AgentSessionPane } from '../components/AgentSessionPane';
import { AgentsSidebar } from '../components/AgentsSidebar';
import { Topbar } from '../components/Topbar';
import { DataModeProvider, dataModeFor } from '../context/data-mode';
-import { type AgentKind, kindForMode, modeForKind } from '../core/agent-kind';
+import { type AgentKind, modeForKind } from '../core/agent-kind';
import type { AgentsMode } from '../core/mode';
import { type AgentsPage, parseAgentsPage } from '../core/pages';
import {
@@ -55,6 +55,7 @@ import {
} from '../core/recent-conversations';
import { kindForBot } from '../core/roster';
import { type AgentsRoute, agentsRouteId } from '../core/route';
+import { createConversationListView } from '../primitives/conversation-list-view';
import { createWorkspaceMode } from '../primitives/workspace-mode';
import { createAgentRosterSource } from '../queries/agent-roster-source';
import { agentsTour } from '../tour';
@@ -84,11 +85,9 @@ function AgentsWorkspace(props: { initialRoute?: AgentsRoute }) {
useWarmAgentSessionQuery(userId);
const notifications = useGlobalNotificationSource();
const mode = (): AgentsMode => props.initialRoute?.mode ?? 'chat';
+ // The composer's Chat/Code choice; an open conversation keeps its own mode.
const workspace = createWorkspaceMode(userId());
- // A session opened from elsewhere brings its own mode, so it is never
- // hidden from the sidebar it lands in.
- if (props.initialRoute) workspace.setMode(props.initialRoute.mode);
- const dataMode = () => dataModeFor(workspace.mode());
+ const listView = createConversationListView(userId());
const [localPage, setPage] = createSignal<AgentsPage>('new');
const isRoutinesPage = () => {
const content = panel.handle.content();
@@ -105,6 +104,7 @@ function AgentsWorkspace(props: { initialRoute?: AgentsRoute }) {
}
: undefined
);
+ const dataMode = () => dataModeFor(selected() ? mode() : workspace.mode());
const [mobileList, setMobileList] = createSignal(!isRoutinesPage());
const [draft, setDraft] = createSignal('');
const [search, setSearch] = createSignal('');
@@ -224,12 +224,6 @@ function AgentsWorkspace(props: { initialRoute?: AgentsRoute }) {
const openRoster = (_kind: AgentKind) => {
openPage('agents');
};
- const changeMode = (next: AgentsMode) => {
- if (next === workspace.mode()) return;
- workspace.setMode(next);
- // The open conversation belongs to the other mode now.
- if (selected()) showComposer();
- };
const openConversation = (
conversation: AgentConversationTarget,
event?: MouseEvent,
@@ -301,13 +295,16 @@ function AgentsWorkspace(props: { initialRoute?: AgentsRoute }) {
if (page() === 'routines') return 'Routines';
if (page() === 'agents') return 'Agents';
if (page() === 'connections') return 'Connections';
- return 'New conversation';
+ return undefined;
};
const sidebar = () => (
<AgentsSidebar
- mode={workspace.mode()}
- onModeChange={changeMode}
+ filters={listView.filters()}
+ grouping={listView.grouping()}
+ onFilterChange={listView.setSelected}
+ onClearFilters={listView.clear}
+ onGroupingChange={listView.setGrouping}
activePage={selected() ? undefined : page()}
onOpenPage={(next) =>
next === 'agents' ? openRoster('agent') : openPage(next)
@@ -321,7 +318,6 @@ function AgentsWorkspace(props: { initialRoute?: AgentsRoute }) {
error={query.isLoadingError}
hasNextPage={Boolean(query.hasNextPage)}
loadingNextPage={query.isFetchingNextPage}
- onNewConversation={showComposer}
onSearchChange={setSearch}
onOpenConversation={(conversation, event) =>
openConversation(conversation, event, modeForConversation(conversation))
@@ -394,28 +390,25 @@ function AgentsWorkspace(props: { initialRoute?: AgentsRoute }) {
class="contents"
classList={{ hidden: page() !== 'new' }}
>
- <Show when={workspace.mode()} keyed>
- {(kind) => (
- <NewChatPage
- kind={kindForMode(kind)}
- active={
- !isTouchDevice() ||
- (!mobileList() && page() === 'new')
- }
- registerFocus={(focus) => {
- composerFocus = focus;
- }}
- workspaceId={panel.handle.id}
- draft={draft()}
- onDraftChange={setDraft}
- roster={rosterSource.roster()}
- rosterLoading={rosterSource.loading()}
- availabilityLoading={rosterSource.availabilityLoading()}
- onStart={startConversation}
- onOpenRoster={openRoster}
- />
- )}
- </Show>
+ <NewChatPage
+ mode={workspace.mode()}
+ onModeChange={workspace.setMode}
+ active={
+ !isTouchDevice() ||
+ (!mobileList() && page() === 'new')
+ }
+ registerFocus={(focus) => {
+ composerFocus = focus;
+ }}
+ workspaceId={panel.handle.id}
+ draft={draft()}
+ onDraftChange={setDraft}
+ roster={rosterSource.roster()}
+ rosterLoading={rosterSource.loading()}
+ availabilityLoading={rosterSource.availabilityLoading()}
+ onStart={startConversation}
+ onOpenRoster={openRoster}
+ />
</div>
</Suspense>
</div>
diff --git a/apps/web/src/features/agents-view/views/MobileAgentPicker.tsx b/apps/web/src/features/agents-view/views/MobileAgentPicker.tsx
index 62a29ccd49..aac7540c79 100644
--- a/apps/web/src/features/agents-view/views/MobileAgentPicker.tsx
+++ b/apps/web/src/features/agents-view/views/MobileAgentPicker.tsx
@@ -1,19 +1,22 @@
import { MobileDrawer } from '@components/app/mobile/MobileDrawer';
+import {
+ buildModelCatalog,
+ 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 ArrowLeft from '@phosphor/arrow-left.svg';
-import CaretDown from '@phosphor/caret-down.svg';
import CaretRight from '@phosphor/caret-right.svg';
import Check from '@phosphor/check.svg';
+import MagnifyingGlass from '@phosphor/magnifying-glass.svg';
import Plus from '@phosphor/plus.svg';
+import SquaresFour from '@phosphor/squares-four.svg';
import { Button } from '@ui';
-import { createSignal, For, Show } from 'solid-js';
+import { createMemo, createSignal, For, Show } from 'solid-js';
import { AgentIcon } from '../components/AgentGlyph';
-import {
- MACRO_PERSONA_ID,
- type RosterAgent,
- rosterForAgentPicker,
-} from '../core/roster';
+import { AgentPickerIdentity } from '../components/AgentPickerIdentity';
+import { agentPickerGroups } from '../core/agent-picker-groups';
+import { MACRO_PERSONA_ID, type RosterAgent } from '../core/roster';
import { createComposerModels } from '../queries/composer-models';
import type { AgentPickerProps } from './AgentPicker';
@@ -21,6 +24,8 @@ import type { AgentPickerProps } from './AgentPicker';
export function MobileAgentPicker(props: AgentPickerProps) {
const [open, setOpen] = createSignal(false);
const [query, setQuery] = createSignal('');
+ const [showAll, setShowAll] = createSignal(false);
+ let searchInput: HTMLInputElement | undefined;
const [browsing, setBrowsing] = createSignal<RosterAgent>();
const macro = () =>
props.agents.find((agent) => agent.id === MACRO_PERSONA_ID);
@@ -32,17 +37,45 @@ export function MobileAgentPicker(props: AgentPickerProps) {
: (props.selected?.name ?? 'Choose agent');
const matches = (text: string) =>
text.toLocaleLowerCase().includes(query().trim().toLocaleLowerCase());
- const models = () =>
- catalog
- .models()
- .filter((option) => matches(modelLabel(option.id, option.name)));
- const agents = () =>
- rosterForAgentPicker(props.agents).filter((agent) => matches(agent.name));
+ const modelSections = createMemo(() => {
+ const options = catalog.models().map((option) => ({
+ id: option.id,
+ label: modelLabel(option.id, option.name),
+ group: option.group ?? undefined,
+ }));
+ const { frontier, providers } = buildModelCatalog(options, true);
+ const search = query().trim().toLowerCase();
+ return (
+ showAll() || search || frontier.length === 0
+ ? providers
+ : [{ label: 'Suggested', options: frontier }]
+ )
+ .map((section) => ({
+ label: section.label,
+ options: section.options.filter((option) =>
+ matchesModelQuery(option, search)
+ ),
+ }))
+ .filter((section) => section.options.length > 0);
+ });
+ const groups = () =>
+ agentPickerGroups(
+ props.agents.filter((agent) =>
+ matches(`${agent.name} ${agent.runtime.label}`)
+ )
+ );
+ const searchLabel = () =>
+ browsing() || showAll()
+ ? 'Search models'
+ : macro()
+ ? 'Search agents and models'
+ : 'Search agents';
const changeOpen = (next: boolean) => {
setOpen(next);
if (!next) {
setQuery('');
setBrowsing(undefined);
+ setShowAll(false);
}
};
const choose = (agent: RosterAgent, model?: string) => {
@@ -52,158 +85,252 @@ export function MobileAgentPicker(props: AgentPickerProps) {
const browse = (agent?: RosterAgent) => {
setQuery('');
setBrowsing(agent);
+ setShowAll(false);
+ searchInput?.focus();
};
return (
- <MobileDrawer side="bottom" open={open()} onOpenChange={changeOpen}>
+ <MobileDrawer
+ side="bottom"
+ open={open()}
+ onOpenChange={changeOpen}
+ restoreFocus={!!props.onCloseAutoFocus}
+ onFinalFocus={props.onCloseAutoFocus}
+ >
<MobileDrawer.Trigger
as={Button}
variant="ghost"
size="sm"
aria-label="Agent"
title={label()}
- class="h-[30px] min-w-0 max-w-full gap-1 rounded-full border border-edge-muted bg-ink/5 px-2 text-[12px] font-medium leading-none text-ink-muted"
+ class={
+ props.showModelLabel
+ ? 'h-[34px] max-w-full min-w-0 gap-1.5 rounded-full px-2 text-ink-muted'
+ : 'size-[34px] shrink-0 rounded-full p-0 text-ink-muted'
+ }
+ // Let click open the sheet before any native focus can move the trigger.
+ // Physical iOS devices also send mousedown after a cancelled pointerdown.
+ onPointerDown={(event: PointerEvent) => event.preventDefault()}
+ onMouseDown={(event: MouseEvent) => event.preventDefault()}
>
- <Show when={props.selected?.id !== MACRO_PERSONA_ID && props.selected}>
- {(agent) => (
- <AgentIcon agent={agent()} class="size-[12px] shrink-0" />
- )}
+ {/* Icon only on a phone; the title and the sheet name the choice. */}
+ <Show
+ when={props.selected?.id !== MACRO_PERSONA_ID && props.selected}
+ fallback={<ModelIcon model={model()} class="size-[18px]" />}
+ >
+ {(agent) => <AgentIcon agent={agent()} class="size-[18px]" />}
+ </Show>
+ <Show when={props.showModelLabel}>
+ <span class="min-w-0 truncate">{modelLabel(model())}</span>
</Show>
- <span class="truncate">{label()}</span>
- <CaretDown class="size-[10px] shrink-0" />
</MobileDrawer.Trigger>
<MobileDrawer.Portal>
<MobileDrawer.Overlay />
<MobileDrawer.Content aria-label="Choose an agent or model">
<MobileDrawer.Handle />
<div class="flex items-center gap-2 px-4 pb-3">
- <Show when={browsing()}>
+ <Show when={browsing() || showAll()}>
<Button
variant="ghost"
size="icon-md"
- label="Back to agents"
- onClick={() => browse()}
+ label={showAll() ? 'Back to Suggested' : 'Back to agents'}
+ onClick={() => {
+ if (showAll()) {
+ setShowAll(false);
+ setQuery('');
+ searchInput?.focus();
+ } else browse();
+ }}
>
<ArrowLeft />
</Button>
</Show>
<h2 class="min-w-0 flex-1 truncate font-medium">
- {browsing()?.name ?? 'Agents and models'}
+ {showAll()
+ ? 'All models'
+ : (browsing()?.name ??
+ (macro() ? 'Agents and models' : 'Choose an agent'))}
</h2>
- </div>
- <input
- aria-label="Search agents and models"
- placeholder="Search"
- value={query()}
- onInput={(event) => setQuery(event.currentTarget.value)}
- class="mx-4 mb-3 rounded-xl border border-edge-muted bg-input px-3 py-2 text-base outline-none"
- />
- <MobileDrawer.ScrollBody>
<Show when={browsing()}>
{(agent) => (
- <MobileDrawer.Item onClick={() => choose(agent())}>
- Use {agent().name} default
- </MobileDrawer.Item>
- )}
- </Show>
- <MobileDrawer.Label>Models</MobileDrawer.Label>
- <For each={models()}>
- {(option) => (
- <MobileDrawer.Item
- onClick={() => {
- const agent = browsing() ?? macro();
- if (agent) choose(agent, option.id);
- }}
+ <Button
+ variant="ghost"
+ size="sm"
+ aria-label={`Use ${agent().name} default`}
+ onClick={() => choose(agent())}
>
- <ModelIcon model={option.id} />
- <span class="min-w-0 flex-1 truncate">
- {modelLabel(option.id, option.name)}
- </span>
- <Show
- when={
- props.selected?.id === (browsing() ?? macro())?.id &&
- model() === option.id
- }
- >
- <Check class="size-4 text-accent" />
- </Show>
- </MobileDrawer.Item>
+ Use default
+ </Button>
)}
- </For>
- <Show when={models().length === 0}>
- <p role="status" class="px-4 py-3 text-sm text-ink-muted">
- {query() ? 'No matching models' : catalog.message()}
- </p>
</Show>
- <Show when={!browsing()}>
- <For each={['agent', 'coder'] as const}>
- {(kind) => (
- <Show when={agents().some((agent) => agent.kind === kind)}>
- <MobileDrawer.Label>
- {kind === 'coder' ? 'Coding agents' : 'Agents'}
+ </div>
+ <div class="mx-4 mb-2 flex h-9 shrink-0 items-center gap-2 px-3">
+ <MagnifyingGlass
+ aria-hidden="true"
+ class="size-4 shrink-0 text-ink-extra-muted"
+ />
+ <input
+ ref={searchInput}
+ aria-label={searchLabel()}
+ placeholder={searchLabel()}
+ 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={browsing() ?? macro()}>
+ <For each={modelSections()}>
+ {(section) => (
+ <div>
+ <MobileDrawer.Label class="px-4 pb-1 font-medium text-ink-muted">
+ {section.label}
</MobileDrawer.Label>
- <For each={agents().filter((agent) => agent.kind === kind)}>
- {(agent) => (
- <div class="flex items-center">
+ <MobileDrawer.Section
+ class="rounded-none bg-transparent p-0"
+ role="group"
+ aria-label={section.label}
+ >
+ <For each={section.options}>
+ {(option) => (
<MobileDrawer.Item
- class="min-w-0 flex-1"
disabled={Boolean(
- agent.unavailableReason && !agent.connectLabel
+ (browsing() ?? macro())?.unavailableReason
)}
onClick={() => {
- if (agent.unavailableReason) {
- changeOpen(false);
- props.onConnect(agent);
- } else choose(agent);
+ const agent = browsing() ?? macro();
+ if (agent) choose(agent, option.id);
}}
>
- <AgentIcon agent={agent} class="size-5 shrink-0" />
- <span class="min-w-0 flex-1 text-left">
- <span class="block truncate">{agent.name}</span>
- <Show when={agent.unavailableReason}>
- <span class="block text-xs text-ink-muted">
- {agent.connectLabel ??
- agent.unavailableReason}
- </span>
- </Show>
+ <ModelIcon model={option.id} />
+ <span class="min-w-0 flex-1 truncate">
+ {option.label}
</span>
- <Show when={props.selected?.id === agent.id}>
+ <Show
+ when={
+ props.selected?.id ===
+ (browsing() ?? macro())?.id &&
+ model() === option.id
+ }
+ >
<Check class="size-4 text-accent" />
</Show>
</MobileDrawer.Item>
- <Show when={!agent.unavailableReason}>
- <Button
- variant="ghost"
- size="icon-md"
- class="mr-3 size-11"
- label={`Models for ${agent.name}`}
- onClick={() => browse(agent)}
+ )}
+ </For>
+ </MobileDrawer.Section>
+ </div>
+ )}
+ </For>
+ <Show
+ when={
+ !showAll() &&
+ !query() &&
+ modelSections().some(
+ (section) => section.label === 'Suggested'
+ )
+ }
+ >
+ <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>
+ <Show when={modelSections().length === 0}>
+ <p role="status" class="px-4 py-3 text-sm text-ink-muted">
+ {query() ? 'No matching models' : catalog.message()}
+ </p>
+ </Show>
+ </Show>
+ <Show when={!browsing() && !showAll()}>
+ <For each={groups()}>
+ {(group) => (
+ <div>
+ <MobileDrawer.Label class="px-4 pb-1 font-medium text-ink-muted">
+ {group.label}
+ </MobileDrawer.Label>
+ <MobileDrawer.Section
+ class="rounded-none bg-transparent p-0"
+ role="group"
+ aria-label={group.label}
+ >
+ <For each={group.agents}>
+ {(agent) => (
+ <div class="flex items-center">
+ <MobileDrawer.Item
+ class="min-w-0 flex-1"
+ disabled={Boolean(
+ agent.unavailableReason && !agent.connectLabel
+ )}
+ onClick={() => {
+ if (agent.unavailableReason) {
+ changeOpen(false);
+ props.onConnect(agent);
+ } else choose(agent);
+ }}
>
- <CaretRight />
- </Button>
- </Show>
- </div>
- )}
- </For>
- </Show>
+ <AgentPickerIdentity
+ agent={agent}
+ selected={props.selected?.id === agent.id}
+ model={
+ props.selected?.id === agent.id
+ ? props.modelOverride
+ : undefined
+ }
+ />
+ </MobileDrawer.Item>
+ <Show when={!agent.unavailableReason}>
+ <Button
+ variant="ghost"
+ size="icon-md"
+ class="mr-1 size-11 shrink-0"
+ label={`Models for ${agent.name}`}
+ onClick={() => browse(agent)}
+ >
+ <CaretRight />
+ </Button>
+ </Show>
+ </div>
+ )}
+ </For>
+ </MobileDrawer.Section>
+ </div>
)}
</For>
+ <Show when={!props.loading && !macro() && groups().length === 0}>
+ <p role="status" class="px-4 py-3 text-sm text-ink-muted">
+ {query() ? 'No matching agents' : 'No agents available'}
+ </p>
+ </Show>
<Show when={props.loading}>
<p role="status" class="px-4 py-3 text-sm text-ink-muted">
Loading agents…
</p>
</Show>
</Show>
+ <div class="flex justify-end px-4 pt-1">
+ <Button
+ variant="strong"
+ size="sm"
+ glass={false}
+ class="gap-1.5"
+ onClick={() => {
+ changeOpen(false);
+ props.onCreate();
+ }}
+ >
+ <Plus class="size-4" />
+ Create agent
+ </Button>
+ </div>
</MobileDrawer.ScrollBody>
- <MobileDrawer.Item
- class="shrink-0 border-t border-edge-muted"
- onClick={() => {
- changeOpen(false);
- props.onCreate();
- }}
- >
- <Plus class="size-5" />
- Create agent
- </MobileDrawer.Item>
</MobileDrawer.Content>
</MobileDrawer.Portal>
</MobileDrawer>
diff --git a/apps/web/src/features/agents-view/views/NewChatPage.test.tsx b/apps/web/src/features/agents-view/views/NewChatPage.test.tsx
index 144ea446d3..7d20b050ad 100644
--- a/apps/web/src/features/agents-view/views/NewChatPage.test.tsx
+++ b/apps/web/src/features/agents-view/views/NewChatPage.test.tsx
@@ -11,7 +11,7 @@ import {
} from '@solidjs/testing-library';
import { createSignal, type JSX } from 'solid-js';
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
-import type { AgentKind } from '../core/agent-kind';
+import type { AgentsMode } from '../core/mode';
import {
buildAgentRoster,
type PersistedAgentLike,
@@ -26,6 +26,8 @@ const mocks = vi.hoisted(() => ({
touch: false,
freePlan: false,
modelsPending: false,
+ tier: 'max',
+ currentEffort: 'low',
openSettings: vi.fn(),
capabilitiesPending: false,
attachments: [] as InputAttachmentData[],
@@ -87,6 +89,14 @@ vi.mock('../queries/repository-branches', () => ({
}));
vi.mock('../components/AgentGlyph', () => ({ AgentIcon: () => <span /> }));
+vi.mock('@queries/auth/ai-billing', () => ({
+ useAiBillingSummaryQuery: () => ({
+ isSuccess: true,
+ get data() {
+ return { tier: mocks.tier };
+ },
+ }),
+}));
vi.mock('@queries/agents/capabilities', () => ({
useAgentCapabilitiesQuery: (
target: () => { model?: string } | undefined
@@ -104,7 +114,7 @@ vi.mock('@queries/agents/capabilities', () => ({
name: 'Effort',
category: 'thought_level',
type: 'select',
- currentValue: 'low',
+ currentValue: mocks.currentEffort,
options: [
{ value: 'low', name: 'Low' },
{ value: 'ultra', name: 'Ultra' },
@@ -158,6 +168,7 @@ vi.mock('@queries/agents/models', () => ({
},
{ id: 'anthropic/claude-opus-5-5', name: 'Claude Opus 5.5' },
{ id: 'openai/gpt-5.6', name: 'GPT-5.6' },
+ { id: 'openai/gpt-6-astra', name: 'GPT-6 Astra' },
{ id: 'google/gemini-3.8-flash', name: 'Gemini 3.8 Flash' },
{ id: 'fireworks/kimi-k3', name: 'Kimi K3' },
{ id: 'fireworks/glm-5p3', name: 'GLM 5.3' },
@@ -176,6 +187,7 @@ vi.mock('@queries/agents/models', () => ({
// Keep the real picker and send wiring; substitute only the Lexical editor.
type ComposerProps = {
+ corner: JSX.Element;
selector: JSX.Element;
drawer: JSX.Element;
drawerOpen: boolean;
@@ -187,6 +199,7 @@ type ComposerProps = {
vi.mock('../components/ChatComposer', () => ({
ChatComposer: (props: ComposerProps) => (
<>
+ {props.corner}
{props.selector}
<output data-testid="attachments">
{props.attachments.map((a) => a.name).join(',')}
@@ -223,13 +236,13 @@ function page(
agents: PersistedAgentLike[] = [],
availabilityLoading = false,
runtimes: RuntimeLike[] = [],
- kind?: AgentKind
+ mode?: AgentsMode
) {
const onStart = vi.fn();
render(() => (
<NewChatPage
compact={mocks.touch}
- kind={kind}
+ mode={mode}
roster={buildAgentRoster({
agents,
runtimes,
@@ -262,6 +275,10 @@ async function selectAgent(name: RegExp) {
}
async function hoverAgent(name: string) {
openAgents();
+ // Chat mode's root menu has its own model search; Code mode's does not.
+ const before = screen.queryAllByRole('textbox', {
+ name: 'Search models',
+ }).length;
const event = new MouseEvent('pointermove', { bubbles: true });
Object.defineProperty(event, 'pointerType', { value: 'mouse' });
screen
@@ -270,7 +287,7 @@ async function hoverAgent(name: string) {
await waitFor(() =>
expect(
screen.getAllByRole('textbox', { name: 'Search models' })
- ).toHaveLength(2)
+ ).toHaveLength(before + 1)
);
const search = screen
.getAllByRole('textbox', { name: 'Search models' })
@@ -285,6 +302,8 @@ describe('agent-led new conversation', () => {
mocks.capabilitiesPending = false;
mocks.freePlan = false;
mocks.modelsPending = false;
+ mocks.tier = 'max';
+ mocks.currentEffort = 'low';
mocks.touch = false;
mocks.attachments = [];
mocks.recentIds = [MACRO_CODER_BOT_ID];
@@ -320,7 +339,7 @@ describe('agent-led new conversation', () => {
});
it('selects a coding model from the phone sheet without hover and preserves the draft', async () => {
mocks.touch = true;
- const send = page();
+ const send = page(true, [], false, [], 'code');
fireEvent.input(screen.getByRole('textbox', { name: 'Draft' }), {
target: { value: 'Phone draft' },
});
@@ -344,8 +363,22 @@ describe('agent-led new conversation', () => {
mocks.touch = true;
const send = page();
fireEvent.click(screen.getByRole('button', { name: 'Agent' }));
+ await screen.findByRole('textbox', { name: 'Search agents and models' });
+ const frontier = within(screen.getByRole('group', { name: 'Suggested' }));
+ expect(
+ frontier.getAllByRole('button').map((item) => item.textContent?.trim())
+ ).toEqual([
+ 'Opus 5.5',
+ 'Sonnet 5.5',
+ 'GPT-5.6',
+ 'GPT-6 Astra',
+ 'Gemini 3.8 Flash',
+ ]);
+ expect(screen.queryByRole('group', { name: 'Google' })).toBeNull();
+ expect(screen.getByRole('button', { name: 'More models' })).toBeTruthy();
+ expect(screen.queryByText('Recommended')).toBeNull();
fireEvent.input(
- await screen.findByRole('textbox', { name: 'Search agents and models' }),
+ screen.getByRole('textbox', { name: 'Search agents and models' }),
{
target: { value: 'Sonnet 5.5' },
}
@@ -360,21 +393,61 @@ describe('agent-led new conversation', () => {
})
);
});
- it('offers both kinds without a mode or model control and starts with the agent default', async () => {
+ it('opens and focuses the mobile model search on the first tap', async () => {
+ mocks.touch = true;
+ page();
+ const trigger = screen.getByRole('button', { name: 'Agent' });
+ for (const type of ['pointerdown', 'mousedown']) {
+ const event = new MouseEvent(type, { bubbles: true, cancelable: true });
+ trigger.dispatchEvent(event);
+ expect(event.defaultPrevented).toBe(true);
+ }
+ fireEvent.pointerUp(trigger);
+ fireEvent.mouseUp(trigger);
+ fireEvent.click(trigger);
+ const search = await screen.findByRole('textbox', {
+ name: 'Search agents and models',
+ });
+ await waitFor(() => expect(document.activeElement).toBe(search));
+ });
+ it('focuses desktop search on opening and reopening the model selector', async () => {
+ page();
+ for (let attempt = 0; attempt < 2; attempt++) {
+ openAgents();
+ 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('starts in Chat and switches to Code from the composer', async () => {
const send = page();
expect(
screen.getByRole('heading', { name: 'What should we work on?' })
).toBeTruthy();
expect(screen.queryByRole('button', { name: 'Model' })).toBeNull();
+ expect(screen.getByRole('button', { name: 'Agent' }).textContent).toContain(
+ 'Chat default'
+ );
expect(
- screen.queryByRole('button', { name: /^(Chat|Code) mode$/ })
- ).toBeNull();
+ (screen.getByRole('radio', { name: 'Chat' }) as HTMLInputElement).checked
+ ).toBe(true);
+ expect(screen.queryByRole('button', { name: 'Repository' })).toBeNull();
+ fireEvent.click(screen.getByRole('radio', { name: 'Code' }));
+ expect(
+ screen.getByRole('heading', { name: 'What should we build?' })
+ ).toBeTruthy();
+ expect(screen.getByRole('button', { name: 'Repository' })).toBeTruthy();
openAgents();
- expect(screen.queryByRole('menuitem', { name: /Macro/ })).toBeNull();
expect(screen.getByRole('menuitem', { name: /Cursor/ })).toBeTruthy();
- expect(screen.queryByText('Macro Coding Agent')).toBeNull();
+ expect(
+ screen.queryByRole('menuitem', { name: /^Chat default$/ })
+ ).toBeNull();
fireEvent.keyDown(document, { key: 'Escape' });
await waitFor(() => expect(screen.queryByRole('menu')).toBeNull());
+ fireEvent.click(screen.getByRole('radio', { name: 'Chat' }));
fireEvent.click(screen.getByRole('button', { name: 'Send' }));
expect(send).toHaveBeenCalledWith({
onFailure: expect.any(Function),
@@ -401,11 +474,12 @@ describe('agent-led new conversation', () => {
fireEvent.input(screen.getByRole('textbox', { name: 'Draft' }), {
target: { value: 'Shared draft' },
});
+ fireEvent.click(screen.getByRole('radio', { name: 'Code' }));
await selectAgent(/Cursor/);
expect(
screen.getByRole('heading', { name: 'What should we build?' })
).toBeTruthy();
- expect(screen.getByTestId('drawer').hasAttribute('hidden')).toBe(false);
+ expect(screen.getByRole('button', { name: 'Repository' })).toBeTruthy();
fireEvent.click(screen.getByRole('button', { name: 'Repository' }));
fireEvent.click(screen.getByRole('option', { name: 'macro-inc/macro' }));
// The listed repository's own default branch, until one is chosen.
@@ -414,8 +488,8 @@ describe('agent-led new conversation', () => {
).toContain('develop');
fireEvent.click(screen.getByRole('button', { name: 'Branch' }));
fireEvent.click(screen.getByRole('option', { name: 'feature/home' }));
- await selectAgent(/^Chat default$/);
- expect(screen.getByTestId('drawer').hasAttribute('hidden')).toBe(true);
+ fireEvent.click(screen.getByRole('radio', { name: 'Chat' }));
+ expect(screen.queryByRole('button', { name: 'Repository' })).toBeNull();
expect(
(screen.getByRole('textbox', { name: 'Draft' }) as HTMLInputElement).value
).toBe('Shared draft');
@@ -427,7 +501,7 @@ describe('agent-led new conversation', () => {
repoUrl: undefined,
modelOverride: 'chat-default',
});
- await selectAgent(/Cursor/);
+ fireEvent.click(screen.getByRole('radio', { name: 'Code' }));
expect(screen.getByRole('button', { name: 'Repository' })).toBeTruthy();
fireEvent.click(screen.getByRole('button', { name: 'Send' }));
expect(send).toHaveBeenLastCalledWith({
@@ -439,15 +513,13 @@ describe('agent-led new conversation', () => {
});
});
it('offers only chat agents in Work and keeps the composer compact', async () => {
- const send = page(true, [], false, [], 'agent');
+ const send = page(true, [], false, [], 'chat');
expect(
screen.getByRole('heading', { name: 'What should we work on?' })
).toBeTruthy();
- expect(screen.getByTestId('drawer').hasAttribute('hidden')).toBe(true);
+ expect(screen.queryByRole('button', { name: 'Repository' })).toBeNull();
openAgents();
- expect(
- screen.getByRole('menuitem', { name: /^Chat default$/ })
- ).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());
@@ -461,11 +533,11 @@ describe('agent-led new conversation', () => {
});
});
it('offers only coding agents in Code and opens the repository drawer', async () => {
- const send = page(true, [], false, [], 'coder');
+ const send = page(true, [], false, [], 'code');
expect(
screen.getByRole('heading', { name: 'What should we build?' })
).toBeTruthy();
- expect(screen.getByTestId('drawer').hasAttribute('hidden')).toBe(false);
+ expect(screen.getByRole('button', { name: 'Repository' })).toBeTruthy();
openAgents();
expect(screen.getByRole('menuitem', { name: /Cursor/ })).toBeTruthy();
expect(
@@ -492,7 +564,7 @@ describe('agent-led new conversation', () => {
it('starts a new conversation on Choose repository, not the last used one', async () => {
mocks.recentIds = [CURSOR_BOT_ID];
mocks.recentUrls = ['https://github.com/macro-inc/macro'];
- const send = page();
+ const send = page(true, [], false, [], 'code');
expect(
screen.getByRole('button', { name: 'Repository' }).textContent
).toContain('Choose repository');
@@ -508,7 +580,7 @@ describe('agent-led new conversation', () => {
});
});
it('refuses an unlisted repository and starts a listed one on its default branch', async () => {
- const send = page();
+ const send = page(true, [], false, [], 'code');
await selectAgent(/Cursor/);
fireEvent.click(screen.getByRole('button', { name: 'Repository' }));
fireEvent.input(
@@ -565,22 +637,28 @@ describe('agent-led new conversation', () => {
it.each(['claude-cloud', 'codex-cloud', 'future-runtime'])(
'shows the drawer for a saved %s coding agent without forwarding unsupported repository overrides',
async (harness) => {
- const send = page(true, [
- {
- bot: {
- id: 'saved-cloud-agent',
- name: 'Cloud reviewer',
- handle: 'cloud-reviewer',
+ const send = page(
+ true,
+ [
+ {
+ bot: {
+ id: 'saved-cloud-agent',
+ name: 'Cloud reviewer',
+ handle: 'cloud-reviewer',
+ },
+ harness,
+ default_model: 'saved-default',
},
- harness,
- default_model: 'saved-default',
- },
- ]);
+ ],
+ false,
+ [],
+ 'code'
+ );
await selectAgent(/Cursor/);
fireEvent.click(screen.getByRole('button', { name: 'Repository' }));
fireEvent.click(screen.getByRole('option', { name: 'macro-inc/macro' }));
await selectAgent(/Cloud reviewer/);
- expect(screen.getByTestId('drawer').hasAttribute('hidden')).toBe(false);
+ expect(screen.getByRole('button', { name: 'Repository' })).toBeTruthy();
expect(screen.getByRole('button', { name: 'Repository' })).toBeTruthy();
expect(screen.getByRole('button', { name: 'Branch' })).toBeTruthy();
fireEvent.click(screen.getByRole('button', { name: 'Send' }));
@@ -605,7 +683,8 @@ describe('agent-led new conversation', () => {
},
],
false,
- [{ id: 'laptop', name: 'Laptop', connected: true }]
+ [{ id: 'laptop', name: 'Laptop', connected: true }],
+ 'code'
);
await selectAgent(/Cursor/);
fireEvent.click(screen.getByRole('button', { name: 'Repository' }));
@@ -628,22 +707,104 @@ describe('agent-led new conversation', () => {
});
it('keeps a disconnected paired agent visible with its availability reason', () => {
- page(true, [
- {
- bot: { id: 'paired-agent', name: 'Laptop agent', handle: 'laptop' },
- harness: 'macrod',
- harness_id: 'offline-machine',
- default_model: 'saved-default',
- },
- ]);
+ page(
+ true,
+ [
+ {
+ bot: { id: 'paired-agent', name: 'Laptop agent', handle: 'laptop' },
+ harness: 'macrod',
+ harness_id: 'offline-machine',
+ default_model: 'saved-default',
+ },
+ ],
+ false,
+ [],
+ 'code'
+ );
openAgents();
const row = screen.getByRole('menuitem', { name: /Laptop agent/ });
expect(row.getAttribute('aria-disabled')).toBe('true');
expect(row.textContent).toContain('Its runtime is disconnected');
});
+ it.each([false, true])(
+ 'clusters coding agents by availability without an empty model catalog (touch: %s)',
+ async (touch) => {
+ mocks.touch = touch;
+ const roster = buildAgentRoster({
+ agents: [
+ {
+ bot: { id: 'reviewer', name: 'Reviewer', handle: 'reviewer' },
+ harness: 'macrod',
+ harness_id: 'laptop',
+ default_model: 'claude-sonnet-5-5',
+ },
+ {
+ bot: { id: 'offline', name: 'Offline agent', handle: 'offline' },
+ harness: 'macrod',
+ harness_id: 'offline',
+ default_model: 'default',
+ },
+ ],
+ runtimes: [{ id: 'laptop', name: 'Laptop', connected: true }],
+ cursorConnected: true,
+ cursorNeedsConnection: false,
+ }).filter((agent) => agent.kind === 'coder');
+ const onCreate = vi.fn();
+ const onSelect = vi.fn();
+ render(() => (
+ <AgentPicker
+ agents={roster}
+ selected={roster[0]}
+ loading={false}
+ onSelect={onSelect}
+ onConnect={vi.fn()}
+ onCreate={onCreate}
+ />
+ ));
+ if (touch) fireEvent.click(screen.getByRole('button', { name: 'Agent' }));
+ else openAgents();
+ const picker = await screen.findByRole(touch ? 'dialog' : 'menu');
+ const builtIn = within(picker).getByRole('group', { name: 'Built-in' });
+ const saved = within(picker).getByRole('group', { name: 'Your agents' });
+ const offline = within(picker).getByRole('group', {
+ name: 'Needs connection',
+ });
+ expect(builtIn.textContent).toContain('Cursor');
+ expect(saved.textContent).toContain('Reviewer');
+ expect(saved.textContent).toContain('Laptop · Sonnet 5.5');
+ expect(offline.textContent).toContain('Offline agent');
+ expect(offline.textContent).toContain('Its runtime is disconnected');
+ expect(
+ within(picker).queryByText('Connect the runtime to load models.')
+ ).toBeNull();
+ expect(within(picker).queryByText('Models')).toBeNull();
+ const unavailable = within(offline).getByRole(
+ touch ? 'button' : 'menuitem'
+ );
+ expect(
+ touch
+ ? unavailable.hasAttribute('disabled')
+ : unavailable.getAttribute('aria-disabled') === 'true'
+ ).toBe(true);
+ fireEvent.click(unavailable);
+ expect(onSelect).not.toHaveBeenCalled();
+ const create = within(picker).getByRole(touch ? 'button' : 'menuitem', {
+ name: 'Create agent',
+ });
+ if (touch) fireEvent.click(create);
+ else {
+ create.focus();
+ fireEvent.keyDown(create, { key: 'Enter' });
+ }
+ expect(onCreate).toHaveBeenCalledOnce();
+ await waitFor(() =>
+ expect(screen.queryByRole(touch ? 'dialog' : 'menu')).toBeNull()
+ );
+ }
+ );
it('focuses model search when hovering an agent submenu', async () => {
- page();
+ page(true, [], false, [], 'code');
const submenu = await hoverAgent('Cursor');
const search = submenu.getByRole('textbox', { name: 'Search models' });
await waitFor(() => expect(document.activeElement).toBe(search));
@@ -657,9 +818,9 @@ describe('agent-led new conversation', () => {
});
it('shows the model beside the agent and sends a hovered model choice only once', async () => {
- const send = page();
- expect(screen.getByRole('button', { name: 'Agent' }).textContent).toContain(
- 'Chat default'
+ const send = page(true, [], false, [], 'code');
+ expect(screen.getByRole('button', { name: 'Agent' }).title).toContain(
+ 'Cursor default'
);
await hoverAgent('Cursor');
expect(screen.queryByText('Use agent default')).toBeNull();
@@ -668,15 +829,15 @@ describe('agent-led new conversation', () => {
.getByRole('menuitem', { name: /Cursor default/ })
.querySelector('.text-accent')
).toBeTruthy();
- const model = screen.getByRole('menuitem', { name: /GPT-5/ });
+ const model = screen.getByTitle('GPT-5');
expect(model.querySelector('.text-accent')).toBeNull();
expect(model.querySelector('[data-ai-provider="openai"] svg')).toBeTruthy();
fireEvent.keyDown(model, { key: 'Enter' });
await waitFor(() => expect(screen.queryByRole('menu')).toBeNull());
- expect(screen.getByRole('button', { name: 'Agent' }).textContent).toContain(
+ expect(screen.getByRole('button', { name: 'Agent' }).title).toContain(
'GPT-5'
);
- expect(screen.getByTestId('drawer').hasAttribute('hidden')).toBe(false);
+ expect(screen.getByRole('button', { name: 'Repository' })).toBeTruthy();
openAgents();
fireEvent.keyDown(screen.getByRole('menuitem', { name: /^Cursor/ }), {
key: 'ArrowRight',
@@ -684,12 +845,10 @@ describe('agent-led new conversation', () => {
await waitFor(() =>
expect(
screen.getAllByRole('textbox', { name: 'Search models' })
- ).toHaveLength(2)
+ ).toHaveLength(1)
);
expect(
- screen
- .getByRole('menuitem', { name: /GPT-5/ })
- .querySelector('.text-accent')
+ screen.getByTitle('GPT-5').querySelector('.text-accent')
).toBeTruthy();
expect(
screen
@@ -707,24 +866,24 @@ describe('agent-led new conversation', () => {
repoUrl: undefined,
modelOverride: 'gpt-5',
});
- expect(screen.getByRole('button', { name: 'Agent' }).textContent).toContain(
+ expect(screen.getByRole('button', { name: 'Agent' }).title).toContain(
'Cursor default'
);
fireEvent.click(screen.getByRole('button', { name: 'Send' }));
expect(send.mock.calls[1][0]).not.toHaveProperty('modelOverride');
});
- it('clears a temporary model choice when selecting another agent', async () => {
+ it('clears a temporary model choice when switching to Code', async () => {
page();
openAgents();
const model = screen.getByTitle('Sonnet 5.5');
model.focus();
fireEvent.keyDown(model, { key: 'Enter' });
await waitFor(() => expect(screen.queryByRole('menu')).toBeNull());
- expect(screen.getByRole('button', { name: 'Agent' }).textContent).toContain(
+ expect(screen.getByRole('button', { name: 'Agent' }).title).toContain(
'Sonnet 5.5'
);
- await selectAgent(/Cursor/);
- expect(screen.getByRole('button', { name: 'Agent' }).textContent).toContain(
+ fireEvent.click(screen.getByRole('radio', { name: 'Code' }));
+ expect(screen.getByRole('button', { name: 'Agent' }).title).toContain(
'Cursor default'
);
});
@@ -736,33 +895,34 @@ describe('agent-led new conversation', () => {
default_model: 'saved-default',
},
]);
- await selectAgent(/Cursor/);
openAgents();
- const modelsGroup = screen.getByRole('group', { name: 'Recommended' });
- const agentsGroup = screen.getByRole('group', { name: 'Agents' });
- const codingGroup = screen.getByRole('group', { name: 'Coding agents' });
+ 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(
- agentsGroup.compareDocumentPosition(codingGroup) &
- Node.DOCUMENT_POSITION_FOLLOWING
- ).toBe(Node.DOCUMENT_POSITION_FOLLOWING);
- const coding = within(codingGroup);
+ expect(screen.queryByRole('group', { name: 'Coding agents' })).toBeNull();
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(coding.getByRole('menuitem', { name: /Cursor/ })).toBeTruthy();
- expect(coding.queryByRole('menuitem', { name: /Macro/ })).toBeNull();
- expect(screen.queryByRole('menuitem', { name: /Macro/ })).toBeNull();
- const models = within(screen.getByRole('group', { name: 'Recommended' }));
+ expect(screen.queryByRole('menuitem', { name: /Cursor/ })).toBeNull();
+ expect(screen.queryByRole('menuitem', { name: /^Macro/ })).toBeNull();
+ const models = within(screen.getByRole('group', { name: 'Suggested' }));
expect(
- models.queryByRole('menuitem', { name: /Cursor default|GPT-5/ })
+ 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')
@@ -774,7 +934,7 @@ describe('agent-led new conversation', () => {
expect(mocks.rememberInmemModel).toHaveBeenCalledWith(
'anthropic/claude-sonnet-5-5'
);
- expect(screen.getByRole('button', { name: 'Agent' }).textContent).toBe(
+ expect(screen.getByRole('button', { name: 'Agent' }).title).toBe(
'Sonnet 5.5'
);
const trigger = screen.getByRole('button', { name: 'Agent' });
@@ -782,7 +942,7 @@ describe('agent-led new conversation', () => {
expect(
trigger.querySelector('[data-ai-provider="anthropic"] svg')
).toBeTruthy();
- expect(screen.getByTestId('drawer').hasAttribute('hidden')).toBe(true);
+ expect(screen.queryByRole('button', { name: 'Repository' })).toBeNull();
fireEvent.click(screen.getByRole('button', { name: 'Send' }));
expect(send).toHaveBeenLastCalledWith({
onFailure: expect.any(Function),
@@ -792,7 +952,7 @@ describe('agent-led new conversation', () => {
modelOverride: 'anthropic/claude-sonnet-5-5',
});
// Macro Models picks stick: a second send still uses the preferred model.
- expect(screen.getByRole('button', { name: 'Agent' }).textContent).toBe(
+ expect(screen.getByRole('button', { name: 'Agent' }).title).toBe(
'Sonnet 5.5'
);
fireEvent.click(screen.getByRole('button', { name: 'Send' }));
@@ -836,7 +996,7 @@ describe('agent-led new conversation', () => {
fireEvent.click(flash);
fireEvent.input(search, { target: { value: '' } });
- const more = screen.getByRole('menuitem', { name: /More models/ });
+ const more = screen.getByRole('menuitem', { name: 'More models' });
more.focus();
fireEvent.keyDown(more, { key: 'ArrowRight' });
const extra = await screen.findByTitle('GLM 5.3 Flash');
@@ -847,7 +1007,7 @@ describe('agent-led new conversation', () => {
it('restores a preferred Macro model on a fresh composer', () => {
mocks.preferredInmemModel = 'anthropic/claude-sonnet-5-5';
page();
- expect(screen.getByRole('button', { name: 'Agent' }).textContent).toBe(
+ expect(screen.getByRole('button', { name: 'Agent' }).title).toBe(
'Sonnet 5.5'
);
});
@@ -855,7 +1015,7 @@ describe('agent-led new conversation', () => {
mocks.freePlan = true;
mocks.preferredInmemModel = 'anthropic/claude-sonnet-5-5';
const send = page();
- expect(screen.getByRole('button', { name: 'Agent' }).textContent).toBe(
+ expect(screen.getByRole('button', { name: 'Agent' }).title).toBe(
'Gemini 3.8 Flash'
);
openAgents();
@@ -874,31 +1034,51 @@ describe('agent-led new conversation', () => {
});
it('restores the most recently used supported agent', async () => {
mocks.recentIds = [CURSOR_BOT_ID];
- page();
- expect(screen.getByRole('button', { name: 'Agent' }).textContent).toContain(
+ page(true, [], false, [], 'code');
+ expect(screen.getByRole('button', { name: 'Agent' }).title).toContain(
'Cursor'
);
- expect(screen.getByTestId('drawer').hasAttribute('hidden')).toBe(false);
+ expect(screen.getByRole('button', { name: 'Repository' })).toBeTruthy();
});
it('keeps the most recent agent while its connection status loads', () => {
mocks.recentIds = [CURSOR_BOT_ID];
- page(false, [], true);
+ page(false, [], true, [], 'code');
expect(
screen.getByRole('heading', { name: 'What should we build?' })
).toBeTruthy();
- expect(screen.getByTestId('drawer').hasAttribute('hidden')).toBe(false);
+ expect(screen.getByRole('button', { name: 'Repository' })).toBeTruthy();
});
it('offers Cursor setup when disconnected without switching to an unavailable agent', async () => {
- page(false);
+ page(false, [], false, [], 'code');
+ const before = screen.getByRole('button', { name: 'Agent' }).title;
await selectAgent(/Cursor/);
expect(mocks.openSettings).toHaveBeenCalledWith('Harness');
- expect(screen.getByRole('button', { name: 'Agent' }).textContent).toContain(
- 'Chat default'
- );
- expect(screen.getByTestId('drawer').hasAttribute('hidden')).toBe(true);
+ expect(screen.getByRole('button', { name: 'Agent' }).title).toBe(before);
});
+ it.each(['free', 'premium', 'max'])(
+ 'uses the correct initial effort for %s',
+ async (tier) => {
+ mocks.tier = tier;
+ mocks.currentEffort = 'ultra';
+ 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.click(screen.getByRole('button', { name: 'Send' }));
+ expect(send).toHaveBeenLastCalledWith(
+ expect.objectContaining({
+ effortOverride:
+ tier === 'max'
+ ? undefined
+ : { configId: 'cursor_effort', value: 'low' },
+ })
+ );
+ }
+ );
it('passes opaque effort and clears it with the model override after sending', async () => {
- const send = page();
+ const send = page(true, [], false, [], 'code');
const models = await hoverAgent('Cursor');
fireEvent.keyDown(models.getByRole('menuitem', { name: /^GPT-5/ }), {
key: 'ArrowRight',
@@ -909,7 +1089,7 @@ describe('agent-led new conversation', () => {
});
await waitFor(() => expect(screen.queryByRole('menu')).toBeNull());
mocks.capabilitiesPending = true;
- expect(screen.getByRole('button', { name: 'Agent' }).textContent).toContain(
+ expect(screen.getByRole('button', { name: 'Agent' }).title).toContain(
'GPT-5 · Ultra'
);
fireEvent.click(screen.getByRole('button', { name: 'Send' }));
@@ -939,6 +1119,14 @@ it('starts a conversation with an uploaded image and no text', () => {
size: 123,
},
];
+ vi.stubGlobal(
+ 'ResizeObserver',
+ class {
+ observe() {}
+ unobserve() {}
+ disconnect() {}
+ }
+ );
const start = page();
fireEvent.click(screen.getByRole('button', { name: 'Send' }));
expect(start).toHaveBeenCalledWith(
diff --git a/apps/web/src/features/agents-view/views/NewChatPage.tsx b/apps/web/src/features/agents-view/views/NewChatPage.tsx
index f836e85d47..5e830b5b1d 100644
--- a/apps/web/src/features/agents-view/views/NewChatPage.tsx
+++ b/apps/web/src/features/agents-view/views/NewChatPage.tsx
@@ -16,17 +16,23 @@ import { useSettingsState } from '@core/constant/SettingsState';
import { useUserId } from '@core/context/user';
import { fireAndForget } from '@core/util/fireAndForget';
import { uploadFile } from '@core/util/upload';
+import ChatIcon from '@phosphor/chat-circle.svg';
+import CodeIcon from '@phosphor/code.svg';
import { useAgentCapabilitiesQuery } from '@queries/agents/capabilities';
+import { useAiBillingSummaryQuery } from '@queries/auth/ai-billing';
import type { PromptAttachment } from '@service-agent-harness/generated/schemas';
+import { Tabs } from '@ui';
import { tourTarget } from '@ui/components/Tour';
import { createMemo, createSignal, Show } from 'solid-js';
+import { EffortSelector } from '../../block-agent/component/EffortSelector';
import {
type EffortChoice,
effortConfigOption,
effortLabel,
} from '../../block-agent/state/session-config';
import { ChatComposer } from '../components/ChatComposer';
-import type { AgentKind } from '../core/agent-kind';
+import { type AgentKind, kindForMode } from '../core/agent-kind';
+import { type AgentsMode, agentsModeLabel } from '../core/mode';
import { defaultBranchFor } from '../core/repository';
import { MACRO_PERSONA_ID, type RosterAgent } from '../core/roster';
import {
@@ -35,6 +41,7 @@ import {
} from '../primitives/composer-draft';
import { createPreferredInmemModel } from '../primitives/preferred-inmem-model';
import { createRecentRepositories } from '../primitives/recent-repositories';
+import { createWorkspaceMode } from '../primitives/workspace-mode';
import { createComposerModels } from '../queries/composer-models';
import { createReachableRepositories } from '../queries/reachable-repositories';
import { createRepositoryBranches } from '../queries/repository-branches';
@@ -69,8 +76,12 @@ export function NewChatPage(props: {
autoFocus?: boolean;
registerFocus?: (focus: () => void) => void;
roster: RosterAgent[];
- /** Offer only this kind; the Agents workspace passes its Work or Code mode. */
- kind?: AgentKind;
+ /**
+ * Chat or Code, which also limits the agents offered. Uncontrolled callers
+ * get the signed-in user's last choice.
+ */
+ mode?: AgentsMode;
+ onModeChange?: (mode: AgentsMode) => void;
rosterLoading: boolean;
/** Agents are listed but whether they can start is still unknown. */
availabilityLoading?: boolean;
@@ -79,19 +90,19 @@ export function NewChatPage(props: {
onOpenRoster: (kind: AgentKind) => void;
}) {
const userId = useUserId();
+ const billing = useAiBillingSummaryQuery();
const { openSettings } = useSettingsState();
const recentAgents = createRecentAgentSelections(userId());
const repositories = createRecentRepositories(userId());
const preferredInmem = createPreferredInmemModel(userId());
- const options = () => {
- const kind = props.kind;
- return kind
- ? props.roster.filter((agent) => agent.kind === kind)
- : props.roster;
- };
+ const ownMode = createWorkspaceMode(userId());
+ const mode = () => props.mode ?? ownMode.mode();
+ const options = () =>
+ props.roster.filter((agent) => agent.kind === kindForMode(mode()));
const [agentId, setAgentId] = createSignal<string>();
/** One-shot model from a coding agent's submenu; Macro uses {@link preferredInmem}. */
const [modelOverride, setModelOverride] = createSignal<string>();
+ const [effortPickerOpen, setEffortPickerOpen] = createSignal(false);
const [repositoryPickerOpen, setRepositoryPickerOpen] = createSignal(false);
// A new conversation starts on Automatic until the caller picks a repository.
const [repoUrl, setRepoUrl] = createSignal<string | undefined>();
@@ -168,12 +179,22 @@ export function NewChatPage(props: {
// The submenu already validated this choice. Retain it while the selected
// model's discovery refreshes; startup revalidates against the runtime.
const effortOverride = () => {
- const selection = selectedEffort();
+ const config = effort();
+ const minimum =
+ billing.isSuccess &&
+ (billing.data.tier === 'free' || billing.data.tier === 'premium')
+ ? config?.options[0]
+ : undefined;
+ const selection =
+ selectedEffort() ??
+ (minimum && config
+ ? { configId: config.id, value: minimum.value, name: minimum.name }
+ : undefined);
return selection
? { configId: selection.configId, value: selection.value }
: undefined;
};
- const coding = () => (props.kind ?? selected()?.kind) === 'coder';
+ const coding = () => mode() === 'code';
const localRuntime = () => selected()?.harness === 'macrod';
const canSelectRepository = () =>
selected()?.harness === 'cursor' || localRuntime();
@@ -304,14 +325,22 @@ export function NewChatPage(props: {
);
};
+ let focusInput: (() => void) | undefined;
+ const restoreInputFocus = (event: Event) => {
+ event.preventDefault();
+ focusInput?.();
+ };
const agentSelector = () => (
<AgentPicker
agents={options()}
selected={selected()}
modelOverride={composerModelOverride()}
loading={props.rosterLoading}
- effortLabel={selectedEffort()?.name ?? effortLabel(effort())}
+ effortLabel={
+ selectedEffort()?.name ?? effortLabel(effort(), effortOverride()?.value)
+ }
effortSelection={effortOverride()}
+ onCloseAutoFocus={restoreInputFocus}
onSelect={selectAgent}
onSelectEffort={selectAgent}
onConnect={connect}
@@ -319,18 +348,88 @@ export function NewChatPage(props: {
/>
);
+ const setMode = (next: AgentsMode) => {
+ // A model or effort picked for the other mode's agent does not carry over.
+ setModelOverride(undefined);
+ setEffortSelection(undefined);
+ if (props.onModeChange) props.onModeChange(next);
+ else ownMode.setMode(next);
+ };
+
+ const modeSwitch = () => (
+ <div ref={tourTarget(AGENTS_TOUR.modeSwitch)} class="shrink-0">
+ <Tabs
+ aria-label="Conversation mode"
+ list={(['chat', 'code'] as const).map((mode) => ({
+ value: mode,
+ label: () => (
+ <span class="flex items-center gap-1.5">
+ {mode === 'code' ? (
+ <CodeIcon class="size-3.5" />
+ ) : (
+ <ChatIcon class="size-3.5" />
+ )}
+ {/* Phones keep the icons; the name stays for assistive tech. */}
+ <span class="touch:sr-only">{agentsModeLabel(mode)}</span>
+ </span>
+ ),
+ }))}
+ value={mode()}
+ onChange={(value) => setMode(value === 'code' ? 'code' : 'chat')}
+ labelClass="px-3 touch:px-2.5"
+ />
+ </div>
+ );
+
+ const repositoryPicker = () => (
+ <RepositoryPicker
+ onOpenChange={setRepositoryPickerOpen}
+ repoUrl={repoUrl()}
+ branch={repoBranch()}
+ branchLocked={localRuntime()}
+ repositories={reachable.repositories()}
+ repositoriesLoading={reachable.loading()}
+ repositoriesError={reachable.error()}
+ recentRepositories={repositories.urls()}
+ onRetryRepositories={reachable.retry}
+ branches={reachableBranches.branches()}
+ branchesLoading={reachableBranches.loading()}
+ branchesError={reachableBranches.error()}
+ onRetryBranches={reachableBranches.retry}
+ onConnectGitHub={() => openSettings('Connected')}
+ onSelectRepository={selectRepository}
+ onSelectBranch={setBranchOverride}
+ />
+ );
+
const composer = () => (
<ChatComposer
autoFocus={props.autoFocus}
collapseOnBlur={props.compact}
- controlsOpen={repositoryPickerOpen()}
- registerFocus={props.registerFocus}
+ controlsOpen={repositoryPickerOpen() || effortPickerOpen()}
+ registerFocus={(focus) => {
+ focusInput = focus;
+ props.registerFocus?.(focus);
+ }}
draft={draft()}
onDraftChange={setDraft}
blockedReason={blocked()}
selector={
<div class="flex min-w-0 items-center gap-1">
{agentSelector()}
+ <EffortSelector
+ onCloseAutoFocus={restoreInputFocus}
+ onOpenChange={setEffortPickerOpen}
+ config={effort()}
+ value={effortOverride()?.value}
+ disabled={Boolean(blocked())}
+ onChange={(choice) =>
+ setEffortSelection({
+ ...choice,
+ target: JSON.stringify(capabilityTarget()),
+ })
+ }
+ />
<Show
when={['macro-inmem', 'in-memory'].includes(
selected()?.harness ?? ''
@@ -341,26 +440,16 @@ export function NewChatPage(props: {
</div>
}
drawer={
- <RepositoryPicker
- onOpenChange={setRepositoryPickerOpen}
- repoUrl={repoUrl()}
- branch={repoBranch()}
- branchLocked={localRuntime()}
- repositories={reachable.repositories()}
- repositoriesLoading={reachable.loading()}
- repositoriesError={reachable.error()}
- recentRepositories={repositories.urls()}
- onRetryRepositories={reachable.retry}
- branches={reachableBranches.branches()}
- branchesLoading={reachableBranches.loading()}
- branchesError={reachableBranches.error()}
- onRetryBranches={reachableBranches.retry}
- onConnectGitHub={() => openSettings('Connected')}
- onSelectRepository={selectRepository}
- onSelectBranch={setBranchOverride}
- />
+ <div class="flex w-full min-w-0 items-center gap-2">
+ {modeSwitch()}
+ <Show when={coding()}>
+ <div class="min-w-0 flex-1 touch:[&>div]:justify-end">
+ {repositoryPicker()}
+ </div>
+ </Show>
+ </div>
}
- drawerOpen={coding()}
+ drawerOpen
placeholder={coding() ? 'Describe what you want to build' : undefined}
onSend={send}
supportsImages={
diff --git a/apps/web/src/features/agents-view/views/RepositoryPicker.test.tsx b/apps/web/src/features/agents-view/views/RepositoryPicker.test.tsx
index df8567446e..bc8fae7767 100644
--- a/apps/web/src/features/agents-view/views/RepositoryPicker.test.tsx
+++ b/apps/web/src/features/agents-view/views/RepositoryPicker.test.tsx
@@ -1,8 +1,19 @@
-import { cleanup, fireEvent, render, screen } from '@solidjs/testing-library';
+import { isTouchDevice } from '@core/mobile/isTouchDevice';
+import {
+ cleanup,
+ fireEvent,
+ render,
+ screen,
+ waitFor,
+} from '@solidjs/testing-library';
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
import type { ReachableRepository } from '../core/repository';
import { RepositoryPicker } from './RepositoryPicker';
+vi.mock('@core/mobile/isTouchDevice', () => ({
+ isTouchDevice: vi.fn(() => false),
+}));
+
const macro: ReachableRepository = {
url: 'https://github.com/macro-inc/macro',
defaultBranch: 'main',
@@ -48,12 +59,62 @@ const optionNames = () =>
.map((option) => option.textContent?.replace(/\s+/g, ' ').trim());
describe('RepositoryPicker', () => {
- beforeEach(() => vi.stubGlobal('scrollTo', vi.fn()));
+ beforeEach(() => {
+ vi.mocked(isTouchDevice).mockReturnValue(false);
+ vi.stubGlobal('scrollTo', vi.fn());
+ vi.spyOn(window, 'scrollTo').mockImplementation(() => {});
+ vi.stubGlobal(
+ 'ResizeObserver',
+ class {
+ observe() {}
+ unobserve() {}
+ disconnect() {}
+ }
+ );
+ });
afterEach(() => {
cleanup();
vi.unstubAllGlobals();
});
+ it('searches and selects repositories in the mobile drawer', async () => {
+ vi.mocked(isTouchDevice).mockReturnValue(true);
+ const handlers = picker();
+ openRepositories();
+ expect(
+ await screen.findByRole('dialog', { name: 'Repository' })
+ ).toBeTruthy();
+ const field = await screen.findByRole('combobox', {
+ name: 'Search repositories',
+ });
+ await waitFor(() => expect(document.activeElement).toBe(field));
+ fireEvent.input(field, { target: { value: 'infra' } });
+ expect(optionNames()).toEqual(['macro-inc/infra']);
+ fireEvent.click(screen.getByRole('option', { name: 'macro-inc/infra' }));
+ expect(handlers.onSelectRepository).toHaveBeenCalledExactlyOnceWith(
+ infra.url
+ );
+ });
+
+ it('searches and selects branches in the mobile drawer', async () => {
+ vi.mocked(isTouchDevice).mockReturnValue(true);
+ const handlers = picker({ repoUrl: macro.url });
+ fireEvent.click(screen.getByRole('button', { name: 'Branch' }));
+ expect(
+ await screen.findByRole('dialog', { name: 'Starting branch' })
+ ).toBeTruthy();
+ const field = await screen.findByRole('combobox', {
+ name: 'Search branches',
+ });
+ await waitFor(() => expect(document.activeElement).toBe(field));
+ fireEvent.input(field, { target: { value: 'feature/home' } });
+ expect(optionNames()).toEqual(['feature/home']);
+ fireEvent.click(screen.getByRole('option', { name: 'feature/home' }));
+ expect(handlers.onSelectBranch).toHaveBeenCalledExactlyOnceWith(
+ 'feature/home'
+ );
+ });
+
it('keeps a runtime-enforced branch visible without opening the branch menu', () => {
const handlers = picker({ repoUrl: macro.url, branchLocked: true });
const branch = screen.getByRole('button', { name: 'Branch' });
diff --git a/apps/web/src/features/agents-view/views/RepositoryPicker.tsx b/apps/web/src/features/agents-view/views/RepositoryPicker.tsx
index 1f7d3a6e86..1f55114f6a 100644
--- a/apps/web/src/features/agents-view/views/RepositoryPicker.tsx
+++ b/apps/web/src/features/agents-view/views/RepositoryPicker.tsx
@@ -1,3 +1,5 @@
+import { MobileDrawer } from '@components/app/mobile/MobileDrawer';
+import { isTouchDevice } from '@core/mobile/isTouchDevice';
import { Popover } from '@kobalte/core/popover';
import CaretDownIcon from '@phosphor/caret-down.svg';
import CheckIcon from '@phosphor/check.svg';
@@ -10,6 +12,7 @@ import {
createSignal,
createUniqueId,
For,
+ type JSX,
Match,
Show,
Switch,
@@ -181,7 +184,7 @@ export function RepositoryPicker(props: {
!branchSearch().trim();
return (
<div class="flex min-w-0 w-full items-center gap-2">
- <Popover
+ <RepositoryPickerMenu
open={repoOpen()}
onOpenChange={(open) => {
setRepoOpen(open);
@@ -191,144 +194,134 @@ export function RepositoryPicker(props: {
list.setSelectedIndex(0);
}
}}
- placement="top-start"
- gutter={8}
+ label="Repository"
+ triggerClass="pill min-w-0 max-w-full text-ink"
+ trigger={
+ <>
+ <FolderIcon class="size-4 shrink-0" />
+ <span class="truncate">
+ {props.repoUrl
+ ? repositoryLabel(props.repoUrl)
+ : 'Choose repository'}
+ </span>
+ <CaretDownIcon class="size-3 shrink-0" />
+ </>
+ }
>
- <Popover.Trigger
- class="pill min-w-0 max-w-full text-ink"
- aria-label="Repository"
+ <form
+ onSubmit={(event) => {
+ event.preventDefault();
+ submitRepository();
+ }}
+ class="flex flex-col gap-2"
>
- <FolderIcon class="size-4 shrink-0" />
- <span class="truncate">
- {props.repoUrl
- ? repositoryLabel(props.repoUrl)
- : 'Choose repository'}
- </span>
- <CaretDownIcon class="size-3 shrink-0" />
- </Popover.Trigger>
- <Popover.Portal>
- <Popover.Content class="menu-surface z-action-menu w-80 max-w-[calc(100vw-1rem)] p-3 text-sm">
- <Popover.Title class="mb-2 font-medium">Repository</Popover.Title>
- <form
- onSubmit={(event) => {
+ <input
+ role="combobox"
+ aria-label="Search repositories"
+ aria-expanded="true"
+ aria-controls={listId}
+ aria-activedescendant={highlightedId()}
+ aria-autocomplete="list"
+ autocomplete="off"
+ placeholder="Search, or paste owner/repo"
+ value={search()}
+ onInput={(event) => {
+ setSearch(event.currentTarget.value);
+ setError('');
+ list.setSelectedIndex(0);
+ }}
+ onKeyDown={(event) => {
+ if (event.key === 'ArrowDown') {
event.preventDefault();
- submitRepository();
- }}
- class="flex flex-col gap-2"
- >
- <input
- role="combobox"
- aria-label="Search repositories"
- aria-expanded="true"
- aria-controls={listId}
- aria-activedescendant={highlightedId()}
- aria-autocomplete="list"
- autocomplete="off"
- placeholder="Search, or paste owner/repo"
- value={search()}
- onInput={(event) => {
- setSearch(event.currentTarget.value);
- setError('');
- list.setSelectedIndex(0);
- }}
- onKeyDown={(event) => {
- if (event.key === 'ArrowDown') {
- event.preventDefault();
- list.selectNext();
- scrollHighlightedIntoView();
- } else if (event.key === 'ArrowUp') {
- event.preventDefault();
- list.selectPrevious();
- scrollHighlightedIntoView();
- }
- }}
- class="w-full rounded-lg border border-edge-muted bg-input px-3 py-2 outline-none focus:border-accent"
- />
- <Show when={error()}>
- <p role="alert" class="text-xs text-failure">
- {error()}
- </p>
- </Show>
- </form>
- <div
- id={listId}
- role="listbox"
- aria-label="Repositories"
- class="mt-2 max-h-56 overflow-y-auto"
- >
- <For each={choices()}>
- {(choice, index) => (
- <button
- type="button"
- role="option"
- id={`${listId}-${index()}`}
- aria-selected={list.isSelected(index())}
- class="flex w-full items-center gap-2 rounded-lg px-2 py-2 text-left hover:bg-hover aria-selected:bg-active"
- onClick={() => choose(choice)}
- onMouseMove={() =>
- list.setSelectedIndexFromPointer(index())
- }
- >
- <Show when={choice.kind !== 'automatic'}>
- <GithubIcon class="size-4 shrink-0" />
- </Show>
- <span class="truncate">{rowLabel(choice)}</span>
- <Show when={chosen(choice)}>
- <CheckIcon class="ml-auto size-4 shrink-0" />
- </Show>
- </button>
- )}
- </For>
- <Switch>
- <Match when={props.repositoriesError}>
- <div class="flex items-center justify-between gap-2 px-2 py-2 text-xs text-ink-muted">
- Couldn't load your repositories.
- <Button
- variant="outline"
- size="sm"
- depth={3}
- onClick={() => props.onRetryRepositories()}
- >
- Retry
- </Button>
- </div>
- </Match>
- <Match
- when={props.repositoriesLoading && offered().length === 0}
+ list.selectNext();
+ scrollHighlightedIntoView();
+ } else if (event.key === 'ArrowUp') {
+ event.preventDefault();
+ list.selectPrevious();
+ scrollHighlightedIntoView();
+ }
+ }}
+ class="w-full rounded-lg border border-edge-muted bg-input px-3 py-2 outline-none focus:border-accent"
+ />
+ <Show when={error()}>
+ <p role="alert" class="text-xs text-failure">
+ {error()}
+ </p>
+ </Show>
+ </form>
+ <div
+ id={listId}
+ role="listbox"
+ aria-label="Repositories"
+ class="mt-2 max-h-56 overflow-y-auto"
+ >
+ <For each={choices()}>
+ {(choice, index) => (
+ <button
+ type="button"
+ role="option"
+ id={`${listId}-${index()}`}
+ aria-selected={list.isSelected(index())}
+ class="flex w-full touch:min-h-11 items-center gap-2 rounded-lg px-2 py-2 text-left not-touch:hover:bg-hover aria-selected:bg-active"
+ onClick={() => choose(choice)}
+ onMouseMove={() => list.setSelectedIndexFromPointer(index())}
+ >
+ <Show when={choice.kind !== 'automatic'}>
+ <GithubIcon class="size-4 shrink-0" />
+ </Show>
+ <span class="truncate">{rowLabel(choice)}</span>
+ <Show when={chosen(choice)}>
+ <CheckIcon class="ml-auto size-4 shrink-0" />
+ </Show>
+ </button>
+ )}
+ </For>
+ <Switch>
+ <Match when={props.repositoriesError}>
+ <div class="flex items-center justify-between gap-2 px-2 py-2 text-xs text-ink-muted">
+ Couldn't load your repositories.
+ <Button
+ variant="outline"
+ size="sm"
+ depth={3}
+ onClick={() => props.onRetryRepositories()}
>
- <div class="px-2 py-2 text-xs text-ink-muted">
- Loading your repositories…
- </div>
- </Match>
- <Match when={nothingReachable()}>
- <div class="flex flex-col gap-2 px-2 py-2 text-xs text-ink-muted">
- No repositories yet. Give Macro's GitHub App access to the
- repositories your coders should work on.
- <Show when={props.onConnectGitHub}>
- <Button
- variant="outline"
- size="sm"
- depth={3}
- class="self-start"
- onClick={() => props.onConnectGitHub?.()}
- >
- Connect GitHub
- </Button>
- </Show>
- </div>
- </Match>
- <Match when={choices().length === 0}>
- <div class="px-2 py-2 text-xs text-ink-muted">
- No repositories match “{search().trim()}”.
- </div>
- </Match>
- </Switch>
- </div>
- </Popover.Content>
- </Popover.Portal>
- </Popover>
+ Retry
+ </Button>
+ </div>
+ </Match>
+ <Match when={props.repositoriesLoading && offered().length === 0}>
+ <div class="px-2 py-2 text-xs text-ink-muted">
+ Loading your repositories…
+ </div>
+ </Match>
+ <Match when={nothingReachable()}>
+ <div class="flex flex-col gap-2 px-2 py-2 text-xs text-ink-muted">
+ No repositories yet. Give Macro's GitHub App access to the
+ repositories your coders should work on.
+ <Show when={props.onConnectGitHub}>
+ <Button
+ variant="outline"
+ size="sm"
+ depth={3}
+ class="self-start"
+ onClick={() => props.onConnectGitHub?.()}
+ >
+ Connect GitHub
+ </Button>
+ </Show>
+ </div>
+ </Match>
+ <Match when={choices().length === 0}>
+ <div class="px-2 py-2 text-xs text-ink-muted">
+ No repositories match “{search().trim()}”.
+ </div>
+ </Match>
+ </Switch>
+ </div>
+ </RepositoryPickerMenu>
<Show when={props.repoUrl}>
- <Popover
+ <RepositoryPickerMenu
open={branchOpen()}
onOpenChange={(open) => {
setBranchOpen(open && !props.branchLocked);
@@ -339,144 +332,211 @@ export function RepositoryPicker(props: {
branchList.setSelectedIndex(selected >= 0 ? selected : 0);
}
}}
+ label="Starting branch"
+ triggerLabel="Branch"
+ triggerClass="pill min-w-0 max-w-[45%] text-ink"
+ disabled={props.branchLocked}
+ title={
+ props.branchLocked
+ ? 'New local sessions start from main'
+ : undefined
+ }
+ trigger={
+ <>
+ <GitBranchIcon class="size-4 shrink-0" />
+ <span class="truncate">{props.branch}</span>
+ <Show when={!props.branchLocked}>
+ <CaretDownIcon class="size-3 shrink-0" />
+ </Show>
+ </>
+ }
+ >
+ <form
+ onSubmit={(event) => {
+ event.preventDefault();
+ submitBranch();
+ }}
+ class="flex flex-col gap-2"
+ >
+ <input
+ role="combobox"
+ aria-label="Search branches"
+ aria-expanded="true"
+ aria-controls={branchListId}
+ aria-activedescendant={highlightedBranchId()}
+ aria-autocomplete="list"
+ autocomplete="off"
+ placeholder="Search, or type a branch name"
+ value={branchSearch()}
+ onInput={(event) => {
+ setBranchSearch(event.currentTarget.value);
+ setError('');
+ branchList.setSelectedIndex(0);
+ }}
+ onKeyDown={(event) => {
+ if (event.key === 'ArrowDown') {
+ event.preventDefault();
+ branchList.selectNext();
+ scrollHighlightedBranchIntoView();
+ } else if (event.key === 'ArrowUp') {
+ event.preventDefault();
+ branchList.selectPrevious();
+ scrollHighlightedBranchIntoView();
+ }
+ }}
+ class="w-full rounded-lg border border-edge-muted bg-input px-3 py-2 outline-none focus:border-accent"
+ />
+ <Show when={error()}>
+ <p role="alert" class="text-xs text-failure">
+ {error()}
+ </p>
+ </Show>
+ </form>
+ <div
+ id={branchListId}
+ role="listbox"
+ aria-label="Branches"
+ class="mt-2 max-h-56 overflow-y-auto"
+ >
+ <For each={branchChoices()}>
+ {(choice, index) => (
+ <button
+ type="button"
+ role="option"
+ id={`${branchListId}-${index()}`}
+ aria-selected={branchList.isSelected(index())}
+ class="flex w-full touch:min-h-11 items-center gap-2 rounded-lg px-2 py-2 text-left not-touch:hover:bg-hover aria-selected:bg-active"
+ onClick={() => chooseBranch(choice)}
+ onMouseMove={() =>
+ branchList.setSelectedIndexFromPointer(index())
+ }
+ >
+ <GitBranchIcon class="size-4 shrink-0" />
+ <span class="min-w-0 truncate">
+ {choice.kind === 'typed'
+ ? `Use ${choice.name}`
+ : choice.name}
+ </span>
+ <Show when={choice.name === defaultBranch()}>
+ <span class="shrink-0 text-xs text-ink-muted">
+ {` (default)`}
+ </span>
+ </Show>
+ <Show when={choice.name === props.branch}>
+ <CheckIcon class="ml-auto size-4 shrink-0" />
+ </Show>
+ </button>
+ )}
+ </For>
+ <Switch>
+ <Match when={props.branchesError}>
+ <div class="flex items-center justify-between gap-2 px-2 py-2 text-xs text-ink-muted">
+ Couldn't load this repository's branches.
+ <Button
+ variant="outline"
+ size="sm"
+ depth={3}
+ onClick={() => props.onRetryBranches()}
+ >
+ Retry
+ </Button>
+ </div>
+ </Match>
+ <Match
+ when={props.branchesLoading && props.branches.length === 0}
+ >
+ <div class="px-2 py-2 text-xs text-ink-muted">
+ Loading branches…
+ </div>
+ </Match>
+ <Match when={nothingListed()}>
+ <div class="px-2 py-2 text-xs text-ink-muted">
+ No branches yet. Type a starting branch to use.
+ </div>
+ </Match>
+ <Match when={branchChoices().length === 0}>
+ <div class="px-2 py-2 text-xs text-ink-muted">
+ No branches match “{branchSearch().trim()}”.
+ </div>
+ </Match>
+ </Switch>
+ </div>
+ </RepositoryPickerMenu>
+ </Show>
+ </div>
+ );
+}
+
+/** Keep repository and branch pickers in the platform's standard overlay. */
+function RepositoryPickerMenu(props: {
+ open: boolean;
+ onOpenChange: (open: boolean) => void;
+ label: string;
+ triggerLabel?: string;
+ triggerClass: string;
+ disabled?: boolean;
+ title?: string;
+ trigger: JSX.Element;
+ children: JSX.Element;
+}) {
+ return (
+ <Show
+ when={isTouchDevice()}
+ fallback={
+ <Popover
+ open={props.open}
+ onOpenChange={props.onOpenChange}
placement="top-start"
gutter={8}
>
<Popover.Trigger
- class="pill min-w-0 max-w-[45%] text-ink"
- aria-label="Branch"
- disabled={props.branchLocked}
- title={
- props.branchLocked
- ? 'New local sessions start from main'
- : undefined
- }
+ class={props.triggerClass}
+ aria-label={props.triggerLabel ?? props.label}
+ disabled={props.disabled}
+ title={props.title}
>
- <GitBranchIcon class="size-4 shrink-0" />
- <span class="truncate">{props.branch}</span>
- <Show when={!props.branchLocked}>
- <CaretDownIcon class="size-3 shrink-0" />
- </Show>
+ {props.trigger}
</Popover.Trigger>
<Popover.Portal>
<Popover.Content class="menu-surface z-action-menu w-80 max-w-[calc(100vw-1rem)] p-3 text-sm">
<Popover.Title class="mb-2 font-medium">
- Starting branch
+ {props.label}
</Popover.Title>
- <form
- onSubmit={(event) => {
- event.preventDefault();
- submitBranch();
- }}
- class="flex flex-col gap-2"
- >
- <input
- role="combobox"
- aria-label="Search branches"
- aria-expanded="true"
- aria-controls={branchListId}
- aria-activedescendant={highlightedBranchId()}
- aria-autocomplete="list"
- autocomplete="off"
- placeholder="Search, or type a branch name"
- value={branchSearch()}
- onInput={(event) => {
- setBranchSearch(event.currentTarget.value);
- setError('');
- branchList.setSelectedIndex(0);
- }}
- onKeyDown={(event) => {
- if (event.key === 'ArrowDown') {
- event.preventDefault();
- branchList.selectNext();
- scrollHighlightedBranchIntoView();
- } else if (event.key === 'ArrowUp') {
- event.preventDefault();
- branchList.selectPrevious();
- scrollHighlightedBranchIntoView();
- }
- }}
- class="w-full rounded-lg border border-edge-muted bg-input px-3 py-2 outline-none focus:border-accent"
- />
- <Show when={error()}>
- <p role="alert" class="text-xs text-failure">
- {error()}
- </p>
- </Show>
- </form>
- <div
- id={branchListId}
- role="listbox"
- aria-label="Branches"
- class="mt-2 max-h-56 overflow-y-auto"
- >
- <For each={branchChoices()}>
- {(choice, index) => (
- <button
- type="button"
- role="option"
- id={`${branchListId}-${index()}`}
- aria-selected={branchList.isSelected(index())}
- class="flex w-full items-center gap-2 rounded-lg px-2 py-2 text-left hover:bg-hover aria-selected:bg-active"
- onClick={() => chooseBranch(choice)}
- onMouseMove={() =>
- branchList.setSelectedIndexFromPointer(index())
- }
- >
- <GitBranchIcon class="size-4 shrink-0" />
- <span class="min-w-0 truncate">
- {choice.kind === 'typed'
- ? `Use ${choice.name}`
- : choice.name}
- </span>
- <Show when={choice.name === defaultBranch()}>
- <span class="shrink-0 text-xs text-ink-muted">
- {` (default)`}
- </span>
- </Show>
- <Show when={choice.name === props.branch}>
- <CheckIcon class="ml-auto size-4 shrink-0" />
- </Show>
- </button>
- )}
- </For>
- <Switch>
- <Match when={props.branchesError}>
- <div class="flex items-center justify-between gap-2 px-2 py-2 text-xs text-ink-muted">
- Couldn't load this repository's branches.
- <Button
- variant="outline"
- size="sm"
- depth={3}
- onClick={() => props.onRetryBranches()}
- >
- Retry
- </Button>
- </div>
- </Match>
- <Match
- when={props.branchesLoading && props.branches.length === 0}
- >
- <div class="px-2 py-2 text-xs text-ink-muted">
- Loading branches…
- </div>
- </Match>
- <Match when={nothingListed()}>
- <div class="px-2 py-2 text-xs text-ink-muted">
- No branches yet. Type a starting branch to use.
- </div>
- </Match>
- <Match when={branchChoices().length === 0}>
- <div class="px-2 py-2 text-xs text-ink-muted">
- No branches match “{branchSearch().trim()}”.
- </div>
- </Match>
- </Switch>
- </div>
+ {props.children}
</Popover.Content>
</Popover.Portal>
</Popover>
- </Show>
- </div>
+ }
+ >
+ <MobileDrawer
+ side="bottom"
+ open={props.open}
+ onOpenChange={props.onOpenChange}
+ restoreFocus
+ >
+ <MobileDrawer.Trigger
+ class={props.triggerClass}
+ aria-label={props.triggerLabel ?? props.label}
+ disabled={props.disabled}
+ title={props.title}
+ onPointerDown={(event: PointerEvent) => event.preventDefault()}
+ onMouseDown={(event: MouseEvent) => event.preventDefault()}
+ >
+ {props.trigger}
+ </MobileDrawer.Trigger>
+ <MobileDrawer.Portal>
+ <MobileDrawer.Overlay />
+ <MobileDrawer.Content>
+ <MobileDrawer.Handle />
+ <MobileDrawer.Title class="px-4 pb-3 font-medium">
+ {props.label}
+ </MobileDrawer.Title>
+ <MobileDrawer.ScrollBody>
+ <MobileDrawer.Section>{props.children}</MobileDrawer.Section>
+ </MobileDrawer.ScrollBody>
+ </MobileDrawer.Content>
+ </MobileDrawer.Portal>
+ </MobileDrawer>
+ </Show>
);
}
diff --git a/apps/web/src/features/block-agent/component/AgentComposer.tsx b/apps/web/src/features/block-agent/component/AgentComposer.tsx
index cb6ff07f59..44107e57ab 100644
--- a/apps/web/src/features/block-agent/component/AgentComposer.tsx
+++ b/apps/web/src/features/block-agent/component/AgentComposer.tsx
@@ -19,6 +19,7 @@ import {
uploadInputAttachments,
} from '@channel/Input';
import { toast } from '@core/component/Toast/Toast';
+import { isTouchDevice } from '@core/mobile/isTouchDevice';
import { fireAndForget } from '@core/util/fireAndForget';
import { uploadFile } from '@core/util/upload';
import type { AgentAction } from '@service-agent-harness/generated/schemas';
@@ -48,6 +49,7 @@ import {
} from '../ui';
import type { AgentModelSelectorProps } from '../ui/AgentModelSelector';
import { AgentModelMenuItem } from './AgentModelMenuItem';
+import { EffortSelector } from './EffortSelector';
import { PermissionRequest } from './PermissionRequest';
import { promptActionOf } from './prompt-action';
import { ToolApprovalRequest } from './ToolApprovalRequest';
@@ -216,6 +218,11 @@ export function AgentComposer(props: {
// Down past that row comes back. Plain variables, read only at call time.
let focusQueueBottom: (() => void) | undefined;
let focusInput: (() => void) | undefined;
+ const restoreInputFocus = (event: Event) => {
+ if (!isTouchDevice()) return;
+ event.preventDefault();
+ focusInput?.();
+ };
// The server queue's entries, shaped for display: prompt text as-is, and
// attribution only when somebody other than the current user queued it —
@@ -378,6 +385,7 @@ export function AgentComposer(props: {
modelControl={
<div class="flex min-w-0 items-center gap-1">
<ModelSelector
+ onCloseAutoFocus={restoreInputFocus}
model={metadata()?.model ?? null}
changingTo={changingModel(messages(), metadata()?.model ?? null)}
options={metadata()?.supportedModels ?? []}
@@ -413,6 +421,26 @@ export function AgentComposer(props: {
/>
)}
/>
+ <EffortSelector
+ onCloseAutoFocus={restoreInputFocus}
+ config={effort()}
+ value={changingEffort()}
+ disabled={
+ loadFailed() ||
+ readOnly() ||
+ pending() ||
+ configuring() ||
+ changingEffort() !== undefined ||
+ changingModel(messages(), metadata()?.model ?? null) !==
+ undefined
+ }
+ onChange={(choice) => {
+ const model = metadata()?.model;
+ if (model)
+ fireAndForget(chooseModel(model, choice), 'agent-composer');
+ }}
+ />
+
<Show
when={metadata()?.configOptions.some(
(option) => option.id === 'speed'
diff --git a/apps/web/src/features/block-agent/component/EffortSelector.test.tsx b/apps/web/src/features/block-agent/component/EffortSelector.test.tsx
new file mode 100644
index 0000000000..13f7c710fe
--- /dev/null
+++ b/apps/web/src/features/block-agent/component/EffortSelector.test.tsx
@@ -0,0 +1,118 @@
+/** @vitest-environment jsdom */
+
+import { isTouchDevice } from '@core/mobile/isTouchDevice';
+import {
+ cleanup,
+ fireEvent,
+ render,
+ screen,
+ waitFor,
+} from '@solidjs/testing-library';
+import { afterEach, beforeEach, expect, it, vi } from 'vitest';
+import type { SelectSessionConfigOption } from '../state/session-config';
+import { EffortSelector } from './EffortSelector';
+
+vi.mock('@core/mobile/isTouchDevice', () => ({
+ isTouchDevice: vi.fn(() => false),
+}));
+
+const config: SelectSessionConfigOption = {
+ id: 'effort',
+ name: 'Effort',
+ category: 'thought_level',
+ description: null,
+ type: 'select',
+ currentValue: 'low',
+ options: [
+ { name: 'Low', value: 'low', group: null, description: null },
+ { name: 'High', value: 'high', group: null, description: null },
+ ],
+};
+const originalScrollTo = HTMLElement.prototype.scrollTo;
+beforeEach(() => {
+ HTMLElement.prototype.scrollTo = vi.fn();
+ vi.spyOn(window, 'scrollTo').mockImplementation(() => {});
+ vi.stubGlobal(
+ 'ResizeObserver',
+ class {
+ observe() {}
+ unobserve() {}
+ disconnect() {}
+ }
+ );
+});
+afterEach(() => {
+ cleanup();
+ HTMLElement.prototype.scrollTo = originalScrollTo;
+ vi.unstubAllGlobals();
+});
+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',
+ });
+ }
+);
+it('hides unsupported effort', () => {
+ render(() => <EffortSelector onChange={vi.fn()} />);
+ expect(screen.queryByRole('button')).toBeNull();
+});
+it('does not open while configuration is disabled', () => {
+ render(() => <EffortSelector config={config} disabled onChange={vi.fn()} />);
+ fireEvent.click(screen.getByRole('button', { name: 'Effort: Low' }));
+ expect(screen.queryByRole('group', { name: 'Reasoning effort' })).toBeNull();
+});
+
+it('returns focus to the composer when the mobile chooser closes', async () => {
+ vi.mocked(isTouchDevice).mockReturnValue(true);
+ let input!: HTMLTextAreaElement;
+ render(() => (
+ <>
+ <style>{`[data-corvu-drawer-content] { transition-duration: 0s; }`}</style>
+ <textarea ref={input} aria-label="Message" />
+ <EffortSelector
+ config={config}
+ onChange={vi.fn()}
+ onCloseAutoFocus={(event) => {
+ event.preventDefault();
+ input.focus();
+ }}
+ />
+ </>
+ ));
+ fireEvent.click(screen.getByRole('button', { name: 'Effort: Low' }));
+ const low = await screen.findByRole('button', { name: 'Low' });
+ await waitFor(() => expect(document.activeElement).toBe(low));
+ fireEvent.keyDown(low, { key: 'Escape' });
+ await waitFor(() => expect(document.activeElement).toBe(input));
+});
diff --git a/apps/web/src/features/block-agent/component/EffortSelector.tsx b/apps/web/src/features/block-agent/component/EffortSelector.tsx
new file mode 100644
index 0000000000..7fd5e39a12
--- /dev/null
+++ b/apps/web/src/features/block-agent/component/EffortSelector.tsx
@@ -0,0 +1,160 @@
+import { MobileDrawer } from '@components/app/mobile/MobileDrawer';
+import { isTouchDevice } from '@core/mobile/isTouchDevice';
+import Check from '@phosphor/check.svg';
+import { Button, Dropdown, Tooltip } from '@ui';
+import { createSignal, For, Show } from 'solid-js';
+import type {
+ EffortChoice,
+ SelectSessionConfigOption,
+} from '../state/session-config';
+
+/** Effort control beside the selected model in the composer. */
+export function EffortSelector(props: {
+ config?: SelectSessionConfigOption;
+ value?: string;
+ disabled?: boolean;
+ onChange: (choice: EffortChoice) => void;
+ onOpenChange?: (open: boolean) => void;
+ onCloseAutoFocus?: (event: Event) => void;
+}) {
+ const [open, setOpen] = createSignal(false);
+ const changeOpen = (value: boolean) => {
+ setOpen(value);
+ props.onOpenChange?.(value);
+ };
+ const choices = () => props.config?.options ?? [];
+ const value = () => props.value ?? props.config?.currentValue;
+ const index = () =>
+ Math.max(
+ 0,
+ choices().findIndex((choice) => choice.value === value())
+ );
+ const label = () => choices()[index()]?.name ?? 'Default';
+ const angle = () => {
+ return -70 + (index() / Math.max(1, choices().length - 1)) * 140;
+ };
+ const contents = () => (
+ <svg viewBox="0 0 24 24" class="size-[22px]" fill="none" aria-hidden="true">
+ <path
+ d="M4.5 18a9 9 0 1 1 15 0"
+ stroke="currentColor"
+ stroke-width="1.5"
+ stroke-linecap="round"
+ opacity="0.45"
+ />
+ <g transform={`rotate(${angle()} 12 14)`}>
+ <path
+ d="M12 14V8"
+ stroke="currentColor"
+ stroke-width="1.8"
+ stroke-linecap="round"
+ />
+ </g>
+ <circle cx="12" cy="14" r="2" fill="currentColor" />
+ </svg>
+ );
+ const choose = (choice: SelectSessionConfigOption['options'][number]) => {
+ if (!props.config || props.disabled) return;
+ props.onChange({
+ configId: props.config.id,
+ value: choice.value,
+ name: choice.name,
+ });
+ changeOpen(false);
+ };
+ const optionLabel = (
+ choice: SelectSessionConfigOption['options'][number]
+ ) => (
+ <>
+ <span class="flex-1">{choice.name}</span>
+ <Show when={choice.value === value()}>
+ <Check class="size-4" />
+ </Show>
+ </>
+ );
+ return (
+ <Show when={choices().length > 1}>
+ <Show
+ when={isTouchDevice()}
+ fallback={
+ <Dropdown open={open()} onOpenChange={changeOpen} placement="bottom">
+ <Tooltip label={`Effort: ${label()}`} disabled={open()}>
+ <Dropdown.Trigger
+ variant="ghost"
+ size="sm"
+ class="size-8 rounded-full p-0"
+ disabled={props.disabled}
+ aria-label={`Effort: ${label()}`}
+ >
+ {contents()}
+ </Dropdown.Trigger>
+ </Tooltip>
+ <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>
+ }
+ >
+ <MobileDrawer
+ side="bottom"
+ open={open()}
+ onOpenChange={changeOpen}
+ restoreFocus={!!props.onCloseAutoFocus}
+ onFinalFocus={props.onCloseAutoFocus}
+ >
+ <MobileDrawer.Trigger
+ as={Button}
+ variant="ghost"
+ size="sm"
+ class="size-[34px] rounded-full p-0"
+ disabled={props.disabled}
+ aria-label={`Effort: ${label()}`}
+ title={`Effort: ${label()}`}
+ onPointerDown={(event: PointerEvent) => event.preventDefault()}
+ onMouseDown={(event: MouseEvent) => event.preventDefault()}
+ >
+ {contents()}
+ </MobileDrawer.Trigger>
+ <MobileDrawer.Portal>
+ <MobileDrawer.Overlay />
+ <MobileDrawer.Content aria-label="Reasoning effort">
+ <MobileDrawer.Handle />
+ <MobileDrawer.Title class="px-4 pb-3 font-medium">
+ Reasoning effort
+ </MobileDrawer.Title>
+ <MobileDrawer.ScrollBody>
+ <MobileDrawer.Section
+ role="group"
+ aria-label="Reasoning effort"
+ >
+ <For each={choices()}>
+ {(choice) => (
+ <MobileDrawer.Item
+ aria-pressed={choice.value === value()}
+ disabled={props.disabled}
+ onClick={() => choose(choice)}
+ >
+ {optionLabel(choice)}
+ </MobileDrawer.Item>
+ )}
+ </For>
+ </MobileDrawer.Section>
+ </MobileDrawer.ScrollBody>
+ </MobileDrawer.Content>
+ </MobileDrawer.Portal>
+ </MobileDrawer>
+ </Show>
+ </Show>
+ );
+}
diff --git a/apps/web/src/features/block-agent/ui/AgentModelSelector.test.tsx b/apps/web/src/features/block-agent/ui/AgentModelSelector.test.tsx
index e2cfca87f1..ebf08ee2c0 100644
--- a/apps/web/src/features/block-agent/ui/AgentModelSelector.test.tsx
+++ b/apps/web/src/features/block-agent/ui/AgentModelSelector.test.tsx
@@ -26,7 +26,9 @@ const INMEM_MODELS: ModelOption[] = [
].map((id) => ({ id, name: id, description: null, group: null }));
let motionStyles: HTMLStyleElement;
+const originalScrollTo = HTMLElement.prototype.scrollTo;
beforeEach(() => {
+ HTMLElement.prototype.scrollTo = vi.fn();
// jsdom omits the motion defaults Kobalte and Corvu track presence with.
motionStyles = document.createElement('style');
motionStyles.textContent =
@@ -44,6 +46,7 @@ beforeEach(() => {
});
afterEach(() => {
cleanup();
+ HTMLElement.prototype.scrollTo = originalScrollTo;
motionStyles.remove();
device.touch = false;
vi.unstubAllGlobals();
@@ -126,3 +129,58 @@ describe('agent model selector', () => {
expect(screen.getByRole('button').textContent).toContain('Opus 5 High');
});
});
+
+it('uses the searchable touch sheet with custom desktop model rows', async () => {
+ device.touch = true;
+ const select = vi.fn();
+ render(() => (
+ <AgentModelSelector
+ model="anthropic/claude-opus-5-5"
+ options={[
+ {
+ id: 'anthropic/claude-opus-5-5',
+ name: 'Opus 5.5',
+ description: null,
+ group: null,
+ },
+ {
+ id: 'anthropic/claude-haiku-4-5',
+ name: 'Haiku 4.5',
+ description: null,
+ group: null,
+ },
+ ]}
+ modelRow={() => <div>Desktop custom row</div>}
+ onSelect={select}
+ />
+ ));
+ fireEvent.click(screen.getByRole('button', { name: 'Agent model' }));
+ const search = await screen.findByRole('textbox', { name: 'Search models' });
+ await waitFor(() => expect(document.activeElement).toBe(search));
+ expect(screen.getByRole('radiogroup', { name: 'Suggested' })).toBeTruthy();
+ expect(screen.queryByText('Desktop custom row')).toBeNull();
+ expect(screen.queryByRole('radio', { name: 'Haiku 4.5' })).toBeNull();
+ fireEvent.click(screen.getByRole('button', { name: 'More models' }));
+ expect(screen.getByRole('radio', { name: 'Opus 5.5' })).toBeTruthy();
+ expect(screen.getByRole('radio', { name: 'Haiku 4.5' })).toBeTruthy();
+ fireEvent.click(screen.getByRole('button', { name: 'Back to Suggested' }));
+ fireEvent.input(search, { target: { value: 'haiku' } });
+ fireEvent.click(screen.getByRole('radio', { name: 'Haiku 4.5' }));
+ expect(select).toHaveBeenCalledExactlyOnceWith('anthropic/claude-haiku-4-5');
+ await waitFor(() => expect(screen.queryByRole('dialog')).toBeNull());
+});
+
+it('keeps the touch picker visible while models load', async () => {
+ device.touch = true;
+ render(() => (
+ <AgentModelSelector
+ model="openai/gpt-5.6"
+ options={[]}
+ onSelect={vi.fn()}
+ />
+ ));
+ fireEvent.click(screen.getByRole('button', { name: 'Agent model' }));
+ const status = await screen.findByRole('status');
+ expect(status.textContent).toContain('Waiting for the agent');
+ expect(screen.getByRole('textbox', { name: 'Search models' })).toBeTruthy();
+});
diff --git a/apps/web/src/features/block-agent/ui/AgentModelSelector.tsx b/apps/web/src/features/block-agent/ui/AgentModelSelector.tsx
index 1230cad02a..82bc3ab0af 100644
--- a/apps/web/src/features/block-agent/ui/AgentModelSelector.tsx
+++ b/apps/web/src/features/block-agent/ui/AgentModelSelector.tsx
@@ -10,7 +10,7 @@
*
* 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 search field once the catalog is long enough to need one. Desktop keeps
+ * 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.
*
@@ -27,6 +27,7 @@ import {
type ModelRowProps,
} from '@core/component/AI/component/input/ModelCatalogPicker';
import {
+ buildModelCatalog,
type CatalogModelOption,
isLargeModelCatalog,
matchesModelQuery,
@@ -35,13 +36,16 @@ 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 '@phosphor/arrow-left.svg';
+import CaretRight from '@phosphor/caret-right.svg';
import Check from '@phosphor/check.svg';
import SearchIcon from '@phosphor/magnifying-glass.svg';
+import SquaresFour from '@phosphor/squares-four.svg';
import CaretDown from '@phosphor-icons/core/regular/caret-down.svg?component-solid';
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 { groupOptions, withoutRedundantGroups } from './model-groups';
+import { withoutRedundantGroups } from './model-groups';
/** Compact ghost pill — same size as the short-list trigger and chat's selector. */
const PILL_TRIGGER_CLASS =
@@ -53,8 +57,6 @@ const ROW_HEIGHT_PX = 28;
const MAX_VISIBLE_ROWS = 10;
/** The scroll container's own top padding, inside the capped window. */
const LIST_PADDING_PX = 6;
-/** Past this many models the sheet gets a search field. */
-const SEARCHABLE_MODEL_COUNT = 8;
/**
* Ten whole rows plus half of the eleventh, clamped to the room the popper
@@ -81,12 +83,15 @@ export interface AgentModelSelectorProps {
modelRow?: Component<ModelRowProps>;
/** Receives the id of the model to switch to. */
onSelect: (model: string) => void;
+ onCloseAutoFocus?: (event: Event) => void;
}
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(
@@ -104,19 +109,28 @@ export function AgentModelSelector(props: AgentModelSelectorProps) {
});
const catalogOptions = () => options().map(toCatalogOption);
const useCatalog = () => isLargeModelCatalog(catalogOptions());
- const searchable = () => props.options.length > SEARCHABLE_MODEL_COUNT;
+ const catalog = createMemo(() => buildModelCatalog(catalogOptions(), true));
const groups = createMemo(() => {
- const normalizedQuery = query().trim().toLowerCase();
- const matching = normalizedQuery
- ? options().filter((option) =>
- matchesModelQuery(toCatalogOption(option), normalizedQuery)
- )
- : options();
- return groupOptions(matching);
+ 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('');
+ if (!open) {
+ setQuery('');
+ setShowAll(false);
+ }
};
const pick = (id: string) => {
@@ -129,6 +143,12 @@ export function AgentModelSelector(props: AgentModelSelectorProps) {
side="bottom"
open={sheetOpen()}
onOpenChange={openSheet}
+ restoreFocus={!!props.onCloseAutoFocus}
+ onFinalFocus={props.onCloseAutoFocus}
+ onInitialFocus={(event) => {
+ event.preventDefault();
+ searchInput?.focus();
+ }}
preventScroll={false}
preventScrollbarShift={false}
>
@@ -138,7 +158,9 @@ export function AgentModelSelector(props: AgentModelSelectorProps) {
variant="ghost"
size="sm"
aria-label="Agent model"
- disabled={props.disabled}
+ 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()} />
@@ -149,23 +171,43 @@ export function AgentModelSelector(props: AgentModelSelectorProps) {
<MobileDrawer.Overlay />
<MobileDrawer.Content aria-label="Choose a model">
<MobileDrawer.Handle />
- <Show when={searchable()}>
- <div class="mx-4 mb-3 flex shrink-0 items-center gap-2 rounded-lg border border-edge-muted bg-surface px-3 py-2">
- <SearchIcon class="size-3.5 shrink-0 text-ink-muted" />
- <input
- type="text"
- aria-label="Search models"
- placeholder="Search models"
- value={query()}
- onInput={(event) => setQuery(event.currentTarget.value)}
- class="min-w-0 flex-1 bg-transparent text-sm text-ink outline-none placeholder:text-ink-placeholder"
- />
- </div>
- </Show>
- <MobileDrawer.ScrollBody>
+ <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 class="px-4 py-6 text-center text-sm text-ink-muted">
- No models match that search.
+ <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()}>
@@ -173,13 +215,15 @@ export function AgentModelSelector(props: AgentModelSelectorProps) {
<>
<Show when={group.label}>
{(heading) => (
- <MobileDrawer.Label>{heading()}</MobileDrawer.Label>
+ <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="mb-3 flex shrink-0 flex-col"
+ class="rounded-none bg-transparent p-0"
>
<For each={group.options}>
{(option) => (
@@ -192,7 +236,7 @@ export function AgentModelSelector(props: AgentModelSelectorProps) {
>
<ModelIcon model={option.id} />
<span class="min-w-0 flex-1 truncate">
- {modelLabel(option.id, option.name)}
+ {option.label}
</span>
<Show when={option.id === shown()}>
<Check class="size-3.5 shrink-0 text-accent" />
@@ -204,6 +248,24 @@ export function AgentModelSelector(props: AgentModelSelectorProps) {
</>
)}
</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>
@@ -258,8 +320,8 @@ export function AgentModelSelector(props: AgentModelSelectorProps) {
);
return (
- <Show when={props.options.length > 0}>
- <Show when={!isTouchDevice() || props.modelRow} fallback={sheet}>
+ <Show when={isTouchDevice() || props.options.length > 0}>
+ <Show when={!isTouchDevice()} fallback={sheet}>
<Show when={useCatalog() || props.modelRow} fallback={shortList}>
<ModelCatalogPicker
value={shown()}
diff --git a/apps/web/src/features/routines/views/routine-execution-picker.tsx b/apps/web/src/features/routines/views/routine-execution-picker.tsx
index 9b8d2df3cd..9cdd73dd7f 100644
--- a/apps/web/src/features/routines/views/routine-execution-picker.tsx
+++ b/apps/web/src/features/routines/views/routine-execution-picker.tsx
@@ -123,6 +123,7 @@ export function RoutineExecutionPickerView(props: Props): JSX.Element {
class="min-w-0 max-w-full"
>
<AgentPicker
+ showModelLabel
triggerClass={badgeTriggerClasses({
variant: 'outline',
size: 'sm',
diff --git a/apps/web/src/lib/core/component/AI/component/input/ModelCatalogPicker.test.tsx b/apps/web/src/lib/core/component/AI/component/input/ModelCatalogPicker.test.tsx
index 6b461f94bc..5bb17ffa4b 100644
--- a/apps/web/src/lib/core/component/AI/component/input/ModelCatalogPicker.test.tsx
+++ b/apps/web/src/lib/core/component/AI/component/input/ModelCatalogPicker.test.tsx
@@ -18,18 +18,6 @@ import {
} from './ModelCatalogPicker';
import type { CatalogModelOption } from './modelCatalog';
-const { isMobileWidth, setMobileWidth } = vi.hoisted(() => {
- let mobile = false;
- return {
- isMobileWidth: () => mobile,
- setMobileWidth: (value: boolean) => {
- mobile = value;
- },
- };
-});
-
-vi.mock('@core/mobile/mobileWidth', () => ({ isMobileWidth }));
-
vi.mock('@ui', () => {
const cn = (...args: unknown[]) =>
args.flat(Infinity).filter(Boolean).join(' ');
@@ -93,9 +81,7 @@ vi.mock('@ui', () => {
Dropdown.SubTrigger = (props: { children?: JSX.Element }) => (
<div>{props.children}</div>
);
- Dropdown.SubContent = (props: { children?: JSX.Element }) => (
- <div>{props.children}</div>
- );
+ Dropdown.SubContent = () => null;
return { cn, Dropdown };
});
@@ -111,7 +97,6 @@ const OPTIONS: CatalogModelOption[] = [
afterEach(() => {
cleanup();
- setMobileWidth(false);
});
function mountPicker() {
@@ -258,25 +243,31 @@ describe('ModelCatalogMenu search focus', () => {
});
});
-describe('ModelCatalogPicker more models at phone width', () => {
- it('replaces the list in place and comes back', () => {
- setMobileWidth(true);
+describe('ModelCatalogPicker frontier and providers', () => {
+ it('shows suggested choices with a full-catalog submenu', () => {
mountPicker();
- fireEvent.click(screen.getByRole('button', { name: 'Agent model' }));
-
- expect(screen.queryByText('Gemini 3.8 Flash High')).toBeNull();
-
- fireEvent.click(screen.getByText('More models'));
- expect(screen.getByText('Gemini 3.8 Flash High')).toBeTruthy();
- expect(screen.queryByText('Opus 5.5 High')).toBeNull();
-
- fireEvent.click(screen.getByRole('menuitem', { name: 'Recommended' }));
- expect(screen.getByText('Opus 5.5 High')).toBeTruthy();
- expect(screen.queryByText('Gemini 3.8 Flash High')).toBeNull();
+ expect(screen.getByText('Suggested')).toBeTruthy();
+ expect(screen.getByText('More models')).toBeTruthy();
+ expect(screen.queryByText('Google')).toBeNull();
+ expect(screen.queryByText('Recommended')).toBeNull();
+ });
+ it('includes suggested choices in the full provider catalog', () => {
+ render(() => (
+ <ModelCatalogMenu
+ fullCatalog
+ value="auto"
+ options={OPTIONS}
+ onSelect={() => {}}
+ />
+ ));
+ expect(screen.queryByText('Suggested')).toBeNull();
+ expect(screen.queryByText('More models')).toBeNull();
+ expect(screen.getByText('Google')).toBeTruthy();
+ for (const option of OPTIONS)
+ expect(screen.getByRole('menuitem', { name: option.label })).toBeTruthy();
});
- it('uses the supplied model row for models beyond the recommended list', () => {
- setMobileWidth(true);
+ it('uses the supplied model row for both frontier and provider choices', () => {
const CustomRow = (props: ModelRowProps) => (
<button type="button" onClick={props.onSelect}>
Custom {props.option.label}
@@ -294,8 +285,15 @@ describe('ModelCatalogPicker more models at phone width', () => {
/>
);
});
-
- fireEvent.click(screen.getByText('More models'));
+ fireEvent.click(
+ screen.getByRole('button', { name: 'Custom Opus 5.5 High' })
+ );
+ expect(
+ screen.getByRole('button', { name: 'Agent model' }).textContent
+ ).toContain('Opus 5.5 High');
+ fireEvent.input(screen.getByRole('textbox', { name: 'Search models' }), {
+ target: { value: 'Google' },
+ });
fireEvent.click(
screen.getByRole('button', { name: 'Custom Gemini 3.8 Flash High' })
);
@@ -303,4 +301,14 @@ describe('ModelCatalogPicker more models at phone width', () => {
screen.getByRole('button', { name: 'Agent model' }).textContent
).toContain('Gemini 3.8 Flash High');
});
+
+ it('searches the entire catalog by provider name', () => {
+ mountPicker();
+ fireEvent.input(screen.getByRole('textbox', { name: 'Search models' }), {
+ target: { value: 'Google' },
+ });
+ expect(screen.getByText('Gemini 3.8 Flash High')).toBeTruthy();
+ expect(screen.queryByText('Opus 5.5 High')).toBeNull();
+ expect(screen.queryByText('Suggested')).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.tsx
index a6cfd3c3f6..570e2d919f 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
@@ -3,6 +3,7 @@ import CaretDown from '@phosphor/caret-left.svg';
import CaretRight from '@phosphor/caret-right.svg';
import CheckIcon from '@phosphor/check.svg';
import MagnifyingGlassIcon from '@phosphor/magnifying-glass.svg';
+import SquaresFour from '@phosphor/squares-four.svg';
import { cn, Dropdown } from '@ui';
import {
type Component,
@@ -18,19 +19,15 @@ import { ModelIcon } from '../ProviderIcon';
import {
buildModelCatalog,
type CatalogModelOption,
- MAX_RECOMMENDED_MODELS,
- type ModelFamily,
matchesModelQuery,
- modelFamilyHint,
- moreModelFamilies,
+ modelProviderLabel,
} from './modelCatalog';
type ModelCatalogPickerProps = {
value: string | null;
- /** Model to feature first without marking it selected. */
- recommendedId?: string | null;
options: CatalogModelOption[];
onSelect: (id: string) => void;
+ onCloseAutoFocus?: (event: Event) => void;
modelRow?: Component<ModelRowProps>;
disabled?: boolean;
pending?: boolean;
@@ -76,9 +73,10 @@ export function ModelRow(props: ModelRowProps) {
);
}
-/** The remaining families, grouped, for the More models screen. */
-function FamilyList(props: {
- families: ModelFamily[];
+/** One model section, shared by the frontier shortlist and provider groups. */
+function ModelList(props: {
+ label: string;
+ options: CatalogModelOption[];
value: string | null;
disabled?: boolean;
onSelect: (id: string) => void;
@@ -87,26 +85,22 @@ function FamilyList(props: {
}) {
const Row = props.row;
return (
- <For each={props.families}>
- {(family) => (
- <>
- <Show when={family.label}>
- <Dropdown.GroupLabel>{family.label}</Dropdown.GroupLabel>
- </Show>
- <For each={family.options}>
- {(option) => (
- <Row
- option={option}
- onClose={props.onClose}
- selected={option.id === props.value}
- disabled={props.disabled}
- onSelect={() => props.onSelect(option.id)}
- />
- )}
- </For>
- </>
- )}
- </For>
+ <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
+ option={option}
+ onClose={props.onClose}
+ selected={option.id === props.value}
+ disabled={props.disabled}
+ onSelect={() => props.onSelect(option.id)}
+ />
+ )}
+ </For>
+ </Dropdown.Group>
);
}
@@ -144,7 +138,7 @@ function keepSearchFocused(input: () => HTMLInputElement | undefined) {
const onNavigate = (event: Event) => {
if (
event.target instanceof Element &&
- event.target.closest('[role="menuitem"]')
+ event.target.closest('[role="menuitem"], input[type="range"]')
) {
navigating = true;
}
@@ -215,6 +209,7 @@ export function ModelCatalogPicker(props: ModelCatalogPickerProps) {
<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(
@@ -228,7 +223,6 @@ export function ModelCatalogPicker(props: ModelCatalogPickerProps) {
>
<ModelCatalogMenu
value={props.value}
- recommendedId={props.recommendedId}
options={props.options}
disabled={props.disabled || props.pending}
onSelect={(id) => {
@@ -256,7 +250,6 @@ export function ModelCatalogMenu(
ModelCatalogPickerProps,
| 'modelRow'
| 'value'
- | 'recommendedId'
| 'options'
| 'onSelect'
| 'disabled'
@@ -266,22 +259,21 @@ export function ModelCatalogMenu(
> & {
searchRef?: (element: HTMLInputElement) => void;
/**
- * Focus search when this catalog mounts — used by hover-opened agent
- * submenus, which never fire the root menu's `onOpenAutoFocus`.
+ * Focus search when this catalog mounts, including root agent pickers
+ * and hover-opened submenus without their own autofocus handler.
*/
autoFocusSearch?: boolean;
+ fullCatalog?: boolean;
onClose?: () => void;
}
) {
let searchEl: HTMLInputElement | undefined;
const Row = props.modelRow ?? ModelRow;
const [query, setQuery] = createSignal('');
+ const [showAll, setShowAll] = createSignal(false);
onMount(() => {
if (props.autoFocusSearch) keepSearchFocused(() => searchEl);
});
- // A submenu needs a second menu's width beside the first, which a phone
- // does not have: there, More models replaces the list in place instead.
- const [showingMore, setShowingMore] = createSignal(false);
const normalizedQuery = () => query().trim().toLowerCase();
const filtered = createMemo(() => {
const currentQuery = normalizedQuery();
@@ -290,23 +282,12 @@ export function ModelCatalogMenu(
matchesModelQuery(option, currentQuery)
);
});
- const catalog = createMemo(() =>
- props.options.length <= MAX_RECOMMENDED_MODELS
- ? { recommended: props.options, families: [] }
- : buildModelCatalog(
- props.options,
- props.value ?? props.recommendedId ?? undefined
- )
- );
- const extraFamilies = createMemo(() => moreModelFamilies(catalog()));
- const extraCount = createMemo(() =>
- extraFamilies().reduce((count, family) => count + family.options.length, 0)
- );
+ const catalog = createMemo(() => buildModelCatalog(props.options, true));
return (
<>
- <div class="bg-menu p-1.5">
- <div class="flex items-center gap-2 px-2">
+ <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"
@@ -328,7 +309,7 @@ export function ModelCatalogMenu(
onKeyUp={(event) => {
if (event.key !== 'Escape') event.stopPropagation();
}}
- class="min-w-0 w-full border-0 bg-transparent py-2 text-sm text-ink outline-none placeholder:text-ink-extra-muted"
+ 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>
@@ -342,100 +323,111 @@ export function ModelCatalogMenu(
<Show
when={normalizedQuery().length > 0}
fallback={
- <Show
- when={!(isMobileWidth() && showingMore())}
- fallback={
- <Dropdown.Group class="max-h-72 overflow-y-auto overscroll-contain">
- <Dropdown.Item
- closeOnSelect={false}
- class="h-8 gap-2 text-ink-muted"
- onSelect={() => setShowingMore(false)}
- >
- <CaretRight class="size-3 shrink-0 rotate-180" />
- <span class="min-w-0 flex-1 truncate text-sm">
- Recommended
- </span>
- </Dropdown.Item>
- <FamilyList
- families={extraFamilies()}
- value={props.value}
- disabled={props.disabled}
- onSelect={props.onSelect}
- row={Row}
- onClose={props.onClose}
- />
- </Dropdown.Group>
- }
- >
- <Show when={catalog().recommended.length > 0}>
- <Dropdown.Group>
- <Dropdown.GroupLabel>Recommended</Dropdown.GroupLabel>
- <For each={catalog().recommended}>
- {(option) => (
- <Row
- option={option}
- onClose={props.onClose}
- hint={modelFamilyHint(option)}
- selected={option.id === props.value}
- disabled={props.disabled}
- onSelect={() => props.onSelect(option.id)}
- />
- )}
- </For>
- </Dropdown.Group>
+ <div class="space-y-1">
+ <Show
+ when={
+ !props.fullCatalog &&
+ !showAll() &&
+ catalog().frontier.length > 0
+ }
+ >
+ <ModelList
+ label="Suggested"
+ options={catalog().frontier}
+ value={props.value}
+ disabled={props.disabled}
+ onSelect={props.onSelect}
+ row={Row}
+ onClose={props.onClose}
+ />
</Show>
-
- <Show when={extraCount() > 0}>
- <Dropdown.Group>
- <Show
- when={!isMobileWidth()}
- fallback={
+ <Show
+ when={
+ props.fullCatalog ||
+ showAll() ||
+ catalog().frontier.length === 0
+ }
+ fallback={
+ <div class="px-1.5 pb-1">
+ <Show
+ when={isMobileWidth()}
+ fallback={
+ <Dropdown.Sub>
+ <Dropdown.SubTrigger class="h-8 gap-2">
+ <SquaresFour class="size-4 shrink-0 text-ink-muted" />
+ <span class="flex-1">More models</span>
+ <CaretRight class="size-3.5" />
+ </Dropdown.SubTrigger>
+ <Dropdown.SubContent
+ aria-label="All models"
+ class="w-72 max-w-[calc(100vw-1rem)] max-h-[min(28rem,var(--kb-popper-content-available-height))] overflow-y-auto overscroll-contain"
+ onOpenAutoFocus={(event: Event) =>
+ event.preventDefault()
+ }
+ onPointerDown={(event: PointerEvent) =>
+ event.stopPropagation()
+ }
+ onMouseDown={(event: MouseEvent) =>
+ event.stopPropagation()
+ }
+ >
+ <ModelCatalogMenu
+ fullCatalog
+ autoFocusSearch
+ value={props.value}
+ options={props.options}
+ disabled={props.disabled}
+ onSelect={props.onSelect}
+ modelRow={Row}
+ onClose={props.onClose}
+ />
+ </Dropdown.SubContent>
+ </Dropdown.Sub>
+ }
+ >
<Dropdown.Item
+ class="h-8 gap-2"
closeOnSelect={false}
- class="justify-between"
- onSelect={() => setShowingMore(true)}
+ onSelect={() => {
+ setShowAll(true);
+ searchEl?.focus();
+ }}
>
- <span class="truncate">More models</span>
- <span class="flex shrink-0 items-center gap-1 text-xs text-ink-extra-muted">
- {extraCount()}
- <CaretRight class="size-3" />
- </span>
+ <SquaresFour class="size-4 shrink-0 text-ink-muted" />
+ <span class="flex-1">More models</span>
+ <CaretRight class="size-3.5" />
</Dropdown.Item>
- }
+ </Show>
+ </div>
+ }
+ >
+ <Show when={showAll()}>
+ <Dropdown.Item
+ closeOnSelect={false}
+ onSelect={() => {
+ setShowAll(false);
+ setQuery('');
+ searchEl?.focus();
+ }}
>
- <Dropdown.Sub overlap>
- <Dropdown.SubTrigger>
- <span class="truncate">More models</span>
- <span class="flex shrink-0 items-center gap-1 text-xs text-ink-extra-muted">
- {extraCount()}
- <CaretRight class="size-3" />
- </span>
- </Dropdown.SubTrigger>
- <Dropdown.SubContent
- onPointerDown={(event: PointerEvent) =>
- event.stopPropagation()
- }
- onMouseDown={(event: MouseEvent) =>
- event.stopPropagation()
- }
- class="w-72 max-w-[calc(100vw-1rem)] max-h-[var(--kb-popper-content-available-height)] overflow-y-auto overscroll-contain"
- >
- <Dropdown.Group class="max-h-72 overflow-y-auto overscroll-contain">
- <FamilyList
- families={extraFamilies()}
- value={props.value}
- disabled={props.disabled}
- onSelect={props.onSelect}
- row={Row}
- onClose={props.onClose}
- />
- </Dropdown.Group>
- </Dropdown.SubContent>
- </Dropdown.Sub>
- </Show>
- </Dropdown.Group>
+ Back to Suggested
+ </Dropdown.Item>
+ </Show>
+ <For each={catalog().providers}>
+ {(provider) => (
+ <ModelList
+ label={provider.label}
+ options={provider.options}
+ value={props.value}
+ disabled={props.disabled}
+ onSelect={props.onSelect}
+ row={Row}
+ onClose={props.onClose}
+ />
+ )}
+ </For>
</Show>
- </Show>
+ </div>
}
>
<Dropdown.Group class="max-h-72 overflow-y-auto overscroll-contain">
@@ -449,7 +441,7 @@ export function ModelCatalogMenu(
<Row
option={option}
onClose={props.onClose}
- hint={modelFamilyHint(option)}
+ hint={modelProviderLabel(option)}
selected={option.id === props.value}
disabled={props.disabled}
onSelect={() => props.onSelect(option.id)}
diff --git a/apps/web/src/lib/core/component/AI/component/input/modelCatalog.test.ts b/apps/web/src/lib/core/component/AI/component/input/modelCatalog.test.ts
new file mode 100644
index 0000000000..7303a87b81
--- /dev/null
+++ b/apps/web/src/lib/core/component/AI/component/input/modelCatalog.test.ts
@@ -0,0 +1,98 @@
+import { describe, expect, it } from 'vitest';
+import {
+ buildModelCatalog,
+ type CatalogModelOption,
+ matchesModelQuery,
+} from './modelCatalog';
+
+describe('model catalog sections', () => {
+ it('keeps flagship models first and leaves all other variants in their providers', () => {
+ const options: CatalogModelOption[] = [
+ { id: 'sol-high', label: 'GPT-5.6 Sol High' },
+ { id: 'opus-fast', label: 'Opus 5.5 Fast' },
+ { id: 'google/gemini-3.8-flash', label: 'Gemini 3.8 Flash' },
+ { id: 'openai/gpt-6-astra', label: 'GPT-6 Astra' },
+ { id: 'sonnet', label: 'Sonnet 5.5' },
+ { id: 'sol', label: 'GPT-5.6 Sol' },
+ { id: 'opus', label: 'Opus 5.5' },
+ { id: 'opus-old', label: 'Opus 4.8' },
+ ];
+ const catalog = buildModelCatalog(options);
+ expect(catalog.frontier.map((option) => option.id)).toEqual([
+ 'opus',
+ 'sonnet',
+ 'sol',
+ 'openai/gpt-6-astra',
+ 'google/gemini-3.8-flash',
+ ]);
+ expect(
+ catalog.providers
+ .find((group) => group.label === 'Anthropic')
+ ?.options.map((option) => option.id)
+ ).toEqual(['opus-fast', 'opus-old']);
+ expect(
+ catalog.providers
+ .find((group) => group.label === 'OpenAI')
+ ?.options.map((option) => option.id)
+ ).toEqual(['sol-high']);
+ const displayed = [
+ ...catalog.frontier,
+ ...catalog.providers.flatMap((group) => group.options),
+ ];
+ expect(displayed.map((option) => option.id).sort()).toEqual(
+ options.map((option) => option.id).sort()
+ );
+ });
+
+ it('does not invent frontier choices for a restricted catalog', () => {
+ const option = { id: 'custom', label: 'Custom model' };
+ expect(buildModelCatalog([option])).toEqual({
+ frontier: [],
+ providers: [{ label: 'Other models', options: [option] }],
+ });
+ });
+
+ it('groups routed and bare models by author rather than their serving gateway', () => {
+ const catalog = buildModelCatalog([
+ { id: 'fireworks/glm-5p3', label: 'GLM 5.3', group: 'GLM' },
+ { id: 'fireworks/qwen3p8-max', label: 'Qwen3.8 Max' },
+ { id: 'cerebras/gpt-oss-120b', label: 'GPT OSS 120B' },
+ { id: 'fireworks/kimi-k3', label: 'Kimi K3' },
+ { id: 'grok-4.6', label: 'Cursor Grok 4.6' },
+ { id: 'auto', label: 'Auto' },
+ { id: 'private-model', label: 'Custom model' },
+ ]);
+ expect(catalog.providers.map((group) => group.label)).toEqual([
+ 'Automatic',
+ 'OpenAI',
+ 'Alibaba',
+ 'Moonshot AI',
+ 'xAI',
+ 'Z.ai',
+ 'Other models',
+ ]);
+ });
+
+ it('keeps distinct model IDs with the same display name selectable', () => {
+ const options = [
+ { id: 'model-a', label: 'Custom model' },
+ { id: 'model-b', label: 'Custom model' },
+ ];
+ expect(buildModelCatalog(options).providers[0]?.options).toEqual(options);
+ });
+
+ it('finds a model by provider even when the runtime used a bare ID', () => {
+ expect(matchesModelQuery({ id: 'glm-5p3', label: 'GLM 5.3' }, 'z.ai')).toBe(
+ true
+ );
+ expect(
+ matchesModelQuery({ id: 'gpt-5.6', label: 'GPT-5.6' }, 'openai')
+ ).toBe(true);
+ expect(
+ matchesModelQuery(
+ { id: 'gemini', label: 'Gemini 3.8 Flash' },
+ 'anthropic'
+ )
+ ).toBe(false);
+ });
+});
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.ts
index c0579764a3..bf9c2a3ee1 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
@@ -1,46 +1,26 @@
+import { modelProvider } from '../ProviderIcon';
+
export type CatalogModelOption = {
id: string;
label: string;
description?: string;
/**
* The heading the harness listed this model under (an ACP select group
- * name). Absent when the harness offered a flat list, in which case the
- * catalog has one unlabelled family.
+ * name), also available as a search term.
*/
group?: string;
};
-export type ModelFamily = {
- /** `null` for models the harness did not put under any heading. */
- label: string | null;
+export type ModelProviderGroup = {
+ label: string;
options: CatalogModelOption[];
};
export type ModelCatalog = {
- recommended: CatalogModelOption[];
- families: ModelFamily[];
+ frontier: CatalogModelOption[];
+ providers: ModelProviderGroup[];
};
-/**
- * The flagship models to feature on the first screen, matched against the
- * label the harness gave them. Product curation, not grouping: which model
- * belongs to which family is the harness's call and arrives on `group`.
- */
-const RECOMMENDED_PREFIXES = [
- 'Auto',
- 'Cursor Grok 4.6',
- 'Opus 5.5',
- 'Sonnet 5.5',
- 'GPT-5.6 Sol',
- 'Gemini 3.8 Flash',
- 'Codex',
- 'GLM 5.3',
- 'Kimi K3',
-] as const;
-
-/** First-screen shortlist size; the rest goes behind More models. */
-export const MAX_RECOMMENDED_MODELS = 5;
-
/** Large third-party catalogs need structure rather than one long flat list. */
export function isLargeModelCatalog(options: readonly CatalogModelOption[]) {
return options.length > 10;
@@ -68,9 +48,8 @@ function isVersionToken(token: string): boolean {
* `o3 Pro`), is its own family.
*
* This is the same rule the Cursor ACP agent applies before it sends ACP
- * groups (`CursorModel::family` in `crates/cursor_cloud_agents`). It runs
- * here only for harnesses that sent no groups, so those catalogs read the
- * same way rather than as one long flat list.
+ * groups (`CursorModel::family` in `crates/cursor_cloud_agents`). It remains
+ * searchable for harnesses that sent no groups.
*/
export function inferModelFamily(label: string): string {
const tokens = label
@@ -93,107 +72,101 @@ export function inferModelFamily(label: string): string {
return family.join(' ');
}
-function bucketBy(
- options: readonly CatalogModelOption[],
- labelOf: (option: CatalogModelOption) => string | null
-): ModelFamily[] {
- const families: ModelFamily[] = [];
- for (const option of options) {
- const label = labelOf(option);
- const family = families.find((candidate) => candidate.label === label);
- if (family) family.options.push(option);
- else families.push({ label, options: [option] });
+const PROVIDER_PATTERNS: [RegExp, string][] = [
+ [/^(anthropic|claude|opus|sonnet|haiku)\b/, 'Anthropic'],
+ [/^(openai|gpt|chatgpt|codex|sol|astra)\b|^o[134](?:$|[ -])/, 'OpenAI'],
+ [/^(google|gemini|gemma)\b/, 'Google'],
+ [/^(cursor[ -])?grok\b|^xai\b/, 'xAI'],
+ [/^deepseek\b/, 'DeepSeek'],
+ [/^(kimi|moonshot)\b/, 'Moonshot AI'],
+ [/^glm(?=\b|\d)|^(z\.ai|zai)\b/, 'Z.ai'],
+ [/^qwen(?=\b|\d)|^alibaba\b/, 'Alibaba'],
+ [/^minimax\b/, 'MiniMax'],
+ [/^llama(?=\b|\d)|^meta\b/, 'Meta'],
+ [/^(nemotron|nvidia)\b/, 'NVIDIA'],
+ [/^(mistral|mixtral|codestral|devstral)\b/, 'Mistral'],
+ [/^muse\b/, 'Muse'],
+ [/^cursor\b/, 'Cursor'],
+];
+
+/** Model authors, independent of the gateway serving a routed model. */
+export function modelProviderLabel(option: CatalogModelOption): string {
+ const id = option.id.toLowerCase().replace(/^[\w.-]+\//, '');
+ const name = option.label.toLowerCase();
+ const group = option.group?.toLowerCase() ?? '';
+ const matches = (pattern: RegExp) =>
+ pattern.test(id) || pattern.test(name) || pattern.test(group);
+ if (matches(/^(auto|automatic|default)(?:$|[ -])/)) return 'Automatic';
+ const known =
+ modelProvider(option.id) ??
+ modelProvider(id) ??
+ modelProvider(name.replace(/\s+/g, '-'));
+ if (known) {
+ return {
+ anthropic: 'Anthropic',
+ openai: 'OpenAI',
+ google: 'Google',
+ kimi: 'Moonshot AI',
+ deepseek: 'DeepSeek',
+ muse: 'Muse',
+ }[known];
}
- return families;
+ return (
+ PROVIDER_PATTERNS.find(([pattern]) => matches(pattern))?.[1] ??
+ 'Other models'
+ );
}
/**
- * Bucket options under the harness's headings, in the order it listed them.
- * A harness that sent no headings gets them inferred from the names; if that
- * still finds no family with two members, the list stays one unlabelled
- * family rather than gaining a header per model.
+ * Flagship choices, followed by Gemini. Prefer the base model over effort/speed
+ * variants; every other variant remains in its provider's section. Include
+ * suggested choices in provider groups when building the complete catalog.
*/
-function familiesOf(options: readonly CatalogModelOption[]): ModelFamily[] {
- if (options.some((option) => option.group)) {
- return bucketBy(options, (option) => option.group ?? null);
- }
- const inferred = bucketBy(options, (option) =>
- inferModelFamily(option.label)
- );
- return inferred.some((family) => family.options.length > 1)
- ? inferred
- : [{ label: null, options: [...options] }];
-}
-
export function buildModelCatalog(
options: readonly CatalogModelOption[],
- selectedId?: string | null
+ includeSuggested = false
): ModelCatalog {
- const families = familiesOf(options);
- const recommended: CatalogModelOption[] = [];
- const recommendedIds = new Set<string>();
- const recommendedLabels = new Set<string>();
-
- const pushRecommended = (option: CatalogModelOption | undefined) => {
- if (
- !option ||
- recommended.length >= MAX_RECOMMENDED_MODELS ||
- recommendedIds.has(option.id) ||
- recommendedLabels.has(option.label)
- )
- return;
- recommended.push(option);
- recommendedIds.add(option.id);
- recommendedLabels.add(option.label);
- };
-
- pushRecommended(options.find((option) => option.id === selectedId));
- for (const prefix of RECOMMENDED_PREFIXES) {
- pushRecommended(
- options.find((option) =>
- prefix === 'Codex'
- ? option.label.startsWith(prefix)
- : option.label === prefix || option.label.startsWith(`${prefix} `)
- )
+ const frontierPatterns = [
+ /^(?:claude[ -])?opus[ -]5[.-]5(?:$|[ -])/i,
+ /^(?:claude[ -])?sonnet[ -]5[.-]5(?:$|[ -])/i,
+ /^(?:gpt[ -]\d+(?:\.\d+)?[ -])?sol(?:$|[ -])|^gpt[ -]5\.6(?:[ -]sol)?(?:$|[ -](?:high|medium|low|fast)\b)/i,
+ /^(?:gpt[ -]\d+(?:\.\d+)?[ -])?astra(?:$|[ -])/i,
+ /^gemini\b/i,
+ ];
+ const frontier: CatalogModelOption[] = [];
+ for (const pattern of frontierPatterns) {
+ const candidates = options.filter((option) => pattern.test(option.label));
+ const base = candidates.find(
+ (option) => !/\b(high|medium|low|fast|thinking|max)\b/i.test(option.label)
);
+ const choice = base ?? candidates[0];
+ if (choice && !frontier.some((option) => option.id === choice.id))
+ frontier.push(choice);
}
- // A harness whose names the curated list does not know still gets a useful
- // shortlist: the first model of each of its headings, in its own order.
- for (const family of families) {
- pushRecommended(family.options[0]);
+ const frontierIds = new Set(frontier.map((option) => option.id));
+ const providers: ModelProviderGroup[] = [];
+ for (const option of options) {
+ if (!includeSuggested && frontierIds.has(option.id)) continue;
+ const label = modelProviderLabel(option);
+ const provider = providers.find((candidate) => candidate.label === label);
+ if (provider) provider.options.push(option);
+ else providers.push({ label, options: [option] });
}
-
- return { recommended, families };
-}
-
-/** Family buckets with the first-screen recommended shortlist removed. */
-export function moreModelFamilies(catalog: ModelCatalog): ModelFamily[] {
- const recommendedIds = new Set(
- catalog.recommended.map((option) => option.id)
- );
- const recommendedLabels = new Set(
- catalog.recommended.map((option) => option.label)
- );
- return catalog.families
- .map((family) => ({
- label: family.label,
- options: family.options.filter(
- (option) =>
- !recommendedIds.has(option.id) && !recommendedLabels.has(option.label)
- ),
- }))
- .filter((family) => family.options.length > 0);
-}
-
-/**
- * The heading to show beside a model: the harness's, or the inferred one when
- * the harness sent none. `undefined` when it would only repeat the label.
- */
-export function modelFamilyHint(
- option: CatalogModelOption
-): string | undefined {
- const family = option.group ?? inferModelFamily(option.label);
- return family === option.label ? undefined : family;
+ // Major providers first, then the rest alphabetically; automatic routing
+ // stays discoverable immediately below the frontier section.
+ const leading = ['Automatic', 'Anthropic', 'OpenAI', 'Google'];
+ providers.sort((a, b) => {
+ const rank = (label: string) => {
+ const index = leading.indexOf(label);
+ return index >= 0
+ ? index
+ : label === 'Other models'
+ ? leading.length + 1
+ : leading.length;
+ };
+ return rank(a.label) - rank(b.label) || a.label.localeCompare(b.label);
+ });
+ return { frontier, providers };
}
/**
@@ -206,6 +179,7 @@ export function matchesModelQuery(option: CatalogModelOption, query: string) {
return (
option.label.toLowerCase().includes(query) ||
family.toLowerCase().includes(query) ||
- option.id.toLowerCase().includes(query)
+ option.id.toLowerCase().includes(query) ||
+ modelProviderLabel(option).toLowerCase().includes(query)
);
}
diff --git a/apps/web/src/lib/core/component/LexicalMarkdown/builder/MarkdownShell.tsx b/apps/web/src/lib/core/component/LexicalMarkdown/builder/MarkdownShell.tsx
index 68e733a44c..399c60a687 100644
--- a/apps/web/src/lib/core/component/LexicalMarkdown/builder/MarkdownShell.tsx
+++ b/apps/web/src/lib/core/component/LexicalMarkdown/builder/MarkdownShell.tsx
@@ -50,6 +50,8 @@ import type { EditorBuilder, EditorComponentProps } from './types';
export type MarkdownShellProps = EditorComponentProps & {
config: EditorBuilder;
+ /** Accessible name independent of a changing visual placeholder. */
+ ariaLabel?: string;
};
export const MarkdownShell: Component<MarkdownShellProps> = (props) => {
@@ -238,6 +240,7 @@ export const MarkdownShell: Component<MarkdownShellProps> = (props) => {
disabled={!!props.disabled}
showPlaceholder={showPlaceholder()}
placeholder={props.placeholder}
+ ariaLabel={props.ariaLabel}
/>
<DecoratorRenderer editor={editor} />
diff --git a/apps/web/src/lib/core/component/LexicalMarkdown/builder/MarkdownShellContent.test.tsx b/apps/web/src/lib/core/component/LexicalMarkdown/builder/MarkdownShellContent.test.tsx
index 1ddfeba469..7903a1fe23 100644
--- a/apps/web/src/lib/core/component/LexicalMarkdown/builder/MarkdownShellContent.test.tsx
+++ b/apps/web/src/lib/core/component/LexicalMarkdown/builder/MarkdownShellContent.test.tsx
@@ -45,6 +45,7 @@ describe('MarkdownShell content', () => {
disabled={false}
showPlaceholder={showPlaceholder()}
placeholder={placeholder()}
+ ariaLabel="Message the agent"
/>
));
@@ -53,6 +54,9 @@ describe('MarkdownShell content', () => {
setPlaceholder('Reply to thread');
expect(screen.queryByText('Write a message')).toBeNull();
expect(screen.getByText('Reply to thread')).toBeTruthy();
+ expect(screen.getByRole('textbox', { name: 'Message the agent' })).toBe(
+ editable
+ );
setShowPlaceholder(false);
expect(screen.queryByText('Reply to thread')).toBeNull();
setShowPlaceholder(true);
diff --git a/apps/web/src/lib/core/component/LexicalMarkdown/builder/MarkdownShellContent.tsx b/apps/web/src/lib/core/component/LexicalMarkdown/builder/MarkdownShellContent.tsx
index a5b8fb04ea..7b0f56b54a 100644
--- a/apps/web/src/lib/core/component/LexicalMarkdown/builder/MarkdownShellContent.tsx
+++ b/apps/web/src/lib/core/component/LexicalMarkdown/builder/MarkdownShellContent.tsx
@@ -6,6 +6,7 @@ export function MarkdownShellContent(props: {
disabled: boolean;
showPlaceholder: boolean;
placeholder: string | undefined;
+ ariaLabel?: string;
}) {
return (
<>
@@ -16,7 +17,7 @@ export function MarkdownShellContent(props: {
role="textbox"
aria-multiline="true"
aria-readonly={props.disabled}
- aria-label={props.placeholder || 'Message'}
+ aria-label={props.ariaLabel || props.placeholder || 'Message'}
/>
<Show when={props.showPlaceholder}>
<div
diff --git a/docs/agent-guide/ai-chat.md b/docs/agent-guide/ai-chat.md
index b20bedf70e..3e4913fead 100644
--- a/docs/agent-guide/ai-chat.md
+++ b/docs/agent-guide/ai-chat.md
@@ -136,19 +136,41 @@ the header back button returns to the previous screen, or Agents for a direct li
Portrait and landscape touch layouts have no conversation side panel. **Changes** opens a full-width,
unified diff with **Back to conversation**; returning preserves the unsent draft.
-The mobile conversation list omits the desktop **New conversation**, **Agents**,
-and **Connections** controls. Use the Home composer or global create menu to start
+The mobile conversation list omits the desktop **Agents** and **Connections** controls. Use the Agents composer or global create menu to start
a conversation. Returning to the list and reopening the composer preserves the
draft, attachments, agent, model, repository, and branch. Tap the
-agent/model control to open a searchable bottom sheet. Tap an agent to use its
+agent/model control once to open a bottom sheet with its search field focused,
+without first focusing or expanding the message input. Tap an agent to use its
default model, or its model arrow to choose a model; **Create agent** opens the
-roster. Desktop navigation remains unchanged.
-
-The mobile Home composer is a filled, rounded input with no placeholder or
-rotating tips. Its collapsed height matches the New button, with the model
-selector and Send always visible. Tap the input to reveal attachment, microphone
-(when enabled), and repository controls; they collapse again when tapping outside.
+roster. Agents are clustered into **Built-in**, **Your agents**, and **Needs
+connection**, with runtime/model details below their names. Code opens directly
+on these groups without an empty Models section or an unrelated runtime warning.
+**Create agent** uses the shared rounded pill button with a subtle fill at the
+bottom right at the end of the scrolling list. The picker uses one
+continuous surface, with labels and spacing separating groups instead of nested
+shaded cards. Provider sections use compact spacing, with labels close to their
+rows. Model lists start with
+**Suggested**, with Gemini last when available, followed by **More models** and your agents. **More models**
+opens the complete provider catalog, including copies of Suggested choices;
+use Back to return. Search accepts
+model names, IDs, and providers. When browsing an agent, **Use default** in the
+header selects its configured model.
+
+The floating mobile composer appears only on **Agents**; Home and other views
+keep their New action or their own reply/comment composer.
+The mobile Agents composer is an opaque, rounded input using the same surface as
+the New button, including its glass treatment in dark mode. Send is a bare up
+arrow without a background, including when disabled. The short placeholder reads
+“Message Macro AI”.
+Its collapsed height matches New, with Send visible and the model/provider control hidden until the input is focused. Tap the input to expand across the row, hiding New and giving the draft
+a full-width text area above the controls.
+Chat/Code stays in the inset bar above the input on phones. Repository controls
+appear alongside it in Code mode.
+Tapping outside collapses the composer and restores New.
The editor and model picker stay mounted so collapsing preserves the draft.
+Dismissing the model or effort selector on mobile returns focus to the message input.
+Active sessions use the same compact mobile model drawer: focused search, Suggested
+with Gemini last, and More models for the complete provider catalog.
Repository and branch pickers keep the composer expanded while their search
fields are focused, so their anchor stays in place.
@@ -167,7 +189,7 @@ draft or queue, the busy composer offers **Stop**. Send-next actions disable and
Steer is hidden during stopping/starting and for read-only sessions.
Phone verification: check portrait and landscape with touch emulation. In the
-Home composer, enter multiple lines and tap Send, attach, or the model control;
+Agents composer, enter multiple lines and tap Send, attach, or the model control;
blurring the editor during the tap must not collapse or move the controls. Then exercise
list → new conversation → back → new conversation, a row and direct session link,
the model sheet and repository controls, queued sends, and Changes → back. Check
@@ -274,7 +296,7 @@ the shimmer.
- Open **Go to Agents** → `/app/component/agents`. With AI agents enabled
(`enable-chat-v3-agents`), the workspace uses one sidebar for Chat and Code.
- Below **New conversation**, **Agents** opens the same roster as the composer’s
+ **Agents** in the sidebar opens the same roster as the composer’s
**Create agent** action. **Connections** manages MCP integrations (including
app authentication and disconnection); this section has moved out of Settings.
Home’s **Connect your tools** and agent replies’ **Connect app** chips open this
@@ -304,8 +326,15 @@ the shimmer.
first; `slack_v2` remains a separate row in Connections where it can be disabled
or disconnected.
- **New conversation** opens the composer. **Conversations** is a mixed list
- of chats and coding sessions, newest first, with one search across both.
+ Start a conversation with **Create → Agent**. The sidebar has no New conversation
+ button, and the empty composer has no New conversation heading.
+ **Conversations** is a mixed list
+ of chats and coding sessions, with one search across both. **Group conversations**
+ switches between Status (the default), Type, and None, preserving newest-first
+ order within each group. **Filter conversations** combines Type, Status, and
+ Pull request filters; choices within a category are ORed and categories are
+ ANDed. Grouping and filters are remembered per user. Clear filters from the menu
+ or an empty filtered list.
Chat rows use a chat icon; coding rows use `</>` (the PR status icon when a
pull request is linked). Home and the Agents sidebar share these agent rows.
Rows have no agent or runtime-status subtext. A session that is starting or
@@ -324,20 +353,36 @@ the shimmer.
Right-click (or long-press on mobile) opens the same entity menu as Home:
Rename, Favorite, Copy link, Share, Archive, Delete, and the other session
actions. Archived sessions are grouped at the bottom under **Archived**.
-- The starting page has a compact composer that starts at one line and grows
- with longer prompts or Shift+Enter. Lists, quotes, headings, and other
- non-paragraph blocks expand immediately, even with short text. This also applies
- to session composers. The editor takes the full width and controls move below;
- returning to a short paragraph restores the compact row. Height changes animate
+- The starting page has **Chat / Code** in the composer’s inset bar, below the input on
+ desktop and above it on phones. The choice limits the offered agents and is
+ remembered per user. Switching modes preserves the draft and attachments and
+ clears model and effort overrides from the previous mode. It does not filter
+ the conversation sidebar. Session composers start at one line and grow with
+ longer prompts or Shift+Enter. Lists, quotes, headings, and other non-paragraph
+ blocks expand immediately, even with short text. The editor takes the full width
+ and controls move below; returning to a short paragraph restores the compact
+ row. Focusing a session input on a phone also expands it. Height changes animate
over 200ms, with reduced-motion preferences respected. **Agent** and **Send**
sit inside the input on the right.
- Direct model selections show only the model name and provider icon in the input.
- Saved and coding agents show their identity beside the current model. There is
- no Chat/Code switch or separate model button.
-- The agent dropdown includes every saved agent regardless of runtime, plus Cursor.
- Macro's models use the same searchable catalog as running sessions: a short
- **Recommended** list and a **More models** submenu grouped by model family,
- followed by **Agents** and **Coding agents** sections. Models have readable
+ Desktop model selectors always show the selected model name alongside the icon.
+ Saved and coding agents show their own icon and name plus the model name on desktop, without a
+ second model icon; phones use an icon-only picker. Routine configuration
+ keeps the saved model name visible in its picker, including unavailable models.
+- The agent dropdown includes saved agents of the selected mode regardless of
+ runtime, plus Cursor in Code mode.
+ 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 header
+ meets the top of the scroll area so rows cannot show through above it.
+ **Built-in**, **Your agents**, and **Needs connection** groups follow when
+ they have entries. Each agent row shows its runtime and model, or its setup
+ action/availability reason. **Create agent** uses the shared rounded pill
+ button at the bottom right with a subtle background. Models have readable
names (for example, **Sonnet 5.5**) and provider or model icons aligned with the
agent icons. The in-memory catalog offers the closed Anthropic and OpenAI chat
models; Kimi, DeepSeek, Muse, GLM, Qwen, MiniMax, GPT OSS, and Nemotron
@@ -345,20 +390,20 @@ the shimmer.
are **Sonnet 5.5**, **Opus 5.5**, and **Haiku 4.5**; older Claude versions
(Sonnet 5, Opus 5, Fable 5.1) are not offered.
Selecting a model here selects
- the default runtime and applies that model to the next send, retracting the repository drawer.
+ the default runtime and applies that model to the next send, hiding the repository controls while keeping the mode bar visible.
A model chosen from that catalog is remembered in local storage as the
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 searchable but
model choices are disabled in every list. Model discovery uses the
- selected runtime, including Claude Cloud. Every coding agent opens the repository
- drawer; chat agents hide it. Repository/branch overrides are currently applied
+ selected runtime, including Claude Cloud. Every coding agent shows repository
+ controls; chat agents hide those controls but keep the mode bar. Repository/branch overrides are currently applied
only to Cursor sessions by the create-session API.
- Coding agents carry a `</>` badge. The most recently used supported,
+ The most recently used supported,
available agent is selected initially; otherwise Macro is selected.
Hover an agent (or use the right arrow key) to open its model submenu, with
- the searchable Settings catalog, provider icons, and scrollable **More models**.
+ the searchable Settings catalog, provider icons, and scrollable provider sections.
The submenu focuses the `Search models` field so you can type immediately.
Clicking an agent directly, or pressing Enter/Space on its focused row, uses
its default and clears any previous model override. Right Arrow still opens
@@ -373,24 +418,22 @@ the shimmer.
when changing agents. Unsent New conversation text and attachments also come
back after opening a session and returning, the same way channel replies persist
when switching channels. Home's agent input also restores unsent text, under a
- separate key from Agents → New conversation. Check the Home path explicitly:
+ separate key from the Agents page composer. Check the Home path explicitly:
type a prompt on Home, visit an agent session, then return using the Home sidebar
button or Back. The Home prompt should remain after returning and after a reload.
Sending or clearing the input removes only that surface's saved text draft.
- **Create agent** stays pinned at the bottom of the dropdown
- while the agent and model lists scroll. It opens the roster on the selected kind's
+ **Create agent** follows the agent and model lists as a right-aligned action,
+ sharing their scroll area without a separate footer. It opens the roster on the selected kind's
tab, where either kind can be created.
-- On Home and New conversation, selecting a coding agent expands the input even
+- On Home and New conversation, selecting Code expands the input even
with an empty or short draft. Both pages place the composer above the viewport's
- vertical center. The heading and first input line stay anchored while the composer
- expands downward. The plus attachment button stays at the far left: before the
+ vertical center. The heading stays anchored while the composer expands downward,
+ with the repository bar below the input on desktop and above it on mobile.
+ The plus attachment button stays at the far left: before the
text in the compact row, and on the bottom control row when expanded. The editor sits above the controls, with attachments
- on the left and the agent/model and Send on the right. A full-width repository bar
- slides and fades in below the rounded input over 200ms, with rounded bottom corners
- and a subtle border along its sides and bottom, with a darker surface in dark mode.
- Selecting a chat agent retracts the bar and
- restores the compact input when the draft fits on one line, without remounting
- the editor or losing the draft. Reduced-motion
+ on the left and the agent/model and Send on the right. On mobile, Chat/Code sits at the top left and repository controls at the top right; repository and branch selection open in standard bottom drawers. These controls sit inside the same continuous surface as the input with no inset or dividing border. On desktop, an inset bar aligned to the full input width holds Chat/Code with rounded outer corners and a subtle border, with a darker surface in dark mode. The settings row keeps a stable height when changing modes: 44 px on desktop, with 2 px more top and side padding on mobile.
+ Selecting Chat hides the repository controls and keeps the mode switch in
+ the settings row, without remounting the editor or losing the draft. Reduced-motion
preferences disable the animation. The hidden drawer is inert. **Repository**
(**Choose repository** until one is picked) opens a searchable list:
**Choose automatically**, then the repositories the signed-in user reaches
@@ -431,12 +474,21 @@ the shimmer.
update the saved agent; configure persistent defaults in the agent editor.
Within an existing session, the model picker remains available on the right.
Its trigger, model options, and session metadata use the same readable model names
- as the new-conversation picker. The menu includes provider icons, search, a short
- **Recommended** list, and a scrollable **More models** submenu shared with Settings.
- At phone width there is no room beside the menu, so **More models** replaces the
- list in place and a **Recommended** row at the top goes back.
-- Chat agents' empty input cycles tips about connectors, skills, mentions, and
- agents; coding agents show **Describe what you want to build**. Type `@` for
+ as the new-conversation picker. Large catalogs share the Settings picker:
+ provider icons, search, **Suggested** first, and **More models** for the
+ complete provider catalog. Desktop opens a submenu; phone widths show
+ the catalog in place with a Back action. Search includes every model.
+- 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.
+- On desktop, chat agents' empty input types tips about connectors, skills,
+ mentions, and agents one character at a time, pauses to read each hint, then
+ quickly erases it before typing the next. Entering a draft pauses the animation;
+ clearing it resumes. The text-only typewriter also runs when reduced motion
+ is enabled.
+ Coding agents show **Describe what you want to build**; phones keep the short
+ **Message Macro AI** placeholder. Type `@` for
mentions and `/` for skills.
Check `/` with the Android software keyboard too: the skills menu should open
and filter while typing, without sending the draft.
@@ -453,8 +505,7 @@ the shimmer.
private agents, each with a TEAM/PRIVATE pill and an "In Macro / In Cursor /
In your harness · model · channels" subtitle, plus Edit / Delete actions.
**Add agent**, the setup strips, and Edit replace the list with full pages,
- not dialogs; Back/Cancel returns to the list. Use **New conversation** in the
- sidebar to return to the composer.
+ not dialogs; Back/Cancel returns to the list. Use **Create → Agent** to open a new composer.
The agent editor has Profile, Instructions, **Where it runs** (In Macro, In
Cursor, In your harness; In Claude Code too with the `claude-cloud` flag once
Claude lists models) and **Who can use it** (Private / Team). The selected
@@ -517,7 +568,7 @@ the shimmer.
chat agents omit that row. Chat and Code session inputs
use the same growing, initially single-line input with the model selector on
the right.
- Existing sessions retain their agent and kind; use **New conversation** to
+ Existing sessions retain their agent and kind; use **Create → Agent** to
choose another. An unsent message in that session — the text and attached
files that finished uploading — stays when you leave for a channel, another
session, or Home and come back, including after reload. Sending or clearing
@@ -1654,10 +1705,11 @@ There is no periodic PR lookup polling.
### Agent reasoning effort
Open the model selector and hover a model to choose its reasoning effort in the
-submenu. Keyboard users open it with Right Arrow; touch users tap the model.
+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 selected label includes the effort, such as `Sonnet 5.5 · High`;
-there is no separate effort control in the input box. Models without effort
+the composer also offers a separate effort button for the selected model. Models without effort
support remain selectable through `Use <model>` (or a desktop click/Enter).
Default keeps the model's existing behavior.
@@ -1896,10 +1948,11 @@ creating an event is a real action, including from a local app connected to dev.
## Agent reasoning effort
Open the model selector and hover a model to choose its reasoning effort in the
-submenu. Keyboard users open it with Right Arrow; touch users tap the model.
+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 selected label includes the effort, such as `Sonnet 5 · High`;
-there is no separate effort control in the input box. Models without effort
+the composer also offers a separate effort button for the selected model. Models without effort
support remain selectable through `Use <model>` (or a desktop click/Enter).
Default keeps the model's existing behavior.
diff --git a/docs/agent-guide/view-tours.md b/docs/agent-guide/view-tours.md
index eaba80917e..e2103585ca 100644
--- a/docs/agent-guide/view-tours.md
+++ b/docs/agent-guide/view-tours.md
@@ -25,7 +25,7 @@ and highlights.
- **Beacons.** A tour never navigates or opens things for you. When a step's
feature is behind something (a collapsed sidebar, another page, an unopened
conversation), the card hides and a pulsing dot marks the control that
- reveals it: the sidebar toggle, the Agents nav item, New conversation, or the
+ reveals it: the sidebar toggle, the Agents nav item, Create, or the
top conversation row. A small card beside it says what to do ("Open a
channel or DM to continue"), with Skip below to move on. If that control is itself in a collapsed
sidebar, the dot marks the sidebar toggle first, then moves once the
@@ -34,8 +34,8 @@ and highlights.
## Per view
-- **Agents:** the Work / Code switch (beacon on the sidebar toggle), then the
- agent and model picker (beacon on New conversation), then the
+- **Agents:** the Chat / Code switch, then the
+ agent and model picker (both use a Create → Agent entry when the composer is hidden), then the
Your agents list and the Cursor / Bring your own agent strips (beacon on
Agents), then Create for automations.
- **Channels:** channels and DMs, creation, then threads, @mentions, and calls,
diff --git a/docs/architecture/agent-effort.md b/docs/architecture/agent-effort.md
index 56547fd7e6..640b88bd9c 100644
--- a/docs/architecture/agent-effort.md
+++ b/docs/architecture/agent-effort.md
@@ -92,11 +92,16 @@ an external harness result.
## Model menu interaction
-Effort is a submenu of each model in new-chat and running-session selectors.
+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 trigger displays the model and selected effort together. Keyboard Right Arrow
-and touch taps open the same submenu. Loading, discovery errors, and models with
+opens the submenu. On mobile, tapping a model selects it directly; use the adjacent
+effort button to adjust its supported effort levels. Loading, discovery errors, and models with
no effort options keep ordinary model selection available.
A combined running-session selection waits for the model's correlated ACP