You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maka.apache.org by wy...@apache.org on 2026/09/22 21:57:03 UTC

(maka) branch feat/runtime-host-rust updated: fix(ui): simplify model choices and acknowledge cache notices

This is an automated email from the ASF dual-hosted git repository.

M4n5ter pushed a commit to branch feat/runtime-host-rust
in repository https://gitbox.apache.org/repos/asf/maka.git


The following commit(s) were added to refs/heads/feat/runtime-host-rust by this push:
     new bb7de7e06b fix(ui): simplify model choices and acknowledge cache notices
bb7de7e06b is described below

commit bb7de7e06b5a272ccc35dc3c1ad2c676d0aedacf
Author: Wang <m4...@gmail.com>
AuthorDate: Wed Sep 23 05:56:58 2026 +0800

    fix(ui): simplify model choices and acknowledge cache notices
    
    Generated-by: Codex
---
 .../desktop/src/renderer/styles/model-switcher.css |   7 ++
 .../__tests__/chat-model-switcher-notice.test.tsx  | 133 +++++++++++++++++++++
 packages/ui/src/chat-model-helpers.ts              |  13 --
 packages/ui/src/chat-model-switcher.tsx            |  93 ++++++++++----
 packages/ui/src/conversation-copy.ts               |   5 +
 packages/ui/src/model-picker-internals.tsx         |  19 +--
 packages/ui/src/model-picker.tsx                   |   7 +-
 packages/ui/src/shared-ui-copy.ts                  |   4 -
 packages/ui/stories/model-picker.stories.tsx       |  48 +++++---
 9 files changed, 255 insertions(+), 74 deletions(-)

diff --git a/apps/desktop/src/renderer/styles/model-switcher.css b/apps/desktop/src/renderer/styles/model-switcher.css
index f7ddf7c830..3a728d2c5c 100644
--- a/apps/desktop/src/renderer/styles/model-switcher.css
+++ b/apps/desktop/src/renderer/styles/model-switcher.css
@@ -86,6 +86,13 @@
   min-width: 0;
 }
 
