diff --git a/ui/src/pages/chat/chat-pane-lifecycle.ts b/ui/src/pages/chat/chat-pane-lifecycle.ts index de17538e492b..06e18f72408e 100644 --- a/ui/src/pages/chat/chat-pane-lifecycle.ts +++ b/ui/src/pages/chat/chat-pane-lifecycle.ts @@ -381,8 +381,9 @@ export abstract class ChatPaneLifecycle extends ChatPaneSessionCreation { pageState.confirmConversationReset = () => this.confirmConversationReset(); pageState.exportCurrentChat = () => exportChatMarkdown(pageState.chatMessages, pageState.assistantName); + // Effective-tools previews key their requests on the model override, so a + // post-switch refresh only needs a re-render. pageState.refreshCurrentSessionTools = async () => { - await pageState.onModelChanged?.(); pageState.requestUpdate?.(); }; pageState.refreshCurrentChat = async () => { diff --git a/ui/src/pages/chat/chat-session.ts b/ui/src/pages/chat/chat-session.ts index dd917d266fa7..c672a78afa94 100644 --- a/ui/src/pages/chat/chat-session.ts +++ b/ui/src/pages/chat/chat-session.ts @@ -43,7 +43,6 @@ type ChatModelSettingsHost = ChatSessionRefreshHost & { chatModelCatalog: Parameters[0]["chatModelCatalog"]; chatModelSwitchPromises?: Record>; chatThinkingLevel: string | null; - onModelChanged?: () => unknown; sessions: SessionCapability; sessionsResult?: SessionsListResult | null; requestUpdate?: () => void; @@ -444,7 +443,6 @@ export async function switchChatModel( ...scopedAgentParamsForSession(host, targetSessionKey), ownsModelOverride, reconcile: async () => { - await host.onModelChanged?.(); await refreshCurrentChatSessionList(host); }, }, diff --git a/ui/src/pages/chat/chat-state-host.ts b/ui/src/pages/chat/chat-state-host.ts index 5ca9894a2148..1c3722803e6d 100644 --- a/ui/src/pages/chat/chat-state-host.ts +++ b/ui/src/pages/chat/chat-state-host.ts @@ -120,7 +120,6 @@ export type ChatPageHost = ChatHost & imageLightboxRequestVersion: number; querySelector: (selectors: string) => Element | null; renderLifecycle: RenderLifecycle; - onModelChanged: () => Promise | void; resetToolStream: () => void; resetChatScroll: () => void; resetChatInputHistoryNavigation: () => void; diff --git a/ui/src/pages/chat/chat-state-page.ts b/ui/src/pages/chat/chat-state-page.ts index 2a3a58abcb5e..90564ee3df4f 100644 --- a/ui/src/pages/chat/chat-state-page.ts +++ b/ui/src/pages/chat/chat-state-page.ts @@ -268,7 +268,6 @@ export function createPageState( } as unknown as ChatPageHost; state.resetToolStream = () => resetToolStream(state as never); - state.onModelChanged = () => undefined; state.resetChatInputHistoryNavigation = () => resetChatInputHistoryNavigation(state); state.resetChatScroll = () => resetChatScroll(state); state.scrollToBottom = (options) => { diff --git a/ui/src/pages/chat/chat-view.test.ts b/ui/src/pages/chat/chat-view.test.ts index 3bac44646989..273e01d471b9 100644 --- a/ui/src/pages/chat/chat-view.test.ts +++ b/ui/src/pages/chat/chat-view.test.ts @@ -76,14 +76,6 @@ function registerChatAttachmentPayload( return attachment; } -async function refreshVisibleToolsEffectiveForCurrentSessionForTest(state: ChatHeaderTestState) { - const agentId = state.agentsSelectedId ?? "main"; - const sessionKey = state.sessionKey; - await state.client?.request("tools.effective", { agentId, sessionKey }); - const override = state.sessions.state.modelOverrides[sessionKey]; - state.toolsEffectiveResultKey = `${agentId}:${sessionKey}:model=${override ?? "(default)"}`; - state.toolsEffectiveResult = { agentId, profile: "coding", groups: [] }; -} const buildChatItemsMock = vi.fn( (props: { messages: unknown[]; @@ -255,7 +247,6 @@ type ChatHeaderTestState = { toolsEffectiveResult: unknown; applySettings(patch: Partial): void; loadAssistantIdentity(): void; - onModelChanged(): void | Promise; resetChatInputHistoryNavigation(): void; resetChatScroll(): void; resetToolStream(): void; @@ -501,8 +492,6 @@ function createChatHeaderState( resetChatInputHistoryNavigation: vi.fn(), resetToolStream: vi.fn(), resetChatScroll: vi.fn(), - onModelChanged: (): Promise => - refreshVisibleToolsEffectiveForCurrentSessionForTest(state), }; sessions.subscribe((next) => { state.sessionsResult = next.result; @@ -6357,7 +6346,12 @@ describe("chat model controls", () => { return patchResult; }, ), - refresh: async () => {}, + // The list refresh is the reconcile step switchChatModel awaits; holding + // it open models a slow reconciliation inside the settings lane. + refresh: async () => { + reconciliationStarted.resolve(); + await releaseReconciliation.promise; + }, setModelOverride: vi.fn(), patchRowLocal: vi.fn(), }; @@ -6379,10 +6373,6 @@ describe("chat model controls", () => { thinkingLevel: "high", }, ]), - onModelChanged: async () => { - reconciliationStarted.resolve(); - await releaseReconciliation.promise; - }, } as unknown as Parameters[0]; const modelSwitch = switchChatModel(host, "openai/gpt-5.6-sol");