Make your computer a home for your AI partner. Avibe is the local-first Agent OS: Vibey, its built-in AI partner, works out of the box, and Claude Code, Codex & OpenCode run unchanged beside it — reach them from your browser, phone, or any chat app.
Python agentagent-osaiai-agentsai-partnerchatopsclaudeclaude-codecodexdevtoolsdiscord-botlark-botllmlocal-firstlong-term-memoryopencodeslack-botvibe-codingvibeywechat
feat(chat): two-row composer with the Agent/model picker beside Send (#2965)
Call White057becc8065d
diff --git a/ui/e2e/workbench-general/desktop-window-chrome.spec.ts b/ui/e2e/workbench-general/desktop-window-chrome.spec.tsindex 4ab0122df..b15d60f18 100644--- a/ui/e2e/workbench-general/desktop-window-chrome.spec.ts+++ b/ui/e2e/workbench-general/desktop-window-chrome.spec.ts@@ -41,20 +41,27 @@ for (const desktop of [false, true]) {const header = page.locator('[data-chat-header]');await expect(header).toBeVisible();await expect(header.getByRole('button', { name: '中文窗口会话' })).toBeVisible();- await expect(header.getByRole('button', { name: /gpt-fixture/ })).toBeVisible();await expect(header.getByRole('button', { name: 'Visualize', exact: true })).toBeVisible();await expect(header.getByRole('button', { name: 'Back', exact: true })).toBeVisible();await expect(header).toHaveCount(1);- // Desktop carries the session menu right after the title, ahead of the route- // picker — not among the page-level controls on the right.+ // Desktop carries the session menu right after the title — not among the+ // page-level controls on the right.const sessionMenu = header.getByRole('button', { name: 'Session actions', exact: true });await expect(sessionMenu).toHaveCount(1);await expect(sessionMenu).toBeVisible();const titleBox = await header.getByRole('button', { name: '中文窗口会话' }).boundingBox();const menuBox = await sessionMenu.boundingBox();- const pickerBox = await header.getByRole('button', { name: /gpt-fixture/ }).boundingBox();+ const visualizeBox = await header.getByRole('button', { name: 'Visualize', exact: true }).boundingBox();expect(menuBox!.x).toBeGreaterThanOrEqual(titleBox!.x + titleBox!.width - 1);- expect(menuBox!.x + menuBox!.width).toBeLessThan(pickerBox!.x);+ expect(menuBox!.x + menuBox!.width).toBeLessThan(visualizeBox!.x);+ // The route picker answers "who replies to the next message", so it lives in+ // the composer's action row, below the text — never in the header.+ const routePicker = page.getByRole('button', { name: /gpt-fixture/ });+ await expect(header.getByRole('button', { name: /gpt-fixture/ })).toHaveCount(0);+ await expect(routePicker).toHaveCount(1);+ const textboxBox = await page.getByRole('textbox').last().boundingBox();+ const pickerBox = await routePicker.boundingBox();+ expect(pickerBox!.y).toBeGreaterThanOrEqual(textboxBox!.y + textboxBox!.height - 1);if (desktop) {await expect(page.locator('[data-desktop-window-chrome] [data-chat-header]')).toHaveCount(1);@@ -86,7 +93,7 @@ for (const desktop of [false, true]) {expect(composer).not.toBeNull();expect(toolbar!.x).toBeCloseTo(composer!.x, 0);expect(toolbar!.width).toBeCloseTo(composer!.width, 0);- await expect(header.getByRole('button', { name: /gpt-fixture/ })).toBeVisible();+ await expect(routePicker).toBeVisible();await expect(header.getByRole('button', { name: 'Visualize', exact: true })).toBeVisible();if (width === 2000) {await page.screenshot({ path: `e2e/.artifacts/workbench-general/shots/chat-chrome-${desktop ? 'native' : 'web'}-wide.png` });@@ -96,7 +103,7 @@ for (const desktop of [false, true]) {await header.getByRole('button', { name: '中文窗口会话' }).click();await expect(header.locator('input')).toBeFocused();await header.locator('input').press('Escape');- await header.getByRole('button', { name: /gpt-fixture/ }).click();+ await routePicker.click();await expect(page.getByRole('dialog')).toBeVisible();await page.keyboard.press('Escape');await expect(page.getByRole('dialog')).toBeHidden();diff --git a/ui/src/components/ui/responsive-menu.tsx b/ui/src/components/ui/responsive-menu.tsxindex 5915d6f22..41fa5bea1 100644--- a/ui/src/components/ui/responsive-menu.tsx+++ b/ui/src/components/ui/responsive-menu.tsx@@ -32,6 +32,9 @@ export const ResponsiveMenu: React.FC<{sheetDescription?: string;/** Sheet-only header block rendered above the items (e.g. the row's identity). */sheetHeader?: React.ReactNode;+ /** The sheet's closing row. Defaults to 取消; a menu whose picks apply at once+ * has nothing to cancel and says 完成 instead. */+ sheetCloseLabel?: string;/** Popover-only sizing/appearance. */className?: string;align?: 'start' | 'center' | 'end';@@ -45,6 +48,7 @@ export const ResponsiveMenu: React.FC<{sheetTitleVisible = true,sheetDescription,sheetHeader,+ sheetCloseLabel,className,align = 'end',sideOffset = 6,@@ -112,7 +116,7 @@ export const ResponsiveMenu: React.FC<{<div className="shrink-0 px-4 pb-4 pt-3"><DialogPrimitive.Close className="flex h-12 w-full items-center justify-center rounded-xl border border-border bg-surface text-[14px] font-semibold text-foreground transition-colors hover:bg-surface-2">- {t('common.cancel')}+ {sheetCloseLabel ?? t('common.cancel')}</DialogPrimitive.Close></div></DialogPrimitive.Content>diff --git a/ui/src/components/workbench/AgentRoutePicker.test.tsx b/ui/src/components/workbench/AgentRoutePicker.test.tsxindex 343c1303a..154f21727 100644--- a/ui/src/components/workbench/AgentRoutePicker.test.tsx+++ b/ui/src/components/workbench/AgentRoutePicker.test.tsx@@ -120,8 +120,9 @@ const OptimisticOwner: React.FC<{isDefaultRoute?: boolean;defaultRoute?: AgentRouteValue;defaultLabel?: string;+ presentation?: 'columns' | 'compact';onWrite: (patch: AgentRoutePatch) => void;-}> = ({ initial = CLAUDE_ROUTE, isDefaultRoute, defaultRoute, defaultLabel, onWrite }) => {+}> = ({ initial = CLAUDE_ROUTE, isDefaultRoute, defaultRoute, defaultLabel, presentation, onWrite }) => {const [route, setRoute] = useState<AgentRouteValue>(initial);const [saving, setSaving] = useState(false);return (@@ -133,6 +134,7 @@ const OptimisticOwner: React.FC<{isDefaultRoute={isDefaultRoute}defaultRoute={defaultRoute}defaultLabel={defaultLabel}+ presentation={presentation}onChange={(patch) => {setRoute((prev) => ({ ...prev, ...patch }));setSaving(true);@@ -166,13 +168,20 @@ const HubPicker: React.FC<{surfaceActive?: boolean;onNavigateAway?: () => void;onChange?: (value: AgentRouteValue) => void;-}> = ({ role, surfaceActive = true, onNavigateAway, onChange = () => {} }) => (+ presentation?: 'columns' | 'compact';+}> = ({ role, surfaceActive = true, onNavigateAway, onChange = () => {}, presentation }) => (<InstanceAuthorizationContext.Providervalue={{ remote: false, instanceKind: null, instanceRole: role, capabilities: capabilitiesFor(role) }}><RouteSurfaceActiveContext.Provider value={surfaceActive}><MemoryRouter>- <AgentRoutePicker value={CLAUDE_ROUTE} agents={AGENTS} onChange={onChange} onNavigateAway={onNavigateAway} />+ <AgentRoutePicker+ value={CLAUDE_ROUTE}+ agents={AGENTS}+ onChange={onChange}+ onNavigateAway={onNavigateAway}+ presentation={presentation}+ /><LocationProbe /></MemoryRouter></RouteSurfaceActiveContext.Provider>@@ -565,3 +574,76 @@ describe('AgentRoutePicker', () => {});});});++// The chat composer's presentation: the same route state and writes, laid out+// model-first — models and an effort radio group up front, the Agent list one+// level down — so the picks most made mid-conversation take one tap.+describe('AgentRoutePicker compact presentation', () => {+ afterEach(() => {+ cleanup();+ catalogReasoning = {};+ catalogMenus = {};+ sourceNames = null;+ hubMode = 'direct';+ });++ const effortGroup = () => within(screen.getByRole('radiogroup', { name: 'chat.picker.effort' }));++ it('writes models and efforts from the first page and keeps Agents one level down', async () => {+ catalogReasoning = {+ sonnet: [{ value: 'low', label: 'Low' }, { value: 'high', label: 'High' }],+ opus: [{ value: 'low', label: 'Low' }, { value: 'high', label: 'High' }],+ };+ const user = userEvent.setup();+ const onWrite = vi.fn();+ render(<OptimisticOwner presentation="compact" onWrite={onWrite} />);+ await openMenu(user);++ // Agents are not on the first page; the route's Agent is named on its row.+ expect(screen.queryByRole('button', { name: /codex/ })).toBeNull();+ expect(screen.queryByRole('button', { name: 'chat.picker.newAgent' })).toBeNull();+ expect(effortGroup().getByRole('radio', { name: 'chat.picker.effortOptions.low' }).getAttribute('aria-checked')).toBe('true');++ await user.click(effortGroup().getByRole('radio', { name: 'chat.picker.effortOptions.high' }));+ expect(onWrite).toHaveBeenLastCalledWith({ reasoning_effort: 'high' });+ expect(effortGroup().getByRole('radio', { name: 'chat.picker.effortOptions.high' }).getAttribute('aria-checked')).toBe('true');++ await user.click(screen.getByRole('button', { name: /^opus/ }));+ expect(onWrite).toHaveBeenLastCalledWith({ model: 'opus' });++ await user.click(screen.getByRole('button', { name: /chat\.picker\.agent/ }));+ await user.click(screen.getByRole('button', { name: /^codex/ }));+ // An Agent pick is the whole route, exactly as the cascade writes it, and+ // the menu returns to its model page.+ expect(onWrite).toHaveBeenLastCalledWith({+ agent_name: 'codex',+ agent_id: 'agt-codex',+ agent_backend: 'codex',+ agent_variant: 'codex',+ model: 'gpt',+ reasoning_effort: null,+ });+ expect(screen.getByText('chat.picker.model')).toBeTruthy();+ expect(screen.queryByRole('button', { name: 'chat.picker.newAgent' })).toBeNull();+ });++ it('still names refusing Sources and a refused saved effort, as the cascade does', async () => {+ hubMode = 'hub';+ catalogReasoning = { sonnet: [{ value: 'medium', label: 'medium' }, { value: 'high', label: 'high' }] };+ catalogMenus = { sonnet: { omitted: ['low'], not_on: { high: ['src_relaygpt1'] } } };+ sourceNames = { src_relaygpt1: 'relay-gpt' };+ const user = userEvent.setup();+ render(<HubPicker role="owner" presentation="compact" />);+ await openMenu(user);++ // The saved `low` every hop now refuses stays checked as itself, with the reason.+ expect(effortGroup().getByRole('radio', { name: 'chat.picker.effortOptions.low' }).getAttribute('aria-checked')).toBe('true');+ expect(screen.getByText('chat.picker.effortRefused')).toBeTruthy();+ // A Source that refuses an offered effort is named under the group and on the option.+ const hint = screen.getByText('chat.picker.effortNotOn:relay-gpt', { selector: 'p > span' });+ expect(hint.parentElement?.textContent).toBe('chat.picker.effortOptions.highchat.picker.effortNotOn:relay-gpt');+ expect(effortGroup().getByRole('radio', { name: 'chat.picker.effortOptions.high' }).getAttribute('title'))+ .toBe('chat.picker.effortNotOn:relay-gpt');+ expect(effortGroup().getByRole('radio', { name: 'chat.picker.effortOptions.medium' }).getAttribute('title')).toBeNull();+ });+});diff --git a/ui/src/components/workbench/AgentRoutePicker.tsx b/ui/src/components/workbench/AgentRoutePicker.tsxindex 8fc3f6ae8..1e70905f7 100644--- a/ui/src/components/workbench/AgentRoutePicker.tsx+++ b/ui/src/components/workbench/AgentRoutePicker.tsx@@ -1,7 +1,7 @@import { useCallback, useEffect, useMemo, useRef, useState } from 'react';import { useTranslation } from 'react-i18next';import { useNavigate } from 'react-router-dom';-import { ChevronDown, Loader2, Plus, Search, Sparkles } from 'lucide-react';+import { Check, ChevronDown, ChevronLeft, ChevronRight, Loader2, Plus, Search, Sparkles } from 'lucide-react';import clsx from 'clsx';import { useApi } from '../../context/ApiContext';@@ -13,6 +13,7 @@ import { isEffortSupported, refusedSavedEffort, resolveEffortOptions } from '../import { useSourceNames } from '../../lib/useSourceNames';import { useRouteSurfaceActive } from '../../lib/routeSurfaceActivity';import { Popover, PopoverContent, PopoverTrigger } from '../ui/popover';+import { ResponsiveMenu } from '../ui/responsive-menu';import { Button } from '../ui/button';import { Input } from '../ui/input';import { BackendAvatar } from '../visual';@@ -59,8 +60,11 @@ interface AgentRoutePickerProps {align?: 'start' | 'end';/** Override the trigger width (chat caps at 62%; the create surfaces go full width). */triggerClassName?: string;- /** On mobile chat headers, keep the closed trigger to the agent label only. */- compactMobile?: boolean;+ /** ``columns`` (default): the bordered trigger and the three-column cascade.+ * ``compact``: a borderless trigger and a model-first menu for the chat+ * composer — models and efforts up front, the Agent one level down — shown as+ * a popover on desktop and a bottom sheet on phones. */+ presentation?: 'columns' | 'compact';/** Make the popover a modal layer — required when nested in a modal Dialog (the* new-session sheet) so its content isn't aria-hidden/inert by the dialog. */modal?: boolean;@@ -94,7 +98,7 @@ export const AgentRoutePicker: React.FC<AgentRoutePickerProps> = ({disabled,align = 'end',triggerClassName,- compactMobile,+ presentation = 'columns',modal,onNavigateAway,}) => {@@ -103,6 +107,9 @@ export const AgentRoutePicker: React.FC<AgentRoutePickerProps> = ({const authorization = useInstanceAuthorization();const navigate = useNavigate();const [open, setOpen] = useState(false);+ const compact = presentation === 'compact';+ // The compact menu's Agent list is a second page, not a column.+ const [agentPage, setAgentPage] = useState(false);const [modelsByBackend, setModelsByBackend] = useState<Record<string, string[]>>({});const [modelLabelsByBackend, setModelLabelsByBackend] = useState<Record<string, Record<string, string>>>({});const [reasoningByBackend, setReasoningByBackend] = useState<@@ -170,7 +177,7 @@ export const AgentRoutePicker: React.FC<AgentRoutePickerProps> = ({const currentEffort = displayValue.reasoning_effort;const currentAgentLabel = displayedAgent?.display_name || currentAgent;const triggerLabel = (routeIsDefault && defaultLabel) || currentAgentLabel || defaultLabel || t('chat.pickAgent');- const compactTriggerLabel = currentAgentLabel || defaultLabel || t('chat.pickAgent');+ const agentLabel = currentAgentLabel || defaultLabel || t('chat.pickAgent');const allowedBackendSet = useMemo(() => new Set((allowedBackends ?? []).map((item) => item.trim()).filter(Boolean)),@@ -327,51 +334,130 @@ export const AgentRoutePicker: React.FC<AgentRoutePickerProps> = ({return t('chat.picker.effortNotOn', { sources: ids.map((id) => sourceNames[id] ?? id).join(', ') });};- return (- <Popover open={open} onOpenChange={setOpen} modal={modal}>- <PopoverTrigger asChild>+ // One set of picks for both presentations, so the compact menu cannot drift+ // from the cascade on what a click writes.+ const pickDefault = () =>+ applyPatch({+ agent_name: null,+ agent_id: null,+ agent_backend: null,+ agent_variant: null,+ model: null,+ reasoning_effort: null,+ });+ const pickAgent = (agent: VibeAgentBrief) =>+ applyPatch({+ agent_name: agent.name,+ agent_id: agent.id,+ agent_backend: agent.backend,+ agent_variant: agent.backend,+ // Explicit null (not undefined) so switching to an agent with+ // no default model/effort clears the previous override.+ model: agent.model ?? null,+ reasoning_effort: agent.reasoning_effort ?? null,+ });+ const pickModel = (model: string) => {+ const patch: AgentRoutePatch = { model };+ // Switching to a model whose effort set no longer includes+ // the current effort: clear it in the same patch so the displayed+ // route matches what dispatches. Choosing the current model+ // again changes nothing, a refused saved effort included.+ if (model !== currentModel && !isEffortSupported(backend, model, currentEffort, backendReasoning)) {+ patch.reasoning_effort = null;+ }+ applyPatch(patch);+ };+ const openNewAgent = () => {+ setOpen(false);+ onNavigateAway?.(); // close the create sheet before leaving, if any+ // Creating an agent needs the Definitions controls, so ask for+ // that tab explicitly instead of resuming the remembered one.+ navigate('/agents?tab=definitions');+ };+ const openAddModelExit = openAddModel+ ? () => {+ setOpen(false);+ openAddModel();+ }+ : null;+ const effortLabel = (effort: string) => t(`chat.picker.effortOptions.${effort}`, { defaultValue: effort });++ // The model list body — search, loading/empty states, rows — is shared; only+ // how a row presents its name differs.+ const modelListBody = (renderRow: (model: string) => React.ReactNode) => (+ <>+ {showModelSearch && (+ <div className="sticky top-0 z-10 -mx-1.5 mb-1 bg-panel px-1.5 pb-1 pt-0.5">+ <div className="flex items-center gap-1.5 rounded-md border border-border bg-surface-2 px-2 focus-within:border-cyan/50">+ <Search className="size-3 shrink-0 text-muted" />+ <Input+ variant="bare"+ value={modelQuery}+ onChange={(e) => setModelQuery(e.target.value)}+ placeholder={t('chat.picker.searchModels')}+ aria-label={t('chat.picker.searchModels')}+ className="h-7 flex-1 text-[11px]"+ />+ </div>+ </div>+ )}+ {loadingModels && models.length === 0 ? (+ <div className="flex items-center gap-1.5 px-2 py-3 text-[11px] text-muted">+ <Loader2 className="size-3 animate-spin" />+ {t('common.loading')}+ </div>+ ) : models.length === 0 ? (+ <div className="px-2 py-3 text-[11px] text-muted">{t('chat.picker.noModels')}</div>+ ) : filteredModels.length === 0 ? (+ <div className="px-2 py-3 text-[11px] text-muted">{t('chat.picker.noModelMatch')}</div>+ ) : (+ filteredModels.map(renderRow)+ )}+ {/* Pinned like the search above it: a long model list must not scroll+ the way to add one out of sight. */}+ {openAddModelExit && (+ <div className="sticky -bottom-1.5 z-10 -mx-1.5 -mb-1.5 border-t border-border bg-panel px-1.5 pb-1.5">+ <PickerExitButton label={t('chat.picker.addModel')} onClick={openAddModelExit} />+ </div>+ )}+ </>+ );++ const triggerButton = (<Buttontype="button"variant="outline"disabled={disabled}className={clsx(- 'inline-flex h-auto items-center justify-start gap-1.5 rounded-lg border-cyan/40 bg-surface-2 px-2.5 py-1.5 text-[12px] font-normal hover:bg-cyan/[0.06]',- triggerClassName ?? 'max-w-[62%]',+ compact+ ? 'inline-flex h-9 min-w-0 items-center justify-start gap-1.5 rounded-lg border-transparent bg-transparent px-2 text-[12px] font-normal shadow-none hover:bg-foreground/[0.05]'+ : 'inline-flex h-auto items-center justify-start gap-1.5 rounded-lg border-cyan/40 bg-surface-2 px-2.5 py-1.5 text-[12px] font-normal hover:bg-cyan/[0.06]',+ triggerClassName ?? (compact ? undefined : 'max-w-[62%]'),)}>- {backend && (- <span- className={clsx(- 'shrink-0 items-center gap-1 rounded border border-cyan/30 bg-cyan/[0.08] px-1.5 py-0.5 font-mono text-[9px] font-bold uppercase text-cyan-ink',- compactMobile ? 'hidden md:inline-flex' : 'inline-flex',- )}- >+ {/* The composer's quiet trigger names the route without the backend+ badge: the Agent name already implies it, and the menu shows it. */}+ {backend && !compact && (+ <span className="inline-flex shrink-0 items-center gap-1 rounded border border-cyan/30 bg-cyan/[0.08] px-1.5 py-0.5 font-mono text-[9px] font-bold uppercase text-cyan-ink"><BackendAvatar backend={backend} className="size-3" />{getBackendUiMeta(backend).label}</span>)}- {compactMobile ? (- <>- <span className="truncate font-semibold text-foreground md:hidden">{compactTriggerLabel}</span>- <span className="hidden truncate font-semibold text-foreground md:inline">{triggerLabel}</span>- </>- ) : (- <span className="truncate font-semibold text-foreground">{triggerLabel}</span>- )}+ <span className="truncate font-semibold text-foreground">{triggerLabel}</span>{currentModel && (<>- <span className={clsx('text-muted', compactMobile && 'hidden md:inline')}>·</span>- <span className={clsx('truncate font-mono text-[10px] text-muted', compactMobile && 'hidden md:inline')}>+ <span className="text-muted">·</span>+ <span className="truncate font-mono text-[10px] text-muted">{currentModel}</span></>)}{currentEffort && (<>- <span className={clsx('text-muted', compactMobile && 'hidden md:inline')}>·</span>+ <span className="text-muted">·</span>{/* Localize via the same key the column uses so the closed triggerdoesn't show raw low/max in zh builds; unknown falls back to raw. */}- <span className={clsx('shrink-0 text-[10px] capitalize text-muted', compactMobile && 'hidden md:inline')}>+ <span className="shrink-0 text-[10px] capitalize text-muted">{t(`chat.picker.effortOptions.${currentEffort}`, { defaultValue: currentEffort })}</span></>@@ -385,6 +471,164 @@ export const AgentRoutePicker: React.FC<AgentRoutePickerProps> = ({<ChevronDown className="ml-auto size-3 shrink-0 text-muted" />)}</Button>+ );++ if (compact) {+ const agentRowLabel = (routeIsDefault && defaultLabel) || agentLabel;+ const agentList = (+ <div className="flex flex-col">+ <div className="border-b border-border p-1.5">+ <button+ type="button"+ onClick={() => setAgentPage(false)}+ className="flex w-full items-center gap-1 rounded px-1.5 py-1.5 text-left text-[12px] font-semibold text-foreground hover:bg-foreground/[0.04]"+ >+ <ChevronLeft className="size-3.5 text-muted" />+ {t('chat.picker.agent')}+ </button>+ </div>+ {/* The popover has no height of its own, so the list bounds and scrolls+ itself on desktop with the way back pinned above it; the phone sheet+ already scrolls its whole body. */}+ <div className="flex flex-col gap-0.5 p-1.5 md:max-h-[min(60vh,420px)] md:overflow-y-auto">+ {defaultLabel && (+ <RouteItem+ active={routeIsDefault}+ onClick={() => {+ pickDefault();+ setAgentPage(false);+ }}+ >+ <Sparkles className="size-3.5 shrink-0 text-cyan-ink" />+ <span className="flex-1 truncate font-semibold">{defaultLabel}</span>+ {routeIsDefault && <Check className="size-3.5 shrink-0" />}+ </RouteItem>+ )}+ {visibleAgents.length === 0 && (+ <div className="px-2 py-3 text-center text-[11px] text-muted">{t('chat.noAgents')}</div>+ )}+ {Object.entries(grouped).map(([be, list]) => (+ <div key={be} className="flex flex-col gap-0.5 pb-1">+ <div className="px-2 pt-1.5 font-mono text-[9px] font-bold uppercase tracking-[0.12em] text-muted">{be}</div>+ {list.map((agent) => {+ const active = !routeIsDefault && agent.name === currentAgent;+ return (+ <RouteItem+ key={agent.id}+ active={active}+ onClick={() => {+ pickAgent(agent);+ setAgentPage(false);+ }}+ >+ <BackendAvatar backend={agent.backend} className="size-3.5 shrink-0" />+ <span className="flex-1 truncate font-semibold">{agent.name}</span>+ {agent.model && <span className="truncate font-mono text-[9px] text-muted">{agent.model}</span>}+ {active && <Check className="size-3.5 shrink-0" />}+ </RouteItem>+ );+ })}+ </div>+ ))}+ <PickerExitButton label={t('chat.picker.newAgent')} onClick={openNewAgent} />+ </div>+ </div>+ );+ const routeMenu = (+ <div className="flex flex-col">+ <button+ type="button"+ onClick={() => setAgentPage(true)}+ className="flex items-center gap-2 px-3 py-2.5 text-left transition-colors hover:bg-foreground/[0.03]"+ >+ <span className="text-[10px] font-bold uppercase tracking-[0.1em] text-muted">{t('chat.picker.agent')}</span>+ <span className="ml-auto flex min-w-0 items-center gap-1.5">+ {backend && <BackendAvatar backend={backend} className="size-3.5 shrink-0" />}+ <span className="truncate text-[12px] font-semibold text-foreground">{agentRowLabel}</span>+ <ChevronRight className="size-3.5 shrink-0 text-muted" />+ </span>+ </button>+ <RouteColumn title={t('chat.picker.model')} className="max-h-[40vh] border-t border-border">+ {modelListBody((model) => {+ const label = modelOptionLabel(model, modelLabels);+ const active = model === currentModel;+ return (+ <RouteItem key={model} active={active} disabled={loadingModels} onClick={() => pickModel(model)}>+ <span className="flex min-w-0 flex-1 flex-col">+ <span className="whitespace-normal break-words font-semibold leading-snug">+ <ModelName label={label} />+ </span>+ {label !== model && (+ <span className="whitespace-normal break-words font-mono text-[10px] leading-snug text-muted">{model}</span>+ )}+ </span>+ {active && <Check className="size-3.5 shrink-0" />}+ </RouteItem>+ );+ })}+ </RouteColumn>+ {showEffortColumn && (+ <div className="border-t border-border p-3">+ <div className="pb-2 text-[10px] font-bold uppercase tracking-[0.1em] text-muted">{t('chat.picker.effort')}</div>+ {/* One tap per effort, wrapping when a model states many. Hints that+ a column would print under each row are listed below instead. */}+ <div+ role="radiogroup"+ aria-label={t('chat.picker.effort')}+ className="flex flex-wrap gap-0.5 rounded-md border border-border bg-foreground/[0.03] p-0.5"+ >+ {refusedEffort && (+ <EffortChip active refused label={effortLabel(refusedEffort)} onClick={() => setOpen(false)} />+ )}+ {effortOptions.map((opt) => (+ <EffortChip+ key={opt}+ active={opt === currentEffort}+ disabled={loadingModels}+ label={effortLabel(opt)}+ hint={notOnLabel(opt)}+ onClick={() => applyPatch({ reasoning_effort: opt })}+ />+ ))}+ </div>+ {refusedEffort && (+ <p className="pt-1.5 text-[10px] leading-snug text-gold-ink">{t('chat.picker.effortRefused')}</p>+ )}+ {effortOptions.map((opt) => {+ const notOn = notOnLabel(opt);+ return notOn ? (+ <p key={opt} className="flex gap-1.5 pt-1 text-[10px] leading-snug text-muted">+ <span className="shrink-0 font-semibold">{effortLabel(opt)}</span>+ <span>{notOn}</span>+ </p>+ ) : null;+ })}+ </div>+ )}+ </div>+ );+ return (+ <ResponsiveMenu+ open={open}+ onOpenChange={(next) => {+ setOpen(next);+ if (!next) setAgentPage(false);+ }}+ trigger={triggerButton}+ sheetTitle={t('chat.picker.sheetTitle')}+ sheetCloseLabel={t('common.done')}+ className="w-[320px] max-w-[92vw] overflow-hidden p-0"+ align={align}+ >+ {agentPage ? agentList : routeMenu}+ </ResponsiveMenu>+ );+ }++ return (+ <Popover open={open} onOpenChange={setOpen} modal={modal}>+ <PopoverTrigger asChild>+ {triggerButton}</PopoverTrigger><PopoverContent align={align} className="z-50 max-h-[70vh] w-[680px] max-w-[92vw] overflow-y-auto p-0">{/* On phones the columns stack into one scrollable list; sm+ keeps the@@ -405,16 +649,7 @@ export const AgentRoutePicker: React.FC<AgentRoutePickerProps> = ({{defaultLabel && (<RouteItemactive={routeIsDefault}- onClick={() =>- applyPatch({- agent_name: null,- agent_id: null,- agent_backend: null,- agent_variant: null,- model: null,- reasoning_effort: null,- })- }+ onClick={pickDefault}><Sparkles className="size-3.5 shrink-0 text-cyan-ink" /><span className="flex-1 truncate font-semibold">{defaultLabel}</span>@@ -430,18 +665,7 @@ export const AgentRoutePicker: React.FC<AgentRoutePickerProps> = ({<RouteItemkey={agent.id}active={!routeIsDefault && agent.name === currentAgent}- onClick={() =>- applyPatch({- agent_name: agent.name,- agent_id: agent.id,- agent_backend: agent.backend,- agent_variant: agent.backend,- // Explicit null (not undefined) so switching to an agent with- // no default model/effort clears the previous override.- model: agent.model ?? null,- reasoning_effort: agent.reasoning_effort ?? null,- })- }+ onClick={() => pickAgent(agent)}><span className="flex-1 truncate font-semibold">{agent.name}</span>{agent.model && <span className="truncate font-mono text-[9px] text-muted">{agent.model}</span>}@@ -449,16 +673,7 @@ export const AgentRoutePicker: React.FC<AgentRoutePickerProps> = ({))}</div>))}- <PickerExitButton- label={t('chat.picker.newAgent')}- onClick={() => {- setOpen(false);- onNavigateAway?.(); // close the create sheet before leaving, if any- // Creating an agent needs the Definitions controls, so ask for- // that tab explicitly instead of resuming the remembered one.- navigate('/agents?tab=definitions');- }}- />+ <PickerExitButton label={t('chat.picker.newAgent')} onClick={openNewAgent} /></RouteColumn>{/* Column 2 — Model (lazy-loaded for the active backend). Its own@@ -466,70 +681,21 @@ export const AgentRoutePicker: React.FC<AgentRoutePickerProps> = ({and Add model rows pin to the nearest scroll box, and a column thatnever scrolls would leave them at the far ends of a long list. */}<RouteColumn title={t('chat.picker.model')} className="max-h-[45vh]">- {showModelSearch && (- <div className="sticky top-0 z-10 -mx-1.5 mb-1 bg-panel px-1.5 pb-1 pt-0.5">- <div className="flex items-center gap-1.5 rounded-md border border-border bg-surface-2 px-2 focus-within:border-cyan/50">- <Search className="size-3 shrink-0 text-muted" />- <Input- variant="bare"- value={modelQuery}- onChange={(e) => setModelQuery(e.target.value)}- placeholder={t('chat.picker.searchModels')}- aria-label={t('chat.picker.searchModels')}- className="h-7 flex-1 text-[11px]"- />- </div>- </div>- )}- {loadingModels && models.length === 0 ? (- <div className="flex items-center gap-1.5 px-2 py-3 text-[11px] text-muted">- <Loader2 className="size-3 animate-spin" />- {t('common.loading')}- </div>- ) : models.length === 0 ? (- <div className="px-2 py-3 text-[11px] text-muted">{t('chat.picker.noModels')}</div>- ) : filteredModels.length === 0 ? (- <div className="px-2 py-3 text-[11px] text-muted">{t('chat.picker.noModelMatch')}</div>- ) : (- filteredModels.map((model) => (- <RouteItem- key={model}- active={model === currentModel}- disabled={loadingModels}- onClick={() => {- const patch: AgentRoutePatch = { model };- // Switching to a model whose effort set no longer includes- // the current effort: clear it in the same patch so the displayed- // route matches what dispatches. Choosing the current model- // again changes nothing, a refused saved effort included.- if (model !== currentModel && !isEffortSupported(backend, model, currentEffort, backendReasoning)) {- patch.reasoning_effort = null;- }- applyPatch(patch);- }}- >- {/* Full id always visible (wraps instead of truncating); the- provider/vendor prefix on OpenCode ids is de-emphasized so the- model name itself stands out. */}- <span className="min-w-0 flex-1 whitespace-normal break-words text-left font-mono text-[11px] leading-snug">- <ModelName label={modelOptionLabel(model, modelLabels)} />- </span>- </RouteItem>- ))- )}- {/* Pinned like the search above it: a long model list must not scroll- the way to add one out of sight. */}- {openAddModel && (- <div className="sticky -bottom-1.5 z-10 -mx-1.5 -mb-1.5 border-t border-border bg-panel px-1.5 pb-1.5">- <PickerExitButton- label={t('chat.picker.addModel')}- onClick={() => {- setOpen(false);- openAddModel();- }}- />- </div>- )}+ {modelListBody((model) => (+ <RouteItem+ key={model}+ active={model === currentModel}+ disabled={loadingModels}+ onClick={() => pickModel(model)}+ >+ {/* Full id always visible (wraps instead of truncating); the+ provider/vendor prefix on OpenCode ids is de-emphasized so the+ model name itself stands out. */}+ <span className="min-w-0 flex-1 whitespace-normal break-words text-left font-mono text-[11px] leading-snug">+ <ModelName label={modelOptionLabel(model, modelLabels)} />+ </span>+ </RouteItem>+ ))}</RouteColumn>{/* Column 3 — Effort (uses per-model catalog entries when available) */}@@ -538,7 +704,7 @@ export const AgentRoutePicker: React.FC<AgentRoutePickerProps> = ({{refusedEffort && (<RouteItem active onClick={() => setOpen(false)}><span className="flex min-w-0 flex-1 flex-col">- <span className="capitalize">{t(`chat.picker.effortOptions.${refusedEffort}`, { defaultValue: refusedEffort })}</span>+ <span className="capitalize">{effortLabel(refusedEffort)}</span><span className="text-[10px] leading-snug text-gold-ink">{t('chat.picker.effortRefused')}</span></span></RouteItem>@@ -553,7 +719,7 @@ export const AgentRoutePicker: React.FC<AgentRoutePickerProps> = ({onClick={() => applyPatch({ reasoning_effort: opt })}><span className="flex min-w-0 flex-1 flex-col">- <span className="capitalize">{t(`chat.picker.effortOptions.${opt}`, { defaultValue: opt })}</span>+ <span className="capitalize">{effortLabel(opt)}</span>{notOn && <span className="text-[10px] leading-snug text-muted">{notOn}</span>}</span></RouteItem>@@ -567,6 +733,38 @@ export const AgentRoutePicker: React.FC<AgentRoutePickerProps> = ({);};+// One effort in the compact menu's radio group. A refused saved effort stays+// checked and gold: routing still sends it, so it shows as itself.+const EffortChip: React.FC<{+ active: boolean;+ label: string;+ onClick: () => void;+ disabled?: boolean;+ hint?: string | null;+ refused?: boolean;+}> = ({ active, label, onClick, disabled, hint, refused }) => (+ <button+ type="button"+ role="radio"+ aria-checked={active}+ disabled={disabled}+ title={hint ?? undefined}+ onClick={onClick}+ className={clsx(+ 'min-w-[3rem] flex-1 whitespace-nowrap rounded-[4px] border px-2 py-1.5 text-[12px] capitalize transition-colors',+ 'focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-cyan/60 disabled:cursor-not-allowed disabled:opacity-60',+ refused+ ? 'border-gold/40 bg-gold/10 font-bold text-gold-ink'+ : active+ ? 'border-cyan/40 bg-cyan-soft font-bold text-cyan-ink'+ : 'border-transparent font-medium text-muted hover:text-foreground',+ hint && !active && 'underline decoration-dotted underline-offset-4',+ )}+ >+ {label}+ </button>+);+const RouteColumn: React.FC<{ title: string; className?: string; children: React.ReactNode }> = ({ title, className, children }) => (<div className={clsx('flex min-w-0 flex-col overflow-y-auto p-1.5 sm:max-h-[320px]', className)}><div className="px-2 pb-1 pt-0.5 text-[10px] font-bold uppercase tracking-[0.1em] text-muted">{title}</div>diff --git a/ui/src/components/workbench/ChatArchivedReadOnly.test.tsx b/ui/src/components/workbench/ChatArchivedReadOnly.test.tsxindex a7ceeb864..8120bab67 100644--- a/ui/src/components/workbench/ChatArchivedReadOnly.test.tsx+++ b/ui/src/components/workbench/ChatArchivedReadOnly.test.tsx@@ -387,9 +387,8 @@ describe('read-only header withdraws the Show Page controls', () => {});it('renders an archived header with the title and badge but no Show Page button', () => {- // Only the read-only header is reachable here: the live one renders- // AgentRoutePicker, which calls useApi() and throws without an ApiProvider.- // The pure matrix above covers the live side.+ // Only the read-only header is reachable here; the pure matrix above covers+ // the live side.const markup = render(<ChatHeaderBarsession={session({ status: 'archived' })}@@ -397,7 +396,6 @@ describe('read-only header withdraws the Show Page controls', () => {defaultAgentName={null}onPatch={async () => undefined}onBack={() => undefined}- working={false}showPageMode={false}showPageBusy={false}onToggleShowPage={() => undefined}@@ -440,7 +438,6 @@ describe('read-only header withdraws the Show Page controls', () => {defaultAgentName={null}onPatch={async () => undefined}onBack={() => undefined}- working={false}showPageMode={false}showPageBusy={false}onToggleShowPage={() => undefined}@@ -580,7 +577,6 @@ describe('archived conflicts converge whatever the verb', () => {defaultAgentName={null}onPatch={async () => undefined}onBack={() => undefined}- working={false}showPageMode={false}showPageBusy={false}onToggleShowPage={() => undefined}@@ -692,7 +688,6 @@ describe('a runtime-owned system session is read-only for its own reason', () =>defaultAgentName="claude"onPatch={async () => undefined}onBack={() => undefined}- working={false}showPageMode={false}showPageBusy={false}onToggleShowPage={() => undefined}diff --git a/ui/src/components/workbench/ChatPage.tsx b/ui/src/components/workbench/ChatPage.tsxindex 94adbfbc6..71f19bfde 100644--- a/ui/src/components/workbench/ChatPage.tsx+++ b/ui/src/components/workbench/ChatPage.tsx@@ -2930,9 +2930,7 @@ export const ChatPage: React.FC = () => {agents={agents}defaultAgentName={defaultAgentName}onPatch={patch}- patchSaving={patchSaving}onBack={goBack}- working={working}showPageMode={showPageActive}showPageBusy={showPageBusy}onToggleShowPage={toggleShowPage}@@ -3088,6 +3086,18 @@ export const ChatPage: React.FC = () => {onSearchAgents={searchAgents}onSearchSessions={searchSessions}readOnlyReason={readOnlyReason}+ // Hidden with the rest of the chat surface in Show Page mode, which is+ // also where the header used to withdraw the picker.+ actions={writable ? (+ <ChatRoutePicker+ session={session}+ agents={agents}+ defaultAgentName={defaultAgentName}+ onPatch={patch}+ patchSaving={patchSaving}+ working={working}+ />+ ) : null}/>}</div>{/* Archive confirm — mounted at the chat surface (not inside the header's@@ -3563,6 +3573,8 @@ export const QueueStrip: React.FC<{interface ComposeProps {composerRef: React.Ref<ComposerHandle>;+ /** The live route picker for the composer's action row; null when read-only. */+ actions: React.ReactNode;readLatestAgentReply: ComposerProps['readLatestAgentReply'];onSend: (text: string, attachments?: ComposerAttachment[], references?: MentionReference[]) => void;onStop: () => void;@@ -3578,7 +3590,7 @@ interface ComposeProps {readOnlyReason: SessionReadOnlyReason | null;}-const Compose: React.FC<ComposeProps> = ({ composerRef, readLatestAgentReply, onSend, onStop, busy, sessionId, initialDraft, onDraftChange, onSearchAgents, onSearchSessions, readOnlyReason }) => {+const Compose: React.FC<ComposeProps> = ({ composerRef, actions, readLatestAgentReply, onSend, onStop, busy, sessionId, initialDraft, onDraftChange, onSearchAgents, onSearchSessions, readOnlyReason }) => {const { t } = useTranslation();const readOnly = readOnlyReason !== null;return (@@ -3601,6 +3613,8 @@ const Compose: React.FC<ComposeProps> = ({ composerRef, readLatestAgentReply, ononSearchAgents={onSearchAgents}onSearchSessions={onSearchSessions}readLatestAgentReply={readLatestAgentReply}+ layout="stacked"+ actions={actions}// Read-only archived session: reuse the composer's own disabled +// placeholder props rather than swapping in a notice bar. ``busy`` is NOT// reliably false here — archive commits before the controller turn is@@ -3630,16 +3644,91 @@ interface TitleFieldHandle {startEditing: () => void;}-interface ChatHeaderBarProps {+interface ChatRoutePickerProps {session: WorkbenchSession;agents: VibeAgentBrief[];defaultAgentName: string | null;- // Applies to the local row first, then persists — never awaited by the header.+ // Applies to the local row first, then persists — never awaited by the picker.onPatch: (changes: Partial<WorkbenchSession>) => void;/** A queued ``onPatch`` write is still in flight. */patchSaving?: boolean;- onBack: () => void;working: boolean;+}++// The live session's agent/model/effort picker, hosted by the composer's action+// row: the route is "who answers the next message", so it sits beside Send.+// Read-only sessions never mount it — their header names the frozen route.+const ChatRoutePicker: React.FC<ChatRoutePickerProps> = ({ session, agents, defaultAgentName, onPatch, patchSaving, working }) => {+ const { t } = useTranslation();+ const defaultAgent = defaultAgentName ? agents.find((agent) => agent.name === defaultAgentName) : null;+ // Mirrors update_session's guard. A session with a NATIVE conversation can+ // still move to another backend: the server replaces the conversation and+ // hands the next turn a handoff (docs/plans/2026-10-22-session-backend-switch.md).+ // It stays on its backend while a turn is RUNNING (the in-flight turn binds+ // its native on the current route any moment), as a pending fork, and for+ // good once it has a Vibey conversation: Vibey is where a session can move+ // to, never from. A bound session also has no "default" choice, which would+ // clear it to a blank backend. A locked session with a KNOWN backend keeps+ // the picker open for same-backend agent/model changes; locked with a BLANK+ // backend (the global-default route mid-turn) has no valid choice at all —+ // every concrete pick would 409 — so the picker disables until the turn+ // settles. Idle blank-backend rows with a native (legacy, pre-backfill) stay+ // enabled: the server allows their one-time "initial pin".+ const concreteBackend = session.agent_backend?.trim() || null;+ const nativeBound = Boolean(session.native_session_id);+ const pendingForkBackend =+ !session.native_session_id &&+ session.metadata?.created_via === 'session_fork' &&+ typeof session.metadata?.fork_source_backend === 'string'+ ? session.metadata.fork_source_backend.trim() || null+ : null;+ const backendLocked =+ (nativeBound && concreteBackend === 'vibey') || working || Boolean(pendingForkBackend);+ const pinnedBackend = pendingForkBackend ?? (backendLocked ? concreteBackend : null);+ const canClearToDefault = !backendLocked && !nativeBound;+ const pickerDisabled = working && !concreteBackend && !pendingForkBackend;+ const defaultRoute = defaultAgent+ ? {+ agent_name: defaultAgent.name,+ agent_id: defaultAgent.id,+ agent_backend: defaultAgent.backend,+ agent_variant: defaultAgent.backend,+ model: defaultAgent.model,+ reasoning_effort: defaultAgent.reasoning_effort,+ }+ : undefined;+ const inheritsDefault = !session.agent_name && !session.agent_backend;+ return (+ <AgentRoutePicker+ presentation="compact"+ value={session}+ agents={agents}+ onChange={onPatch}+ saving={patchSaving}+ disabled={pickerDisabled}+ allowedBackends={pinnedBackend ? [pinnedBackend] : undefined}+ defaultLabel={+ canClearToDefault+ ? defaultAgent+ ? t('newSession.defaultAgentNamed', { name: defaultAgent.name })+ : t('newSession.defaultAgent')+ : undefined+ }+ defaultRoute={defaultRoute}+ isDefaultRoute={inheritsDefault}+ triggerClassName="max-w-[min(60vw,360px)]"+ align="end"+ />+ );+};++interface ChatHeaderBarProps {+ session: WorkbenchSession;+ agents: VibeAgentBrief[];+ defaultAgentName: string | null;+ // Applies to the local row first, then persists — never awaited by the header.+ onPatch: (changes: Partial<WorkbenchSession>) => void;+ onBack: () => void;// The EFFECTIVE mode (ChatPage passes ``showPageActive``): whether the page is// actually framed right now, which a read-only session is never.showPageMode: boolean;@@ -3671,10 +3760,8 @@ interface ChatHeaderBarProps {}// Exported for the read-only regression test (ChatArchivedReadOnly.test.tsx),-// which renders the header alone rather than mounting the whole page. Note the-// live (non-readOnly) header pulls in AgentRoutePicker → useApi, so only the-// read-only rendering is reachable without an ApiProvider.-export const ChatHeaderBar: React.FC<ChatHeaderBarProps> = ({ session, agents, defaultAgentName, onPatch, patchSaving, onBack, working, showPageMode, showPageBusy, onToggleShowPage, onPrepareShowPageLaunch, onShowPageVisibilityChange, onShareOpenChange, annotation, onAnnotateOpenChange, readOnlyReason, writable = readOnlyReason === null, showPageAccess = null, canOpenShowPage = true, canManageShowPage = true, canManageInstance = false, canPinToDock = false, sessionActions, titleFieldRef }) => {+// which renders the header alone rather than mounting the whole page.+export const ChatHeaderBar: React.FC<ChatHeaderBarProps> = ({ session, agents, defaultAgentName, onPatch, onBack, showPageMode, showPageBusy, onToggleShowPage, onPrepareShowPageLaunch, onShowPageVisibilityChange, onShareOpenChange, annotation, onAnnotateOpenChange, readOnlyReason, writable = readOnlyReason === null, showPageAccess = null, canOpenShowPage = true, canManageShowPage = true, canManageInstance = false, canPinToDock = false, sessionActions, titleFieldRef }) => {const { t } = useTranslation();const windowChrome = useDesktopWindowChrome();const readOnly = !writable;@@ -3692,46 +3779,11 @@ export const ChatHeaderBar: React.FC<ChatHeaderBarProps> = ({ session, agents, dconst hasSessionActions = writable && headerSessionActions.length > 0;const defaultAgent = defaultAgentName ? agents.find((agent) => agent.name === defaultAgentName) : null;const sessionAgentLabel = sessionAgentDisplayName(session, agents);- // Mirrors update_session's guard. A session with a NATIVE conversation can- // still move to another backend: the server replaces the conversation and- // hands the next turn a handoff (docs/plans/2026-10-22-session-backend-switch.md).- // It stays on its backend while a turn is RUNNING (the in-flight turn binds- // its native on the current route any moment), as a pending fork, and for- // good once it has a Vibey conversation: Vibey is where a session can move- // to, never from. A bound session also has no "default" choice, which would- // clear it to a blank backend. A locked session with a KNOWN backend keeps- // the picker open for same-backend agent/model changes; locked with a BLANK- // backend (the global-default route mid-turn) has no valid choice at all —- // every concrete pick would 409 — so the picker disables until the turn- // settles. Idle blank-backend rows with a native (legacy, pre-backfill) stay- // enabled: the server allows their one-time "initial pin".- const concreteBackend = session.agent_backend?.trim() || null;- const nativeBound = Boolean(session.native_session_id);- const pendingForkBackend =- !session.native_session_id &&- session.metadata?.created_via === 'session_fork' &&- typeof session.metadata?.fork_source_backend === 'string'- ? session.metadata.fork_source_backend.trim() || null- : null;- const backendLocked =- (nativeBound && concreteBackend === 'vibey') || working || Boolean(pendingForkBackend);- const pinnedBackend = pendingForkBackend ?? (backendLocked ? concreteBackend : null);- const canClearToDefault = !backendLocked && !nativeBound;- const pickerDisabled = working && !concreteBackend && !pendingForkBackend;- const defaultRoute = defaultAgent- ? {- agent_name: defaultAgent.name,- agent_id: defaultAgent.id,- agent_backend: defaultAgent.backend,- agent_variant: defaultAgent.backend,- model: defaultAgent.model,- reasoning_effort: defaultAgent.reasoning_effort,- }- : undefined;- const inheritsDefault = !session.agent_name && !session.agent_backend;const header = (// A single compact row (design.pen IDQ5n): back button + click-to-edit- // title on the left, the agent/model/effort picker on the right. The bar+ // title and the session menu on the left, page controls on the right. The+ // live agent/model/effort picker sits in the composer's action row (see+ // ChatRoutePicker); a read-only session names its frozen route here. The bar// runs edge-to-edge (the page root cancels the shell padding) with a// hairline bottom border separating it from the scrolling transcript.// No project-id pill and no override banner — both were noise the user@@ -3773,7 +3825,8 @@ export const ChatHeaderBar: React.FC<ChatHeaderBarProps> = ({ session, agents, d)}{/* Hidden while the Show Page is open so the view gets the full width.On a read-only session the route is frozen, so show it as static text- plus a badge naming WHY instead of an interactive picker. A runtime-owned+ plus a badge naming WHY; a live session picks its route in the+ composer instead. A runtime-ownedrow has no backend at all (``agent_backend`` is empty by design), so theagent name — which would fall back to the default agent's, naming a routethis session will never run — is omitted there rather than invented. */}@@ -3791,26 +3844,6 @@ export const ChatHeaderBar: React.FC<ChatHeaderBarProps> = ({ session, agents, d)}</div>)}- {!showPageMode && !readOnly && (- <AgentRoutePicker- value={session}- agents={agents}- onChange={onPatch}- saving={patchSaving}- disabled={pickerDisabled}- allowedBackends={pinnedBackend ? [pinnedBackend] : undefined}- defaultLabel={- canClearToDefault- ? defaultAgent- ? t('newSession.defaultAgentNamed', { name: defaultAgent.name })- : t('newSession.defaultAgent')- : undefined- }- defaultRoute={defaultRoute}- isDefaultRoute={inheritsDefault}- compactMobile- />- )}{/* Chat hides the brand header, so mount the install nudge here too —IM-launched users often land straight in a chat. Renders only on iOSSafari + not-installed; null otherwise. */}diff --git a/ui/src/components/workbench/ChatRowOptimisticWrites.test.tsx b/ui/src/components/workbench/ChatRowOptimisticWrites.test.tsxindex debe8da59..b5f1f7ff1 100644--- a/ui/src/components/workbench/ChatRowOptimisticWrites.test.tsx+++ b/ui/src/components/workbench/ChatRowOptimisticWrites.test.tsx@@ -130,13 +130,16 @@ vi.mock('./Composer', () => ({Composer: ({onSend,onStop,+ actions,}: {onSend: (text: string) => void | Promise<unknown>;onStop: () => void | Promise<unknown>;+ actions?: React.ReactNode;}) => {mocks.onSend = onSend;mocks.onStop = onStop;- return null;+ // The route picker lives in the composer's action row.+ return <>{actions}</>;},}));@@ -238,7 +241,7 @@ function messagePosts() {return mocks.apiFetch.mock.calls.filter(([url]) => String(url).includes('/messages'));}-// What the header's picker is showing right now.+// What the composer's route picker is showing right now.function shownRoute() {return screen.getByTestId('route').dataset;}@@ -268,8 +271,8 @@ async function mountChat() {</MemoryRouter>,);await settle();- // The live header only renders once the row is loaded, and the picker is where- // a route pick comes from.+ // The live header and composer only render once the row is loaded, and the+ // composer's picker is where a route pick comes from.if (!mocks.onPatch || !mocks.onSend || !mocks.onStop) {throw new Error('ChatPage did not mount its header/composer');}diff --git a/ui/src/components/workbench/Composer.layout.test.tsx b/ui/src/components/workbench/Composer.layout.test.tsxnew file mode 100644index 000000000..a806c4095--- /dev/null+++ b/ui/src/components/workbench/Composer.layout.test.tsx@@ -0,0 +1,93 @@+/* @vitest-environment jsdom */++// The chat composer's two-row box: the text takes the whole first row, and the+// action row keeps Attach on the left and the caller's route picker, Voice and+// Send on the right. ChatPage tests mock the Composer, so this is where the+// arrangement itself is pinned.++import { createInstance } from 'i18next';+import { cleanup, render, screen } from '@testing-library/react';+import { I18nextProvider, initReactI18next } from 'react-i18next';+import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';++vi.hoisted(() => {+ Object.defineProperty(window, 'matchMedia', {+ configurable: true,+ value: vi.fn().mockReturnValue({ matches: false }),+ });+});+const apiFetch = vi.hoisted(() => vi.fn());+vi.mock('../../lib/apiFetch', () => ({ apiFetch }));++import { ToastProvider } from '../../context/ToastProvider';+import en from '../../i18n/en.json';+import { Composer, type ComposerProps } from './Composer';++const i18n = createInstance();+void i18n.use(initReactI18next).init({+ lng: 'en',+ fallbackLng: 'en',+ resources: { en: { translation: en } },+ interpolation: { escapeValue: false },+});++const renderComposer = (props: Partial<ComposerProps>) => render(+ <I18nextProvider i18n={i18n}>+ <ToastProvider>+ <Composer sessionId="ses-layout" onSend={vi.fn()} {...props} />+ </ToastProvider>+ </I18nextProvider>,+);++const before = (a: Element, b: Element) => Boolean(a.compareDocumentPosition(b) & Node.DOCUMENT_POSITION_FOLLOWING);++/** The child of `a` and `b`'s nearest common ancestor that holds `a`. */+const branchOf = (a: Element, b: Element): Element => {+ let branch = a;+ while (branch.parentElement && !branch.parentElement.contains(b)) branch = branch.parentElement;+ return branch;+};++beforeEach(() => {+ apiFetch.mockReset().mockResolvedValue({+ ok: true,+ json: async () => ({ available: true, max_file_bytes: 10_000_000 }),+ });+});++afterEach(cleanup);++describe('Composer stacked layout', () => {+ it('puts the input on its own row above Attach on the left and the route, Voice and Send on the right', async () => {+ renderComposer({ layout: 'stacked', actions: <button type="button">route</button> });++ const mic = await screen.findByRole('button', { name: en.chat.compose.voice });+ const textbox = screen.getByRole('textbox');+ const attach = screen.getByRole('button', { name: en.chat.compose.attach });+ const route = screen.getByRole('button', { name: 'route' });+ const send = screen.getByRole('button', { name: en.chat.compose.send });++ // Row one is the input alone; every control sits in the row after it.+ const inputRow = branchOf(textbox, send);+ for (const control of [attach, route, mic, send]) {+ expect(inputRow.contains(control)).toBe(false);+ expect(before(textbox, control)).toBe(true);+ }+ // Attach holds the left edge alone; the route picker, Voice and Send share the right.+ const right = branchOf(send, attach);+ expect(right.contains(route)).toBe(true);+ expect(right.contains(mic)).toBe(true);+ expect(branchOf(attach, send).contains(route)).toBe(false);+ expect(before(attach, route) && before(route, mic) && before(mic, send)).toBe(true);+ });++ it('keeps the inline box for callers that ask for nothing else', async () => {+ renderComposer({ actions: <button type="button">route</button> });++ const mic = await screen.findByRole('button', { name: en.chat.compose.voice });+ const textbox = screen.getByRole('textbox');+ // Attach and Voice lead the single row; the stacked-only actions are not drawn.+ expect(before(mic, textbox)).toBe(true);+ expect(screen.queryByRole('button', { name: 'route' })).toBeNull();+ });+});diff --git a/ui/src/components/workbench/Composer.tsx b/ui/src/components/workbench/Composer.tsxindex 1530843c4..61781d5ca 100644--- a/ui/src/components/workbench/Composer.tsx+++ b/ui/src/components/workbench/Composer.tsx@@ -402,10 +402,13 @@ export interface ComposerProps {sendDisabled?: boolean;/** Override the row container — e.g. a narrower max-width on the home canvas. */className?: string;- /** Caller-owned controls (Agent + workspace pickers on the home). Supplying- * them moves the box to the two-row layout: input on top, then an action row- * carrying these on the left and Send on the right. Callers that pass nothing- * keep the single-row box the chat has always used. */+ /** ``inline`` (default): one row — Attach and Voice, the input, Send.+ * ``stacked``: the input takes the whole first row; the action row below keeps+ * Attach on the left and ``actions``, Voice and Send on the right, so the text+ * gets the full width and no control moves as it grows. */+ layout?: 'inline' | 'stacked';+ /** Caller-owned controls for the stacked action row, placed just before Voice+ * (the chat's Agent/model picker). Ignored by the inline layout. */actions?: React.ReactNode;/** Upload + retained voice scope for an existing chat session. */sessionId?: string;@@ -461,6 +464,7 @@ export const Composer = forwardRef<ComposerHandle, ComposerProps>(function Compodisabled = false,sendDisabled = false,className,+ layout = 'inline',actions,sessionId,stageMedia = false,@@ -1597,137 +1601,144 @@ export const Composer = forwardRef<ComposerHandle, ComposerProps>(function Compo}};- // The left-edge media cluster and the input itself, named so both box- // layouts below compose the same controls instead of duplicating them.- const mediaControls = (+ // The media controls and the input itself, named so both box layouts below+ // compose the same controls instead of duplicating them. Attach stays in the+ // first idle slot and withdraws once a voice flow starts. The inline box keeps+ // Attach and Voice together on the left; the stacked box splits them — Attach+ // bottom-left, Voice beside Send.+ const stacked = layout === 'stacked';+ const attachControl = (<>- {/* Attach stays in the first idle slot and voice starts in the second.- Once a voice flow starts, the unrelated attachment control withdraws- and the active voice action takes the left edge. */}- {mediaEnabled && (- <div className="flex items-end">- <input- ref={fileInputRef}- type="file"- multiple- disabled={disabled || voiceDraftReadOnly}- className="hidden"- onChange={(e) => {- if (e.target.files?.length) void uploadFiles(Array.from(e.target.files));- e.target.value = '';- }}- />- {!voiceFlowActive && (- /* Attach uses a generic plus rather than a paperclip so it reads- as the general "add anything" entry point. */- <Button- type="button"- variant="ghost"- size="icon"- onClick={() => fileInputRef.current?.click()}- disabled={disabled}- aria-label={t('chat.compose.attach')}- className={actions ? 'size-7 shrink-0' : 'h-9 w-7 shrink-0'}- >- <Plus className="size-4" />- </Button>- )}- {voiceControlMode === 'record' && (- <Button- type="button"- variant="ghost"- size="icon"- onPointerDown={() => {- void prewarmVoiceCapture().catch(() => undefined);- pendingVoiceInsertionRef.current = captureVoiceInsertion();- }}- onPointerCancel={() => {- pendingVoiceInsertionRef.current = null;- }}- onContextMenu={() => {- pendingVoiceInsertionRef.current = null;- }}- onClick={(event) => {- focusNextVoiceControlRef.current = true;- toggleRecording(event.detail > 0);- }}- disabled={isVoiceControlDisabled(- disabled,- recording,- voiceProcessing,- Boolean(voiceRetainedSession),- )}- aria-label={t('chat.compose.voice')}- title={voiceShortcutAvailable ? voiceShortcutHint : t('chat.compose.voice')}- className={actions ? 'size-7 shrink-0' : 'size-9 shrink-0'}- >- <Mic className="size-4" />- </Button>- )}- {voiceControlMode === 'finish' && (- <Button- ref={finishVoiceControlRef}- type="button"- variant="default"- size="icon"- onClick={stopRecording}- aria-label={t('chat.compose.stopRecording')}- title={voiceShortcutAvailable ? voiceShortcutHint : t('chat.compose.stopRecording')}- className="h-9 w-12 shrink-0"- >- <Check className="size-[18px]" strokeWidth={2.5} />- </Button>- )}- {voiceControlMode === 'loading' && (- <Button- type="button"- variant="secondary"- size="icon"- disabled- aria-label={t('chat.compose.voiceProcessing')}- className={actions ? 'size-7 shrink-0' : 'size-9 shrink-0'}- >- <Loader2 className="size-4 animate-spin" />- </Button>- )}- {voiceControlMode === 'retry' && voiceRetainedSession && (- <Button- type="button"- variant="ghost"- size="icon"- onClick={() => void retryVoiceSession(voiceRetainedSession)}- aria-label={t('chat.compose.voiceRetry')}- title={t('chat.compose.voiceRetry')}- className={actions ? 'size-7 shrink-0' : 'size-9 shrink-0'}- >- <RotateCcw className="size-4" />- </Button>- )}- {voiceControlMode === 'copy' && voiceRetainedSession && (- <Button- type="button"- variant="ghost"- size="icon"- onClick={() => void copyReadyVoiceTranscript(voiceRetainedSession)}- aria-label={t('chat.compose.voiceCopyTranscript')}- title={t('chat.compose.voiceCopyTranscript')}- className={actions ? 'size-7 shrink-0' : 'size-9 shrink-0'}- >- <Copy className="size-4" />- </Button>- )}- {recording && (- <span- className="flex h-9 w-10 items-center justify-center text-xs tabular-nums text-muted"- aria-live="off"- >- {formatRecordingDuration(recordingSeconds)}- </span>- )}- </div>- )}+ <input+ ref={fileInputRef}+ type="file"+ multiple+ disabled={disabled || voiceDraftReadOnly}+ className="hidden"+ onChange={(e) => {+ if (e.target.files?.length) void uploadFiles(Array.from(e.target.files));+ e.target.value = '';+ }}+ />+ {!voiceFlowActive && (+ /* Attach uses a generic plus rather than a paperclip so it reads+ as the general "add anything" entry point. */+ <Button+ type="button"+ variant="ghost"+ size="icon"+ onClick={() => fileInputRef.current?.click()}+ disabled={disabled}+ aria-label={t('chat.compose.attach')}+ className={stacked ? 'size-9 shrink-0' : 'h-9 w-7 shrink-0'}+ >+ <Plus className="size-4" />+ </Button>+ )}</>);+ const voiceControl = (+ <>+ {voiceControlMode === 'record' && (+ <Button+ type="button"+ variant="ghost"+ size="icon"+ onPointerDown={() => {+ void prewarmVoiceCapture().catch(() => undefined);+ pendingVoiceInsertionRef.current = captureVoiceInsertion();+ }}+ onPointerCancel={() => {+ pendingVoiceInsertionRef.current = null;+ }}+ onContextMenu={() => {+ pendingVoiceInsertionRef.current = null;+ }}+ onClick={(event) => {+ focusNextVoiceControlRef.current = true;+ toggleRecording(event.detail > 0);+ }}+ disabled={isVoiceControlDisabled(+ disabled,+ recording,+ voiceProcessing,+ Boolean(voiceRetainedSession),+ )}+ aria-label={t('chat.compose.voice')}+ title={voiceShortcutAvailable ? voiceShortcutHint : t('chat.compose.voice')}+ className="size-9 shrink-0"+ >+ <Mic className="size-4" />+ </Button>+ )}+ {voiceControlMode === 'finish' && (+ <Button+ ref={finishVoiceControlRef}+ type="button"+ variant="default"+ size="icon"+ onClick={stopRecording}+ aria-label={t('chat.compose.stopRecording')}+ title={voiceShortcutAvailable ? voiceShortcutHint : t('chat.compose.stopRecording')}+ className="h-9 w-12 shrink-0"+ >+ <Check className="size-[18px]" strokeWidth={2.5} />+ </Button>+ )}+ {voiceControlMode === 'loading' && (+ <Button+ type="button"+ variant="secondary"+ size="icon"+ disabled+ aria-label={t('chat.compose.voiceProcessing')}+ className="size-9 shrink-0"+ >+ <Loader2 className="size-4 animate-spin" />+ </Button>+ )}+ {voiceControlMode === 'retry' && voiceRetainedSession && (+ <Button+ type="button"+ variant="ghost"+ size="icon"+ onClick={() => void retryVoiceSession(voiceRetainedSession)}+ aria-label={t('chat.compose.voiceRetry')}+ title={t('chat.compose.voiceRetry')}+ className="size-9 shrink-0"+ >+ <RotateCcw className="size-4" />+ </Button>+ )}+ {voiceControlMode === 'copy' && voiceRetainedSession && (+ <Button+ type="button"+ variant="ghost"+ size="icon"+ onClick={() => void copyReadyVoiceTranscript(voiceRetainedSession)}+ aria-label={t('chat.compose.voiceCopyTranscript')}+ title={t('chat.compose.voiceCopyTranscript')}+ className="size-9 shrink-0"+ >+ <Copy className="size-4" />+ </Button>+ )}+ {recording && (+ <span+ className="flex h-9 w-10 items-center justify-center text-xs tabular-nums text-muted"+ aria-live="off"+ >+ {formatRecordingDuration(recordingSeconds)}+ </span>+ )}+ </>+ );+ const mediaControls = mediaEnabled && (+ <div className="flex items-end">+ {attachControl}+ {voiceControl}+ </div>+ );const inputControl = (<>@@ -1830,7 +1841,7 @@ export const Composer = forwardRef<ComposerHandle, ComposerProps>(function Compo? 'chat.compose.cancelRecording': 'chat.compose.voiceDiscard',)}- className={actions ? 'size-7 shrink-0' : 'size-9 shrink-0'}+ className="size-9 shrink-0"><Trash2 className="size-4" /></Button>@@ -1853,7 +1864,7 @@ export const Composer = forwardRef<ComposerHandle, ComposerProps>(function CompoonClick={submit}aria-label={t('chat.compose.queueSend')}title={t('chat.compose.queueSend')}- className={actions ? 'size-7 shrink-0' : 'size-9 shrink-0'}+ className="size-9 shrink-0"><span className="relative inline-flex"><Send className="size-4" />@@ -1871,7 +1882,7 @@ export const Composer = forwardRef<ComposerHandle, ComposerProps>(function CompoonClick={onStop}disabled={!stopArmed}aria-label={t('chat.compose.stop')}- className={actions ? 'size-7 shrink-0' : 'size-9 shrink-0'}+ className="size-9 shrink-0"><Square className="size-4" /></Button>@@ -1884,7 +1895,7 @@ export const Composer = forwardRef<ComposerHandle, ComposerProps>(function CompoonClick={submit}disabled={!canSubmit}aria-label={t('chat.compose.send')}- className={actions ? 'size-7 shrink-0' : 'size-9 shrink-0'}+ className="size-9 shrink-0"><Send className="size-4" /></Button>@@ -1940,18 +1951,20 @@ export const Composer = forwardRef<ComposerHandle, ComposerProps>(function Compo? `${t('chat.compose.voicePreview')}: ${realtimeAnnouncement}`: ''}</div>- {actions ? (- /* Two-row box (design TfqkD): the input on top, then an action row- carrying the caller's pickers on the left and Send on the right. */- <div className="flex w-full flex-col gap-3 rounded-2xl border border-border-strong bg-surface-2 p-3 shadow-[0_-4px_24px_-12px_rgba(0,0,0,0.5)]">- <div className="flex w-full items-end gap-1.5">{inputControl}</div>- <div className="flex w-full items-end justify-between gap-2">- <div className="flex min-w-0 flex-1 flex-wrap items-center gap-1">+ {stacked ? (+ /* Two-row box: the input across the top, then the action row — Attach+ (or, mid-voice, Discard) on the left; the caller's actions, Voice and+ Send on the right. */+ <div className="flex w-full flex-col gap-1 rounded-2xl border border-border-strong bg-surface-2 p-2 shadow-[0_-4px_24px_-12px_rgba(0,0,0,0.5)]">+ <div className="flex w-full min-w-0 px-1.5">{inputControl}</div>+ <div className="flex w-full items-center justify-between gap-2">+ <div className="flex shrink-0 items-center gap-1">{voiceDiscardControl}- {actions}+ {mediaEnabled && <div className="flex items-end">{attachControl}</div>}</div>- <div className="flex shrink-0 items-center gap-1.5">- {mediaControls}+ <div className="flex min-w-0 items-center justify-end gap-1">+ {actions}+ {mediaEnabled && <div className="flex items-end">{voiceControl}</div>}{sendControls}</div></div>diff --git a/ui/src/i18n/en.json b/ui/src/i18n/en.jsonindex 9443e34bc..546292a91 100644--- a/ui/src/i18n/en.json+++ b/ui/src/i18n/en.json@@ -199,6 +199,7 @@"edit": "Edit","configure": "Configure","cancel": "Cancel",+ "done": "Done","confirm": "Confirm","clear": "Clear","retry": "Retry",@@ -5024,6 +5025,7 @@},"picker": {"agent": "Agent",+ "sheetTitle": "Agent & model","model": "Model","effort": "Effort","effortNotOn": "Not on {{sources}}",diff --git a/ui/src/i18n/zh.json b/ui/src/i18n/zh.jsonindex b7070e368..25ca786b1 100644--- a/ui/src/i18n/zh.json+++ b/ui/src/i18n/zh.json@@ -199,6 +199,7 @@"edit": "编辑","configure": "配置","cancel": "取消",+ "done": "完成","confirm": "确定","clear": "清除","retry": "重试",@@ -5024,6 +5025,7 @@},"picker": {"agent": "Agent",+ "sheetTitle": "Agent 与模型","model": "模型","effort": "思考强度","effortNotOn": "{{sources}} 不支持",