+/* The prompt-cache notice leads the session switcher's list as an option
+   whose activation acknowledges it (chat-model-switcher.tsx). Its label wraps
+   because it is passed as a node; only the glyph needs the warning tone. */
+.modelPickerSwitchNoticeGlyph {
+  color: var(--warning-text);
+}
+
 /* Selector's popover stretches to its positioning context, not its content —
    left alone it renders far wider than the option labels. Hug the widest row
    instead, and cap it so one long id cannot stretch the popup past the
diff --git a/packages/ui/src/__tests__/chat-model-switcher-notice.test.tsx b/packages/ui/src/__tests__/chat-model-switcher-notice.test.tsx
new file mode 100644
index 0000000000..065c28cfdd
--- /dev/null
+++ b/packages/ui/src/__tests__/chat-model-switcher-notice.test.tsx
@@ -0,0 +1,133 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+import assert from 'node:assert/strict';
+import test from 'node:test';
+import { act } from 'react';
+import { createRoot } from 'react-dom/client';
+import { parseHTML } from 'linkedom';
+import type { ChatModelChoice } from '@maka/core/chat-model-choice';
+import type { SessionSummary } from '@maka/core/session';
+import { ChatModelSwitcher } from '../chat-model-switcher.js';
+import { LocaleProvider } from '../locale-context.js';
+
+const WARNING = 'Switching may rebuild the provider prompt cache';
+
+function choice(connectionSlug: string, model: string, label: string): ChatModelChoice {
+  return {
+    connectionId: `connection-${connectionSlug}`,
+    connectionSlug,
+    connectionName: connectionSlug,
+    providerType: 'openrouter',
+    providerLabel: 'OpenRouter',
+    model,
+    label,
+    isDefault: false,
+    thinkingLevels: [],
+  };
+}
+
+test('the prompt-cache notice is acknowledged per Session without closing the list', async () => {
+  const original = {
+    document: globalThis.document,
+    window: globalThis.window,
+    Element: globalThis.Element,
+    HTMLElement: globalThis.HTMLElement,
+    Node: globalThis.Node,
+    matchMedia: globalThis.matchMedia,
+    requestAnimationFrame: globalThis.requestAnimationFrame,
+    cancelAnimationFrame: globalThis.cancelAnimationFrame,
+    IS_REACT_ACT_ENVIRONMENT: (globalThis as typeof globalThis & {
+      IS_REACT_ACT_ENVIRONMENT?: boolean;
+    }).IS_REACT_ACT_ENVIRONMENT,
+  };
+  const { document, window } = parseHTML('<div id="root"></div>');
+  window.getComputedStyle = () =>
+    new Proxy(
+      { direction: 'ltr', writingMode: 'horizontal-tb', getPropertyValue: () => '' },
+      { get: (target, key) => (key in target ? target[key as keyof typeof target] : '') },
+    ) as unknown as CSSStyleDeclaration;
+  window.matchMedia = () =>
+    ({ matches: false, addEventListener() {}, removeEventListener() {} }) as unknown as MediaQueryList;
+  window.scrollTo = () => {};
+  Object.assign(globalThis, {
+    document,
+    window,
+    Element: window.Element,
+    HTMLElement: window.HTMLElement,
+    Node: window.Node,
+    matchMedia: window.matchMedia,
+    requestAnimationFrame: () => 1,
+    cancelAnimationFrame() {},
+    IS_REACT_ACT_ENVIRONMENT: true,
+  });
+  const container = document.querySelector('#root');
+  assert.ok(container);
+  const root = createRoot(container);
+  const choices = [choice('openrouter', 'openai/gpt-5', 'GPT-5'), choice('openrouter', 'openai/o3', 'o3')];
+  const switches: unknown[] = [];
+  const session = (id: string) =>
+    ({ id, llmConnectionId: 'connection-openrouter', llmConnectionSlug: 'openrouter', model: 'openai/gpt-5' }) as SessionSummary;
+  const render = (sessionId: string, openNonce: number) =>
+    act(() => root.render(
+      <LocaleProvider locale="en">
+        <ChatModelSwitcher
+          activeSession={session(sessionId)}
+          choices={choices}
+          hasConversationHistory
+          openNonce={openNonce}
+          onChange={(input) => { switches.push(input); }}
+        />
+      </LocaleProvider>,
+    ));
+  const options = () => [...document.querySelectorAll<HTMLElement>('[role="option"]')];
+  const noticeRow = () => options().find((option) => option.textContent?.includes(WARNING));
+  const expanded = () =>
+    document.querySelector('[aria-haspopup="listbox"]')?.getAttribute('aria-expanded');
+
+  try {
+    await render('session-a', 1);
+    assert.equal(expanded(), 'true', 'the nonce opens the list');
+    const notice = noticeRow();
+    assert.ok(notice, 'the notice leads the open list');
+    assert.equal(options()[0], notice);
+    assert.notEqual(notice.getAttribute('aria-disabled'), 'true', 'the notice row is activatable');
+    assert.equal(options().length, 3);
+
+    await act(() => notice.dispatchEvent(new window.Event('click', { bubbles: true })));
+
+    assert.equal(noticeRow(), undefined, 'activating the notice dismisses it');
+    assert.equal(options().length, 2, 'the model rows remain');
+    assert.equal(expanded(), 'true', 'the list is open again after the acknowledgement');
+    assert.deepEqual(switches, [], 'acknowledging is not a model switch');
+
+    await render('session-a', 2);
+    assert.equal(noticeRow(), undefined, 'a Selector remount keeps the mounted switcher acknowledgement');
+
+    await render('session-b', 0);
+    assert.equal(expanded(), 'false', 'a fresh Session mounts closed');
+    await render('session-b', 1);
+    assert.ok(noticeRow(), 'another Session raises its own notice');
+
+    await render('session-a', 3);
+    assert.equal(noticeRow(), undefined, 'direct Session switches preserve the mounted switcher acknowledgement');
+  } finally {
+    await act(() => root.unmount());
+    Object.assign(globalThis, original);
+  }
+});
diff --git a/packages/ui/src/chat-model-helpers.ts b/packages/ui/src/chat-model-helpers.ts
index 3edc61911f..7c4f94f834 100644
--- a/packages/ui/src/chat-model-helpers.ts
+++ b/packages/ui/src/chat-model-helpers.ts
@@ -47,19 +47,6 @@ import type { UiLocale } from '@maka/core/ui-locale';
 import { getSharedUiCopy } from './shared-ui-copy.js';
 export type { ChatModelChoice } from '@maka/core/chat-model-choice';
 
-export function modelChoiceDescription(
-  choice: Pick<ChatModelChoice, 'description' | 'knowledgeCutoff'>,
-  locale: UiLocale,
-): string | undefined {
-  const description = choice.description?.trim();
-  const knowledge = choice.knowledgeCutoff?.trim();
-  const copy = getSharedUiCopy(locale).modelPicker;
-  const parts = [description, knowledge ? copy.knowledgeCutoff(knowledge) : undefined].filter(
-    (value): value is string => Boolean(value),
-  );
-  return parts.length > 0 ? parts.join(' · ') : undefined;
-}
-
 export interface ModelMenuGroup {
   connectionSlug: string;
   /** Provider of this group, so the menu can render its brand mark on the heading. */
