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(desktop): 分步选择辅助模型 Agent

DavidShen3866362efa51
diff --git a/apps/desktop/src/main/maker-ipc/auxiliary-model-settings.ts b/apps/desktop/src/main/maker-ipc/auxiliary-model-settings.ts
index dc24720fcc..369439d1c1 100644
--- a/apps/desktop/src/main/maker-ipc/auxiliary-model-settings.ts
+++ b/apps/desktop/src/main/maker-ipc/auxiliary-model-settings.ts
@@ -81,7 +81,7 @@ export function buildAuxiliaryModelOptions(args: {
if (!decoded) continue;
result.push({
id: pin,
- label: `${decoded.model} · ${decoded.providerId} · ${decoded.agentKind === 'codex' ? 'Codex' : 'Claude Code'}`,
+ label: `${decoded.agentKind === 'codex' ? 'Codex' : 'Claude Code'} · ${decoded.model} · ${decoded.providerId}`,
group: decoded.providerId,
providerId: decoded.providerId,
agentKind: decoded.agentKind,
diff --git a/apps/desktop/src/main/utility-model/__tests__/textOneshotPinOptions.test.ts b/apps/desktop/src/main/utility-model/__tests__/textOneshotPinOptions.test.ts
index d9e23f8501..5939e685d7 100644
--- a/apps/desktop/src/main/utility-model/__tests__/textOneshotPinOptions.test.ts
+++ b/apps/desktop/src/main/utility-model/__tests__/textOneshotPinOptions.test.ts
@@ -89,7 +89,7 @@ describe('buildTextOneshotPinOptions', () => {
expect(options).toEqual([
{
id: 'cat:xd:codex:codex/gpt-5.5',
- label: 'GPT 5.5 折扣 · Cindy Gateway · Codex',
+ label: 'Codex · GPT 5.5 折扣 · Cindy Gateway',
group: 'Cindy Gateway',
providerId: 'xd',
agentKind: 'codex',
@@ -105,7 +105,7 @@ describe('buildTextOneshotPinOptions', () => {
},
{
id: 'cat:openai:codex:gpt-5.5',
- label: 'GPT 5.5 · OpenAI · Codex',
+ label: 'Codex · GPT 5.5 · OpenAI',
group: 'OpenAI',
providerId: 'openai',
agentKind: 'codex',
@@ -298,10 +298,10 @@ describe('buildTextOneshotPinOptions', () => {
undefined,
);
expect(options.map((o) => [o.id, o.label])).toEqual([
- ['cat:xd:codex:gpt-5.5', 'GPT 5.5 · GW · Codex'],
- ['cat:xd:claude-code:gpt-5.5', 'GPT 5.5 · GW · Claude Code'],
- ['cat:dual:codex:gpt-5.5', 'GPT 5.5 · Dual · Codex'],
- ['cat:dual:claude-code:gpt-5.5', 'GPT 5.5 · Dual · Claude Code'],
+ ['cat:xd:codex:gpt-5.5', 'Codex · GPT 5.5 · GW'],
+ ['cat:xd:claude-code:gpt-5.5', 'Claude Code · GPT 5.5 · GW'],
+ ['cat:dual:codex:gpt-5.5', 'Codex · GPT 5.5 · Dual'],
+ ['cat:dual:claude-code:gpt-5.5', 'Claude Code · GPT 5.5 · Dual'],
]);
expect(options.map((o) => o.agentSuffix)).toEqual([
'Codex',
@@ -328,7 +328,7 @@ describe('buildTextOneshotPinOptions', () => {
);
expect(options.map((o) => [o.id, o.label])).toEqual([
- ['cat:xd:codex:gpt-5.5', 'GPT 5.5 · xd · Codex'],
+ ['cat:xd:codex:gpt-5.5', 'Codex · GPT 5.5 · xd'],
]);
});
diff --git a/apps/desktop/src/main/utility-model/textOneshotPinOptions.ts b/apps/desktop/src/main/utility-model/textOneshotPinOptions.ts
index 2b3112b042..3e597e0b40 100644
--- a/apps/desktop/src/main/utility-model/textOneshotPinOptions.ts
+++ b/apps/desktop/src/main/utility-model/textOneshotPinOptions.ts
@@ -125,7 +125,7 @@ function routingForRenderer(routing: Provider['routing']): Provider['routing'] {
export interface TextOneshotPinOption {
/** 钉值(cat: 编码)。 */
id: string;
- /** 兜底行文案:`<模型名> · <供应商名> · <Agent>`。 */
+ /** 兜底行文案:`<Agent> · <模型名> · <供应商名>`。 */
label: string;
/** 分组(供应商显示名)。 */
group: string;
@@ -209,7 +209,7 @@ export function buildTextOneshotPinOptions(
const base = `${e.model.name} · ${e.provider.name}`;
return {
id: encodeCatalogPin(e.provider.id, e.agentKind, e.model.id),
- label: `${base} · ${AGENT_LABEL[e.agentKind]}`,
+ label: `${AGENT_LABEL[e.agentKind]} · ${base}`,
group: e.provider.name,
providerId: e.provider.id,
agentKind: e.agentKind,
diff --git a/apps/desktop/src/renderer/cindy-brain/OneshotModelPinPicker.tsx b/apps/desktop/src/renderer/cindy-brain/OneshotModelPinPicker.tsx
index 2922c6140d..dec8b3d690 100644
--- a/apps/desktop/src/renderer/cindy-brain/OneshotModelPinPicker.tsx
+++ b/apps/desktop/src/renderer/cindy-brain/OneshotModelPinPicker.tsx
@@ -2,18 +2,21 @@
* OneshotModelPinPicker — 快问快答(text.oneshot)钉档选择器。
*
* 钉值是目录钉(cat: 编码的 供应商×agent×模型),清单 = 当前供应商目录的全部
- * 文本模型(主侧 cindy-prefs 同步下发)。视觉与信息层级对齐新建对话 / 开协同的
- * 模型选择器(ModelSelector):厂牌图标 + 模型名 + 折扣/订阅徽标 + 供应商分组
- * 标题 + 搜索过滤;首行恒为「跟随默认」(身份卡声明了偏好模型时如实显示声明)。
+ * 文本模型(主侧 cindy-prefs 同步下发)。选择器先让用户选择 Agent,再只展示该
+ * Agent 可用的模型;选中模型后才一次性写回完整钉值。模型层视觉与信息层级对齐
+ * 新建对话 / 开协同的模型选择器(ModelSelector):厂牌图标 + 模型名 + 折扣/订阅
+ * 徽标 + 供应商分组标题 + 搜索过滤。第一层首行恒为「跟随默认」(身份卡声明了
+ * 偏好模型时如实显示声明)。
*/
-import { useMemo, useRef, useState, type ReactNode } from 'react';
-import { Check, ChevronDown, Search } from 'lucide-react';
+import { useEffect, useMemo, useRef, useState, type ReactNode } from 'react';
+import { Check, ChevronDown, ChevronLeft, Search } from 'lucide-react';
import { useTranslation } from 'react-i18next';
import { cn } from '@/lib/utils';
import { Popover, PopoverContent, PopoverTrigger } from '@/components/ui/popover';
import { ModelIconMark } from '@/components/new-chat/ModelSelector';
+import { decodeCatalogModelPin } from '../../shared/catalogModelPin';
/** 主侧 cindy-prefs 下发的目录钉条目(与 TextOneshotPinOption 同形)。 */
export interface OneshotPinOption {
@@ -36,13 +39,8 @@ export interface OneshotPinOption {
available?: boolean;
}
-function optionAgentLabel(option: OneshotPinOption): string {
- return option.agentSuffix
- ?? (option.agentKind === 'claude-code'
- ? 'Claude Code'
- : option.agentKind === 'codex'
- ? 'Codex'
- : option.agentKind);
+function agentKindLabel(agentKind: string): string {
+ return agentKind === 'claude-code' ? 'Claude Code' : agentKind === 'codex' ? 'Codex' : agentKind;
}
export function OneshotModelPinPicker({
@@ -87,6 +85,7 @@ export function OneshotModelPinPicker({
}): ReactNode {
const { t } = useTranslation();
const [open, setOpen] = useState(false);
+ const [selectedAgent, setSelectedAgent] = useState<string | null>(null);
const [query, setQuery] = useState('');
const searchRef = useRef<HTMLInputElement>(null);
@@ -94,6 +93,7 @@ export function OneshotModelPinPicker({
// 覆盖值已不在当前清单(目录演进):如实显示原值,不假装跟随默认。
// 存量档位钉不是 stale——它合法且仍可路由,只是不再能新建,展示友好名。
const staleValue = value && !current && !legacyPinLabel ? value : null;
+ const staleRoute = staleValue ? decodeCatalogModelPin(staleValue) : null;
const automaticLabel = defaultOptionLabel
?? (declaredLabel
? t('settings.ghosts.detail.cindyPrefs.defaultOptionDeclared', { model: declaredLabel })
@@ -103,8 +103,7 @@ export function OneshotModelPinPicker({
?? staleValue
?? automaticLabel;
- const filtered = useMemo(() => {
- const q = query.trim().toLowerCase();
+ const visibleOptions = useMemo(() => {
const visible: OneshotPinOption[] = [];
const indexByRouteName = new Map<string, number>();
for (const option of options) {
@@ -121,15 +120,33 @@ export function OneshotModelPinPicker({
visible[existingIndex] = option;
}
}
+ return visible;
+ }, [options, value]);
+
+ const agentChoices = useMemo(() => {
+ const kinds: string[] = [];
+ for (const option of visibleOptions) {
+ if (!kinds.includes(option.agentKind)) kinds.push(option.agentKind);
+ }
+ if (staleRoute && !kinds.includes(staleRoute.agentKind)) kinds.push(staleRoute.agentKind);
+ return kinds.map((kind) => ({ kind, label: agentKindLabel(kind) }));
+ }, [staleRoute, visibleOptions]);
+
+ const currentAgent = current?.agentKind ?? staleRoute?.agentKind ?? null;
+ const selectedAgentLabel = selectedAgent ? agentKindLabel(selectedAgent) : '';
+
+ const filtered = useMemo(() => {
+ if (!selectedAgent) return [];
+ const q = query.trim().toLowerCase();
+ const visible = visibleOptions.filter((option) => option.agentKind === selectedAgent);
if (!q) return visible;
return visible.filter(
(o) =>
o.modelName.toLowerCase().includes(q)
|| o.modelId.toLowerCase().includes(q)
- || optionAgentLabel(o).toLowerCase().includes(q)
|| o.group.toLowerCase().includes(q),
);
- }, [options, query, value]);
+ }, [query, selectedAgent, visibleOptions]);
const groups = useMemo(() => {
const names: string[] = [];
@@ -139,16 +156,24 @@ export function OneshotModelPinPicker({
return names.map((name) => ({ name, items: filtered.filter((o) => o.group === name) }));
}, [filtered]);
+ useEffect(() => {
+ if (open && selectedAgent) searchRef.current?.focus();
+ }, [open, selectedAgent]);
+
const select = (pin: string | null): void => {
// 点中的就是当前值(含 stale 行):只收起,不回写——stale 的目录钉已不在
// 白名单里,回写必被 INVALID_PARAMS 拒成「操作失败」toast,且同值回写
// 本来就是无操作。
- if (pin === value) {
+ if (pin === value || (pin === null && value === undefined)) {
setOpen(false);
+ setSelectedAgent(null);
+ setQuery('');
return;
}
onChange(pin);
setOpen(false);
+ setSelectedAgent(null);
+ setQuery('');
};
const rowClass = (active: boolean): string =>
@@ -165,7 +190,10 @@ export function OneshotModelPinPicker({
onOpenChange={(next) => {
if (disabled && next) return;
setOpen(next);
- if (!next) setQuery('');
+ if (!next) {
+ setSelectedAgent(null);
+ setQuery('');
+ }
}}
>
<PopoverTrigger asChild>
@@ -200,132 +228,189 @@ export function OneshotModelPinPicker({
className="w-[320px] overflow-hidden rounded-[12px] border border-[var(--model-dropdown-border)] bg-[var(--model-dropdown-bg)] p-2 shadow-[var(--shadow-menu)]"
>
<div className="flex flex-col gap-1.5">
- {/* 搜索框 —— 药丸样式,与模型选择器同。 */}
- <div className="flex items-center gap-2 rounded-full border border-[var(--model-dropdown-border)] bg-[var(--surface)] px-3 py-[7px]">
- <Search size={16} className="shrink-0 text-[var(--text-tertiary)]" />
- <input
- ref={searchRef}
- type="text"
- value={query}
- onChange={(e) => setQuery(e.target.value)}
- placeholder={searchPlaceholder ?? t('settings.ghosts.detail.cindyPrefs.searchPlaceholder')}
- aria-label={searchPlaceholder ?? t('settings.ghosts.detail.cindyPrefs.searchPlaceholder')}
- className="min-w-0 flex-1 bg-transparent text-14 text-[var(--model-item-text)] outline-none placeholder:text-[var(--text-tertiary)]"
- />
- </div>
-
- <div
- role="listbox"
- aria-label={ariaLabel}
- className="flex max-h-[300px] flex-col gap-0.5 overflow-y-auto overscroll-contain"
- >
- {/* 「跟随默认」行(声明了偏好模型时如实显示声明内容)。搜索态也保留:
- 它是唯一能清除钉档的行。 */}
- <button
- type="button"
- role="option"
- aria-selected={value === undefined}
- className={rowClass(value === undefined)}
- onClick={() => select(null)}
+ {selectedAgent === null ? (
+ <div
+ role="listbox"
+ aria-label={ariaLabel}
+ className="flex max-h-[300px] flex-col gap-0.5 overflow-y-auto overscroll-contain"
>
- <span className="min-w-0 truncate text-14 font-medium leading-5 text-[var(--model-item-text)]">
- {automaticLabel}
- </span>
- {value === undefined && (
- <Check size={15} className="ml-2 shrink-0 text-[var(--model-item-check)]" />
- )}
- </button>
+ <button
+ type="button"
+ role="option"
+ aria-selected={value === undefined}
+ className={rowClass(value === undefined)}
+ onClick={() => select(null)}
+ >
+ <span className="min-w-0 truncate text-14 font-medium leading-5 text-[var(--model-item-text)]">
+ {automaticLabel}
+ </span>
+ {value === undefined && (
+ <Check size={15} className="ml-2 shrink-0 text-[var(--model-item-check)]" />
+ )}
+ </button>
- {groups.length === 0 ? (
- <div className="px-3 py-6 text-center text-13 text-[var(--text-tertiary)]">
- {noResultsLabel ?? t('newChat.modelSelector.search.noResults')}
- </div>
- ) : (
- groups.map((g) => (
- <div key={g.name} role="group" aria-label={g.name}>
+ {agentChoices.length === 0 ? (
+ <div className="px-3 py-6 text-center text-13 text-[var(--text-tertiary)]">
+ {noResultsLabel ?? t('newChat.modelSelector.search.noResults')}
+ </div>
+ ) : (
+ <div role="group" aria-label={t('settings.auxiliaryModels.chooseAgent')}>
<div className="mx-1 my-1 h-px bg-[var(--model-dropdown-border)]" />
<div className="truncate px-3 pb-0.5 pt-1 text-11 font-medium text-[var(--text-tertiary)]">
- {g.name}
+ {t('settings.auxiliaryModels.chooseAgent')}
</div>
- {g.items.map((o) => {
- const active = value === o.id;
- const unavailable = o.available === false;
+ {agentChoices.map((agent) => {
+ const active = currentAgent === agent.kind;
return (
<button
- key={o.id}
+ key={agent.kind}
type="button"
role="option"
aria-selected={active}
- data-pin-id={o.id}
- aria-disabled={unavailable}
- className={cn(rowClass(active), unavailable && 'opacity-60')}
- onClick={() => select(o.id)}
+ data-agent-kind={agent.kind}
+ className={rowClass(active)}
+ onClick={() => {
+ setSelectedAgent(agent.kind);
+ setQuery('');
+ }}
>
- <span className="flex min-w-0 flex-1 items-center gap-2.5">
- <ModelIconMark
- icon={o.icon}
- providerId={o.providerId}
- name={o.group}
- routing={o.routing}
- colorClass="text-[var(--text-secondary)]"
- withMargin={false}
- dense
- />
- <span className="flex min-w-0 flex-1 items-center gap-1.5">
- <span className="truncate text-14 font-medium leading-5 text-[var(--model-item-text)]">
- {o.modelName}
- </span>
- <span className="shrink-0 text-13 font-normal text-[var(--text-tertiary)]">
- · {optionAgentLabel(o)}
- </span>
- {unavailable && (
- <span className="shrink-0 text-11 font-normal text-[var(--text-tertiary)]">
- {unavailableLabel ?? t('settings.auxiliaryModels.unavailable')}
- </span>
- )}
- </span>
- <span className="ml-auto flex shrink-0 items-center gap-1.5">
- {o.subscription && (
- <span className="inline-flex shrink-0 items-center rounded-full bg-[var(--surface-chip)] px-2 py-[1px] text-11 font-medium text-[var(--text-secondary)]">
- {subscriptionLabel ?? t('settings.providers.models.subscription')}
- </span>
- )}
- {o.budget && (
- <span className="inline-flex shrink-0 items-center rounded-full bg-[var(--accent-cta-bg)] px-2 py-[1px] text-11 font-medium leading-[1.45] text-[var(--accent-pure-cta-fg)]">
- {budgetLabel ?? t('settings.ghosts.detail.cindyPrefs.budgetBadge')}
- </span>
- )}
- </span>
+ <span className="min-w-0 truncate text-14 font-medium leading-5 text-[var(--model-item-text)]">
+ {agent.label}
</span>
- {active && (
- <Check size={15} className="ml-2 shrink-0 text-[var(--model-item-check)]" />
- )}
+ <ChevronDown
+ size={15}
+ className="-rotate-90 shrink-0 text-[var(--text-tertiary)]"
+ />
</button>
);
})}
</div>
- ))
- )}
+ )}
+ </div>
+ ) : (
+ <>
+ <button
+ type="button"
+ aria-label={t('settings.auxiliaryModels.backToAgents')}
+ className="flex w-full items-center gap-1.5 rounded-[8px] px-2 py-1.5 text-left text-13 font-medium text-[var(--model-item-text)] hover:bg-[var(--model-item-hover)] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--focus-ring)]"
+ onClick={() => {
+ setSelectedAgent(null);
+ setQuery('');
+ }}
+ >
+ <ChevronLeft size={15} className="shrink-0 text-[var(--text-tertiary)]" />
+ <span className="truncate">{selectedAgentLabel}</span>
+ </button>
- {/* 覆盖值已不在当前清单(目录演进):如实显示原值,可选回。 */}
- {staleValue && query.trim() === '' && (
- <div role="group" aria-label={staleValue}>
- <div className="mx-1 my-1 h-px bg-[var(--model-dropdown-border)]" />
- <button
- type="button"
- role="option"
- aria-selected
- className={rowClass(true)}
- onClick={() => select(staleValue)}
- >
- <span className="min-w-0 truncate text-14 font-medium leading-5 text-[var(--model-item-text)]">
- {staleValue}
- </span>
- <Check size={15} className="ml-2 shrink-0 text-[var(--model-item-check)]" />
- </button>
+ <div className="flex items-center gap-2 rounded-full border border-[var(--model-dropdown-border)] bg-[var(--surface)] px-3 py-[7px]">
+ <Search size={16} className="shrink-0 text-[var(--text-tertiary)]" />
+ <input
+ ref={searchRef}
+ type="text"
+ value={query}
+ onChange={(e) => setQuery(e.target.value)}
+ placeholder={searchPlaceholder ?? t('settings.ghosts.detail.cindyPrefs.searchPlaceholder')}
+ aria-label={searchPlaceholder ?? t('settings.ghosts.detail.cindyPrefs.searchPlaceholder')}
+ className="min-w-0 flex-1 bg-transparent text-14 text-[var(--model-item-text)] outline-none placeholder:text-[var(--text-tertiary)]"
+ />
</div>
- )}
- </div>
+
+ <div
+ role="listbox"
+ aria-label={`${ariaLabel}: ${selectedAgentLabel}`}
+ className="flex max-h-[300px] flex-col gap-0.5 overflow-y-auto overscroll-contain"
+ >
+ {groups.length === 0
+ && !(staleValue && staleRoute?.agentKind === selectedAgent && query.trim() === '') ? (
+ <div className="px-3 py-6 text-center text-13 text-[var(--text-tertiary)]">
+ {noResultsLabel ?? t('newChat.modelSelector.search.noResults')}
+ </div>
+ ) : (
+ groups.map((g) => (
+ <div key={g.name} role="group" aria-label={g.name}>
+ <div className="mx-1 my-1 h-px bg-[var(--model-dropdown-border)]" />
+ <div className="truncate px-3 pb-0.5 pt-1 text-11 font-medium text-[var(--text-tertiary)]">
+ {g.name}
+ </div>
+ {g.items.map((o) => {
+ const active = value === o.id;
+ const unavailable = o.available === false;
+ return (
+ <button
+ key={o.id}
+ type="button"
+ role="option"
+ aria-selected={active}
+ data-pin-id={o.id}
+ aria-disabled={unavailable}
+ className={cn(rowClass(active), unavailable && 'opacity-60')}
+ onClick={() => select(o.id)}
+ >
+ <span className="flex min-w-0 flex-1 items-center gap-2.5">
+ <ModelIconMark
+ icon={o.icon}
+ providerId={o.providerId}
+ name={o.group}
+ routing={o.routing}
+ colorClass="text-[var(--text-secondary)]"
+ withMargin={false}
+ dense
+ />
+ <span className="flex min-w-0 flex-1 items-center gap-1.5">
+ <span className="truncate text-14 font-medium leading-5 text-[var(--model-item-text)]">
+ {o.modelName}
+ </span>
+ {unavailable && (
+ <span className="shrink-0 text-11 font-normal text-[var(--text-tertiary)]">
+ {unavailableLabel ?? t('settings.auxiliaryModels.unavailable')}
+ </span>
+ )}
+ </span>
+ <span className="ml-auto flex shrink-0 items-center gap-1.5">
+ {o.subscription && (
+ <span className="inline-flex shrink-0 items-center rounded-full bg-[var(--surface-chip)] px-2 py-[1px] text-11 font-medium text-[var(--text-secondary)]">
+ {subscriptionLabel ?? t('settings.providers.models.subscription')}
+ </span>
+ )}
+ {o.budget && (
+ <span className="inline-flex shrink-0 items-center rounded-full bg-[var(--accent-cta-bg)] px-2 py-[1px] text-11 font-medium leading-[1.45] text-[var(--accent-pure-cta-fg)]">
+ {budgetLabel ?? t('settings.ghosts.detail.cindyPrefs.budgetBadge')}
+ </span>
+ )}
+ </span>
+ </span>
+ {active && (
+ <Check size={15} className="ml-2 shrink-0 text-[var(--model-item-check)]" />
+ )}
+ </button>
+ );
+ })}
+ </div>
+ ))
+ )}
+
+ {staleValue
+ && staleRoute?.agentKind === selectedAgent
+ && query.trim() === '' && (
+ <div role="group" aria-label={staleValue}>
+ <div className="mx-1 my-1 h-px bg-[var(--model-dropdown-border)]" />
+ <button
+ type="button"
+ role="option"
+ aria-selected
+ className={rowClass(true)}
+ onClick={() => select(staleValue)}
+ >
+ <span className="min-w-0 truncate text-14 font-medium leading-5 text-[var(--model-item-text)]">
+ {staleValue}
+ </span>
+ <Check size={15} className="ml-2 shrink-0 text-[var(--model-item-check)]" />
+ </button>
+ </div>
+ )}
+ </div>
+ </>
+ )}
</div>
</PopoverContent>
</Popover>
diff --git a/apps/desktop/src/renderer/features/plugin/__tests__/GhostPluginDetailSections.test.tsx b/apps/desktop/src/renderer/features/plugin/__tests__/GhostPluginDetailSections.test.tsx
index 82b384e8cc..cae50d59b7 100644
--- a/apps/desktop/src/renderer/features/plugin/__tests__/GhostPluginDetailSections.test.tsx
+++ b/apps/desktop/src/renderer/features/plugin/__tests__/GhostPluginDetailSections.test.tsx
@@ -694,7 +694,7 @@ describe('Ghost plugin detail sections', () => {
options: [
{
id: 'cat:xd:codex:codex/gpt-5.5',
- label: 'GPT 5.5 折扣 · GW',
+ label: 'Codex · GPT 5.5 折扣 · GW',
group: 'GW',
providerId: 'xd',
agentKind: 'codex',
@@ -706,7 +706,7 @@ describe('Ghost plugin detail sections', () => {
},
{
id: 'cat:openai:codex:gpt-5.5',
- label: 'GPT 5.5 · OpenAI · Codex',
+ label: 'Codex · GPT 5.5 · OpenAI',
group: 'OpenAI',
providerId: 'openai',
agentKind: 'codex',
@@ -718,7 +718,7 @@ describe('Ghost plugin detail sections', () => {
},
{
id: 'cat:openai:codex:chatgpt/gpt-5.5',
- label: 'GPT 5.5 · OpenAI · Codex',
+ label: 'Codex · GPT 5.5 · OpenAI',
group: 'OpenAI',
providerId: 'openai',
agentKind: 'codex',
@@ -730,7 +730,7 @@ describe('Ghost plugin detail sections', () => {
},
{
id: 'cat:openai:claude-code:chatgpt/gpt-5.5',
- label: 'GPT 5.5 · OpenAI · Claude Code',
+ label: 'Claude Code · GPT 5.5 · OpenAI',
group: 'OpenAI',
providerId: 'openai',
agentKind: 'claude-code',
@@ -757,24 +757,41 @@ describe('Ghost plugin detail sections', () => {
screen.getByRole('button', { name: 'settings.ghosts.detail.cindyPrefs.cap.text.oneshot' }),
);
- const listbox = await screen.findByRole('listbox');
- // 分组标题 + 首行是声明版"跟随默认"(i18n mock 透传 key)。
- expect(within(listbox).getByText('GW')).toBeTruthy();
- expect(within(listbox).getByText('OpenAI')).toBeTruthy();
- const defaultRow = within(listbox).getAllByRole('option')[0]!;
+ const agentList = await screen.findByRole('listbox');
+ // 第一层只显示自动选择和 Agent,不混入模型排列组合。
+ expect(within(agentList).queryByText('GW')).toBeNull();
+ expect(within(agentList).queryByText('OpenAI')).toBeNull();
+ const defaultRow = within(agentList).getAllByRole('option')[0]!;
expect(defaultRow.textContent).toContain(
'settings.ghosts.detail.cindyPrefs.defaultOptionDeclared',
);
- // 折扣徽标只出现在预算行;订阅徽标只出现在订阅行。
- const budgetRow = within(listbox).getByText('GPT 5.5 折扣').closest('button')!;
- expect(within(budgetRow).getByText(/Codex/)).toBeTruthy();
+ fireEvent.click(agentList.querySelector('[data-agent-kind="codex"]')!);
+
+ let codexModels = await screen.findByRole('listbox');
+ expect(within(codexModels).getByText('GW')).toBeTruthy();
+ expect(within(codexModels).getByText('OpenAI')).toBeTruthy();
+ expect(codexModels.querySelector('[data-pin-id*="claude-code"]')).toBeNull();
+
+ fireEvent.click(
+ screen.getByRole('button', { name: 'settings.auxiliaryModels.backToAgents' }),
+ );
+ const agentListAgain = await screen.findByRole('listbox');
+ fireEvent.click(agentListAgain.querySelector('[data-agent-kind="claude-code"]')!);
+ const claudeModels = await screen.findByRole('listbox');
+ expect(claudeModels.querySelector('[data-pin-id*="claude-code"]')).toBeTruthy();
+ expect(claudeModels.querySelector('[data-pin-id*="openai:codex:"]')).toBeNull();
+
+ fireEvent.click(
+ screen.getByRole('button', { name: 'settings.auxiliaryModels.backToAgents' }),
+ );
+ fireEvent.click(
+ (await screen.findByRole('listbox')).querySelector('[data-agent-kind="codex"]')!,
+ );
+ codexModels = await screen.findByRole('listbox');
+ // 同 Agent 的同名别名折叠;另一个 Agent 的同名模型不混在本层。
+ const budgetRow = within(codexModels).getByText('GPT 5.5 折扣').closest('button')!;
expect(within(budgetRow).getByText('settings.ghosts.detail.cindyPrefs.budgetBadge')).toBeTruthy();
- const plainRows = within(listbox)
- .getAllByText('GPT 5.5', { exact: true })
- .map((modelName) => modelName.closest('button')!);
- expect(plainRows).toHaveLength(2);
- const plainRow = plainRows.find((row) => row.textContent?.includes('Codex'))!;
- expect(plainRows.some((row) => row.textContent?.includes('Claude Code'))).toBe(true);
+ const plainRow = within(codexModels).getByText('GPT 5.5', { exact: true }).closest('button')!;
expect(
within(plainRow).queryByText('settings.ghosts.detail.cindyPrefs.budgetBadge'),
).toBeNull();
@@ -814,7 +831,7 @@ describe('Ghost plugin detail sections', () => {
options: [
{
id: 'cat:xd:codex:codex/gpt-5.5',
- label: 'GPT 5.5 折扣 · GW',
+ label: 'Codex · GPT 5.5 折扣 · GW',
group: 'GW',
providerId: 'xd',
agentKind: 'codex',
@@ -870,7 +887,7 @@ describe('Ghost plugin detail sections', () => {
options: [
{
id: 'cat:xd:codex:codex/gpt-5.5',
- label: 'GPT 5.5 折扣 · GW',
+ label: 'Codex · GPT 5.5 折扣 · GW',
group: 'GW',
providerId: 'xd',
agentKind: 'codex',
@@ -895,6 +912,8 @@ describe('Ghost plugin detail sections', () => {
fireEvent.click(
screen.getByRole('button', { name: 'settings.ghosts.detail.cindyPrefs.cap.text.oneshot' }),
);
+ const agentList = await screen.findByRole('listbox');
+ fireEvent.click(agentList.querySelector('[data-agent-kind="codex"]')!);
const listbox = await screen.findByRole('listbox');
// stale 行如实显示原值且为当前选中;点它不回写。
const staleRow = within(listbox).getByText('cat:gone:codex:retired-model').closest('button')!;
diff --git a/apps/desktop/src/renderer/i18n/locales/en/common.json b/apps/desktop/src/renderer/i18n/locales/en/common.json
index 85ffb6d0ff..3551c3c95d 100644
--- a/apps/desktop/src/renderer/i18n/locales/en/common.json
+++ b/apps/desktop/src/renderer/i18n/locales/en/common.json
@@ -2544,8 +2544,10 @@
"ariaLabel": "Choose the composer prompt suggestion model",
"automatic": "Automatic (keep current routing)"
},
+ "chooseAgent": "Choose an Agent",
+ "backToAgents": "Back to Agent selection",
"explicitRouteHint": "An explicit selection uses only that Agent and model. If unavailable, Cindy will not switch automatically.",
- "searchPlaceholder": "Search Agents, models, or providers",
+ "searchPlaceholder": "Search models or providers",
"noResults": "No available models",
"unavailable": "Currently unavailable",
"budget": "Discount",
diff --git a/apps/desktop/src/renderer/i18n/locales/ja/common.json b/apps/desktop/src/renderer/i18n/locales/ja/common.json
index 32dd5d604b..3f92c7a42b 100644
--- a/apps/desktop/src/renderer/i18n/locales/ja/common.json
+++ b/apps/desktop/src/renderer/i18n/locales/ja/common.json
@@ -2543,8 +2543,10 @@
"ariaLabel": "入力欄のおすすめプロンプト用モデルを選択",
"automatic": "自動選択(現在のルーティングを維持)"
},
+ "chooseAgent": "Agent を選択",
+ "backToAgents": "Agent の選択に戻る",
"explicitRouteHint": "明示的に指定した場合は、その Agent とモデルだけを使用します。利用できなくても自動では切り替えません。",
- "searchPlaceholder": "Agent、モデル、プロバイダーを検索",
+ "searchPlaceholder": "モデルまたはプロバイダーを検索",
"noResults": "利用可能なモデルがありません",
"unavailable": "現在利用不可",
"budget": "割引",
diff --git a/apps/desktop/src/renderer/i18n/locales/ko/common.json b/apps/desktop/src/renderer/i18n/locales/ko/common.json
index bc8e3cd89e..64004fe542 100644
--- a/apps/desktop/src/renderer/i18n/locales/ko/common.json
+++ b/apps/desktop/src/renderer/i18n/locales/ko/common.json
@@ -2543,8 +2543,10 @@
"ariaLabel": "입력창 추천 프롬프트 모델 선택",
"automatic": "자동 선택(현재 라우팅 유지)"
},
+ "chooseAgent": "Agent 선택",
+ "backToAgents": "Agent 선택으로 돌아가기",
"explicitRouteHint": "명시적으로 지정하면 해당 Agent와 모델만 사용합니다. 사용할 수 없어도 자동으로 전환하지 않습니다.",
- "searchPlaceholder": "Agent, 모델 또는 제공자 검색",
+ "searchPlaceholder": "모델 또는 제공자 검색",
"noResults": "사용 가능한 모델이 없습니다",
"unavailable": "현재 사용할 수 없음",
"budget": "할인",
diff --git a/apps/desktop/src/renderer/i18n/locales/zh-CN/common.json b/apps/desktop/src/renderer/i18n/locales/zh-CN/common.json
index 8ea0407310..727782f7df 100644
--- a/apps/desktop/src/renderer/i18n/locales/zh-CN/common.json
+++ b/apps/desktop/src/renderer/i18n/locales/zh-CN/common.json
@@ -2543,8 +2543,10 @@
"ariaLabel": "选择输入框推荐指令模型",
"automatic": "自动选择(保持当前规则)"
},
+ "chooseAgent": "选择 Agent",
+ "backToAgents": "返回选择 Agent",
"explicitRouteHint": "显式指定后只使用该 Agent 和模型;不可用时不会自动切换。",
- "searchPlaceholder": "搜索 Agent、模型或供应商",
+ "searchPlaceholder": "搜索模型或供应商",
"noResults": "没有可用模型",
"unavailable": "当前不可用",
"budget": "折扣",
diff --git a/apps/desktop/src/renderer/i18n/locales/zh-TW/common.json b/apps/desktop/src/renderer/i18n/locales/zh-TW/common.json
index 3243a5ff4e..8d2e5f1f00 100644
--- a/apps/desktop/src/renderer/i18n/locales/zh-TW/common.json
+++ b/apps/desktop/src/renderer/i18n/locales/zh-TW/common.json
@@ -2543,8 +2543,10 @@
"ariaLabel": "選擇輸入框推薦指令模型",
"automatic": "自動選擇(維持目前規則)"
},
+ "chooseAgent": "選擇 Agent",
+ "backToAgents": "返回選擇 Agent",
"explicitRouteHint": "明確指定後只使用該 Agent 和模型;無法使用時不會自動切換。",
- "searchPlaceholder": "搜尋 Agent、模型或供應商",
+ "searchPlaceholder": "搜尋模型或供應商",
"noResults": "沒有可用模型",
"unavailable": "目前無法使用",
"budget": "折扣",