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
fix(workbench): hold effort writes while the effort menu rereads, and check the effort again at Create (#2817)
Call Whitedccfc9833f35
diff --git a/tests/scenarios/INDEX.yaml b/tests/scenarios/INDEX.yamlindex 7ab83b0d9..16176f01b 100644--- a/tests/scenarios/INDEX.yaml+++ b/tests/scenarios/INDEX.yaml@@ -61,6 +61,7 @@ capabilities:- ui/src/lib/backendModels.test.ts- ui/src/components/workbench/AgentRoutePicker.test.tsx- ui/src/components/workbench/AgentsPage.test.tsx+ - ui/src/components/workbench/NewAgentDialog.test.tsx- tests/agent_core/ai/test_hosted_requests.py- tests/agent_core/ai/test_hosted_parsing.py- tests/agent_core/ai/test_hosted_transform.pydiff --git a/tests/scenarios/model_hub/catalog.yaml b/tests/scenarios/model_hub/catalog.yamlindex 4c819d614..ef49314da 100644--- a/tests/scenarios/model_hub/catalog.yaml+++ b/tests/scenarios/model_hub/catalog.yaml@@ -15,6 +15,7 @@ capability:- ui/src/lib/backendModels.test.ts- ui/src/components/workbench/AgentRoutePicker.test.tsx- ui/src/components/workbench/AgentsPage.test.tsx+ - ui/src/components/workbench/NewAgentDialog.test.tsx- tests/agent_core/ai/test_hosted_requests.py- tests/agent_core/ai/test_hosted_parsing.py- tests/agent_core/ai/test_hosted_transform.py@@ -329,6 +330,15 @@ scenarios:test:- ui/src/components/workbench/AgentRoutePicker.test.tsx::MH-EFFORT-MENU-003- ui/src/components/workbench/AgentsPage.test.tsx::MH-EFFORT-MENU-003+ - id: MH-EFFORT-MENU-004+ name: While an effort-menu read is in flight, the route picker and the Agents page hold the controls that can write an effort, and the New Agent dialog reads again at Create, creating only an effort the answer still offers and nothing when Model Hub cannot answer+ status: covered+ kind: observation+ layer: unit+ test:+ - ui/src/components/workbench/AgentRoutePicker.test.tsx::MH-EFFORT-MENU-004+ - ui/src/components/workbench/AgentsPage.test.tsx::MH-EFFORT-MENU-004+ - ui/src/components/workbench/NewAgentDialog.test.tsx::MH-EFFORT-MENU-004- id: MH-HOSTED-VIBEY-001name: Vibey declares a search tool natively, verbatim with its include values, exactly when the hop's facts assume it, and pins that request to the hop's Sourcestatus: covereddiff --git a/ui/src/components/workbench/AgentRoutePicker.test.tsx b/ui/src/components/workbench/AgentRoutePicker.test.tsxindex a4df39ae1..343c1303a 100644--- a/ui/src/components/workbench/AgentRoutePicker.test.tsx+++ b/ui/src/components/workbench/AgentRoutePicker.test.tsx@@ -338,6 +338,33 @@ describe('AgentRoutePicker', () => {expect(effortColumn().queryByRole('button', { name: /chat\.picker\.effortOptions\.high/ })).toBeNull();});+ it('MH-EFFORT-MENU-004: holds the efforts and models of the last answer while the reopened menu reads again', async () => {+ hubMode = 'hub';+ catalogReasoning = { sonnet: [{ value: 'low', label: 'low' }, { value: 'high', label: 'high' }] };+ const onChange = vi.fn();+ const user = userEvent.setup();+ render(<HubPicker role="owner" onChange={onChange} />);+ await openMenu(user);+ await user.keyboard('{Escape}');++ // A turn recorded that every hop refuses `high`, and the reopened menu's read is still out.+ catalogReasoning = { sonnet: [{ value: 'low', label: 'low' }] };+ catalogMenus = { sonnet: { omitted: ['high'], not_on: {} } };+ deferReads = true;+ await openMenu(user);+ const high = effortColumn().getByRole('button', { name: /chat\.picker\.effortOptions\.high/ }) as HTMLButtonElement;+ expect(high.disabled).toBe(true);+ await user.click(high);+ // A model choice keeps or clears the effort, so it waits for the answer too.+ const opus = screen.getByRole('button', { name: 'opus' }) as HTMLButtonElement;+ expect(opus.disabled).toBe(true);+ await user.click(opus);+ expect(onChange).not.toHaveBeenCalled();++ act(() => pendingReads.shift()!());+ expect(effortColumn().queryByRole('button', { name: /chat\.picker\.effortOptions\.high/ })).toBeNull();+ });+it('keeps the last Hub answer, and reads Hub again, when one open falls back to the native list', async () => {// Hub: every hop refuses the route's `low`.hubMode = 'hub';diff --git a/ui/src/components/workbench/AgentRoutePicker.tsx b/ui/src/components/workbench/AgentRoutePicker.tsxindex 35facb4a7..8fc3f6ae8 100644--- a/ui/src/components/workbench/AgentRoutePicker.tsx+++ b/ui/src/components/workbench/AgentRoutePicker.tsx@@ -232,7 +232,9 @@ export const AgentRoutePicker: React.FC<AgentRoutePickerProps> = ({// under Settings reads again as it is uncovered. A Hub catalog is read again on// every open: its effort menu follows capability evidence, which any turn can// change, and the read is the persisted catalog, which starts no CLI. The last- // answer shows until the new one lands.+ // answer shows until the new one lands, and its efforts and models (a model+ // choice keeps or clears the effort) are held while the read is in flight+ // (`readHubBackendModels`).useEffect(() => {const loadedBackends = loadedModelBackendsRef.current;if (!open || !surfaceActive || !backend || loadedBackends.has(backend)) return;@@ -268,6 +270,7 @@ export const AgentRoutePicker: React.FC<AgentRoutePickerProps> = ({);return () => {cancel();+ setLoadingModels(false);if (reloadOnNextOpen) loadedBackends.delete(backend);};}, [open, surfaceActive, backend, api]);@@ -492,6 +495,7 @@ export const AgentRoutePicker: React.FC<AgentRoutePickerProps> = ({<RouteItemkey={model}active={model === currentModel}+ disabled={loadingModels}onClick={() => {const patch: AgentRoutePatch = { model };// Switching to a model whose effort set no longer includes@@ -545,6 +549,7 @@ export const AgentRoutePicker: React.FC<AgentRoutePickerProps> = ({<RouteItemkey={opt}active={opt === currentEffort}+ disabled={loadingModels}onClick={() => applyPatch({ reasoning_effort: opt })}><span className="flex min-w-0 flex-1 flex-col">@@ -588,13 +593,15 @@ const PickerExitButton: React.FC<{ label: string; onClick: () => void }> = ({ la// so it inherits the design system's focus/disabled behavior.const RouteItem: React.FC<{active: boolean;+ disabled?: boolean;onClick: () => void;children: React.ReactNode;-}> = ({ active, onClick, children }) => (+}> = ({ active, disabled, onClick, children }) => (<Buttontype="button"variant="ghost"size="sm"+ disabled={disabled}onClick={onClick}className={clsx('h-auto w-full justify-start gap-2 rounded px-2 py-1.5 text-left text-[12px] font-normal',diff --git a/ui/src/components/workbench/AgentsPage.test.tsx b/ui/src/components/workbench/AgentsPage.test.tsxindex 607125ea7..62e999461 100644--- a/ui/src/components/workbench/AgentsPage.test.tsx+++ b/ui/src/components/workbench/AgentsPage.test.tsx@@ -1731,6 +1731,41 @@ describe('AgentsPage reconnect reconciliation', () => {await waitFor(() => expect(screen.queryByRole('button', { name: 'xhigh', exact: true })).toBeNull());});+ it('MH-EFFORT-MENU-004: holds the effort buttons while that read is out, so a click cannot write an effort its answer removes', async () => {+ modelCatalog = {+ models: [],+ reasoningOptions: { 'reasoning-model': [{ value: 'medium', label: 'Medium' }, { value: 'xhigh', label: 'xhigh' }] },+ effortMenus: { 'reasoning-model': { omitted: [], not_on: {} } },+ };+ const initial = { ...brief('agent-a', 'description'), model: 'reasoning-model', reasoning_effort: 'medium' };+ const updateVibeAgent = vi.fn().mockResolvedValue({ ok: true, agent: fullAgent(initial, 'prompt') });+ const api = makeApi(+ vi.fn().mockResolvedValue(listResult(initial)), vi.fn().mockResolvedValue(fullAgent(initial, 'prompt')),+ undefined, undefined, updateVibeAgent,+ );+ renderPage(api, { canManageAgents: true });+ await waitFor(() => expect(screen.getByRole('button', { name: 'xhigh', exact: true })).toBeTruthy());++ // Another session's turn records that every hop refuses `xhigh`; the re-read is still out.+ modelCatalog = {+ models: [],+ reasoningOptions: { 'reasoning-model': [{ value: 'medium', label: 'Medium' }] },+ effortMenus: { 'reasoning-model': { omitted: ['xhigh'], not_on: {} } },+ };+ deferModelReads = true;+ fireEvent.pointerEnter(document.querySelector('[data-effort-field]') as HTMLElement);+ const xhigh = screen.getByRole('button', { name: 'xhigh', exact: true }) as HTMLButtonElement;+ expect(xhigh.disabled).toBe(true);+ fireEvent.click(xhigh);+ // A model choice keeps or falls back from the effort, so it waits for the answer too.+ expect((screen.getByRole('combobox') as HTMLButtonElement).disabled).toBe(true);+ expect(updateVibeAgent).not.toHaveBeenCalled();++ act(() => pendingModelReads.shift()!());+ expect(screen.queryByRole('button', { name: 'xhigh', exact: true })).toBeNull();+ expect((screen.getByRole('button', { name: 'medium', exact: true }) as HTMLButtonElement).disabled).toBe(false);+ });+it('keeps the last Hub effort menu when a refresh falls back to the native list, and asks Hub again next time', async () => {const hub = {models: [],diff --git a/ui/src/components/workbench/AgentsPage.tsx b/ui/src/components/workbench/AgentsPage.tsxindex 24970f41d..6a4e5e37f 100644--- a/ui/src/components/workbench/AgentsPage.tsx+++ b/ui/src/components/workbench/AgentsPage.tsx@@ -2152,16 +2152,23 @@ const AgentDetailPanel: React.FC<DetailProps> = ({ agent, isDefault, canEdit, ca// A Hub catalog's effort menu follows capability evidence, which a turn in any// session can change while this panel stays open. Like the route picker, which// reads it as its menu opens, read it again as the user turns to the effort- // field, the moment it is chosen from; the last answer shows until it lands.+ // field, the moment it is chosen from; the last answer shows until it lands,+ // and the controls that can write an effort are held while the read is in+ // flight (`readHubBackendModels`).const effortRefreshRef = useRef<(() => void) | null>(null);// One read per approach: a read still out answers for this one too. Dropping a// read does not stop its request, so restarting would only add requests.const effortRefreshOutRef = useRef(false);+ const [effortRefreshOut, setEffortRefreshOut] = useState(false);const refreshEffortMenus = useCallback(() => {if (!surfaceActive || !hubKnownRef.current || effortRefreshOutRef.current) return;effortRefreshOutRef.current = true;+ setEffortRefreshOut(true);const backend = agent.backend;- const settle = () => { effortRefreshOutRef.current = false; };+ const settle = () => {+ effortRefreshOutRef.current = false;+ setEffortRefreshOut(false);+ };effortRefreshRef.current = loadBackendModelsWithRefresh(api,backend,@@ -2178,6 +2185,7 @@ const AgentDetailPanel: React.FC<DetailProps> = ({ agent, isDefault, canEdit, caeffortRefreshRef.current?.();effortRefreshRef.current = null;effortRefreshOutRef.current = false;+ setEffortRefreshOut(false);// A new activation or backend starts without knowing which catalog serves it.hubKnownRef.current = false;}, [agent.backend, api, surfaceActive]);@@ -2509,6 +2517,7 @@ const AgentDetailPanel: React.FC<DetailProps> = ({ agent, isDefault, canEdit, caplaceholder={t('agents.detail.modelPlaceholder')}emptyText={t('agents.detail.modelEmpty')}allowCustomValue+ disabled={effortRefreshOut}footerAction={openAddModel ? { label: t('chat.picker.addModel'), onSelect: openAddModel } : undefined}/>)}@@ -2543,7 +2552,7 @@ const AgentDetailPanel: React.FC<DetailProps> = ({ agent, isDefault, canEdit, ca<buttonkey={opt}type="button"- disabled={!canEdit || !effortsAnswered}+ disabled={!canEdit || !effortsAnswered || effortRefreshOut}title={canEdit ? undefined : t('agents.remoteReadOnlyHint')}onClick={() => {markFieldEdit('effort');diff --git a/ui/src/components/workbench/NewAgentDialog.test.tsx b/ui/src/components/workbench/NewAgentDialog.test.tsxindex 4e1d3fa1e..0daccfc51 100644--- a/ui/src/components/workbench/NewAgentDialog.test.tsx+++ b/ui/src/components/workbench/NewAgentDialog.test.tsx@@ -40,6 +40,7 @@ vi.mock('../../context/ApiContext', async (importOriginal) => ({type FakeModelCatalog = {models: string[];reasoningOptions?: Record<string, { value: string; label: string }[]>;+ effortMenus?: Record<string, { omitted: string[]; not_on: Record<string, string[]> }>;};let modelCatalog: FakeModelCatalog = { models: [] };let modelCatalogReads = 0;@@ -70,12 +71,18 @@ vi.mock('../../lib/backendModels', async (importOriginal) => ({const renderDialog = () => {const createVibeAgent = vi.fn().mockResolvedValue({ ok: true, agent: { id: 'agt-new' } });apiRef.current = { createVibeAgent };- render(+ const view = render(<MemoryRouter><NewAgentDialog open onClose={vi.fn()} onCreated={vi.fn()} /></MemoryRouter>,);- return { createVibeAgent };+ // The parent closing and reopening the dialog, as the Agents page does.+ const setOpen = (open: boolean) => view.rerender(+ <MemoryRouter>+ <NewAgentDialog open={open} onClose={vi.fn()} onCreated={vi.fn()} />+ </MemoryRouter>,+ );+ return { createVibeAgent, setOpen };};const chooseModel = (value: string) => {@@ -234,6 +241,116 @@ describe('NewAgentDialog', () => {expect(create().disabled).toBe(false);});+ it("MH-EFFORT-MENU-004: creates only an effort Model Hub still offers at Create, not just when the dialog opened", async () => {+ modelCatalog = {+ models: [],+ reasoningOptions: { sonnet: [{ value: 'medium', label: 'medium' }, { value: 'high', label: 'high' }] },+ effortMenus: { sonnet: { omitted: [], not_on: {} } },+ };+ const { createVibeAgent } = renderDialog();+ // While the dialog stays open, a turn records that every hop refuses `high`.+ const row = (efforts: string[], omitted: string[]) => ({+ backend: 'claude', mode: 'hub',+ catalog_models: [{ id: 'sonnet', routeable: true, reasoning_efforts: efforts, effort_menu: { omitted, not_on: {} } }],+ });+ apiRef.current!.readModelHubAgentCatalogForModelPicker = vi.fn().mockResolvedValue(row(['medium'], ['high']));++ fireEvent.change(screen.getByPlaceholderText('agents.create.namePlaceholder'), { target: { value: 'router' } });+ chooseModel('sonnet');+ fireEvent.click(screen.getByRole('button', { name: 'high', exact: true }));+ submit();++ await waitFor(() => expect(screen.getByText('agents.create.effortRefused:{"effort":"high"}')).toBeTruthy());+ expect(createVibeAgent).not.toHaveBeenCalled();+ // The menu now follows that answer, so the effort moved to one it offers.+ expect(screen.queryByRole('button', { name: 'high', exact: true })).toBeNull();+ // The refused Create has settled when its button takes clicks again.+ const create = screen.getByRole('button', { name: /agents\.create\.submit/ }) as HTMLButtonElement;+ await waitFor(() => expect(create.disabled).toBe(false));+ submit();+ await waitFor(() => expect(createVibeAgent).toHaveBeenCalledWith(expect.objectContaining({+ model: 'sonnet', reasoning_effort: 'medium',+ })));+ });++ it('creates nothing when Model Hub cannot answer at Create, and says to try again', async () => {+ modelCatalog = {+ models: [],+ reasoningOptions: { sonnet: [{ value: 'medium', label: 'medium' }] },+ effortMenus: { sonnet: { omitted: [], not_on: {} } },+ };+ const { createVibeAgent } = renderDialog();+ apiRef.current!.readModelHubAgentCatalogForModelPicker = vi.fn().mockResolvedValue(null);+ fireEvent.change(screen.getByPlaceholderText('agents.create.namePlaceholder'), { target: { value: 'router' } });+ chooseModel('sonnet');+ submit();++ await waitFor(() => expect(screen.getByText('agents.create.effortUnconfirmed')).toBeTruthy());+ expect(createVibeAgent).not.toHaveBeenCalled();+ });++ it('drops a Create still checking the effort when the backend changes meanwhile', async () => {+ modelCatalog = {+ models: [],+ reasoningOptions: { sonnet: [{ value: 'medium', label: 'medium' }, { value: 'high', label: 'high' }] },+ effortMenus: { sonnet: { omitted: [], not_on: {} } },+ };+ const { createVibeAgent } = renderDialog();+ let answer: (value: unknown) => void = () => {};+ apiRef.current!.readModelHubAgentCatalogForModelPicker = vi.fn(() => new Promise((resolve) => { answer = resolve; }));+ fireEvent.change(screen.getByPlaceholderText('agents.create.namePlaceholder'), { target: { value: 'router' } });+ chooseModel('sonnet');+ fireEvent.click(screen.getByRole('button', { name: 'high', exact: true }));+ submit();++ fireEvent.click(screen.getByRole('button', { name: /Codex/ }));+ await act(async () => answer({+ backend: 'claude', mode: 'hub',+ catalog_models: [{ id: 'sonnet', routeable: true, reasoning_efforts: ['medium'], effort_menu: { omitted: ['high'], not_on: {} } }],+ }));++ // The answer was for the Claude form: the Codex one shows no refusal, and nothing was created.+ expect(screen.queryByText('agents.create.effortRefused:{"effort":"high"}')).toBeNull();+ expect(createVibeAgent).not.toHaveBeenCalled();+ });++ it('keeps a reopened form submitting while its own Create runs, whatever an earlier one settles', async () => {+ modelCatalog = {+ models: [],+ reasoningOptions: { sonnet: [{ value: 'medium', label: 'medium' }] },+ effortMenus: { sonnet: { omitted: [], not_on: {} } },+ };+ const { createVibeAgent, setOpen } = renderDialog();+ const answers: ((value: unknown) => void)[] = [];+ apiRef.current!.readModelHubAgentCatalogForModelPicker = vi.fn(() => new Promise((resolve) => { answers.push(resolve); }));+ const hub = {+ backend: 'claude', mode: 'hub',+ catalog_models: [{ id: 'sonnet', routeable: true, reasoning_efforts: ['medium'], effort_menu: { omitted: [], not_on: {} } }],+ };+ const fill = () => {+ fireEvent.change(screen.getByPlaceholderText('agents.create.namePlaceholder'), { target: { value: 'router' } });+ chooseModel('sonnet');+ };+ const create = () => screen.getByRole('button', { name: /agents\.create\.submit/ }) as HTMLButtonElement;+ fill();+ submit();++ // Closed and reopened while that Create checks the effort: the new form starts its own Create.+ setOpen(false);+ setOpen(true);+ fill();+ submit();+ expect(answers).toHaveLength(2);+ expect(create().disabled).toBe(true);++ // The first Create settles for a form that is gone: the current one stays submitting.+ await act(async () => answers[0](hub));+ expect(create().disabled).toBe(true);+ fireEvent.click(create());+ await act(async () => answers[1](hub));+ await waitFor(() => expect(createVibeAgent).toHaveBeenCalledTimes(1));+ });+it('creates with no effort when the catalog says the model has none', async () => {// `medium` is only a starting suggestion. Sending it for a model whose// catalog row states no efforts would create an Agent whose very firstdiff --git a/ui/src/components/workbench/NewAgentDialog.tsx b/ui/src/components/workbench/NewAgentDialog.tsxindex 84f1f1abe..b73c23f94 100644--- a/ui/src/components/workbench/NewAgentDialog.tsx+++ b/ui/src/components/workbench/NewAgentDialog.tsx@@ -1,11 +1,11 @@-import { useEffect, useMemo, useState } from 'react';+import { useEffect, useMemo, useRef, useState } from 'react';import { useTranslation } from 'react-i18next';import { ArrowRight, Maximize2, X } from 'lucide-react';import clsx from 'clsx';import { useApi } from '../../context/ApiContext';import type { VibeAgentFull } from '../../context/ApiContext';-import { loadBackendModelsWithRefresh, modelOptionLabel, useAddModelExit } from '../../lib/backendModels';+import { loadBackendModelsWithRefresh, modelOptionLabel, readHubBackendModels, useAddModelExit } from '../../lib/backendModels';import { resolveEffortOptions } from '../../lib/effortOptions';import { useRouteSurfaceActive } from '../../lib/routeSurfaceActivity';import { estimateTokens } from '../../lib/tokenEstimate';@@ -57,6 +57,17 @@ export const NewAgentDialog: React.FC<NewAgentDialogProps> = ({ open, onClose, o// (a backend switch, or a Settings visit). Until it has, nothing the dialog// offers is confirmed against it.const [catalogAnswered, setCatalogAnswered] = useState(false);+ // Whether that answer was Model Hub's, whose effort menu can change while the+ // dialog stays open, so Create reads it again.+ const [hubAnswered, setHubAnswered] = useState(false);+ // The form a Create was made from: a backend switch or a close starts another,+ // which starts unsubmitted. A Create's state belongs to its form, so one still+ // running for an earlier form changes nothing the current one shows.+ const formRef = useRef(0);+ useEffect(() => {+ formRef.current += 1;+ setSubmitting(false);+ }, [backend, open]);const [editorOpen, setEditorOpen] = useState(false);const openAddModel = useAddModelExit(backend, open);const surfaceActive = useRouteSurfaceActive();@@ -87,9 +98,10 @@ export const NewAgentDialog: React.FC<NewAgentDialogProps> = ({ open, onClose, oconst cancel = loadBackendModelsWithRefresh(api,backend,- ({ models, modelLabels, reasoningOptions: opts }) => {+ ({ models, modelLabels, reasoningOptions: opts, effortMenus }) => {setModelOptions(models.map((m) => ({ value: m, label: modelOptionLabel(m, modelLabels) })));setReasoningOptions(opts ?? {});+ setHubAnswered(effortMenus !== undefined);setCatalogAnswered(true);},() => {@@ -97,12 +109,14 @@ export const NewAgentDialog: React.FC<NewAgentDialogProps> = ({ open, onClose, o// unknown model, never the efforts read before the visit.setModelOptions([]);setReasoningOptions({});+ setHubAnswered(false);setCatalogAnswered(true);},);return () => {cancel();setModelOptions([]);+ setHubAnswered(false);setCatalogAnswered(false);};}, [backend, open, api, surfaceActive]);@@ -141,7 +155,25 @@ export const NewAgentDialog: React.FC<NewAgentDialogProps> = ({ open, onClose, oif (!canSubmit) return;setError(null);setSubmitting(true);+ const form = formRef.current;+ const current = () => form === formRef.current;try {+ if (hubAnswered) {+ // Create writes the effort, so it is checked against Model Hub's answer+ // now, not the one read when the dialog opened (`readHubBackendModels`).+ const fresh = await readHubBackendModels(api, backend);+ if (!current()) return;+ if (fresh === 'unread') {+ setError(t('agents.create.effortUnconfirmed'));+ return;+ }+ if (fresh && effort !== null && !resolveEffortOptions(backend, model, fresh.reasoningOptions).includes(effort)) {+ // The menu follows the answer, which moves the effort to one it offers.+ setReasoningOptions(fresh.reasoningOptions ?? {});+ setError(t('agents.create.effortRefused', { effort }));+ return;+ }+ }const result = await api.createVibeAgent({name: name.trim(),backend,@@ -152,13 +184,14 @@ export const NewAgentDialog: React.FC<NewAgentDialogProps> = ({ open, onClose, oenabled: true,});if (result.ok) {+ // The agent exists whichever form is showing now; only its own form closes.onCreated(result.agent);- onClose();+ if (current()) onClose();}} catch (err) {- setError(errorMessage(err) ?? String(err));+ if (current()) setError(errorMessage(err) ?? String(err));} finally {- setSubmitting(false);+ if (current()) setSubmitting(false);}};diff --git a/ui/src/i18n/en.json b/ui/src/i18n/en.jsonindex 31ca22d2a..5d511bcaa 100644--- a/ui/src/i18n/en.json+++ b/ui/src/i18n/en.json@@ -4328,6 +4328,8 @@"model": "Model","modelPlaceholder": "e.g. claude-sonnet-4-6","effort": "Effort",+ "effortRefused": "No Source accepts {{effort}} now, so the agent was not created. Check the effort and create it again.",+ "effortUnconfirmed": "Model Hub could not confirm the effort just now, so the agent was not created. Try again.","systemPrompt": "System prompt","systemPromptHint": "Optional","systemPromptPlaceholder": "Optional. Prepended to every conversation that uses this agent.",diff --git a/ui/src/i18n/zh.json b/ui/src/i18n/zh.jsonindex 4989d1a32..8753814db 100644--- a/ui/src/i18n/zh.json+++ b/ui/src/i18n/zh.json@@ -4328,6 +4328,8 @@"model": "模型","modelPlaceholder": "例如 claude-sonnet-4-6","effort": "Effort",+ "effortRefused": "当前没有供应商支持 {{effort}},Agent 未创建。请确认 Effort 后重新创建。",+ "effortUnconfirmed": "模型网关暂时无法确认 Effort,Agent 未创建。请重试。","systemPrompt": "系统提示词","systemPromptHint": "可选","systemPromptPlaceholder": "可选。会拼接到使用本 Agent 的每一段对话前。",diff --git a/ui/src/lib/backendModels.ts b/ui/src/lib/backendModels.tsindex a6ec0b1b6..cbc92b3e5 100644--- a/ui/src/lib/backendModels.ts+++ b/ui/src/lib/backendModels.ts@@ -84,6 +84,29 @@ const hubCatalogModels = (agent: PickerAgentCatalog | null, backend: string): Baexport const supersedesHubAnswer = (result: BackendModels, knownHub: boolean): boolean =>!knownHub || result.effortMenus !== undefined || result.hubUnread !== true;+/**+ * Model Hub's catalog answer for a backend: null when Hub does not serve it,+ * `'unread'` when Hub gave no answer. It starts no CLI.+ *+ * A Hub effort menu follows capability evidence that any turn can change+ * (#2606). The route picker and the Agents page read it again as their menu+ * opens or the effort field is approached, and while that read is in flight the+ * controls that can write an effort (an effort, or a model that keeps or clears+ * one) are held. The New Agent dialog writes on Create, so Create reads this+ * answer again and creates only an effort it still offers, and nothing when Hub+ * cannot answer. A write made outside those (a model changed before any read+ * started, or after a read that came back unread) uses the last answer; a stale+ * effort then fails at the turn as `effort_unsupported`, which records the+ * evidence the next read uses.+ */+export async function readHubBackendModels(+ api: ApiContextType,+ backend: string,+): Promise<BackendModels | null | 'unread'> {+ const agent = await api.readModelHubAgentCatalogForModelPicker(backend);+ return agent === null ? 'unread' : hubCatalogModels(agent, backend);+}+// Single source of truth for "list the selectable models for a backend",// shared by ChatPage, the Agents detail panel, and the New Agent dialog so a// new backend (or a fix like OpenCode's provider-prefixing) lands in one place.