Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.
TypeScript agentaiai-agentsall-in-onecrmcrm-systememaillinearmcpmessagingnotesnotionofficerustslackslack-alternativestartupstartup-toolstypescriptworkspace
feat(agent): select and confirm effort in existing sessions (#7158)
Eric Hayesc40c29095140
diff --git a/apps/web/src/features/agents-view/components/ModelSelector.tsx b/apps/web/src/features/agents-view/components/ModelSelector.tsxindex 0c242040b2..04af5e847a 100644--- a/apps/web/src/features/agents-view/components/ModelSelector.tsx+++ b/apps/web/src/features/agents-view/components/ModelSelector.tsx@@ -1,8 +1,11 @@import type { AgentModelSelectorProps } from '@app/features/block-agent/ui/AgentModelSelector';-import { ModelCatalogPicker } from '@core/component/AI/component/input/ModelCatalogPicker';+import {+ ModelCatalogPicker,+ type ModelRowProps,+} from '@core/component/AI/component/input/ModelCatalogPicker';import { isModelPickerOption } from '@core/component/AI/constant/model';import { modelLabel } from '@core/component/AI/constant/model-label';-import type { JSX } from 'solid-js';+import type { Component, JSX } from 'solid-js';export type ModelChoice = {id: string;@@ -17,6 +20,7 @@ export function ModelSelector(props: {label: JSX.Element;options: ModelChoice[];disabled?: boolean;+ modelRow?: Component<ModelRowProps>;pending?: boolean;onSelect: (id: string) => void;children?: JSX.Element;@@ -41,6 +45,7 @@ export function ModelSelector(props: {disabled={props.disabled}pending={props.pending}onSelect={props.onSelect}+ modelRow={props.modelRow}emptyMessage={props.emptyMessage ?? 'Waiting for the agent to report its models.'}@@ -56,10 +61,16 @@ export function SessionModelSelector(props: AgentModelSelectorProps) {return (<ModelSelectormodel={shown()}- label={modelLabel(- shown(),- props.options.find((option) => option.id === shown())?.name- )}+ 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,diff --git a/apps/web/src/features/block-agent/agent-session-provider.tsx b/apps/web/src/features/block-agent/agent-session-provider.tsxindex ed3cc84d1f..228013f132 100644--- a/apps/web/src/features/block-agent/agent-session-provider.tsx+++ b/apps/web/src/features/block-agent/agent-session-provider.tsx@@ -149,6 +149,7 @@ export function AgentSessionProvider(retryLoad: live.retry,turn,issue: live.issue,+ selectModel: live.selectModel,sendNext,interactions,queue,diff --git a/apps/web/src/features/block-agent/component/AgentComposer.test.tsx b/apps/web/src/features/block-agent/component/AgentComposer.test.tsxindex 675116bfd6..07544cc115 100644--- a/apps/web/src/features/block-agent/component/AgentComposer.test.tsx+++ b/apps/web/src/features/block-agent/component/AgentComposer.test.tsx@@ -9,6 +9,7 @@ import { AgentComposer } from './AgentComposer';const mocks = vi.hoisted(() => ({session: () => ({ canEdit: false as boolean | undefined }),issue: vi.fn(),+ selectModel: vi.fn(),sendNext: vi.fn(),editQueued: vi.fn(),removeQueued: vi.fn(),@@ -39,6 +40,7 @@ vi.mock('../context/AgentSessionContext', () => ({userId: () => 'viewer',interactions: { pending: () => [], canAnswer: () => false },issue: mocks.issue,+ selectModel: mocks.selectModel,loadFailed: () => false,messages: () => [],metadata: () => undefined,@@ -100,6 +102,7 @@ describe('view-only session controls', () => {mocks.queued?.onRemove('queued-1');expect(mocks.issue).not.toHaveBeenCalled();+ expect(mocks.selectModel).not.toHaveBeenCalled();expect(mocks.sendNext).not.toHaveBeenCalled();expect(mocks.upload).not.toHaveBeenCalled();expect(mocks.consumeNotes).not.toHaveBeenCalled();@@ -121,6 +124,7 @@ describe('view-only session controls', () => {expect(mocks.queued?.disabled).toBe(true);mocks.input?.onSend('Cannot send now', []);expect(mocks.issue).not.toHaveBeenCalled();+ expect(mocks.selectModel).not.toHaveBeenCalled();});it.each([true, undefined])(diff --git a/apps/web/src/features/block-agent/component/AgentComposer.tsx b/apps/web/src/features/block-agent/component/AgentComposer.tsxindex bc9f7b0d55..05c032d51e 100644--- a/apps/web/src/features/block-agent/component/AgentComposer.tsx+++ b/apps/web/src/features/block-agent/component/AgentComposer.tsx@@ -1,8 +1,8 @@/*** The block's composer container: reads the session from context and drives* the dumb `AgentInput` with derived props. Every in-flight state it shows- * is read off the fold — the turn discriminant and the messages' pending- * marks — so the composer keeps no state of its own.+ * comes from the fold. The composer also holds the model selector while a+ * combined model-and-effort change waits for runtime confirmation.*/import { useOptionalAgentChanges } from '@app/features/agent-changes/context/agent-changes-controller';@@ -14,9 +14,18 @@ import {import { toast } from '@core/component/Toast/Toast';import { uploadFile } from '@core/util/upload';import type { AgentAction } from '@service-agent-harness/generated/schemas';-import { type Component, For, Show } from 'solid-js';+import { type Component, createSignal, For, Show } from 'solid-js';import { useAgentSession } from '../context/AgentSessionContext';-import { changingModel, hasPendingStop } from '../state/control-message';+import {+ changingConfig,+ changingModel,+ hasPendingStop,+} from '../state/control-message';+import {+ type EffortSelection,+ effortConfigOption,+ effortLabel,+} from '../state/session-config';import {AgentInput,type AgentInputProps,@@ -26,6 +35,7 @@ import {QueuedPrompts,} from '../ui';import type { AgentModelSelectorProps } from '../ui/AgentModelSelector';+import { AgentModelMenuItem } from './AgentModelMenuItem';import { PermissionRequest } from './PermissionRequest';import { promptActionOf } from './prompt-action';@@ -41,6 +51,8 @@ export function AgentComposer(props: {const Input = props.input ?? AgentInput;const ModelSelector = props.modelSelector ?? AgentModelSelector;const {+ session,+ selectModel,displayName,userId,interactions,@@ -50,7 +62,6 @@ export function AgentComposer(props: {metadata,pending,queue,- session,sendNext,turn,registerQuoteInsert,@@ -70,6 +81,29 @@ export function AgentComposer(props: {}};+ const [configuring, setConfiguring] = createSignal(false);+ const chooseModel = async (model: string, selection?: EffortSelection) => {+ if (readOnly() || configuring()) return;+ setConfiguring(true);+ try {+ await selectModel(model, selection);+ } catch (error) {+ toast.failure(+ error instanceof Error+ ? error.message+ : 'The model settings could not be changed'+ );+ } finally {+ setConfiguring(false);+ }+ };++ const effort = () => effortConfigOption(metadata()?.configOptions ?? []);+ const changingEffort = () => {+ const option = effort();+ return option ? changingConfig(messages(), option.id) : undefined;+ };+// A turn is open in some form: the send button becomes a stop square and// prompts sent now wait in the server queue behind it. A stop the fold has// speculated already reads as done - the button goes back to send with the@@ -242,13 +276,32 @@ export function AgentComposer(props: {model={metadata()?.model ?? null}changingTo={changingModel(messages(), metadata()?.model ?? null)}options={metadata()?.supportedModels ?? []}- disabled={loadFailed() || readOnly()}- onSelect={(model) =>- void act(- { type: 'setModel', model },- 'The model could not be changed'- )+ effortLabel={effortLabel(effort(), changingEffort())}+ disabled={+ loadFailed() ||+ readOnly() ||+ pending() ||+ configuring() ||+ changingEffort() !== undefined}+ onSelect={(model) => void chooseModel(model)}+ modelRow={(row) => (+ <AgentModelMenuItem+ {...row}+ harness={session()?.harness}+ effort={+ row.option.id === metadata()?.model ? effort() : undefined+ }+ effortValue={+ row.option.id === metadata()?.model+ ? changingEffort()+ : undefined+ }+ onSelectEffort={(selection) =>+ void chooseModel(row.option.id, selection)+ }+ />+ )}/>}/>diff --git a/apps/web/src/features/block-agent/component/AgentModelMenuItem.test.tsx b/apps/web/src/features/block-agent/component/AgentModelMenuItem.test.tsxnew file mode 100644index 0000000000..cafe7f19c0--- /dev/null+++ b/apps/web/src/features/block-agent/component/AgentModelMenuItem.test.tsx@@ -0,0 +1,161 @@+import { ModelCatalogPicker } from '@core/component/AI/component/input/ModelCatalogPicker';+import {+ cleanup,+ fireEvent,+ render,+ screen,+ waitFor,+} from '@solidjs/testing-library';+import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';+import { AgentModelMenuItem } from './AgentModelMenuItem';++const state = vi.hoisted(() => ({+ error: false,+ pending: false,+ targets: [] as (() => { harness: string; model?: string } | undefined)[],+}));+vi.mock('@queries/agents/capabilities', () => ({+ useAgentCapabilitiesQuery: (+ target: () => { harness: string; model?: string } | undefined+ ) => {+ state.targets.push(target);+ return {+ get isSuccess() {+ return !!target() && !state.error && !state.pending;+ },+ get isFetching() {+ return !!target() && state.pending;+ },+ get isError() {+ return !!target() && state.error;+ },+ get data() {+ return {+ configOptions:+ target()?.model === 'haiku'+ ? []+ : [+ {+ id: 'opaque_effort',+ type: 'select',+ category: 'thought_level',+ currentValue: 'low',+ options: [+ { value: 'low', name: 'Low' },+ { value: 'ultra', name: 'Ultra' },+ ],+ },+ ],+ };+ },+ };+ },+}));+let style: HTMLStyleElement;+beforeEach(() => {+ state.targets = [];+ state.error = false;+ state.pending = false;+ vi.stubGlobal('scrollTo', vi.fn());+ style = document.createElement('style');+ style.textContent =+ '[role="menu"] { animation-name: none; transition-duration: 0s; }';+ document.head.append(style);+});+afterEach(() => {+ cleanup();+ style.remove();+ vi.unstubAllGlobals();+});+function mount(harness = 'cursor', disabled = false) {+ const select = vi.fn();+ const effort = vi.fn();+ render(() => (+ <ModelCatalogPicker+ value="gpt"+ ariaLabel="Model"+ options={[+ { id: 'gpt', label: 'GPT' },+ { id: 'haiku', label: 'Haiku' },+ ]}+ onSelect={select}+ modelRow={(row) => (+ <AgentModelMenuItem+ {...row}+ disabled={disabled}+ harness={harness}+ onSelectEffort={(choice) => effort(row.option.id, choice)}+ />+ )}+ />+ ));+ fireEvent.keyDown(screen.getByRole('button', { name: 'Model' }), {+ key: 'Enter',+ });+ return { select, effort };+}+describe('model effort submenu', () => {+ it('does not select a disabled model on click or Enter', () => {+ const f = mount('cursor', true);+ const row = screen.getByRole('menuitem', { name: 'GPT' });+ expect(row.getAttribute('aria-disabled')).toBe('true');+ fireEvent.click(row);+ fireEvent.keyDown(row, { key: 'Enter' });+ expect(f.select).not.toHaveBeenCalled();+ expect(f.effort).not.toHaveBeenCalled();+ });+ it('discovers only the opened model and selects its opaque effort, closing the catalog', async () => {+ const f = mount('macro-inmem');+ expect(state.targets.every((target) => !target())).toBe(true);+ fireEvent.keyDown(screen.getByRole('menuitem', { name: 'GPT' }), {+ key: 'ArrowRight',+ });+ await screen.findByRole('menuitem', { name: 'Ultra' });+ expect(state.targets.map((t) => t()).filter(Boolean)).toEqual([+ { harness: 'in-memory', model: 'gpt' },+ ]);+ fireEvent.keyDown(screen.getByRole('menuitem', { name: 'Ultra' }), {+ key: 'Enter',+ });+ expect(f.effort).toHaveBeenCalledWith('gpt', {+ configId: 'opaque_effort',+ value: 'ultra',+ name: 'Ultra',+ });+ expect(f.select).not.toHaveBeenCalled();+ await waitFor(() => expect(screen.queryByRole('menu')).toBeNull());+ });+ it('leaves unsupported models selectable without inventing effort values', async () => {+ const f = mount();+ fireEvent.keyDown(screen.getByRole('menuitem', { name: 'Haiku' }), {+ key: 'ArrowRight',+ });+ await screen.findByText('No effort options for this model.');+ expect(screen.queryByRole('menuitem', { name: 'Ultra' })).toBeNull();+ fireEvent.keyDown(screen.getByRole('menuitem', { name: 'Use Haiku' }), {+ key: 'Enter',+ });+ expect(f.select).toHaveBeenCalledWith('haiku');+ });+ it('keeps model selection available when capability discovery fails', async () => {+ state.error = true;+ const f = mount();+ fireEvent.keyDown(screen.getByRole('menuitem', { name: 'GPT' }), {+ key: 'ArrowRight',+ });+ await screen.findByText('Effort options unavailable.');+ fireEvent.keyDown(screen.getByRole('menuitem', { name: 'Use GPT' }), {+ key: 'Enter',+ });+ expect(f.select).toHaveBeenCalledWith('gpt');+ expect(f.effort).not.toHaveBeenCalled();+ });+ it('uses ordinary model rows for harnesses without discovery or live effort metadata', () => {+ const f = mount('other');+ const row = screen.getByRole('menuitem', { name: 'GPT' });+ expect(row.hasAttribute('aria-haspopup')).toBe(false);+ fireEvent.keyDown(row, { key: 'Enter' });+ expect(f.select).toHaveBeenCalledWith('gpt');+ expect(state.targets).toHaveLength(0);+ });+});diff --git a/apps/web/src/features/block-agent/component/AgentModelMenuItem.tsx b/apps/web/src/features/block-agent/component/AgentModelMenuItem.tsxnew file mode 100644index 0000000000..7064e8bbad--- /dev/null+++ b/apps/web/src/features/block-agent/component/AgentModelMenuItem.tsx@@ -0,0 +1,155 @@+import {+ ModelRow,+ type ModelRowProps,+} from '@core/component/AI/component/input/ModelCatalogPicker';+import { ModelIcon } from '@core/component/AI/component/ProviderIcon';+import { isTouchDevice } from '@core/mobile/isTouchDevice';+import CaretRight from '@phosphor/caret-right.svg';+import Check from '@phosphor/check.svg';+import { useAgentCapabilitiesQuery } from '@queries/agents/capabilities';+import { Dropdown } from '@ui';+import { createSignal, For, Show, Suspense } from 'solid-js';+import {+ type EffortChoice,+ effortConfigOption,+ type SelectSessionConfigOption,+} from '../state/session-config';++/** Discover only the hovered model; a live session's current snapshot takes precedence. */+export function AgentModelMenuItem(+ props: ModelRowProps & {+ harness?: string;+ effort?: SelectSessionConfigOption;+ effortValue?: string;+ onSelectEffort: (effort: EffortChoice) => void;+ }+) {+ const discoverable = () =>+ ['cursor', 'in-memory', 'macro-inmem'].includes(props.harness ?? '');+ return (+ <Show+ when={discoverable() || props.effort}+ fallback={<ModelRow {...props} />}+ >+ <EffortModelSubmenu {...props} />+ </Show>+ );+}++function EffortModelSubmenu(+ props: ModelRowProps & {+ harness?: string;+ effort?: SelectSessionConfigOption;+ effortValue?: string;+ onSelectEffort: (effort: EffortChoice) => void;+ }+) {+ const [open, setOpen] = createSignal(false);+ const query = useAgentCapabilitiesQuery(() => {+ const harness =+ props.harness === 'macro-inmem' ? 'in-memory' : props.harness;+ return open() &&+ !props.effort &&+ (harness === 'cursor' || harness === 'in-memory')+ ? { harness, model: props.option.id }+ : undefined;+ });+ const effort = () =>+ props.effort ??+ (query.isSuccess+ ? effortConfigOption(query.data.configOptions)+ : undefined);+ return (+ <Dropdown.Sub open={open()} onOpenChange={setOpen} overlap>+ <Dropdown.SubTrigger+ disabled={props.disabled}+ class="h-8 gap-2"+ textValue={props.option.label}+ title={props.option.description ?? props.option.label}+ onKeyDown={(event) => {+ if (props.disabled) return;+ if (event.key === 'Enter' || event.key === ' ') {+ event.preventDefault();+ event.stopPropagation();+ props.onSelect();+ }+ }}+ onClick={() => {+ if (props.disabled) return;+ if (!isTouchDevice()) props.onSelect();+ }}+ >+ <ModelIcon model={props.option.id} />+ <span class="min-w-0 flex-1 truncate text-sm">+ {props.option.label}+ </span>+ <Show when={props.hint}>+ <span class="shrink-0 text-xs text-ink-extra-muted">+ {props.hint}+ </span>+ </Show>+ <Show when={props.selected}>+ <Check class="size-3.5 shrink-0 text-accent" />+ </Show>+ <CaretRight class="size-3 shrink-0 text-ink-muted" />+ </Dropdown.SubTrigger>+ <Dropdown.SubContent+ aria-label={`Effort for ${props.option.label}`}+ class="w-48 max-w-[calc(100vw-1rem)] max-h-[var(--kb-popper-content-available-height)] overflow-y-auto overscroll-contain"+ onPointerDown={(event: PointerEvent) => event.stopPropagation()}+ onMouseDown={(event: MouseEvent) => event.stopPropagation()}+ >+ <Suspense>+ <Dropdown.Group>+ <Dropdown.Item closeOnSelect onSelect={props.onSelect}>+ Use {props.option.label}+ </Dropdown.Item>+ <Dropdown.GroupLabel>Reasoning effort</Dropdown.GroupLabel>+ <Show+ when={effort()}+ fallback={+ <div role="status" class="px-2 py-2 text-xs text-ink-muted">+ {query.isFetching+ ? 'Loading effort options…'+ : query.isError+ ? 'Effort options unavailable.'+ : 'No effort options for this model.'}+ </div>+ }+ >+ {(config) => (+ <For each={config().options}>+ {(option) => (+ <Dropdown.Item+ closeOnSelect+ title={option.description ?? undefined}+ onSelect={() => {+ props.onSelectEffort({+ configId: config().id,+ value: option.value,+ name: option.name,+ });+ props.onClose?.();+ }}+ >+ <span class="flex-1">{option.name}</span>+ <Show+ when={+ props.selected &&+ option.value ===+ (props.effortValue ?? config().currentValue)+ }+ >+ <Check class="size-3.5 text-accent" />+ </Show>+ </Dropdown.Item>+ )}+ </For>+ )}+ </Show>+ </Dropdown.Group>+ </Suspense>+ </Dropdown.SubContent>+ </Dropdown.Sub>+ );+}diff --git a/apps/web/src/features/block-agent/context/AgentSessionContext.tsx b/apps/web/src/features/block-agent/context/AgentSessionContext.tsxindex 9042a3a005..5e7f03e47f 100644--- a/apps/web/src/features/block-agent/context/AgentSessionContext.tsx+++ b/apps/web/src/features/block-agent/context/AgentSessionContext.tsx@@ -12,6 +12,7 @@ import type {SessionBot,} from '@service-agent-harness/generated/schemas';import { type Accessor, createContext, useContext } from 'solid-js';+import type { EffortSelection } from '../state/session-config';import type { QuoteInsert } from '../ui';import type { QueueController } from './create-queue-controller';import type { InteractionController } from './interaction';@@ -61,6 +62,8 @@ export type AgentSessionState = {* has no session to act on.*/issue: (action: AgentAction) => Promise<IssueResult> | undefined;+ /** Resolve only after the runtime confirms the selected model and effort. */+ selectModel: (model: string, effort?: EffortSelection) => Promise<void>;/*** Send the next queued message now: stop the running turn, and show the* queue head as sent under the id the server already holds it by. Thediff --git a/apps/web/src/features/block-agent/context/configure-session-model.test.ts b/apps/web/src/features/block-agent/context/configure-session-model.test.tsnew file mode 100644index 0000000000..296bcb0fa7--- /dev/null+++ b/apps/web/src/features/block-agent/context/configure-session-model.test.ts@@ -0,0 +1,110 @@+import type { AgentSession } from '@core/agent-session/AgentSession';+import type { AgentAction } from '@service-agent-harness/generated/schemas';+import { ok } from 'neverthrow';+import { describe, expect, it, vi } from 'vitest';+import { configureSessionModel } from './configure-session-model';++function fixture() {+ let listener = () => {};+ const config = {+ id: 'cursor_effort',+ type: 'select',+ category: 'thought_level',+ currentValue: 'low',+ options: [{ value: 'low' }, { value: 'ultra' }],+ };+ const snapshot = {+ metadata: { model: 'old', configOptions: [config] },+ messages: [] as unknown[],+ };+ const issue = vi.fn(async (_action: AgentAction) =>+ ok({ actionId: `action-${issue.mock.calls.length}`, status: 'sent' })+ );+ const session = {+ issue,+ snapshot: async () => snapshot,+ subscribe: (callback: () => void) => {+ listener = callback;+ return () => {};+ },+ } as unknown as AgentSession;+ return {+ session,+ issue,+ snapshot,+ config,+ confirm(action: number, kind = 'accepted') {+ snapshot.messages.push({+ requestId: `action-${action}`,+ pending: false,+ parts: [+ { kind: 'control', outcome: { kind, message: 'Model rejected' } },+ ],+ });+ listener();+ },+ };+}+const selection = { configId: 'cursor_effort', value: 'ultra' };+const flush = async () => {+ for (let i = 0; i < 12; i++) await Promise.resolve();+};++describe('combined model and effort selection', () => {+ it('waits for the model confirmation before issuing the opaque effort, then waits for effort confirmation', async () => {+ const f = fixture();+ let finished = false;+ const result = (async () => {+ await configureSessionModel(f.session, 'new', selection);+ finished = true;+ })();+ await flush();+ expect(f.issue.mock.calls).toEqual([[{ type: 'setModel', model: 'new' }]]);+ f.snapshot.metadata.model = 'new';+ f.confirm(1);+ await flush();+ expect(f.issue.mock.calls[1]).toEqual([+ { type: 'setConfigOption', ...selection },+ ]);+ expect(finished).toBe(false);+ f.confirm(2);+ await result;+ expect(finished).toBe(true);+ });+ it('does not send effort after the model is rejected', async () => {+ const f = fixture();+ const result = configureSessionModel(f.session, 'new', selection);+ const assertion = expect(result).rejects.toThrow('Model rejected');+ await flush();+ f.confirm(1, 'rejected');+ await assertion;+ expect(f.issue).toHaveBeenCalledTimes(1);+ });+ it('revalidates discovery against the confirmed model snapshot', async () => {+ const f = fixture();+ const result = configureSessionModel(f.session, 'new', selection);+ const assertion = expect(result).rejects.toThrow('no longer supports');+ await flush();+ f.snapshot.metadata.model = 'new';+ f.snapshot.metadata.configOptions = [];+ f.confirm(1);+ await assertion;+ expect(f.issue).toHaveBeenCalledTimes(1);+ });+ it('changes only effort for the current model and skips an already selected value', async () => {+ const f = fixture();+ await configureSessionModel(f.session, 'old', {+ ...selection,+ value: 'low',+ });+ expect(f.issue).not.toHaveBeenCalled();+ const result = configureSessionModel(f.session, 'old', selection);+ await flush();+ expect(f.issue).toHaveBeenCalledWith({+ type: 'setConfigOption',+ ...selection,+ });+ f.confirm(1);+ await result;+ });+});diff --git a/apps/web/src/features/block-agent/context/configure-session-model.ts b/apps/web/src/features/block-agent/context/configure-session-model.tsnew file mode 100644index 0000000000..5a80e2a892--- /dev/null+++ b/apps/web/src/features/block-agent/context/configure-session-model.ts@@ -0,0 +1,33 @@+import type { AgentSession } from '@core/agent-session/AgentSession';+import {+ type EffortSelection,+ effortConfigOption,+} from '../state/session-config';+import { confirmSessionControl } from './confirm-session-control';++/** Validate against the model's confirmed runtime snapshot before setting effort. */+export async function configureSessionModel(+ session: Pick<AgentSession, 'issue' | 'snapshot' | 'subscribe'>,+ model: string,+ effort?: EffortSelection+) {+ if ((await session.snapshot()).metadata.model !== model) {+ await confirmSessionControl(session, { type: 'setModel', model });+ }+ if (!effort) return;+ const option = effortConfigOption(+ (await session.snapshot()).metadata.configOptions+ );+ if (+ option?.id !== effort.configId ||+ !option.options.some((choice) => choice.value === effort.value)+ ) {+ throw new Error('The selected model no longer supports this effort.');+ }+ if (option.currentValue === effort.value) return;+ await confirmSessionControl(session, {+ type: 'setConfigOption',+ configId: effort.configId,+ value: effort.value,+ });+}diff --git a/apps/web/src/features/block-agent/context/confirm-session-control.test.ts b/apps/web/src/features/block-agent/context/confirm-session-control.test.tsnew file mode 100644index 0000000000..75c6c240e0--- /dev/null+++ b/apps/web/src/features/block-agent/context/confirm-session-control.test.ts@@ -0,0 +1,92 @@+import type { AgentSession } from '@core/agent-session/AgentSession';+import { err, ok } from 'neverthrow';+import { afterEach, describe, expect, it, vi } from 'vitest';+import { confirmSessionControl } from './confirm-session-control';++function session() {+ let listener = () => {};+ const unsubscribe = vi.fn();+ const snapshot = { messages: [] as unknown[] };+ const value = {+ issue: vi+ .fn()+ .mockResolvedValue(ok({ actionId: 'action', status: 'sent' })),+ snapshot: vi.fn(async () => snapshot),+ subscribe: vi.fn((callback: () => void) => {+ listener = callback;+ return unsubscribe;+ }),+ };+ return {+ value: value as unknown as AgentSession,+ issue: value.issue,+ unsubscribe,+ outcome(kind: string, requestId = 'action') {+ snapshot.messages = [+ {+ requestId,+ pending: false,+ parts: [+ {+ kind: 'control',+ outcome: { kind, message: 'unsupported effort' },+ },+ ],+ },+ ];+ listener();+ },+ };+}+const action = {+ type: 'setConfigOption',+ configId: 'effort',+ value: 'ultra',+} as const;+const flush = async () => {+ await Promise.resolve();+ await Promise.resolve();+ await Promise.resolve();+};+afterEach(() => vi.useRealTimers());+describe('confirmed session controls', () => {+ it('waits past HTTP acceptance and unrelated actions for the correlated runtime outcome', async () => {+ const test = session();+ const done = vi.fn();+ const result = confirmSessionControl(test.value, action).then(done);+ await flush();+ expect(done).not.toHaveBeenCalled();+ test.outcome('accepted', 'another-action');+ await flush();+ expect(done).not.toHaveBeenCalled();+ test.outcome('accepted');+ await result;+ expect(done).toHaveBeenCalledOnce();+ expect(test.unsubscribe).toHaveBeenCalledOnce();+ });+ it('rejects when ACP rejects a queued setting', async () => {+ const test = session();+ const result = confirmSessionControl(test.value, action);+ const assertion = expect(result).rejects.toThrow('unsupported effort');+ await flush();+ test.outcome('rejected');+ await assertion;+ expect(test.unsubscribe).toHaveBeenCalledOnce();+ });+ it('times out without treating silence as acceptance', async () => {+ vi.useFakeTimers();+ const test = session();+ const result = confirmSessionControl(test.value, action);+ const assertion = expect(result).rejects.toThrow('did not confirm');+ await vi.advanceTimersByTimeAsync(60_000);+ await assertion;+ expect(test.unsubscribe).toHaveBeenCalledOnce();+ });+ it('fails immediately on HTTP rejection', async () => {+ const test = session();+ test.issue.mockResolvedValue(err([{ message: 'disconnected' }]));+ await expect(confirmSessionControl(test.value, action)).rejects.toThrow(+ 'disconnected'+ );+ });+});diff --git a/apps/web/src/features/block-agent/context/confirm-session-control.ts b/apps/web/src/features/block-agent/context/confirm-session-control.tsnew file mode 100644index 0000000000..922f2af342--- /dev/null+++ b/apps/web/src/features/block-agent/context/confirm-session-control.ts@@ -0,0 +1,53 @@+import type { AgentSession } from '@core/agent-session/AgentSession';+import type { AgentAction } from '@service-agent-harness/generated/schemas';++/** HTTP acceptance only queues a control. Wait for its correlated ACP outcome. */+export async function confirmSessionControl(+ session: Pick<AgentSession, 'issue' | 'snapshot' | 'subscribe'>,+ action: AgentAction+): Promise<void> {+ const result = await session.issue(action);+ if (result.isErr())+ throw new Error(result.error.map((error) => error.message).join(' '));+ const actionId = result.value.actionId;+ await new Promise<void>((resolve, reject) => {+ let finished = false;+ const finish = (error?: Error) => {+ if (finished) return;+ finished = true;+ clearTimeout(timeout);+ unsubscribe();+ if (error) reject(error);+ else resolve();+ };+ const inspect = async () => {+ try {+ const snapshot = await session.snapshot();+ const message = snapshot.messages.find(+ (message) => message.requestId === actionId+ );+ if (!message || message.pending) return;+ const part = message.parts.find((part) => part.kind === 'control');+ if (part?.kind !== 'control' || part.outcome.kind === 'pending') return;+ finish(+ part.outcome.kind === 'rejected'+ ? new Error(part.outcome.message)+ : undefined+ );+ } catch (error) {+ finish(+ error instanceof Error+ ? error+ : new Error('Could not confirm the session setting.')+ );+ }+ };+ const timeout = setTimeout(+ () =>+ finish(new Error('The agent did not confirm the selected setting.')),+ 60_000+ );+ const unsubscribe = session.subscribe(() => void inspect());+ void inspect();+ });+}diff --git a/apps/web/src/features/block-agent/context/create-agent-session.ts b/apps/web/src/features/block-agent/context/create-agent-session.tsindex 91e1055352..136ed224b5 100644--- a/apps/web/src/features/block-agent/context/create-agent-session.ts+++ b/apps/web/src/features/block-agent/context/create-agent-session.ts@@ -40,6 +40,8 @@ import {untrack,} from 'solid-js';import { createStore, produce, reconcile } from 'solid-js/store';+import type { EffortSelection } from '../state/session-config';+import { configureSessionModel } from './configure-session-model';export type AgentSessionHandle = {/** Session row, absent until the load resolves. */@@ -60,6 +62,8 @@ export type AgentSessionHandle = {* log. `undefined` while the block has no session to act on.*/issue: (action: AgentAction) => Promise<IssueResult> | undefined;+ /** Confirm a model change, then validate and confirm its optional effort. */+ selectModel: (model: string, effort?: EffortSelection) => Promise<void>;/*** Show a queued action as dispatched under the id the server holds it* by. See {@link AgentSession.expect}.@@ -305,6 +309,20 @@ export function createAgentSession(accessDenied: () => resource.error instanceof AgentSessionAccessDenied,retry: () => void refetch(),issue: (action) => live()?.issue(action, { userId: options.userId() }),+ selectModel: async (model, effort) => {+ const current = live();+ if (!current) throw new Error('The agent session is not ready.');+ await configureSessionModel(+ {+ issue: (action) =>+ current.issue(action, { userId: options.userId() }),+ snapshot: () => current.snapshot(),+ subscribe: (listener) => current.subscribe(listener),+ },+ model,+ effort+ );+ },expect: (actionId, action) =>live()?.expect(actionId, action, { userId: options.userId() }),retract: (actionId) => live()?.retract(actionId),diff --git a/apps/web/src/features/block-agent/state/control-message.ts b/apps/web/src/features/block-agent/state/control-message.tsindex 117950e4ec..3fc9a94f93 100644--- a/apps/web/src/features/block-agent/state/control-message.ts+++ b/apps/web/src/features/block-agent/state/control-message.ts@@ -73,3 +73,24 @@ export function hasPendingStop(messages: readonly FoldedMessage[]): boolean {message.parts[0].control.kind === 'stop');}++/** A config change remains pending until the runtime answers it. */+export function changingConfig(+ messages: readonly FoldedMessage[],+ configId: string+): string | undefined {+ for (let index = messages.length - 1; index >= 0; index--) {+ const message = messages[index]!;+ const part = message.parts[0];+ if (message.parts.length !== 1 || part?.kind !== 'control') continue;+ if (+ part.control.kind !== 'set_config_option' ||+ part.control.config_id !== configId+ )+ continue;+ return message.pending || part.outcome.kind === 'pending'+ ? part.control.value+ : undefined;+ }+ return undefined;+}diff --git a/apps/web/src/features/block-agent/state/session-config.ts b/apps/web/src/features/block-agent/state/session-config.tsnew file mode 100644index 0000000000..1efe6977a2--- /dev/null+++ b/apps/web/src/features/block-agent/state/session-config.ts@@ -0,0 +1,44 @@+import type { SessionConfigOption } from '@service-agent-fold/generated/types';++export type SelectSessionConfigOption = Extract<+ SessionConfigOption,+ { type: 'select' }+>;++/** Find one select by ACP semantic category, with an id fallback for agents+ * that predate categories. */+export function selectConfigOption(+ options: readonly SessionConfigOption[],+ category: string,+ fallbackId: string+): SelectSessionConfigOption | undefined {+ const candidate =+ options.find((option) => option.category === category) ??+ options.find((option) => option.id === fallbackId);+ return candidate?.type === 'select' ? candidate : undefined;+}++export function modelConfigOption(+ options: readonly SessionConfigOption[]+): SelectSessionConfigOption | undefined {+ return selectConfigOption(options, 'model', 'model');+}++export function effortConfigOption(+ options: readonly SessionConfigOption[]+): SelectSessionConfigOption | undefined {+ return selectConfigOption(options, 'thought_level', 'reasoning_effort');+}++/** Opaque harness setting selected alongside a model. */+export type EffortSelection = { configId: string; value: string };+export type EffortChoice = EffortSelection & { name: string };++export function effortLabel(+ option: SelectSessionConfigOption | undefined,+ value?: string+) {+ return option?.options.find(+ (choice) => choice.value === (value ?? option.currentValue)+ )?.name;+}diff --git a/apps/web/src/features/block-agent/ui/AgentModelSelector.tsx b/apps/web/src/features/block-agent/ui/AgentModelSelector.tsxindex 2be810aa25..1230cad02a 100644--- a/apps/web/src/features/block-agent/ui/AgentModelSelector.tsx+++ b/apps/web/src/features/block-agent/ui/AgentModelSelector.tsx@@ -22,7 +22,10 @@*/import { MobileDrawer } from '@components/app/mobile/MobileDrawer';-import { ModelCatalogPicker } from '@core/component/AI/component/input/ModelCatalogPicker';+import {+ ModelCatalogPicker,+ type ModelRowProps,+} from '@core/component/AI/component/input/ModelCatalogPicker';import {type CatalogModelOption,isLargeModelCatalog,@@ -37,7 +40,7 @@ import SearchIcon from '@phosphor/magnifying-glass.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 { createMemo, createSignal, For, Show } from 'solid-js';+import { type Component, createMemo, createSignal, For, Show } from 'solid-js';import { groupOptions, withoutRedundantGroups } from './model-groups';/** Compact ghost pill — same size as the short-list trigger and chat's selector. */@@ -74,6 +77,8 @@ export interface AgentModelSelectorProps {/** The models the harness offers, in the order it listed them. */options: ModelOption[];disabled?: boolean;+ effortLabel?: string;+ modelRow?: Component<ModelRowProps>;/** Receives the id of the model to switch to. */onSelect: (model: string) => void;}@@ -83,11 +88,13 @@ export function AgentModelSelector(props: AgentModelSelectorProps) {const [sheetOpen, setSheetOpen] = createSignal(false);const [query, setQuery] = createSignal('');const shown = () => props.changingTo ?? props.model;- const label = () =>+ const baseLabel = () =>modelLabel(shown() ?? undefined,props.options.find((option) => option.id === shown())?.name);+ const label = () =>+ [baseLabel(), props.effortLabel].filter(Boolean).join(' · ');const options = createMemo(() => withoutRedundantGroups(props.options));const toCatalogOption = (option: ModelOption): CatalogModelOption => ({id: option.id,@@ -252,12 +259,14 @@ export function AgentModelSelector(props: AgentModelSelectorProps) {return (<Show when={props.options.length > 0}>- <Show when={!isTouchDevice()} fallback={sheet}>- <Show when={useCatalog()} fallback={shortList}>+ <Show when={!isTouchDevice() || props.modelRow} fallback={sheet}>+ <Show when={useCatalog() || props.modelRow} fallback={shortList}><ModelCatalogPickervalue={shown()}options={catalogOptions()}onSelect={pick}+ modelRow={props.modelRow}+ triggerLabel={label()}disabled={props.disabled}ariaLabel="Agent model"searchPlaceholder="Search models"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.tsxindex d29686b46c..4db4e613cc 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@@ -11,7 +11,11 @@ import {} from '@solidjs/testing-library';import { createSignal, type JSX } from 'solid-js';import { afterEach, describe, expect, it, vi } from 'vitest';-import { ModelCatalogMenu, ModelCatalogPicker } from './ModelCatalogPicker';+import {+ ModelCatalogMenu,+ ModelCatalogPicker,+ type ModelRowProps,+} from './ModelCatalogPicker';import type { CatalogModelOption } from './modelCatalog';const { isMobileWidth, setMobileWidth } = vi.hoisted(() => {@@ -176,27 +180,81 @@ describe('ModelCatalogMenu search focus', () => {it('reclaims search focus when the submenu trigger steals it', async () => {render(() => (- <ModelCatalogMenu- autoFocusSearch- value="auto"- options={OPTIONS}- onSelect={() => {}}- />+ <>+ <button type="button" id="agent-model-trigger">+ Agent+ </button>+ <div role="menu" aria-labelledby="agent-model-trigger">+ <ModelCatalogMenu+ autoFocusSearch+ value="auto"+ options={OPTIONS}+ onSelect={() => {}}+ />+ </div>+ </>));const search = screen.getByRole('textbox', { name: 'Search models' });await waitFor(() => {expect(document.activeElement).toBe(search);});- const thief = document.createElement('button');- document.body.append(thief);+ const thief = screen.getByRole('button', { name: 'Agent' });thief.focus();expect(document.activeElement).toBe(thief);await waitFor(() => {expect(document.activeElement).toBe(search);});- thief.remove();+ });++ it('allows focus to move into a nested effort menu', async () => {+ render(() => (+ <>+ <div role="menu" aria-labelledby="agent-model-trigger">+ <ModelCatalogMenu+ autoFocusSearch+ value="auto"+ options={OPTIONS}+ onSelect={() => {}}+ />+ </div>+ <div role="menu" aria-label="Effort">+ <button type="button">High</button>+ </div>+ </>+ ));+ const search = screen.getByRole('textbox', { name: 'Search models' });+ await waitFor(() => expect(document.activeElement).toBe(search));+ const effort = screen.getByRole('button', { name: 'High' });+ effort.focus();+ await Promise.resolve();+ expect(document.activeElement).toBe(effort);+ });++ it('keeps initial search focus until the user navigates a model row', async () => {+ render(() => (+ <div role="menu" aria-labelledby="agent-model-trigger">+ <ModelCatalogMenu+ autoFocusSearch+ value="auto"+ options={OPTIONS}+ onSelect={() => {}}+ />+ <button type="button" role="menuitem">+ Selected model+ </button>+ </div>+ ));+ const search = screen.getByRole('textbox', { name: 'Search models' });+ await waitFor(() => expect(document.activeElement).toBe(search));+ const model = screen.getByRole('menuitem', { name: 'Selected model' });+ model.focus();+ await waitFor(() => expect(document.activeElement).toBe(search));+ fireEvent.pointerMove(model);+ model.focus();+ await Promise.resolve();+ expect(document.activeElement).toBe(model);});});@@ -216,4 +274,33 @@ describe('ModelCatalogPicker more models at phone width', () => {expect(screen.getByText('Opus 5 High')).toBeTruthy();expect(screen.queryByText('Gemini 3.8 Flash High')).toBeNull();});++ it('uses the supplied model row for models beyond the recommended list', () => {+ setMobileWidth(true);+ const CustomRow = (props: ModelRowProps) => (+ <button type="button" onClick={props.onSelect}>+ Custom {props.option.label}+ </button>+ );+ render(() => {+ const [value, setValue] = createSignal('auto');+ return (+ <ModelCatalogPicker+ value={value()}+ options={OPTIONS}+ onSelect={setValue}+ modelRow={CustomRow}+ ariaLabel="Agent model"+ />+ );+ });++ fireEvent.click(screen.getByText('More models'));+ fireEvent.click(+ screen.getByRole('button', { name: 'Custom Gemini 3.8 Flash High' })+ );+ expect(+ screen.getByRole('button', { name: 'Agent model' }).textContent+ ).toContain('Gemini 3.8 Flash High');+ });});diff --git a/apps/web/src/lib/core/component/AI/component/input/ModelCatalogPicker.tsx b/apps/web/src/lib/core/component/AI/component/input/ModelCatalogPicker.tsxindex 7b46fda173..a6cfd3c3f6 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@@ -5,6 +5,7 @@ import CheckIcon from '@phosphor/check.svg';import MagnifyingGlassIcon from '@phosphor/magnifying-glass.svg';import { cn, Dropdown } from '@ui';import {+ type Component,createMemo,createSignal,For,@@ -30,6 +31,7 @@ type ModelCatalogPickerProps = {recommendedId?: string | null;options: CatalogModelOption[];onSelect: (id: string) => void;+ modelRow?: Component<ModelRowProps>;disabled?: boolean;pending?: boolean;triggerLabel?: JSX.Element;@@ -43,14 +45,17 @@ type ModelCatalogPickerProps = {placement?: 'top-start' | 'top-end' | 'bottom-start' | 'bottom-end';};-function ModelRow(props: {+export type ModelRowProps = {option: CatalogModelOption;selected: boolean;disabled?: boolean;/** Trailing muted text, e.g. the family a search hit belongs to. */hint?: string;onSelect: () => void;-}) {+ onClose?: () => void;+};++export function ModelRow(props: ModelRowProps) {return (<Dropdown.ItemcloseOnSelect@@ -77,7 +82,10 @@ function FamilyList(props: {value: string | null;disabled?: boolean;onSelect: (id: string) => void;+ row: Component<ModelRowProps>;+ onClose?: () => void;}) {+ const Row = props.row;return (<For each={props.families}>{(family) => (@@ -87,8 +95,9 @@ function FamilyList(props: {</Show><For each={family.options}>{(option) => (- <ModelRow+ <Rowoption={option}+ onClose={props.onClose}selected={option.id === props.value}disabled={props.disabled}onSelect={() => props.onSelect(option.id)}@@ -124,24 +133,53 @@ function focusSearchAfterMenuOpen(input: () => HTMLInputElement | undefined) {* + rAF in `focusSearchAfterMenuOpen` waits past that onMount.* 2. SubTrigger `onPointerMove` keeps calling `focusWithoutScrolling` on* the agent row, so any mouse move while hovering it yanks focus back.- * Reclaim on blur; Escape / click-outside close the sub first, which- * unregisters this listener before focus leaves the tree.+ * Keep startup autofocus on search, then reclaim only when that parent+ * trigger steals focus. Model rows and their nested effort menus must+ * retain focus once the user navigates them.*/function keepSearchFocused(input: () => HTMLInputElement | undefined) {focusSearchAfterMenuOpen(input);+ const menu = input()?.closest('[role="menu"]');+ let navigating = false;+ const onNavigate = (event: Event) => {+ if (+ event.target instanceof Element &&+ event.target.closest('[role="menuitem"]')+ ) {+ navigating = true;+ }+ };+ for (const type of ['pointermove', 'pointerdown', 'keydown']) {+ menu?.addEventListener(type, onNavigate, true);+ }const onBlur = () => {queueMicrotask(() => {const search = input();- if (search?.isConnected && document.activeElement !== search) {+ const triggerId = menu?.getAttribute('aria-labelledby');+ const active = document.activeElement;+ // Kobalte may focus its selected row after the search's initial focus.+ // Once the user navigates the catalog, leave those rows in control.+ const initialRowFocus =+ !navigating && menu && active?.closest('[role="menu"]') === menu;+ if (+ search?.isConnected &&+ (triggerId === active?.id || initialRowFocus)+ ) {search.focus();}});};input()?.addEventListener('blur', onBlur);- onCleanup(() => input()?.removeEventListener('blur', onBlur));+ onCleanup(() => {+ input()?.removeEventListener('blur', onBlur);+ for (const type of ['pointermove', 'pointerdown', 'keydown']) {+ menu?.removeEventListener(type, onNavigate, true);+ }+ });}export function ModelCatalogPicker(props: ModelCatalogPickerProps) {+ const [open, setOpen] = createSignal(false);let searchRef: HTMLInputElement | undefined;const selected = () =>@@ -149,7 +187,11 @@ export function ModelCatalogPicker(props: ModelCatalogPickerProps) {const displayValue = () => selected()?.label ?? props.placeholder ?? 'Model';return (- <Dropdown placement={props.placement ?? 'top-start'}>+ <Dropdown+ open={open()}+ onOpenChange={setOpen}+ placement={props.placement ?? 'top-start'}+ ><Dropdown.Triggervariant="ghost"size="sm"@@ -159,7 +201,11 @@ export function ModelCatalogPicker(props: ModelCatalogPickerProps) {)}aria-label={props.ariaLabel}aria-busy={props.pending || undefined}- title={displayValue()}+ title={+ typeof props.triggerLabel === 'string'+ ? props.triggerLabel+ : displayValue()+ }disabled={props.disabled || props.pending}><ModelIcon model={props.value} />@@ -185,7 +231,12 @@ export function ModelCatalogPicker(props: ModelCatalogPickerProps) {recommendedId={props.recommendedId}options={props.options}disabled={props.disabled || props.pending}- onSelect={props.onSelect}+ onSelect={(id) => {+ props.onSelect(id);+ setOpen(false);+ }}+ onClose={() => setOpen(false)}+ modelRow={props.modelRow}emptyMessage={props.emptyMessage}searchPlaceholder={props.searchPlaceholder}searchRef={(element) => {@@ -203,6 +254,7 @@ export function ModelCatalogPicker(props: ModelCatalogPickerProps) {export function ModelCatalogMenu(props: Pick<ModelCatalogPickerProps,+ | 'modelRow'| 'value'| 'recommendedId'| 'options'@@ -218,9 +270,11 @@ export function ModelCatalogMenu(* submenus, which never fire the root menu's `onOpenAutoFocus`.*/autoFocusSearch?: boolean;+ onClose?: () => void;}) {let searchEl: HTMLInputElement | undefined;+ const Row = props.modelRow ?? ModelRow;const [query, setQuery] = createSignal('');onMount(() => {if (props.autoFocusSearch) keepSearchFocused(() => searchEl);@@ -307,6 +361,8 @@ export function ModelCatalogMenu(value={props.value}disabled={props.disabled}onSelect={props.onSelect}+ row={Row}+ onClose={props.onClose}/></Dropdown.Group>}@@ -316,8 +372,9 @@ export function ModelCatalogMenu(<Dropdown.GroupLabel>Recommended</Dropdown.GroupLabel><For each={catalog().recommended}>{(option) => (- <ModelRow+ <Rowoption={option}+ onClose={props.onClose}hint={modelFamilyHint(option)}selected={option.id === props.value}disabled={props.disabled}@@ -346,7 +403,7 @@ export function ModelCatalogMenu(</Dropdown.Item>}>- <Dropdown.Sub>+ <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">@@ -369,6 +426,8 @@ export function ModelCatalogMenu(value={props.value}disabled={props.disabled}onSelect={props.onSelect}+ row={Row}+ onClose={props.onClose}/></Dropdown.Group></Dropdown.SubContent>@@ -387,8 +446,9 @@ export function ModelCatalogMenu(</Dropdown.GroupLabel><For each={filtered()}>{(option) => (- <ModelRow+ <Rowoption={option}+ onClose={props.onClose}hint={modelFamilyHint(option)}selected={option.id === props.value}disabled={props.disabled}diff --git a/docs/AGENT_EFFORT.md b/docs/AGENT_EFFORT.mdindex 24d86fed40..0e7f339662 100644--- a/docs/AGENT_EFFORT.md+++ b/docs/AGENT_EFFORT.md@@ -44,15 +44,19 @@ Sources checked September 21, 2026:## Session lifecycle-- POST /agent-capabilities/discover accepts a selected model for Cursor and- in-memory. The existing /agent-models/load API remains available.-- External ACP runtimes do not advertise model-specific preflight capabilities.+- `POST /agent-capabilities/discover` accepts a selected model for Cursor and+ in-memory. The existing `/agent-models/load` API remains available.+- Capability cache identity includes the harness and model. External harnesses+ expose controls after opening a session; model-specific preflight is not guessed.- New/resumed sessions and setting changes return the complete configuration.Clients replace their previous options, including removing unsupported controls.- In-memory rejects unsupported models and effort values. A model change resetsan incompatible effort to Default. Replay restores confirmed snapshots only;failed or unanswered requests do not become session settings.+The [ACP configuration contract](https://agentclientprotocol.com/protocol/v1/session-config-options)+documents full snapshots, semantic categories, and opaque values.+## Probe evidence and limitsPrompt-free local ACP probes initialized a session, switched advertised models,@@ -78,3 +82,17 @@ and `session/set_config_option` using the returned session id and advertisedconfig ids/values. Re-read the full `configOptions` after every model change.Record harness and adapter versions. Never infer a native provider profile froman external harness result.++## Model menu interaction++Effort is a submenu of each model in running-session selectors.+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+no effort options keep ordinary model selection available.++A combined running-session selection waits for the model's correlated ACP+confirmation, validates effort against the new snapshot, then confirms effort.+A model rejection prevents the effort request. An effort rejection leaves the+accepted model in place and reports the failure.diff --git a/docs/AGENT_GUIDE/ai-chat.md b/docs/AGENT_GUIDE/ai-chat.mdindex ebd274aea8..b042ac132c 100644--- a/docs/AGENT_GUIDE/ai-chat.md+++ b/docs/AGENT_GUIDE/ai-chat.md@@ -966,6 +966,23 @@ Verify status changes (open/merged/closed) while the chip stays mounted, andverify that reconnecting the gateway catches up changes missed while disconnected.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.+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+support remain selectable through `Use <model>` (or a desktop click/Enter).+Default keeps the model's existing behavior.++In an open session, choosing a different model's effort confirms the model first,+then validates and applies effort. Wait for the selector to become available+again. If the model succeeds but effort is rejected, the new model remains+selected with its confirmed effort; the error is shown and no unsupported+setting is presented as accepted.++See [effort capabilities](../AGENT_EFFORT.md) for the harness contracts and test coverage.## Reading skillsdiff --git a/docs/AGENT_GUIDE/surfaces.md b/docs/AGENT_GUIDE/surfaces.mdindex 20689cea80..61e8cf661a 100644--- a/docs/AGENT_GUIDE/surfaces.md+++ b/docs/AGENT_GUIDE/surfaces.md@@ -1637,3 +1637,21 @@ action is unavailable.focus to its trigger. Busy overlapping events are labeled, while cancelled, declined,and free events do not count as conflicts. Calendar 12/24-hour preferences apply toalready-open invitation cards as well as the calendar view.++### 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.+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+support remain selectable through `Use <model>` (or a desktop click/Enter).+Default keeps the model's existing behavior.++In an open session, choosing a different model's effort confirms the model first,+then validates and applies effort. Wait for the selector to become available+again. If the model succeeds but effort is rejected, the new model remains+selected with its confirmed effort; the error is shown and no unsupported+setting is presented as accepted.++See [effort capabilities](../AGENT_EFFORT.md) for the harness contracts and test coverage.