Skip to content

armgit / cindy

Public Imported from GitHub
0

Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。

fix(ui): 模型菜单选中行保留整行底色、不加勾

kirozeng7b4bb92eee9a
diff --git a/apps/desktop/src/renderer/__tests__/unifiedModelPanelRendering.test.tsx b/apps/desktop/src/renderer/__tests__/unifiedModelPanelRendering.test.tsx
index 0bc0316100..64a76d8c92 100644
--- a/apps/desktop/src/renderer/__tests__/unifiedModelPanelRendering.test.tsx
+++ b/apps/desktop/src/renderer/__tests__/unifiedModelPanelRendering.test.tsx
@@ -608,6 +608,20 @@ describe('统一面板 · 会话内形态', () => {
expect(list.querySelector('[data-group-provider="xd"]')).not.toBeNull();
});
+ it('选中的模型行保持整行底色、不加勾,名字保持 500(输入框菜单约定里模型面板的例外)', () => {
+ renderPanel({ vendorKey: 'codex', currentProviderId: 'xd', modelId: 'gpt-5.5' });
+ const list = screen.getByRole('listbox');
+ const selected = list.querySelector<HTMLElement>('[data-model-selected="true"]');
+ expect(selected).not.toBeNull();
+ expect(selected!.className).toContain('bg-sidebar-item-hover');
+ expect(selected!.querySelector('svg.lucide-check')).toBeNull();
+ expect(selected!.querySelector('span[title].font-medium')).not.toBeNull();
+ const other = Array.from(list.querySelectorAll<HTMLElement>('[data-unified-anchor]')).find(
+ (row) => row !== selected,
+ );
+ expect(other?.className).not.toContain('bg-sidebar-item-hover');
+ });
+
it('收藏置顶但不选中,推荐当前值优先并移除下方空供应商组', () => {
const uid = addModelFavorite({ providerId: 'xd', modelId: 'gpt-5.5', agent: 'codex' });
renderPanel({ actualRoute: true, sessionEngineFilter, currentProviderId: 'xd', modelId: 'gpt-5.5', selectedFavoriteUid: uid });
diff --git a/apps/desktop/src/renderer/components/new-chat/ModelSelector.tsx b/apps/desktop/src/renderer/components/new-chat/ModelSelector.tsx
index 9b39376242..80b306a220 100644
--- a/apps/desktop/src/renderer/components/new-chat/ModelSelector.tsx
+++ b/apps/desktop/src/renderer/components/new-chat/ModelSelector.tsx
@@ -2315,12 +2315,13 @@ function ModelSelectorContentView({
onClick={() => available && handleEditEffort(e)}
role="option"
aria-selected={selected}
- // Shared menu row (DESIGN §4 Composer dropdown rows): glide highlight, the
- // chosen effort is the check and 500.
+ // Shared menu row (DESIGN §4 Composer dropdown rows): glide highlight. Model
+ // menu exception: the chosen effort keeps its whole-row fill and the check.
{...menuRowAttrs({ checked: selected, disabled: !available })}
className={cn(
COMPOSER_MENU_ROW,
'flex w-full items-center justify-between px-3 py-2 text-left',
+ selected && 'bg-sidebar-item-hover',
!available && 'cursor-not-allowed opacity-45',
)}
>
@@ -2595,6 +2596,8 @@ function ModelSelectorContentView({
className={cn(
COMPOSER_MENU_ROW,
'group/row flex w-full cursor-pointer items-center justify-between px-3 py-2',
+ // Model menu exception (DESIGN §4): the chosen row keeps its whole-row fill.
+ isSelected && 'bg-sidebar-item-hover',
constrainedListMaxHeight !== undefined && 'min-h-9',
(disabled || paymentRequired) && 'opacity-50',
)}
@@ -3132,6 +3135,7 @@ function ModelSelectorContentView({
COMPOSER_MENU_ROW,
'flex w-full items-center justify-between px-3 py-2',
'hover:bg-sidebar-item-hover focus-visible:bg-sidebar-item-hover',
+ followSession.active && 'bg-sidebar-item-hover',
)}
>
{withMenuLabels(<span>{followSession.label}</span>)}
diff --git a/apps/desktop/src/renderer/components/new-chat/UnifiedModelRow.tsx b/apps/desktop/src/renderer/components/new-chat/UnifiedModelRow.tsx
index 118d9fed9a..c258aa7aa6 100644
--- a/apps/desktop/src/renderer/components/new-chat/UnifiedModelRow.tsx
+++ b/apps/desktop/src/renderer/components/new-chat/UnifiedModelRow.tsx
@@ -1,6 +1,6 @@
import { localizedModelDescription } from '@/lib/modelDescriptions';
import { localizedModelName } from '@/lib/modelDisplayNames';
-import { Check, Lock, SlidersHorizontal, Star, Zap } from 'lucide-react';
+import { Lock, SlidersHorizontal, Star, Zap } from 'lucide-react';
import { useTranslation } from 'react-i18next';
import type { KeyboardEvent as ReactKeyboardEvent, MouseEvent as ReactMouseEvent } from 'react';
@@ -111,7 +111,7 @@ export function UnifiedModelRow({
'aria-keyshortcuts': paymentRequired ? undefined : 'ArrowLeft',
tabIndex: interactionDisabled ? -1 : 0,
'data-model-selected': selected ? ('true' as const) : undefined,
- // Shared menu row: the panel's glide highlight, chosen row = check, config open = open.
+ // Shared menu row: the panel's glide highlight; the chosen row keeps its static fill (below).
...menuRowAttrs(),
'data-state': active ? 'open' : selected ? 'checked' : undefined,
'data-unified-anchor': anchorKey(anchor),
@@ -223,8 +223,10 @@ export function UnifiedModelRow({
className={cn(
// DESIGN §4 Composer dropdown rows: shared row text and motion; the list's glide
// highlight marks the pointer / keyboard-focused row and the row whose config is open.
+ // The model panel is the one exception on the chosen row: whole-row fill, no check.
COMPOSER_MENU_ROW,
'[&+[data-unified-anchor]]:mt-1 group/row flex w-full cursor-pointer flex-col px-3 py-2',
+ selected && 'bg-sidebar-item-hover',
(interactionDisabled || paymentRequired) && 'cursor-not-allowed opacity-50',
)}
>
@@ -292,14 +294,9 @@ export function UnifiedModelRow({
{paymentRequiredUnlock}
{paymentRequiredBadge}
</span>
- {/* 选中标记:悬停 / 键盘改为整面板一块滑动高亮后,选中行不再有静态底色,改用勾
- (与权限 / + / 引擎菜单一致;2026-08-13「已有底色不加勾」随底色撤销而失效)。
- 未选中也占位,列宽不随选中变化,宽度 sizer 量到的就是终宽。 */}
- <Check
- size={15}
- aria-hidden="true"
- className={cn('shrink-0 text-[var(--model-item-check)]', !selected && 'invisible')}
- />
+ {/* 行尾不放 ✅(Chris 2026-08-13 裁决:选中已有整行底色,再加勾是重复信号,
+ 还平白吃掉一列宽度);选中态语义由 aria-selected 承载。模型面板是输入框菜单
+ 「选中 = 勾 + 500」约定的唯一例外,2026-10-04 用户再次确认保留整行底色、不加勾。 */}
</div>
{sourceLabel && entry.providerId !== 'xd' ? (
<ModelSourceDetails
diff --git a/docs/design-rules/DESIGN.md b/docs/design-rules/DESIGN.md
index 690a484bd0..168faa8e06 100644
--- a/docs/design-rules/DESIGN.md
+++ b/docs/design-rules/DESIGN.md
@@ -450,7 +450,7 @@ Ordinary confirmations opt into standard buttons with `presentation="standard"`
- **Menu hover highlight** (`components/ui/dropdown-menu-highlight.ts`): one `--sidebar-item-hover` surface (8px) per `DropdownMenuContent` / `DropdownMenuSubContent` glides between rows with `transform`; the row nearest the pointer anywhere in the panel wins, and separators do not interrupt the glide. Entering fades in from the checked row (or the target), leaving fades out; keyboard follows Radix's highlighted item, and an open SubTrigger stays highlighted while its submenu is in use. Motion: `transform` / `opacity` on `--motion-instant` / `--motion-ease-out` (fade-out `--motion-ease-in`), size snaps, no slide under reduced motion. Danger rows use the same grey layer. Rows whose caller sets its own `focus:` / `hover:` / `data-[highlighted]:` / `data-[state=open]:` background keep it and get no layer; `hoverHighlight={false}` restores per-row fills. Sidebar menus (`features/cc-agent/sidebar/menuStyles.ts`: `MENU_ITEM_CLASS` / `MENU_ROW_CLASS` = `h-8 gap-2`, triggers `cursor-pointer`) use the same highlight.
- **Panel width must bind to the trigger width** — never narrower or wider than the control that opened it. Radix Select: `position="popper"` + `width: var(--radix-select-trigger-width)`; other primitives measure the trigger. (A repeatedly-tripped rule: dropdown width must match the control above.)
- **Select listbox option rows** (Select only; dropdown menu rows follow the Menu entries above): selected / hovered highlight fills use the **8px inner radius** (see §5 — the panel is a 12px container, the row highlight is the inner 8px tier; the inner radius must be smaller than the container's to nest cleanly). Highlight bg via `--surface-hover` / Radix `data-[highlighted]`; selected rows get the chip fill, unselected rows stay transparent.
-- **Composer dropdown rows — one contract with the shared menu** (2026-10-04, supersedes 2026-07-22): the composer menus keep their own shells — MorphPopover (model / permission / + / agent; §14.4 container transform unchanged), the / and @ lists, the bot-chat @ list and the settings search results — but use the shared menu row parts from `components/ui/menu-row.tsx`: `COMPOSER_MENU_ROW` (8px radius, menu text / weight / motion), `menuRowAttrs`, `withMenuLabels`, and one glide highlight per panel (`useMenuPanel` + `MenuHighlightLayer`, the same `--sidebar-item-hover` layer as the shared menu). Rows set no `hover:` / `focus:` fill of their own. The selected row is marked by a check + 500 and never by a fill (the model panel now shows a check too; the 2026-08-13 "fill, no check" rule is retired); danger-tier orange / blue tints the **text only**. Lists that keep focus in a text input (/, @, bot @, settings search) stay focus-in-input: the highlight follows their own current index (`data-menu-current` or `aria-selected`) through `attachMenuHighlight`'s `current` option, never Radix focus. Panels: MorphPopover ends on `--menu-panel-surface` (the shared menu's glass under Cindy themes, opaque on Windows) with `--cmd-palette-border` and `--shadow-menu`; the / and @ lists and the model config flyout use the same 12px panel and `--shadow-menu` (the softer `--cmd-palette-shadow` stays for the command palette and the / tooltip). Group labels use the shared label (12 / 500 / `--cmd-palette-item-meta`). When touching any composer menu's row styles, change them through `menu-row.tsx` — never one menu alone.
+- **Composer dropdown rows — one contract with the shared menu** (2026-10-04, supersedes 2026-07-22): the composer menus keep their own shells — MorphPopover (model / permission / + / agent; §14.4 container transform unchanged), the / and @ lists, the bot-chat @ list and the settings search results — but use the shared menu row parts from `components/ui/menu-row.tsx`: `COMPOSER_MENU_ROW` (8px radius, menu text / weight / motion), `menuRowAttrs`, `withMenuLabels`, and one glide highlight per panel (`useMenuPanel` + `MenuHighlightLayer`, the same `--sidebar-item-hover` layer as the shared menu). Rows set no `hover:` / `focus:` fill of their own. The selected row is marked by a check + 500 and never by a fill — permission, + and agent menus. **The model menu is the one exception** (owner ruling 2026-10-04, keeping the 2026-08-13 ruling): its chosen row keeps a whole-row `--sidebar-item-hover` fill with no check, the model name stays 500, and the effort / follow-session rows keep their fill and existing check; it still takes the shared glide highlight and the glass panel. Danger-tier orange / blue tints the **text only**. Lists that keep focus in a text input (/, @, bot @, settings search) stay focus-in-input: the highlight follows their own current index (`data-menu-current` or `aria-selected`) through `attachMenuHighlight`'s `current` option, never Radix focus. Panels: MorphPopover ends on `--menu-panel-surface` (the shared menu's glass under Cindy themes, opaque on Windows) with `--cmd-palette-border` and `--shadow-menu`; the / and @ lists and the model config flyout use the same 12px panel and `--shadow-menu` (the softer `--cmd-palette-shadow` stays for the command palette and the / tooltip). Group labels use the shared label (12 / 500 / `--cmd-palette-item-meta`). When touching any composer menu's row styles, change them through `menu-row.tsx` — never one menu alone.
FormField → Select forwards descriptions, required/error semantics, and the semantic error border; native browser required validation remains opt-in by the business form.
diff --git a/docs/design-rules/design-decision-log.md b/docs/design-rules/design-decision-log.md
index ce7f0f0326..6c26bbfed0 100644
--- a/docs/design-rules/design-decision-log.md
+++ b/docs/design-rules/design-decision-log.md
@@ -12,7 +12,7 @@
## 2026-10
-- **10-04 输入框菜单与手写菜单接入共享下拉菜单外观**——承接 10-03 与 09-30(#5272)「不含」的两类菜单。①输入框菜单(模型 / 权限 / + / 智能体选择、/ 与 @ 面板、伙伴群聊 @ 点名、设置搜索结果、模型配置浮层)保留各自外壳(MorphPopover 容器形变 §14.4 不变;/、@、伙伴 @、设置搜索的焦点继续留在输入框),只换用共享菜单的行零件:共享逻辑抽到 `components/ui/menu-row.tsx`(行文字、悬停 500、图标 1.5 → 2、宽度预留、整面板一块滑动高亮),`attachMenuHighlight` 新增可配置的「当前项」,让焦点留在输入框的列表按自己的当前序号驱动高亮。按 Design Lab Dropdown Menu v8 的建议实现,用户要求据此完成(原话「做完上面的任务」),逐项最终确认在草稿 PR 阶段进行:悬停色由 `--model-item-hover` 改为共享菜单的 `--sidebar-item-hover`(Cindy 浅 1.11 / 深 1.25:1,原 1.13 / 1.16:1);选中行一律「勾 + 500、不铺底」,模型面板因此加勾,取代 2026-08-13「已有整行底色不再加勾」;/ 与 @ 面板阴影由 `--cmd-palette-shadow` 改为登记阴影 `--shadow-menu`;MorphPopover 终态材质改为共享菜单的毛玻璃(`--menu-panel-surface`,Windows 实色);模型配置浮层 16px 圆角改为 12px 并修正无效的阴影写法。被取代:2026-07-22「三个输入框菜单行用 `--model-item-hover` 悬停与选中铺底」契约。②手写或直接调用 Radix 的点击菜单改用共享组件:更新公告版本跳转(当前版本改为单选勾选行)、右侧面板「添加标签页」、发布到市场的标签多选与发布团队 / 可用范围(单选用 RadioItem,多选用 CheckboxItem,发布团队的锁定项改为禁用的勾选行)。行为不变,另外获得共享组件自带的方向键、Home / End、首字母跳转与关闭后焦点回到触发按钮。悬停打开的协同面板 Worker 列表 / 显示方式菜单与折叠侧栏的项目 / 对话面板若换成共享菜单会改变打开方式,本次不动,单列报告。落点:DESIGN §4「Composer dropdown rows」「Menu hover highlight」;守护:`composerMenuHighlight.test.tsx`、`sharedMenuCallers.test.tsx`、`PlatformTagSelector.test.tsx`、`dropdownMenuHighlight.test.tsx`。本条为方向与规则裁决;macOS 浅 / 深色用 Design Lab 真组件对比过,Windows 未实机验收。
+- **10-04 输入框菜单与手写菜单接入共享下拉菜单外观**——承接 10-03 与 09-30(#5272)「不含」的两类菜单。①输入框菜单(模型 / 权限 / + / 智能体选择、/ 与 @ 面板、伙伴群聊 @ 点名、设置搜索结果、模型配置浮层)保留各自外壳(MorphPopover 容器形变 §14.4 不变;/、@、伙伴 @、设置搜索的焦点继续留在输入框),只换用共享菜单的行零件:共享逻辑抽到 `components/ui/menu-row.tsx`(行文字、悬停 500、图标 1.5 → 2、宽度预留、整面板一块滑动高亮),`attachMenuHighlight` 新增可配置的「当前项」,让焦点留在输入框的列表按自己的当前序号驱动高亮。按 Design Lab Dropdown Menu v8 的建议实现,用户要求据此完成(原话「做完上面的任务」),逐项最终确认在草稿 PR 阶段进行:悬停色由 `--model-item-hover` 改为共享菜单的 `--sidebar-item-hover`(Cindy 浅 1.11 / 深 1.25:1,原 1.13 / 1.16:1);选中行「勾 + 500、不铺底」,适用于权限 / + / 智能体菜单;用户看过测试版后明确**模型菜单是例外**(原话「保持整行灰底,不要打钩;模型名保持加粗;面板是毛玻璃,这个地方特例」):选中模型行保留整行 `--sidebar-item-hover` 底色、不加勾,2026-08-13 裁决继续有效,面板仍用共享毛玻璃与滑动高亮;/ 与 @ 面板阴影由 `--cmd-palette-shadow` 改为登记阴影 `--shadow-menu`;MorphPopover 终态材质改为共享菜单的毛玻璃(`--menu-panel-surface`,Windows 实色);模型配置浮层 16px 圆角改为 12px 并修正无效的阴影写法。被取代:2026-07-22「三个输入框菜单行用 `--model-item-hover` 悬停与选中铺底」契约(模型菜单的选中铺底保留)。②手写或直接调用 Radix 的点击菜单改用共享组件:更新公告版本跳转(当前版本改为单选勾选行)、右侧面板「添加标签页」、发布到市场的标签多选与发布团队 / 可用范围(单选用 RadioItem,多选用 CheckboxItem,发布团队的锁定项改为禁用的勾选行)。行为不变,另外获得共享组件自带的方向键、Home / End、首字母跳转与关闭后焦点回到触发按钮。悬停打开的协同面板 Worker 列表 / 显示方式菜单与折叠侧栏的项目 / 对话面板若换成共享菜单会改变打开方式,本次不动,单列报告。落点:DESIGN §4「Composer dropdown rows」「Menu hover highlight」;守护:`composerMenuHighlight.test.tsx`、`sharedMenuCallers.test.tsx`、`PlatformTagSelector.test.tsx`、`dropdownMenuHighlight.test.tsx`。本条为方向与规则裁决;macOS 浅 / 深色用 Design Lab 真组件对比过,Windows 未实机验收。
- **10-03 Desktop 下拉菜单调用方改回共享默认**——承接 09-30(#5272)「明确不包含」中自带逐行底色的菜单:文件树 / 右侧栏页签 / 会话页签右键菜单、项目切换、自动化与运行记录、插件页与插件详情、技能市场、套餐、伙伴触发器、审查面板、iOS 模拟器、标题栏菜单按钮等调用方,删去行级 `focus:` / `hover:` / `data-[state=open]:` 底色、行圆角 / 字号 / 字色、面板圆角 / 底色 / 描边色 / 阴影覆盖(含无效的 `shadow-[var(--shadow-menu)]`、`shadow-none` 与内联 `boxShadow: 'none'`)及分隔线颜色,改由共享面板与滑动高亮接管;自带淡红底的危险项改为 `variant="danger"`(灰底红字);原来不是红字的「删除自动化」与技能「卸载」也按用户确认改为危险项,伙伴分组计划菜单的分组标题删去字重与字色覆盖、回到共享 Label 默认。行内文字同样收口(用户确认「两类都改」):两行菜单的主标题(内置工具 / 插件作用范围、安卓设备、账号切换、伙伴添加成员)删去常驻 13px / 500,回到行默认 14px、悬停变 500;行内辅助说明(项目进行中数、成员说明、画质当前值、提交相对时间、副本路径、版本号及上述两行菜单的说明行)由 10–12px 与各自的灰统一为 `text-12 leading-[1.33] text-[var(--cmd-palette-item-meta)]`,与共享快捷键、侧栏菜单一致。按键标签(审查提交快捷键)与面板底部的说明段落不在此列。用户确认:行高统一为共享默认 32px / 14px,原 28px / 13px 的紧凑右键菜单与 36–40px 的加高菜单都不留例外(原话「都可以统一」);标题栏菜单按钮不再用 `bg-titlebar` / `titlebar-button-hover`,改用共享菜单配色。保留:宽度、定位、层级,DESIGN §5 允许的 6–8px 面板内边距,以及有状态含义的字色字重(当前项加粗、被拒设备灰字、脱敏 Key 等宽灰字)。不含:输入框内模型 / 权限 / + 菜单(MorphPopover)、手写菜单(`FileBodyView`、`FileTabsBar`、`UpdateNoticeDialog`)、Select、弹窗与 Popover。实测(dev 实例,Cindy 浅 / 深):旧悬停与面板 1.02–1.14:1(深色多处悬停色比面板更暗),新灰高亮 1.12(浅)/ 1.28–1.31:1(深)。落点:DESIGN §4 Select & Dropdown;守护:`dropdownMenuHighlight.test.tsx`、`IOSSimulatorTabBody.test.tsx`。macOS 实机看过浅深两种模式,Windows 未实机验收。