diff --git a/packages/ui/src/chat-model-switcher.tsx b/packages/ui/src/chat-model-switcher.tsx
index e581f8b16a..993c99c8f2 100644
--- a/packages/ui/src/chat-model-switcher.tsx
+++ b/packages/ui/src/chat-model-switcher.tsx
@@ -31,15 +31,14 @@
  * the inline wheel (`presentation="wheel"`) it was built for.
  */
 
-import { type ReactNode, useEffect, useMemo, useState } from 'react';
+import { type ReactNode, useCallback, useEffect, useMemo, useState } from 'react';
 import { Button as UiButton } from '@astryxdesign/core';
-import { Selector } from '@astryxdesign/core/Selector';
+import { Selector, SelectorOption, type SelectorOptionData } from '@astryxdesign/core/Selector';
 import { ModelWheelPicker, type ModelWheelOption } from './model-wheel-picker.js';
-import { ICON_SIZE, Settings } from './icons.js';
+import { ICON_SIZE, AlertTriangle, Settings, X } from './icons.js';
 import {
   type ChatModelChoice,
   exactModelChoiceValue,
-  modelChoiceDescription,
   modelMenuGroups,
   type ModelMenuGroup,
 } from './chat-model-helpers.js';
@@ -59,7 +58,11 @@ import { usePendingSelection } from './use-pending-selection.js';
 import type { ComposerModelSwitchAvailability } from './composer-helpers.js';
 
 const DEFAULT_THINKING_LEVEL = '__default__';
-/** Sentinel option value for the switch-warning row; disabled so it can never be picked. */
+/**
+ * Sentinel option value for the switch-warning row. Selecting it acknowledges
+ * the notice for the Session while the switcher remains mounted; it never
+ * reaches the pending selection or `onChange`.
+ */
 const SWITCH_WARNING_VALUE = '__maka_model_switch_warning__';
 
 const exactChoiceValue = (choice: ChatModelChoice) =>
@@ -67,14 +70,12 @@ const exactChoiceValue = (choice: ChatModelChoice) =>
 
 function wheelOptions(
   groups: readonly ModelMenuGroup[],
-  locale: Parameters<typeof modelChoiceDescription>[1],
 ): ModelWheelOption[] {
   return groups.flatMap((group) =>
     group.choices.map((choice) => ({
       value: exactChoiceValue(choice),
       label: choice.label,
       heading: group.heading,
-      description: modelChoiceDescription(choice, locale),
     })),
   );
 }
