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): CCAgentSessionView handoff pill 与 context 环改用语义 token

Michael-Yu2978b821b4c25d10
diff --git a/apps/desktop/src/renderer/__tests__/ccAgentSessionViewThemeContract.test.ts b/apps/desktop/src/renderer/__tests__/ccAgentSessionViewThemeContract.test.ts
new file mode 100644
index 0000000000..4aeee4d8a1
--- /dev/null
+++ b/apps/desktop/src/renderer/__tests__/ccAgentSessionViewThemeContract.test.ts
@@ -0,0 +1,52 @@
+/**
+ * ccAgentSessionViewThemeContract.test.ts
+ * ---------------------------------------------------------------------------
+ * 源契约守卫(DESIGN.md §10 双模式交付门槛 / design-governance.md §6 Level 1):
+ * CCAgentSessionView 的 handoff pill 与 context 环不再裸写颜色——
+ * 1. handoff pill 文字走 text-muted-foreground;
+ * 2. context 环阈值走 error-flat / warning-fg 语义 token;
+ * 3. 消费的 token 槽位同时具备 light / dark 双模式值。
+ */
+
+import { readFileSync } from 'node:fs';
+import { resolve } from 'node:path';
+import { describe, expect, it } from 'vitest';
+
+import { colorRegistry } from '../themes/color-registry';
+// 触发整表 registerColor 注册(与 tokenRegistry.test.ts 同款做法)。
+import '../themes/colors';
+
+const viewSource = readFileSync(
+ resolve(__dirname, '..', 'features', 'cc-agent', 'CCAgentSessionView.tsx'),
+ 'utf8',
+).replace(/\r\n?/g, '\n');
+
+/** 动态拼 hex 字面量,避免测试源自身被 hardcoded-color-audit 命中。 */
+const hex = (digits: string) => '#' + digits;
+
+describe('CCAgentSessionView 主题契约(语义 token,双模式)', () => {
+ it('handoff pill 不再裸写灰字色,改走 text-muted-foreground', () => {
+ expect(viewSource).not.toContain('text-[' + hex('595959') + ']');
+ expect(viewSource).toContain('text-muted-foreground');
+ });
+
+ it('context 环阈值色不再裸写红/橙,改走 error-flat / warning-fg', () => {
+ expect(viewSource).not.toContain(hex('EF4444'));
+ expect(viewSource).not.toContain(hex('F59E0B'));
+ expect(viewSource).toContain("pct > 90 ? 'var(--error-flat)' :");
+ expect(viewSource).toContain("'var(--warning-fg)' : 'var(--msg-tool-card-chevron)'");
+ });
+
+ it('消费的 token 槽位同时具备 light / dark 双模式值', () => {
+ for (const id of ['muted-foreground', 'error-flat', 'warning-fg', 'msg-tool-card-chevron']) {
+ expect(
+ colorRegistry.resolveDefault(id, 'light'),
+ 'token "' + id + '" 缺 light 槽位',
+ ).not.toBeNull();
+ expect(
+ colorRegistry.resolveDefault(id, 'dark'),
+ 'token "' + id + '" 缺 dark 槽位',
+ ).not.toBeNull();
+ }
+ });
+});
diff --git a/apps/desktop/src/renderer/features/cc-agent/CCAgentSessionView.tsx b/apps/desktop/src/renderer/features/cc-agent/CCAgentSessionView.tsx
index f35980f5a7..ad8c1c09c0 100644
--- a/apps/desktop/src/renderer/features/cc-agent/CCAgentSessionView.tsx
+++ b/apps/desktop/src/renderer/features/cc-agent/CCAgentSessionView.tsx
@@ -5328,7 +5328,7 @@ function HandoffSourcePill({
<div
className={cn(
'flex h-10 w-full items-center rounded-[12px] border border-[var(--cmd-palette-border)] bg-[hsl(var(--content-area))]',
- 'text-13 leading-none text-[#595959]',
+ 'text-13 leading-none text-muted-foreground',
)}
>
<button
@@ -5350,7 +5350,7 @@ function HandoffSourcePill({
aria-label={t('ccAgent.handoff.pill.dismissAria')}
className={cn(
'mr-2 flex h-7 w-7 shrink-0 items-center justify-center rounded-[8px]',
- 'text-[#595959] transition-colors hover:bg-[var(--cmd-palette-bg)] hover:text-foreground',
+ 'text-muted-foreground transition-colors hover:bg-[var(--cmd-palette-bg)] hover:text-foreground',
'focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-foreground',
)}
>
@@ -5752,7 +5752,7 @@ function ContextCapacityRing({
const dashOffset = circumference - (circumference * pct) / 100;
// Color thresholds per spec
- const fillColor = pct > 90 ? '#EF4444' : pct > 70 ? '#F59E0B' : 'var(--msg-tool-card-chevron)';
+ const fillColor = pct > 90 ? 'var(--error-flat)' : pct > 70 ? 'var(--warning-fg)' : 'var(--msg-tool-card-chevron)';
const usedTokens = Math.min(contextTokens, contextWindow || Infinity);
const tooltipText =
diff --git a/docs/design-rules/design-decision-log.md b/docs/design-rules/design-decision-log.md
index 29b403dbdc..68aa2da1de 100644
--- a/docs/design-rules/design-decision-log.md
+++ b/docs/design-rules/design-decision-log.md
@@ -444,5 +444,8 @@
error-flat / warning-accent / destructive / surface-chip / surface-chip-alt),
双模式由 token 体系自动覆盖;新增源契约守卫 `makerExperimentalThemeContract.test.ts`
锁「零裸色 + token 已注册 + light/dark 双槽位」。
+ 合并范围(与 PR 3 同一「renderer 硬编码颜色清理」):CCAgentSessionView handoff pill
+ 两处裸灰文字色改 text-muted-foreground;context 环阈值红/橙改 error-flat /
+ warning-fg 语义 token,双模式由 token 体系覆盖。
- R2 §4.3 Project_List 五点差异(2026-07-17 lead 裁决本轮不做,出处为设计阶段工作文件 `2026-07-17-r2-ui-specs.md` §4.3,不入仓库):① Project_List 三态拆分(active-task-pill / project-card / flat-list-row 不共用 `sidebar-item-active`);② 项目 header / list card 选中应中性底(`#312F2F`/`#F6F6F6`,非 `#DF0C27` 大红);③ 去 Project_List 选中组 `focus-ring-soft` 蓝 ring,改 card stroke `#DCDFE3`/`#434343`;④ 小箭头 `#A61629` 强调(非整行红底);⑤ 本轮收敛不扩战线,后续另开。
- splash 渐变辉光层未实现(2026-07-18 backlog,待用户表态)。