@@ -152,8 +153,9 @@ export function ChatModelSwitcher(props: {
   /**
    * Selector has no controlled open prop, so recovery bumps this instead: the
    * remount keyed on it opens the panel via `isDefaultOpen`, an entirely
-   * documented surface. Session changes share the key so a switch always lands
-   * closed.
+   * documented surface. The key combines the Session id, this recovery nonce,
+   * and the notice acknowledgement nonce. The Composer resets recovery on
+   * Session changes so the new Session lands closed.
    */
   openNonce?: number;
   /** Force any open surface closed while an interaction prompt occludes the composer. */
@@ -195,6 +197,12 @@ export function ChatModelSwitcher(props: {
     () => new Map(props.choices.map((choice) => [exactChoiceValue(choice), choice] as const)),
     [props.choices],
   );
+  // Acknowledgements survive direct Session switches, but not unmounting.
+  const [acknowledgedSessions, setAcknowledgedSessions] = useState<ReadonlySet<string>>(
+    () => new Set(),
+  );
+  const noticeShown =
+    props.hasConversationHistory === true && !acknowledgedSessions.has(props.activeSession.id);
   const options = useMemo(() => {
     const list = buildModelPickerOptions(
       grouped,
@@ -202,17 +210,47 @@ export function ChatModelSwitcher(props: {
         ? { value: currentValue, label: displayLabel, providerType: props.currentProviderType, disabled: true }
         : undefined,
       exactChoiceValue,
-      { locale, renderProviderMark: props.renderProviderMark },
+      props.renderProviderMark,
     );
-    // Switching can abandon a provider prompt cache — a property of the pending
-    // action, shown as a disabled first row whenever the panel opens.
-    if (props.hasConversationHistory === true) {
-      list.unshift({ value: SWITCH_WARNING_VALUE, label: copy.switchWarning, disabled: true });
+    // Option activation works for pointer, keyboard and screen readers;
+    // a nested dismiss button would be hidden by the option's semantics.
+    if (noticeShown) {
+      list.unshift({
+        value: SWITCH_WARNING_VALUE,
+        label: copy.switchWarning,
+        description: copy.switchWarningDismiss,
+      });
     }
     return list;
   }, [grouped, currentKnownChoice, currentValue, props.hideUnavailableCurrentOption,
-      props.hasConversationHistory, displayLabel, props.currentProviderType, copy.switchWarning,
-      locale, props.renderProviderMark]);
+      noticeShown, displayLabel, props.currentProviderType, copy.switchWarning,
+      copy.switchWarningDismiss, props.renderProviderMark]);
+  const renderOption = useCallback((option: SelectorOptionData) => (
+    option.value === SWITCH_WARNING_VALUE
+      ? (
+        <SelectorOption
+          className="modelPickerOption modelPickerSwitchNotice"
+          icon={<AlertTriangle className="modelPickerSwitchNoticeGlyph" size={ICON_SIZE.control} aria-hidden="true" />}
+          // A node, not a string: Item ellipsizes string labels to one line,
+          // and this is a sentence to read, not an id to recognise.
+          label={<span>{option.label}</span>}
+          description={option.description}
+          endContent={<X size={ICON_SIZE.control} aria-hidden="true" />}
+        />
+      )
+      : renderModelPickerOption(option)
+  ), []);
+
+  // Selector closes on selection. Reopen after acknowledgement, then consume
+  // the request so a later presentation remount cannot open spontaneously.
+  const [reopen, setReopen] = useState({ nonce: 0, pending: false });
+  useEffect(() => {
+    if (reopen.pending) setReopen((current) => ({ nonce: current.nonce, pending: false }));
+  }, [reopen.pending]);
+  const acknowledgeNotice = () => {
+    setAcknowledgedSessions((current) => new Set(current).add(props.activeSession.id));
+    setReopen((current) => ({ nonce: current.nonce + 1, pending: true }));
+  };
 
   // Reflect the pick on the trigger immediately and hold it until the write
   // settles, then defer to the authoritative value. See usePendingSelection.
@@ -227,6 +265,13 @@ export function ChatModelSwitcher(props: {
       });
     } catch { /* The action owner reports the failure. */ }
   });
+  const onSelect = (value: string) => {
+    if (value === SWITCH_WARNING_VALUE) {
+      acknowledgeNotice();
+      return;
+    }
+    void selection.onChange(value);
+  };
 
   // The collapsed WorkHub window keeps the wheel it was built for. The nonce
   // edge opens it once, then the wheel owns its own open state.
@@ -242,7 +287,7 @@ export function ChatModelSwitcher(props: {
   }, [props.presentation]);
   useEffect(() => setWheelOpen(false), [props.activeSession.id]);
   if (props.presentation === 'wheel') {
-    const wheelList = wheelOptions(grouped, locale);
+    const wheelList = wheelOptions(grouped);
     if (!currentKnownChoice && currentValue && !props.hideUnavailableCurrentOption) {
       wheelList.unshift({ value: currentValue, label: displayLabel, disabled: true });
     }
@@ -275,7 +320,7 @@ export function ChatModelSwitcher(props: {
 
   return (
     <Selector
-      key={`${props.activeSession.id}:${props.openNonce ?? 0}`}
+      key={`${props.activeSession.id}:${props.openNonce ?? 0}:${reopen.nonce}`}
       label={`${copy.switchAriaLabel}: ${displayLabel}`}
       isLabelHidden
       options={options}
@@ -289,11 +334,11 @@ export function ChatModelSwitcher(props: {
       isDisabled={disabled}
       isReadOnly={props.isReadOnly}
       disabledMessage={props.disabledReason}
-      isDefaultOpen={Boolean(props.openNonce)}
+      isDefaultOpen={Boolean(props.openNonce) || reopen.pending}
       placeholder={displayLabel}
       className="maka-model-switcher-trigger"
-      onChange={selection.onChange}
-      renderOption={renderModelPickerOption}
+      onChange={onSelect}
+      renderOption={renderOption}
       renderValue={renderModelPickerValue}
     />
   );
@@ -341,10 +386,10 @@ export function NewChatModelPicker(props: {
         ? { label: props.label, value: currentValue, providerType: props.currentProviderType, disabled: true }
         : undefined,
       exactChoiceValue,
-      { locale, renderProviderMark: props.renderProviderMark },
+      props.renderProviderMark,
     ),
     [grouped, currentKnownChoice, currentValue, props.label, props.currentProviderType,
-      locale, props.renderProviderMark],
+      props.renderProviderMark],
   );
   // The only producer is synchronous state (pending new-chat model), so the
   // pick shows through `currentValue` on the same render — no pending state.
@@ -359,7 +404,7 @@ export function NewChatModelPicker(props: {
     }));
   };
   if (props.presentation === 'wheel') {
-    const wheelList = wheelOptions(grouped, locale);
+    const wheelList = wheelOptions(grouped);
     if (!currentKnownChoice && currentValue) {
       wheelList.unshift({ value: currentValue, label: props.label, disabled: true });
     }
diff --git a/packages/ui/src/conversation-copy.ts b/packages/ui/src/conversation-copy.ts
index 14e7493c2a..7115d8ab2d 100644
--- a/packages/ui/src/conversation-copy.ts
+++ b/packages/ui/src/conversation-copy.ts
@@ -160,6 +160,8 @@ export interface ConversationCopy {
     model: string;
     switchAriaLabel: string;
     switchWarning: string;
+    /** Secondary line on the cache warning row: activating the row dismisses it. */
+    switchWarningDismiss: string;
     newChatAriaLabel: (label: string) => string;
     newChatTitle: (label: string) => string;
     configureAriaLabel: (label: string) => string;
@@ -456,6 +458,7 @@ const CONVERSATION_COPY = {
       level: { off: '关', minimal: '最少', low: '低', medium: '中', high: '高', xhigh: '超高', max: '最高' },
       switching: '切换中', model: '模型', switchAriaLabel: '切换当前任务模型',
       switchWarning: '切换模型可能需要重建服务商提示缓存,使下一次请求更慢或成本更高。',
+      switchWarningDismiss: '选择即可关闭',
       newChatAriaLabel: (label) => `选择新任务模型,当前 ${label}`, newChatTitle: (label) => `新任务使用的模型:${label}`,
       configureAriaLabel: (label) => `配置模型连接,当前 ${label}`, configureTitle: '配置模型连接',
     },
@@ -634,6 +637,7 @@ const CONVERSATION_COPY = {
       level: { off: '關', minimal: '最少', low: '低', medium: '中', high: '高', xhigh: '超高', max: '最高' },
       switching: '切換中', model: '模型', switchAriaLabel: '切換目前任務模型',
       switchWarning: '切換模型可能需要重建服務商提示快取,使下一次請求更慢或成本更高。',
+      switchWarningDismiss: '選擇即可關閉',
       newChatAriaLabel: (label) => `選擇新任務模型,目前 ${label}`, newChatTitle: (label) => `新任務使用的模型:${label}`,
       configureAriaLabel: (label) => `設定模型連線,目前 ${label}`, configureTitle: '設定模型連線',
     },
@@ -809,6 +813,7 @@ const CONVERSATION_COPY = {
       level: { off: 'Off', minimal: 'Minimal', low: 'Low', medium: 'Medium', high: 'High', xhigh: 'Extra high', max: 'Maximum' },
       switching: 'Switching', model: 'Model', switchAriaLabel: 'Switch model for this task',
       switchWarning: 'Switching may rebuild the provider prompt cache, making the next request slower or more expensive.',
+      switchWarningDismiss: 'Select to dismiss',
       newChatAriaLabel: (label) => `Choose a model for the new task, currently ${label}`, newChatTitle: (label) => `Model for the new task: ${label}`,
       configureAriaLabel: (label) => `Configure model connections, currently ${label}`, configureTitle: 'Configure model connections',
     },
diff --git a/packages/ui/src/model-picker-internals.tsx b/packages/ui/src/model-picker-internals.tsx
index 5e6acf1bb6..886669b1b4 100644
--- a/packages/ui/src/model-picker-internals.tsx
+++ b/packages/ui/src/model-picker-internals.tsx
@@ -25,10 +25,8 @@ import {
   type SelectorSection,
 } from '@astryxdesign/core/Selector';
 import type { ProviderType } from '@maka/core/llm-connections';
-import type { UiLocale } from '@maka/core/ui-locale';
 import {
   type ModelMenuGroup,
-  modelChoiceDescription,
 } from './chat-model-helpers.js';
 
 export interface ModelPickerLeadingOption {
@@ -54,10 +52,9 @@ export function providerMarkIcon(
 
 /**
  * Shapes Maka's provider catalog into Astryx Selector's public option model:
- * each option carries its provider mark as `icon` and the catalog line as
- * `description`, so Selector's default row and trigger rendering need no
- * product markup. Search, flattening, keyboard navigation, selection, and
- * empty results remain entirely inside Selector.
+ * each option carries its provider mark as `icon`, so Selector's default row
+ * and trigger rendering need no product markup. Search, flattening, keyboard
+ * navigation, selection, and empty results remain entirely inside Selector.
  *
  * `toValue` is `modelChoiceValue` for the settings catalog (slug-scoped) and
  * `exactModelChoiceValue` for the session switcher (connection-id-scoped).
@@ -66,10 +63,7 @@ export function buildModelPickerOptions(
   groups: readonly ModelMenuGroup[],
   leadingOption: ModelPickerLeadingOption | undefined,
   toValue: ModelChoiceValueFn,
-  extras: {
-    locale: UiLocale;
-    renderProviderMark?(type: ProviderType): ReactNode;
-  },
+  renderProviderMark?: (type: ProviderType) => ReactNode,
 ): SelectorOptionType[] {
   const sections: SelectorSection[] = groups.map((group) => ({
     type: 'section',
@@ -77,8 +71,7 @@ export function buildModelPickerOptions(
     options: group.choices.map((choice) => ({
       value: toValue(choice),
       label: choice.label,
-      icon: providerMarkIcon(group.providerType, extras.renderProviderMark),
-      description: modelChoiceDescription(choice, extras.locale),
+      icon: providerMarkIcon(group.providerType, renderProviderMark),
     })),
   }));
 
@@ -87,7 +80,7 @@ export function buildModelPickerOptions(
   const option: SelectorOptionData = {
     value: leadingOption.value,
     label: leadingOption.label,
-    icon: providerMarkIcon(leadingOption.providerType, extras.renderProviderMark),
+    icon: providerMarkIcon(leadingOption.providerType, renderProviderMark),
     disabled: leadingOption.disabled,
   };
   return sections.length > 0 ? [option, { type: 'divider' }, ...sections] : [option];
diff --git a/packages/ui/src/model-picker.tsx b/packages/ui/src/model-picker.tsx
index 3bdb287010..04b44e5312 100644
--- a/packages/ui/src/model-picker.tsx
+++ b/packages/ui/src/model-picker.tsx
@@ -66,11 +66,8 @@ export function ModelPicker(props: ModelPickerProps) {
 
   const options = useMemo(
     () =>
-      buildModelPickerOptions(props.groups, props.leadingOption, slugScopedValue, {
-        locale,
-        renderProviderMark: props.renderProviderMark,
-      }),
-    [props.groups, props.leadingOption, locale, props.renderProviderMark],
+      buildModelPickerOptions(props.groups, props.leadingOption, slugScopedValue, props.renderProviderMark),
+    [props.groups, props.leadingOption, props.renderProviderMark],
   );
 
   // Reflect the pick immediately and hold it until the caller's write settles,
diff --git a/packages/ui/src/shared-ui-copy.ts b/packages/ui/src/shared-ui-copy.ts
index cc6fc00034..2a0bc8aa68 100644
--- a/packages/ui/src/shared-ui-copy.ts
+++ b/packages/ui/src/shared-ui-copy.ts
@@ -63,7 +63,6 @@ export interface SharedUiCopy {
   };
   modelPicker: {
     searchPlaceholder: string;
-    knowledgeCutoff: (date: string) => string;
   };
   moduleHubs: {
     extensions: {
@@ -159,7 +158,6 @@ const SHARED_UI_COPY = {
     },
     modelPicker: {
       searchPlaceholder: '搜索模型…',
-      knowledgeCutoff: (date) => `知识截止:${date}`,
     },
     moduleHubs: {
       extensions: {
@@ -238,7 +236,6 @@ const SHARED_UI_COPY = {
     },
     modelPicker: {
       searchPlaceholder: '搜尋模型…',
-      knowledgeCutoff: (date) => `知識截止:${date}`,
     },
     moduleHubs: {
       extensions: {
@@ -317,7 +314,6 @@ const SHARED_UI_COPY = {
     },
     modelPicker: {
       searchPlaceholder: 'Search models…',
-      knowledgeCutoff: (date) => `Knowledge cutoff: ${date}`,
     },
     moduleHubs: {
       extensions: {
diff --git a/packages/ui/stories/model-picker.stories.tsx b/packages/ui/stories/model-picker.stories.tsx
index 5482a1c040..2140daf269 100644
--- a/packages/ui/stories/model-picker.stories.tsx
+++ b/packages/ui/stories/model-picker.stories.tsx
@@ -26,7 +26,6 @@ import type { SessionSummary } from '@maka/core/session';
 import { ChatModelSwitcher, ModelChipStatic, NewChatModelPicker, ThinkingLevelSelector } from '../src/chat-model-switcher.js';
 import {
   exactModelChoiceValue,
-  modelChoiceDescription,
   modelChoiceValue,
   modelMenuGroups,
   type ChatModelChoice,
@@ -178,7 +177,8 @@ export const Default: Story = {
 
 // Real path: an existing conversation -> composer footer model control. The
 // cache notice belongs inside this picker's open decision surface; the resting
-// trigger and the new-chat picker below stay quiet.
+// trigger and the new-chat picker below stay quiet. Activating the notice row
+// acknowledges it for the Session and leaves the list open.
 export const ExistingConversation: Story = {
   render: function ExistingConversationRender() {
     const [activeChoice, setActiveChoice] = useState(CHOICES[4]!);
@@ -219,23 +219,41 @@ export const ExistingConversation: Story = {
     const warning = english
       ? 'Switching may rebuild the provider prompt cache, making the next request slower or more expensive.'
       : '切换模型可能需要重建服务商提示缓存,使下一次请求更慢或成本更高。';
-    const trigger = within(canvasElement).getByRole('button', {
-      name: /切换当前任务模型|Switch model for this task/,
-    });
+    // The row's accessible name is the warning plus its "select to dismiss" line.
+    const noticeName = (name: string) => name.startsWith(warning);
+    const triggerName = /切换当前任务模型|Switch model for this task/;
+    const trigger = () => within(canvasElement).getByRole('button', { name: triggerName });
+    const body = within(document.body);
 
-    await userEvent.click(trigger);
-    // The cache warning leads the open list as a disabled row, announced by its
-    // option text — reachable but never pickable.
-    const warningRow = await within(document.body).findByRole('option', { name: warning });
-    await expect(warningRow).toHaveAttribute('aria-disabled', 'true');
+    await userEvent.click(trigger());
+    // The cache notice leads the open list as a regular row, announced by its
+    // option text — reachable, and activating it is the acknowledgement.
+    const notice = await body.findByRole('option', { name: noticeName });
+    await expect(notice).not.toHaveAttribute('aria-disabled', 'true');
 
     await userEvent.keyboard('{Escape}');
-    // Closing restores focus to the same trigger next frame.
-    await waitFor(() => expect(within(canvasElement).getByRole('button', {
-      name: /切换当前任务模型|Switch model for this task/,
-    })).toHaveFocus());
+    // Closing restores focus to the same trigger next frame, and is not an
+    // acknowledgement: the notice is back on reopen.
+    await waitFor(() => expect(trigger()).toHaveFocus());
+    await userEvent.keyboard('{ArrowDown}');
+    await body.findByRole('option', { name: noticeName });
+    // Opening with ArrowDown highlights the first row, the notice; Enter on it
+    // is the keyboard acknowledgement (a click on the row is the pointer one).
+    await userEvent.keyboard('{Enter}');
+
+    // Acknowledged: the list is open again without the notice, the model rows
+    // are still there, and nothing was switched.
+    await waitFor(() => expect(trigger()).toHaveAttribute('aria-expanded', 'true'));
+    await body.findByRole('option', { name: /Claude Sonnet 4/ });
+    await expect(body.queryByRole('option', { name: noticeName })).toBeNull();
+    await expect(trigger()).toHaveTextContent('Claude Sonnet 4');
+
+    // The acknowledgement holds for the Session across close and reopen.
+    await userEvent.keyboard('{Escape}');
+    await waitFor(() => expect(trigger()).toHaveFocus());
     await userEvent.keyboard('{ArrowDown}');
-    await within(document.body).findByRole('option', { name: warning });
+    await body.findByRole('option', { name: /Claude Sonnet 4/ });
+    await expect(body.queryByRole('option', { name: noticeName })).toBeNull();
   },
 };
 


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org
For additional commands, e-mail: commits-help@maka.apache.org