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。

feat(desktop): 插件召唤卡改为气泡内标注行,法阵动画补终态编舞 (#917)

Chris Zhang4204e8db8b38
diff --git a/apps/desktop/src/renderer/__tests__/ghostSummonChip.test.tsx b/apps/desktop/src/renderer/__tests__/ghostSummonChip.test.tsx
new file mode 100644
index 0000000000..65fbf8cdac
--- /dev/null
+++ b/apps/desktop/src/renderer/__tests__/ghostSummonChip.test.tsx
@@ -0,0 +1,201 @@
+// @vitest-environment jsdom
+
+/**
+ * GhostSummonCard chip 形态(2026-07-29 改版)回归:
+ * - 标注行渲染意识名 + 状态文字;不再渲「调用插件 · GHOST」overline,
+ * 也不再吞用户 prompt(合并形态已取消,正文由 UserMessage 气泡承载)。
+ * - 状态文字对齐兑现事实:running「调用中…」;turn 结束后按
+ * GhostFulfillmentContext 区分「已调用/已完成」,不替 AI 撒谎。
+ * - 法阵终态编舞:running→false 时缺口收拢(dasharray → 100 0)+ ✓ 弹出;
+ * 历史消息(挂载即非 running)直接静态落终态帧,不播编舞。
+ * - 展开抽屉保留透明性:$指令 徽章 + 指令原文双色分段。
+ * - 未兑现软提示保持低调胶囊形态不变。
+ */
+
+import { act, cleanup, fireEvent, render, screen } from '@testing-library/react';
+import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
+
+import '@/i18n';
+import i18n from '@/i18n';
+import { GhostFulfillmentContext, GhostSummonCard } from '@/components/chat/GhostSummonCard';
+import type { GhostDirectiveDisplay } from '@/cindy-brain/ghostCommand';
+
+vi.mock('@/cindy-brain/useInstalledGhosts', () => ({
+ useInstalledGhosts: () => [],
+}));
+
+const commandDirective: GhostDirectiveDisplay = {
+ kind: 'command',
+ command: 'xd-feishu',
+ name: 'XD Feishu',
+ ghostId: 'xd-feishu',
+ raw: '[插件指令] 用户显式点名插件 XD Feishu(id: xd-feishu)',
+};
+
+const mentionDirective: GhostDirectiveDisplay = {
+ kind: 'mention',
+ ghosts: [{ name: 'XD Feishu', ghostId: 'xd-feishu' }],
+ raw: '[插件提示] 消息提及了插件 XD Feishu(id: xd-feishu)',
+};
+
+/** 模拟 prefers-reduced-motion 匹配结果(jsdom 默认无 matchMedia)。 */
+function stubMatchMedia(matches: boolean) {
+ window.matchMedia = ((query: string) => ({
+ matches,
+ media: query,
+ onchange: null,
+ addListener: () => {},
+ removeListener: () => {},
+ addEventListener: () => {},
+ removeEventListener: () => {},
+ dispatchEvent: () => false,
+ })) as typeof window.matchMedia;
+}
+
+function fulfillmentOf(clientId: string, ghostIds: string[]) {
+ return new Map<string, ReadonlySet<string>>([[clientId, new Set(ghostIds)]]);
+}
+
+beforeEach(async () => {
+ await i18n.changeLanguage('zh-CN');
+});
+
+afterEach(() => {
+ cleanup();
+ vi.useRealTimers();
+ // biome-ignore lint/performance/noDelete: 还原 jsdom 默认(无 matchMedia)。
+ delete (window as { matchMedia?: unknown }).matchMedia;
+});
+
+describe('GhostSummonCard(chip 形态)', () => {
+ it('renders the seal chip with plugin name and no overline/prompt slot', () => {
+ render(<GhostSummonCard directive={commandDirective} running />);
+ expect(screen.getByText('XD Feishu')).toBeTruthy();
+ expect(screen.getByText('调用中…')).toBeTruthy();
+ expect(screen.queryByText(/GHOST/)).toBeNull();
+ });
+
+ it('reports 已调用 only when the turn actually issued a ghost_call', () => {
+ const { unmount } = render(
+ <GhostFulfillmentContext.Provider value={fulfillmentOf('m1', ['xd-feishu'])}>
+ <GhostSummonCard directive={commandDirective} messageClientId="m1" />
+ </GhostFulfillmentContext.Provider>,
+ );
+ expect(screen.getByText('已调用')).toBeTruthy();
+ unmount();
+
+ render(<GhostSummonCard directive={commandDirective} messageClientId="m2" />);
+ expect(screen.getByText('已完成')).toBeTruthy();
+ });
+
+ it('mounts historic messages directly on the closed static frame', () => {
+ const { container } = render(
+ <GhostFulfillmentContext.Provider value={fulfillmentOf('m1', ['xd-feishu'])}>
+ <GhostSummonCard directive={commandDirective} messageClientId="m1" />
+ </GhostFulfillmentContext.Provider>,
+ );
+ const arcs = container.querySelectorAll('circle.summon-seal-arc');
+ expect(arcs.length).toBe(2);
+ for (const arc of arcs) {
+ expect(arc.getAttribute('stroke-dasharray')).toBe('100 0');
+ }
+ // 静态终态:✓ 直显(fulfilled)但不挂弹出动画(历史消息零动画)。
+ expect(container.querySelector('svg.lucide-check')).toBeTruthy();
+ expect(container.querySelector('.summon-seal-tick-pop')).toBeNull();
+ });
+
+ it('closes neutrally without tick or halo when the plugin was never actually called', () => {
+ vi.useFakeTimers();
+ const { container, rerender } = render(
+ <GhostSummonCard directive={commandDirective} messageClientId="m2" running />,
+ );
+ rerender(<GhostSummonCard directive={commandDirective} messageClientId="m2" running={false} />);
+ act(() => {
+ vi.advanceTimersByTime(1500);
+ });
+ // 环中性闭合 = turn 结束;不放 ✓/光晕伪造成功,状态文字为「已完成」。
+ for (const arc of container.querySelectorAll('circle.summon-seal-arc')) {
+ expect(arc.getAttribute('stroke-dasharray')).toBe('100 0');
+ }
+ expect(container.querySelector('svg.lucide-check')).toBeNull();
+ expect(container.querySelector('.summon-seal-halo')).toBeNull();
+ expect(screen.getByText('已完成')).toBeTruthy();
+ });
+
+ it('plays the closing choreography when running flips false', () => {
+ vi.useFakeTimers();
+ const { container, rerender } = render(
+ <GhostFulfillmentContext.Provider value={fulfillmentOf('m1', ['xd-feishu'])}>
+ <GhostSummonCard directive={commandDirective} messageClientId="m1" running />
+ </GhostFulfillmentContext.Provider>,
+ );
+ let arcs = container.querySelectorAll('circle.summon-seal-arc');
+ expect(arcs[0]?.getAttribute('stroke-dasharray')).toBe('83 17');
+ expect(arcs[1]?.getAttribute('stroke-dasharray')).toBe('39 61');
+
+ rerender(
+ <GhostFulfillmentContext.Provider value={fulfillmentOf('m1', ['xd-feishu'])}>
+ <GhostSummonCard directive={commandDirective} messageClientId="m1" running={false} />
+ </GhostFulfillmentContext.Provider>,
+ );
+ // closing:缺口已收拢,旋转仍挂着(满圆前不摘)。
+ arcs = container.querySelectorAll('circle.summon-seal-arc');
+ for (const arc of arcs) {
+ expect(arc.getAttribute('stroke-dasharray')).toBe('100 0');
+ }
+ expect(container.querySelector('.animate-\\[spin_2\\.4s_linear_infinite\\]')).toBeTruthy();
+
+ // settling:光晕 + ✓ 弹出,旋转已摘除。
+ act(() => {
+ vi.advanceTimersByTime(600);
+ });
+ expect(container.querySelector('.summon-seal-halo')).toBeTruthy();
+ expect(container.querySelector('.summon-seal-tick-pop')).toBeTruthy();
+ expect(container.querySelector('.animate-\\[spin_2\\.4s_linear_infinite\\]')).toBeNull();
+
+ // done:光晕一次性卸载,✓ 常驻。
+ act(() => {
+ vi.advanceTimersByTime(900);
+ });
+ expect(container.querySelector('.summon-seal-halo')).toBeNull();
+ expect(container.querySelector('.summon-seal-tick-pop')).toBeTruthy();
+ });
+
+ it('skips the choreography under prefers-reduced-motion and lands on the terminal frame', () => {
+ stubMatchMedia(true);
+ vi.useFakeTimers();
+ const { container, rerender } = render(
+ <GhostFulfillmentContext.Provider value={fulfillmentOf('m1', ['xd-feishu'])}>
+ <GhostSummonCard directive={commandDirective} messageClientId="m1" running />
+ </GhostFulfillmentContext.Provider>,
+ );
+ rerender(
+ <GhostFulfillmentContext.Provider value={fulfillmentOf('m1', ['xd-feishu'])}>
+ <GhostSummonCard directive={commandDirective} messageClientId="m1" running={false} />
+ </GhostFulfillmentContext.Provider>,
+ );
+ // 不走 closing/settling 计时:立即闭合 + ✓ 直显 + 无旋转、无光晕。
+ const arcs = container.querySelectorAll('circle.summon-seal-arc');
+ for (const arc of arcs) {
+ expect(arc.getAttribute('stroke-dasharray')).toBe('100 0');
+ }
+ expect(container.querySelector('.animate-\\[spin_2\\.4s_linear_infinite\\]')).toBeNull();
+ expect(container.querySelector('.summon-seal-halo')).toBeNull();
+ expect(container.querySelector('svg.lucide-check')).toBeTruthy();
+ });
+
+ it('keeps transparency: expanding reveals the $command badge and directive text', () => {
+ render(<GhostSummonCard directive={commandDirective} messageClientId="m1" />);
+ fireEvent.click(screen.getByRole('button', { expanded: false }));
+ // $指令 徽章 + 指令原文里的注入值,至少各出现一次。
+ expect(screen.getAllByText('$xd-feishu').length).toBeGreaterThanOrEqual(1);
+ expect(screen.getByText('追加给模型的指令')).toBeTruthy();
+ });
+
+ it('keeps the low-key pill for unfulfilled mentions', () => {
+ render(<GhostSummonCard directive={mentionDirective} messageClientId="m1" />);
+ expect(screen.getByText(/提及插件/)).toBeTruthy();
+ // 胶囊形态没有法阵。
+ expect(document.querySelector('circle.summon-seal-arc')).toBeNull();
+ });
+});
diff --git a/apps/desktop/src/renderer/__tests__/sentPastedTextPreview.test.ts b/apps/desktop/src/renderer/__tests__/sentPastedTextPreview.test.ts
index bf33d47f66..a3a71c0a3e 100644
--- a/apps/desktop/src/renderer/__tests__/sentPastedTextPreview.test.ts
+++ b/apps/desktop/src/renderer/__tests__/sentPastedTextPreview.test.ts
@@ -141,21 +141,22 @@ describe('UserMessage pasted-text chip wiring', () => {
expect(chipBlock).toContain('onPastedTextChipClick');
expect(chipBlock).toContain('onClick:');
expect(chipBlock).toContain('event.currentTarget');
- // 三个 renderContent 调用点(引用交错分段 / 普通正文 / 召唤卡 prompt)都要传,
- // 少传一处那条路径上的粘贴段就又变回不可点。
- expect(source.match(/handlePastedTextChipClick,/g)?.length).toBe(3);
+ // 两个 renderContent 调用点(引用交错分段 / 普通正文)都要传,少传一处
+ // 那条路径上的粘贴段就又变回不可点。召唤卡 prompt 插槽已随「卡片即消息」
+ // 合并形态一并取消(chip 标注行改版):$指令 正文回归气泡,由普通正文
+ // 调用点统一渲染,不再有第三个调用点。
+ expect(source.match(/handlePastedTextChipClick,/g)?.length).toBe(2);
});
- it('S1b 三个调用点都拿到同一份 sessionReferences(不再有 undefined 占位)', () => {
- // 召唤卡 prompt 曾经漏传 sessionReferences(实参列表止于 slashCommandRanges),
- // prompt 里的会话深链 chip 因此少了 referenceMetadata 的 tooltip 明细行,与气泡
- // 正文渲染不一致(PR #966 review)。sessionReferences 按 sessionId /
- // messageClientId 匹配、不依赖文本偏移,三处理应拿同一份。
- // 三个调用点的末两个实参恒为 `sessionReferences, handlePastedTextChipClick`,
+ it('S1b 两个调用点都拿到同一份 sessionReferences(不再有 undefined 占位)', () => {
+ // 召唤卡 prompt 曾经漏传 sessionReferences(PR #966 review);该插槽现已
+ // 随合并形态取消,$指令 正文并入普通正文调用点。sessionReferences 按
+ // sessionId / messageClientId 匹配、不依赖文本偏移,两处理应拿同一份。
+ // 调用点的末两个实参恒为 `sessionReferences, handlePastedTextChipClick`,
// 一并锁住"都可点"与"都有引用元数据"。
expect(
source.match(/sessionReferences,\s*\n\s*handlePastedTextChipClick,/g)?.length,
- ).toBe(3);
+ ).toBe(2);
});
it('S2 ToolPayloadLightbox 以只读 text 模式挂载', () => {
diff --git a/apps/desktop/src/renderer/components/chat/GhostSummonCard.tsx b/apps/desktop/src/renderer/components/chat/GhostSummonCard.tsx
index dab920faf0..138e771047 100644
--- a/apps/desktop/src/renderer/components/chat/GhostSummonCard.tsx
+++ b/apps/desktop/src/renderer/components/chat/GhostSummonCard.tsx
@@ -1,44 +1,39 @@
/**
- * GhostSummonCard — 消息流「意识召唤卡片」。
+ * GhostSummonCard — 用户气泡内的「插件召唤标注行」(chip 形态)。
*
- * 用户消息尾部由 expandGhostCommand 追加的机器指令(splitGhostDirective 拆出)
- * 不再以裸文本刷在气泡里,而是收进这张卡:
+ * 2026-07-29 改版:此前 $指令 / 软提示兑现 / 语义召唤走「卡片即消息」合并
+ * 形态(整条正文收进一张独立大卡),卡头压过一句话正文、插件调用看起来像
+ * 一条系统卡片而非用户发言。现改为:正文回归普通文字气泡,召唤信息缩为
+ * 气泡顶部一行 26px 标注(法阵 + 意识名 + 状态文字 + 展开 caret),由
+ * UserMessage 嵌入气泡内部渲染。三种来源同形态:
*
- * - **硬指令($指令 显式点名)**:随主题的"召唤印记"卡(--surface-elevated
- * + --border-default,light/dark 各归其位,不做反色)。$指令 消息不再另渲
- * 文字气泡——用户 prompt 由 UserMessage 经 prompt 插槽收进卡身(合并形态,
- * 卡片即消息)。左侧幽灵印记环——意识声明了 icon 时印记环内嵌其头像
- * (iconDataUrl,来自 useInstalledGhosts 实时清单),未声明或已卸下时回退
- * 通用幽灵图标;中间 overline + 意识名($指令 等宽徽章仅展开态显示,
- * 收起态信息降噪),点卡片展开查看追加给模型的原始指令——展开区按
- * 来源双色渲染(commandDirectiveSegments 单一事实源):系统模板文字降透明
- * 度,意识身份卡注入的值(指令词/名称/id)全亮,用户一眼可辨
- * "哪些字是系统说的、哪些是这段意识填的"(第三方意识的信任边界视图)。
- * 展开区排版对标 ToolCallCard(区块标签 text-xs font-medium、等宽正文
- * 跟随 --app-code-font-size − 1px),与工具调用卡视觉同规格。
- * - **软提示(语言提及,2026-07-14 起发送期已停止生成,本形态仅服务历史
- * 消息)**:低调描边胶囊,点开同样可查提示原文(非反色,
- * 普通描边容器)。一旦被真实 ghost_call 兑现(GhostFulfillmentContext),
- * 升级为与硬指令**完全同形态**的大卡(overline + 名字 + 展开区,用户
- * prompt 由 UserMessage 收进卡身)——语义调用与 $ 显式召唤最终渲染一致,
- * 区别只在展开区内容(软提示原文 vs 硬指令原文)。
- * - **语义自主召唤(semantic,无追加段)**:消息一个触发词都没命中、没有
- * 任何机器追加段,但 AI 本轮仍通过 ghost_call 召唤了意识——UserMessage
- * 据兑现关联合成 semantic 展示数据,渲染同一张大卡(意识名/头像/指令词
- * 从已装清单实时解析;已卸下回退 ghostId)。展开区如实说明"AI 自主判断
- * 召唤、消息未追加指令"(透明性:没追加就说没追加,不伪造原文)。
+ * - **硬指令($指令 显式点名)**:气泡正文 = 剥掉 $token 的余文,标注行
+ * 报意识名;展开区按来源双色渲染追加给模型的指令原文
+ * (commandDirectiveSegments 单一事实源):系统模板文字降透明度,意识
+ * 身份卡注入的值(指令词/名称/id)全亮,用户一眼可辨"哪些字是系统说
+ * 的、哪些是这段意识填的"(第三方意识的信任边界视图)。
+ * - **软提示(语言提及,2026-07-14 起发送期已停止生成,仅服务历史消息)**:
+ * 未兑现保持低调描边胶囊(由 UserMessage 放在气泡下方);一旦被真实
+ * ghost_call 兑现(GhostFulfillmentContext),升级为与硬指令完全同形态
+ * 的标注行,区别只在展开区内容(软提示原文 vs 硬指令原文)。
+ * - **语义自主召唤(semantic,无追加段)**:消息一个触发词都没命中,AI
+ * 本轮仍通过 ghost_call 召唤了意识——UserMessage 据兑现关联合成
+ * semantic 展示数据,渲染同一行标注。展开区如实说明"AI 自主判断召唤、
+ * 消息未追加指令"(透明性:没追加就说没追加,不伪造原文)。
*
- * 透明性承诺不变:追加文本对用户可见、不做暗改——只是从"刷屏"变"可查"。
- * 动画遵守规则 7:历史卡片纯静态;仅当本条消息触发的 turn 仍在执行
- * (running,由 UserMessage 以 sessionRunning && isLastUserMessage 判定)时,
- * 印记环挂慢速旋转作 loading——动画写在 HTML span wrapper 的 transform 上
- * (compositor-only,不挂 SVG),turn 结束即卸载,motion-reduce 下不转;
- * 非 running 时保留 hover 一次性 transform 旋转过渡(瞬态)。
+ * 状态文字对齐兑现事实(不撒谎):turn 进行中「调用中…」;结束后本条
+ * turn 真发生过 ghost_call 的报「已调用」,没发生的只报「已完成」。
+ *
+ * 透明性承诺不变:追加文本对用户可见、不做暗改;$指令 徽章 / 版本号 /
+ * 指令原文双色图例全部保留,收进点击展开的抽屉。
+ *
+ * 召唤法阵(SummonSeal)双弧几何与 2.4s 旋转动画与旧版一致(用户明确
+ * 要求保留),新增终态编舞——见 SummonSeal 头注与 DESIGN.md §14.4 登记。
*/
-import { createContext, useContext, useState, type ReactNode } from 'react';
+import { createContext, useContext, useEffect, useRef, useState } from 'react';
import { useTranslation } from 'react-i18next';
-import { ChevronDown, ChevronUp, Ghost } from 'lucide-react';
+import { Check, ChevronDown, Ghost } from 'lucide-react';
import { cn } from '@/lib/utils';
import { Collapse } from '@/components/ui/collapse';
import {
@@ -52,14 +47,15 @@ import { useInstalledGhosts } from '@/cindy-brain/useInstalledGhosts';
/**
* 「提及 → 兑现」关联(方案 2):Map<userMessageClientId, Set<被召唤 ghostId>>。
* MessageStream 从会话历史现算并 Provider 下发;软提示卡据此把"被兑现"的
- * 意识从徽章升级成召唤卡。渲染期推导、不落状态,重启幂等。
+ * 意识从徽章升级成召唤标注,状态文字据此区分「已调用/已完成」。
+ * 渲染期推导、不落状态,重启幂等。
*/
export const GhostFulfillmentContext = createContext<ReadonlyMap<string, ReadonlySet<string>>>(
new Map(),
);
/**
- * 召唤卡展示数据:发送期追加段解析出的 command / mention 之外,再加一种
+ * 召唤标注展示数据:发送期追加段解析出的 command / mention 之外,再加一种
* semantic——消息没有任何追加段、AI 纯靠语义自主召唤(只有 ghostId 清单,
* 来自兑现关联),由 UserMessage 合成。定义在本组件而非 ghostCommand.ts:
* 它不是"追加文本的解析结果",只是渲染层的展示形态。
@@ -68,7 +64,7 @@ export type GhostSummonDisplay =
| GhostDirectiveDisplay
| { kind: 'semantic'; ghostIds: string[] };
-/** 展开区正文:按来源双色渲染分段(injected = 意识注入值,高亮 + 下划线)。 */
+/** 展开区正文:按来源双色渲染分段(injected = 意识注入值,高亮)。 */
function DirectiveSegments({
segments,
systemClassName,
@@ -90,67 +86,156 @@ function DirectiveSegments({
);
}
+/** 法阵终态编舞:缺口收拢时长(旋转中;DESIGN.md §14.4 登记的一次性瞬态)。 */
+const SEAL_CLOSE_MS = 600;
+/** 法阵终态编舞:光晕荡开 + ✓ 弹出时长,结束后摘除旋转(满圆旋转不可见,零跳变)。 */
+const SEAL_SETTLE_MS = 900;
+
+type SealPhase = 'running' | 'closing' | 'settling' | 'done';
+
+/**
+ * motion-reduce 下终态编舞整段跳过(不只是 CSS 层禁动画):JS 状态机也不走
+ * closing/settling 计时,直接落 done 帧——否则 ✓ 要等 600ms 计时器才出现,
+ * 与「直接落终态帧」的承诺不符(review 反馈)。jsdom 等无 matchMedia 环境
+ * 视为不减动效。
+ */
+const prefersReducedMotion = (): boolean =>
+ typeof window.matchMedia === 'function' &&
+ window.matchMedia('(prefers-reduced-motion: reduce)').matches;
+
/**
* 幽灵印记(召唤法阵):两道反向圆弧环,环心是意识头像(声明了 icon 时),
* 否则回退通用幽灵图标;圆弧走 currentColor 随主题文本色。
- * running 时圆弧环持续旋转作执行中 loading(动画挂 HTML wrapper 而非 SVG,
- * 规则 7 compositor-only;仅 running 时挂载,motion-reduce 退化为静止)。
+ *
+ * 双弧几何(外弧 83/17 · 内弧 39/61)与 running 旋转(2.4s 匀速,挂 HTML
+ * wrapper 而非 SVG,规则 7 compositor-only)保持旧版原样。终态编舞
+ * (2026-07-29,DESIGN.md §14.4 登记)解决"完成后缺口留在原地像卡死":
+ *
+ * running(旋转) → closing(仍在旋转中,两道弧缺口收拢至满圆,600ms
+ * 一次性 stroke-dasharray 过渡,globals.css .summon-seal-arc) →
+ * settling(fulfilled 时光晕从法阵荡开一圈 + ✓ 在头像角弹出;满圆旋转
+ * 不可见,此刻摘除旋转动画零跳变) → done(静态)。
+ *
+ * 语义自洽:缺口 = 进行中,满圆 = turn 结束。✓ 与光晕只在 fulfilled(本轮
+ * 真发生过 ghost_call)时出现——$指令 被取消 / AI 最终没调插件的,环中性
+ * 闭合、不放成功徽标,与状态文字「已完成」一致(不伪造成功,review 反馈)。
+ * 历史消息挂载时已非 running,直接渲 done 静态帧、零动画(规则 7);
+ * motion-reduce 下旋转/过渡/光晕全部禁用(globals.css 白名单)且 JS 状态机
+ * 直落终态帧。
*/
-function SummonSeal({ iconDataUrl, running }: { iconDataUrl: string | null; running?: boolean }) {
+function SummonSeal({
+ iconDataUrl,
+ running,
+ fulfilled,
+}: {
+ iconDataUrl: string | null;
+ running?: boolean;
+ /** 本轮是否真调过该插件:成功徽标(✓/光晕)的唯一开关,中性终态只闭环。 */
+ fulfilled?: boolean;
+}) {
+ const [phase, setPhase] = useState<SealPhase>(running ? 'running' : 'done');
+ // 本次挂载期间是否亲历过 running:只有亲历者播终态编舞,历史消息静态落帧。
+ const livedRunningRef = useRef(Boolean(running));
+ useEffect(() => {
+ if (running) {
+ livedRunningRef.current = true;
+ setPhase('running');
+ return;
+ }
+ if (!livedRunningRef.current) return undefined;
+ if (prefersReducedMotion()) {
+ setPhase('done');
+ return undefined;
+ }
+ setPhase('closing');
+ const settleTimer = window.setTimeout(() => setPhase('settling'), SEAL_CLOSE_MS);
+ const doneTimer = window.setTimeout(() => setPhase('done'), SEAL_CLOSE_MS + SEAL_SETTLE_MS);
+ return () => {
+ window.clearTimeout(settleTimer);
+ window.clearTimeout(doneTimer);
+ };
+ }, [running]);
+
+ const spinning = phase === 'running' || phase === 'closing';
+ const closed = phase !== 'running';
+ const showTick = Boolean(fulfilled) && (phase === 'settling' || phase === 'done');
+
return (
- <span className="relative flex h-10 w-10 shrink-0 items-center justify-center">
+ <span className="relative flex h-[26px] w-[26px] shrink-0 items-center justify-center">
<span
aria-hidden="true"
className={cn(
'absolute inset-0',
- running && 'animate-[spin_2.4s_linear_infinite] motion-reduce:animate-none',
+ spinning && 'animate-[spin_2.4s_linear_infinite] motion-reduce:animate-none',
)}
>
- <svg
- viewBox="0 0 40 40"
- aria-hidden="true"
- className={cn(
- 'h-full w-full transition-transform duration-500 ease-out',
- !running && 'group-hover:rotate-90',
- )}
- >
+ <svg viewBox="0 0 40 40" aria-hidden="true" className="h-full w-full">
<circle
+ className="summon-seal-arc"
cx="20"
cy="20"
r="19"
fill="none"
stroke="currentColor"
strokeWidth="1.5"
- opacity="0.45"
+ opacity={closed ? 0.55 : 0.45}
pathLength="100"
- strokeDasharray="83 17"
+ strokeDasharray={closed ? '100 0' : '83 17'}
strokeLinecap="round"
transform="rotate(120 20 20)"
/>
<circle
+ className="summon-seal-arc"
cx="20"
cy="20"
r="15"
fill="none"
stroke="currentColor"
strokeWidth="1"
- opacity="0.22"
+ opacity={closed ? 0.28 : 0.22}
pathLength="100"
- strokeDasharray="39 61"
+ strokeDasharray={closed ? '100 0' : '39 61'}
strokeLinecap="round"
transform="rotate(-40 20 20)"
/>
</svg>
</span>
+ {fulfilled && phase === 'settling' && (
+ <span
+ aria-hidden="true"
+ className="summon-seal-halo pointer-events-none absolute inset-0 rounded-full border"
+ style={{ borderColor: 'var(--card-status-done)' }}
+ />
+ )}
{iconDataUrl ? (
<img
src={iconDataUrl}
alt=""
draggable={false}
- className="h-[26px] w-[26px] rounded-full object-cover"
+ className="h-4 w-4 rounded-full object-cover"
/>
) : (
- <Ghost size={18} strokeWidth={1.75} aria-hidden="true" />
+ <Ghost size={12} strokeWidth={1.75} aria-hidden="true" />
+ )}
+ {showTick && (
+ <span
+ aria-hidden="true"
+ className={cn(
+ 'absolute -bottom-px -right-px flex h-[11px] w-[11px] items-center justify-center rounded-full',
+ 'border border-[var(--msg-user-bg)]',
+ // 弹出动画只给亲历编舞的挂载;历史静态直显(both 保持终帧,
+ // motion-reduce 下动画禁用、自然落在 scale(1))。
+ livedRunningRef.current && 'summon-seal-tick-pop',
+ )}
+ style={{ backgroundColor: 'var(--card-status-done)' }}
+ >
+ <Check
+ size={7}
+ strokeWidth={3}
+ className="text-[var(--completion-badge-fg)]"
+ aria-hidden="true"
+ />
+ </span>
)}
</span>
);
@@ -159,17 +244,16 @@ function SummonSeal({ iconDataUrl, running }: { iconDataUrl: string | null; runn
export function GhostSummonCard({
directive,
running,
- prompt,
messageClientId,
+ className,
}: {
directive: GhostSummonDisplay;
- /** 本条消息触发的 turn 是否仍在执行(印记环 loading 旋转的唯一开关)。 */
+ /** 本条消息触发的 turn 是否仍在执行(法阵旋转与「调用中…」的唯一开关)。 */
running?: boolean;
- /** 用户给意识的输入(硬指令已剥 $指令 token;软提示兑现态是整条正文;
- * 由 UserMessage 富渲染后传入);仅合并形态使用,空输入不传。 */
- prompt?: ReactNode;
- /** 本条用户消息的 clientId(查"提及 → 兑现"关联;软提示升级用)。 */
+ /** 本条用户消息的 clientId(查"提及 → 兑现"关联;状态文字与软提示升级用)。 */
messageClientId?: string;
+ /** 外层附加样式:UserMessage 在气泡内嵌时用它加分隔线与间距。 */
+ className?: string;
}) {
const { t } = useTranslation();
const [expanded, setExpanded] = useState(false);
@@ -178,7 +262,7 @@ export function GhostSummonCard({
const installedGhosts = useInstalledGhosts();
const iconByGhostId = (ghostId: string): string | null =>
installedGhosts.find((g) => g.manifest.id === ghostId)?.iconDataUrl ?? null;
- // 「提及 → 兑现」:本条消息触发的那一轮,AI 真召唤了哪些被提及的意识。
+ // 「提及 → 兑现」:本条消息触发的那一轮,AI 真召唤了哪些意识。
const fulfillment = useContext(GhostFulfillmentContext);
const fulfilledIds = messageClientId ? fulfillment.get(messageClientId) : undefined;
// 软提示的兑现子集(方案 2):AI 真调了才算,只提及没调的不升级(不撒谎)。
@@ -243,11 +327,11 @@ export function GhostSummonCard({
);
}
- // ── 大卡形态:硬指令 / 软提示被兑现 / 语义自主召唤(三者完全同形态)────
+ // ── 标注行形态:硬指令 / 软提示被兑现 / 语义自主召唤(三者完全同形态)──
const isCommand = directive.kind === 'command';
- // 卡片承载的意识:硬指令固定一个;兑现态取被真实召唤的子集;semantic 只有
- // ghostId,名字/指令词从已装清单实时解析(已卸下回退显示 ghostId)。
- // 多意识时名字并列、印记环取第一个。
+ // 标注承载的意识:硬指令固定一个;兑现态取被真实召唤的子集;semantic 只有
+ // ghostId,名字/指令词从已装清单实时解析(已卸下回退 ghostId)。
+ // 多意识时名字并列、法阵取第一个。
const cardGhosts: Array<{ name: string; ghostId: string; command?: string }> = isCommand
? [{ name: directive.name, ghostId: directive.ghostId, command: directive.command }]
: directive.kind === 'mention'
@@ -260,7 +344,7 @@ export function GhostSummonCard({
...(g?.manifest.command ? { command: g.manifest.command } : {}),
};
});
- // 兜底:空清单不渲卡(semantic 由 UserMessage 保证非空,此处防御性短路)。
+ // 兜底:空清单不渲(semantic 由 UserMessage 保证非空,此处防御性短路)。
if (cardGhosts.length === 0) return null;
// 命中已装意识时取实时安装态(头像/版本号);已卸下则都不显示,
// 与消息文本里固化的 id/名字解耦(不缓存失效数据)。
@@ -282,19 +366,18 @@ export function GhostSummonCard({
: directive.kind === 'mention'
? mentionDirectiveSegments(directive.ghosts)
: null;
+ // 状态文字对齐兑现事实:mention 兑现态/semantic 由构造保证真调过;硬指令
+ // 查兑现关联,AI 最终没调的只说「已完成」,不替 AI 撒谎。
+ const anyFulfilled =
+ !isCommand || cardGhosts.some((g) => Boolean(fulfilledIds?.has(g.ghostId)));
+ const statusText = running
+ ? t('chat.ghostSummon.status.running')
+ : anyFulfilled
+ ? t('chat.ghostSummon.status.called')
+ : t('chat.ghostSummon.status.done');
return (
- <div
- className={cn(
- 'max-w-full overflow-hidden rounded-[12px] border',
- expanded ? 'w-[400px]' : 'w-fit',
- )}
- style={{
- backgroundColor: 'var(--surface-elevated)',
- borderColor: 'var(--border-default)',
- color: 'var(--text-primary)',
- }}
- >
+ <div className={cn('max-w-full', className)}>
<button
type="button"
aria-expanded={expanded}
@@ -309,71 +392,56 @@ export function GhostSummonCard({
)}
onClick={() => setExpanded((v) => !v)}
className={cn(
- 'group flex w-full cursor-pointer items-center gap-3 py-2.5 pl-2.5 pr-3.5 text-left',
- 'focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset',
+ 'group flex max-w-full cursor-pointer select-none items-center gap-2 text-left',
+ 'focus-visible:rounded-lg focus-visible:outline-none focus-visible:ring-2',
'focus-visible:ring-[var(--focus-ring-soft)]',
)}
>
- <SummonSeal iconDataUrl={installedGhost?.iconDataUrl ?? null} running={running} />
- <span className="flex min-w-0 flex-1 flex-col gap-2">
- <span
- className="text-[10px] leading-none tracking-[0.1em]"
- style={{ color: 'var(--text-tertiary)' }}
- >
- {t('chat.ghostSummon.overline')}
- </span>
- <span className="flex items-center gap-2">
- <span className="truncate text-[14px] font-medium leading-none">{cardNames}</span>
- {/* $指令 徽章 + 版本号仅展开态显示:收起态卡头降噪(指令词在
- 展开区原文里也查得到,收起时不重复报幕);版本号来自实时
- 安装态,意识已卸下时不显示。 */}
- {/* 行内徽章不套 Collapse:父级是 span 行内流,块级 grid 容器会
- 非法嵌套且把徽章挤成换行;行内显隐保持瞬时条件渲染。 */}
- {expanded && (
- <>
- {badgeCommand && (
- <span
- className="shrink-0 rounded-full px-2 py-[2px] font-mono text-[11px] leading-none"
- style={{ backgroundColor: 'var(--surface-chip)', color: 'var(--text-secondary)' }}
- >
- ${badgeCommand}
- </span>
- )}
- {versionLabel && (
- <span
- className="shrink-0 font-mono text-[11px] leading-none"
- style={{ color: 'var(--text-tertiary)' }}
- >
- {versionLabel}
- </span>
- )}
- </>
- )}
- </span>
+ <SummonSeal
+ iconDataUrl={installedGhost?.iconDataUrl ?? null}
+ running={running}
+ fulfilled={anyFulfilled}
+ />
+ <span
+ className="min-w-0 truncate text-xs font-medium transition-colors group-hover:text-[var(--text-primary)]"
+ style={{ color: 'var(--text-secondary)' }}
+ >
+ {cardNames}
</span>
- {expanded ? (
- <ChevronUp size={16} className="shrink-0 opacity-60" aria-hidden="true" />
- ) : (
- <ChevronDown size={16} className="shrink-0 opacity-60" aria-hidden="true" />
- )}
+ <span className="shrink-0 text-xs" style={{ color: 'var(--text-tertiary)' }}>
+ {statusText}
+ </span>
+ <ChevronDown
+ size={13}
+ aria-hidden="true"
+ className={cn('shrink-0 opacity-60 transition-transform', expanded && 'rotate-180')}
+ />
</button>
- {/* 卡身:用户给意识的输入(合并形态下即原文字气泡的内容),排版与
- 消息气泡同规格;常显、不随展开态变化。 */}
- {prompt != null && (
- <div
- className={cn(
- 'select-text whitespace-pre-wrap [overflow-wrap:anywhere]',
- 'px-3.5 pb-3 text-15 font-normal leading-[1.6]',
- )}
- >
- {prompt}
- </div>
- )}
<Collapse open={expanded}>
<div
- className="px-3.5 pb-3 pt-2.5"
- style={{ borderTop: '1px solid var(--border-default)' }}
+ className="mt-2 rounded-[12px] border px-3 py-2.5"
+ style={{ borderColor: 'var(--border-default)' }}
>
+ {(badgeCommand || versionLabel) && (
+ <div className="mb-2 flex items-center gap-2">
+ {badgeCommand && (
+ <span
+ className="shrink-0 rounded-full px-2 py-[2px] font-mono text-[11px] leading-none"
+ style={{ backgroundColor: 'var(--surface-chip)', color: 'var(--text-secondary)' }}
+ >
+ ${badgeCommand}
+ </span>
+ )}
+ {versionLabel && (
+ <span
+ className="shrink-0 font-mono text-[11px] leading-none"
+ style={{ color: 'var(--text-tertiary)' }}
+ >
+ {versionLabel}
+ </span>
+ )}
+ </div>
+ )}
{segments ? (
<>
<div
diff --git a/apps/desktop/src/renderer/components/chat/UserMessage.tsx b/apps/desktop/src/renderer/components/chat/UserMessage.tsx
index 4326d73715..c2a191d1cb 100644
--- a/apps/desktop/src/renderer/components/chat/UserMessage.tsx
+++ b/apps/desktop/src/renderer/components/chat/UserMessage.tsx
@@ -826,16 +826,16 @@ export function UserMessage({
() => (quotesEncoded ? quoteSegmentsToComposerDocument(quoteSegments) : undefined),
[quoteSegments, quotesEncoded],
);
- // $指令 开头且确认命中意识时,消息走"合并形态":不渲文字气泡,prompt
- // (剥掉指令 token 的余文)收进召唤卡卡身;普通消息里的 $word 不受影响。
+ // $指令 开头且确认命中意识时,气泡正文渲剥掉指令 token 的余文($token 的
+ // 语义由气泡内的召唤标注行承载,正文不重复报幕);普通消息里的 $word 不受
+ // 影响。2026-07-29 起取消「卡片即消息」合并形态:正文永远回归文字气泡。
const ghostCmdWord =
ghostDirective?.kind === 'command' ? parseGhostCommandWord(bubbleBody) : null;
// 触发符恒为 1 个字符($ 或全角变体),token = 触发符 + 指令词。
const ghostCmdToken = ghostCmdWord ? bubbleBody.slice(0, 1 + ghostCmdWord.length) : null;
const ghostPromptBody = ghostCmdToken ? bubbleBody.slice(ghostCmdToken.length).trim() : '';
// 软提示兑现(语义调用):本条消息触发的那一轮 AI 真调了被提及的意识时,
- // 与硬指令走同一合并形态——不渲文字气泡,整条正文作为 prompt 收进召唤卡,
- // 语义调用与 $ 显式召唤最终渲染一致。判据来自 GhostFulfillmentContext
+ // 升级为与硬指令同形态的召唤标注行。判据来自 GhostFulfillmentContext
// (MessageStream 从会话历史现算,重启幂等)。
const ghostFulfillment = useContext(GhostFulfillmentContext);
const ghostFulfilledIds = messageClientId ? ghostFulfillment.get(messageClientId) : undefined;
@@ -845,8 +845,8 @@ export function UserMessage({
ghostFulfilledIds && ghostDirective.ghosts.some((g) => ghostFulfilledIds.has(g.ghostId)),
);
// 语义自主召唤:消息一个触发词都没命中(无任何追加段),AI 本轮仍真调了
- // ghost_call → 合成 semantic 展示数据,同样走合并大卡(与硬指令/兑现软
- // 提示渲染一致)。orca / hook 消息不参与(它们本就不经意识展开)。
+ // ghost_call → 合成 semantic 展示数据,渲染同一行召唤标注(与硬指令/兑现
+ // 软提示渲染一致)。orca / hook 消息不参与(它们本就不经意识展开)。
const ghostSemanticDisplay: GhostSummonDisplay | null =
!ghostDirective &&
!orcaCommunication &&
@@ -855,23 +855,22 @@ export function UserMessage({
ghostFulfilledIds.size > 0
? { kind: 'semantic', ghostIds: [...ghostFulfilledIds] }
: null;
- // 召唤卡的最终展示数据(追加段解析优先;没有追加段才可能是 semantic)。
+ // 召唤展示数据(追加段解析优先;没有追加段才可能是 semantic),按形态分流:
+ // - 标注行(chip):硬指令 / 软提示已兑现 / semantic → 嵌进气泡顶部;
+ // - 胶囊(pill):软提示未兑现 → 保持原低调形态,留在气泡下方。
const ghostCardDisplay: GhostSummonDisplay | null = ghostDirective ?? ghostSemanticDisplay;
- // 兑现驱动的合并(软提示兑现 / 语义召唤)对自动化任务消息豁免:模板化
- // 调度 prompt 每轮重复出现,靠专门的低阈值收起反刷屏(见 collapseThreshold),
- // 合并进卡身会绕过收起、每轮全文刷屏——自动化消息保留气泡 + 收起,召唤卡
- // 照渲但不吞正文(subagent review P1)。$指令 合并不受影响(用户显式点名)。
- const ghostFulfillMerge =
- !automationOrigin && (ghostMentionFulfilled || ghostSemanticDisplay !== null);
- // 合并形态总开关:$指令 / 软提示兑现 / 语义自主召唤,都是"卡片即消息"。
- const ghostMergedForm = Boolean(ghostCmdToken) || ghostFulfillMerge;
- // 合并形态下收进卡身的 prompt 原文:硬指令剥 $token 余文;其余整条正文。
- const ghostCardPromptBody = ghostCmdToken ? ghostPromptBody : ghostFulfillMerge ? bubbleBody : '';
- const ghostCardPromptSourceStart = useMemo(() => {
- if (!ghostCardPromptBody || ghostBodySourceStart === null) return null;
- const localStart = ghostBody.indexOf(ghostCardPromptBody);
+ const ghostPillForm = ghostDirective?.kind === 'mention' && !ghostMentionFulfilled;
+ const ghostChipDisplay = ghostPillForm ? null : ghostCardDisplay;
+ const ghostPillDisplay = ghostPillForm ? ghostDirective : null;
+ // 气泡实际显示的正文与其在原始 content 中的起点(粘贴块/斜杠命令高亮的
+ // 偏移投影用):硬指令剥 $token,其余原样。
+ const displayBubbleBody = ghostCmdToken ? ghostPromptBody : bubbleBody;
+ const displayBubbleSourceStart = useMemo(() => {
+ if (!ghostCmdToken) return ghostBodySourceStart;
+ if (!ghostPromptBody || ghostBodySourceStart === null) return null;
+ const localStart = ghostBody.indexOf(ghostPromptBody);
return localStart >= 0 ? ghostBodySourceStart + localStart : null;
- }, [ghostBody, ghostBodySourceStart, ghostCardPromptBody]);
+ }, [ghostCmdToken, ghostPromptBody, ghostBody, ghostBodySourceStart]);
// 长消息收起以真实排版为准:粗筛命中的消息在气泡里挂隐藏镜像节点实测
// 视觉行数,窗口缩放 / 侧栏开合导致气泡宽度变化时由 ResizeObserver 重算。
// 自动化任务注入的消息(模板化调度 prompt,每轮重复出现)用更低的收起
@@ -879,26 +878,27 @@ export function UserMessage({
const collapseThreshold = automationOrigin
? AUTOMATION_USER_MESSAGE_VISUAL_LINE_THRESHOLD
: LONG_USER_MESSAGE_VISUAL_LINE_THRESHOLD;
- // 粘贴段在 bubbleBody 局部坐标下的 range(与下方富渲染同一份投影)。
+ // 粘贴段在气泡展示正文(displayBubbleBody)局部坐标下的 range(与下方
+ // 富渲染同一份投影;硬指令剥 $token 后起点用 displayBubbleSourceStart)。
const bubblePastedRanges = useMemo(
- () => projectSentRanges(pastedTextRanges ?? [], ghostBodySourceStart, bubbleBody.length),
- [bubbleBody.length, ghostBodySourceStart, pastedTextRanges],
+ () =>
+ projectSentRanges(pastedTextRanges ?? [], displayBubbleSourceStart, displayBubbleBody.length),
+ [displayBubbleBody.length, displayBubbleSourceStart, pastedTextRanges],
);
// 测量与收起态渲染共用的投影正文:粘贴段按胶囊文案计量,不再拿被折叠掉的
- // 几百行原文去撞收起阈值(issue #946)。偏移只在 bubbleBody 与 ghostBody 同源时
- // 精确 —— 引用交错的消息(quote 块被 join 掉,偏移会整体前移)保持原文测量。
+ // 几百行原文去撞收起阈值(issue #946)。偏移只在 bubbleBody 与 ghostBody 同源
+ // (无引用交错)时精确 —— quote 块被 join 掉的消息偏移会整体前移,保持原文
+ // 测量;硬指令剥 $token 不影响精确性(displayBubbleSourceStart 已重定位)。
const collapseMeasureBody = useMemo(
() =>
bubbleBody === ghostBody
- ? projectSentPastedPlainText(bubbleBody, bubblePastedRanges)
- : bubbleBody,
- [bubbleBody, bubblePastedRanges, ghostBody],
+ ? projectSentPastedPlainText(displayBubbleBody, bubblePastedRanges)
+ : displayBubbleBody,
+ [bubbleBody, ghostBody, displayBubbleBody, bubblePastedRanges],
);
- // 合并形态($指令 / 软提示兑现 / 语义召唤)不渲文字气泡,镜像测量无处挂载,直接关掉。
const collapseMeasureEnabled =
!orcaCommunication &&
!hookSource &&
- !ghostMergedForm &&
mayExceedVisualLineThreshold(collapseMeasureBody, collapseThreshold);
const { mirrorRef: collapseMirrorRef, shouldCollapse: shouldCollapseLongMessage } =
useUserMessageAutoCollapse(collapseMeasureBody, collapseMeasureEnabled, collapseThreshold);
@@ -1288,8 +1288,10 @@ export function UserMessage({
/>
) : (
<>
- {/* 合并形态下用户正文由召唤卡承载,但引用上下文仍留在原消息中。 */}
- {(inlineQuoteCount > 0 || (bubbleBody.trim() && !ghostMergedForm)) && (
+ {/* 召唤标注行(chip)嵌进气泡顶部;正文永远回归文字气泡(2026-07-29
+ 取消合并形态)。气泡在有标注、有引用或有正文任一时渲染——$指令
+ 无余文时气泡只剩标注行。 */}
+ {(inlineQuoteCount > 0 || displayBubbleBody.trim() || ghostChipDisplay) && (
<div
className={cn(
// overflow-wrap:anywhere(不是 break-words)才能让超长无空格序列
@@ -1305,6 +1307,22 @@ export function UserMessage({
'select-text',
)}
>
+ {ghostChipDisplay && (
+ /* ghost-summon-chip:标注行(法阵 + 意识名 + 状态 + 展开
+ caret)。running = 本条消息触发的 turn 仍在执行(最后一条
+ user 消息 + 会话流式中),期间法阵旋转,turn 结束播终态编舞。
+ 下方有正文/引用时加分隔线,单独成泡时不加。 */
+ <GhostSummonCard
+ directive={ghostChipDisplay}
+ running={Boolean(sessionRunning) && Boolean(isLastUserMessage)}
+ {...(messageClientId ? { messageClientId } : {})}
+ className={
+ inlineQuoteCount > 0 || displayBubbleBody.trim()
+ ? 'mb-2.5 border-b border-[var(--msg-user-border)] pb-2.5'
+ : undefined
+ }
+ />
+ )}
{collapseMeasureEnabled && (
/* 收起判定的测量镜像:与正文同宽(inset-x-4 对应 px-4)、同字号
同换行规则的纯文本。max-h-0 + overflow-hidden 让它不占布局、
@@ -1336,7 +1354,7 @@ export function UserMessage({
>
<QuoteChip quote={segment.quote} />
</span>
- ) : ghostMergedForm ? null : (
+ ) : (
<span
// biome-ignore lint/suspicious/noArrayIndexKey: 已发送消息内容不可变,顺序稳定。
key={index}
@@ -1386,7 +1404,7 @@ export function UserMessage({
),
)}
</div>
- ) : (
+ ) : displayBubbleBody.trim() ? (
<div
className={cn(
'whitespace-pre-wrap [overflow-wrap:anywhere]',
@@ -1401,7 +1419,7 @@ export function UserMessage({
// 且与上方测量镜像同一份文本(issue #946)。
collapseMeasureBody
: renderContent(
- bubbleBody,
+ displayBubbleBody,
workingDir,
async (abs, name, chip) => {
if (!(await shouldOpenTextLightboxForOrigin(sessionFileCtx, abs)))
@@ -1421,14 +1439,14 @@ export function UserMessage({
? undefined
: projectSentRanges(
slashCommandRanges,
- ghostBodySourceStart,
- bubbleBody.length,
+ displayBubbleSourceStart,
+ displayBubbleBody.length,
),
sessionReferences,
handlePastedTextChipClick,
)}
</div>
- )}
+ ) : null}
{shouldCollapseLongMessage && (
<button
type="button"
@@ -1454,55 +1472,12 @@ export function UserMessage({
)}
</div>
)}
- {/* ghost-summon-card:硬指令 / 软提示被兑现 / 语义自主召唤都走合并
- 形态(卡片即消息,prompt 富渲染后收进卡身,附件/引用仍在上方
- 各自的区块);未兑现的软提示保持低调胶囊。机器追加段的原文收进
- 卡片展开区(semantic 无追加段,展开区为来由说明)。running =
- 本条消息触发的 turn 仍在执行(最后一条 user 消息 + 会话流式中),
- 期间印记环旋转作 loading,turn 结束自动停。 */}
- {ghostCardDisplay && (
+ {/* ghost-summon-pill:未兑现的软提示保持低调胶囊,留在气泡下方
+ (chip 标注行形态见气泡内部;提示原文仍可点开查看)。 */}
+ {ghostPillDisplay && (
<GhostSummonCard
- directive={ghostCardDisplay}
- running={Boolean(sessionRunning) && Boolean(isLastUserMessage)}
+ directive={ghostPillDisplay}
{...(messageClientId ? { messageClientId } : {})}
- prompt={
- ghostCardPromptBody
- ? renderContent(
- ghostCardPromptBody,
- workingDir,
- async (abs, name, chip) => {
- if (!(await shouldOpenTextLightboxForOrigin(sessionFileCtx, abs)))
- return;
- activeFileChipRef.current = chip;
- setTextLightboxFile({ path: abs, name });
- },
- (xdtFileUrl) => setLightboxSrc(xdtFileUrl),
- t,
- sessionId,
- isRemoteFileOrigin(sessionFileCtx.origin),
- projectSentRanges(
- pastedTextRanges ?? [],
- ghostCardPromptSourceStart,
- ghostCardPromptBody.length,
- ),
- slashCommandRanges === undefined
- ? undefined
- : projectSentRanges(
- slashCommandRanges,
- ghostCardPromptSourceStart,
- ghostCardPromptBody.length,
- ),
- // 召唤卡 prompt 与气泡正文用同一份 sessionReferences:它按
- // sessionId / messageClientId 匹配,不依赖文本偏移,不需要像
- // pastedTextRanges / slashCommandRanges 那样投影到 prompt 局部
- // 坐标。此前这里漏传(实参列表止于 slashCommandRanges),导致
- // prompt 里的会话深链 chip 少了 referenceMetadata 的 tooltip
- // 明细行,与正文渲染不一致(PR #966 review)。
- sessionReferences,
- handlePastedTextChipClick,
- )
- : undefined
- }
/>
)}
{/* 订阅槽①:被意识钩子拦下 —— 气泡照常显示(未发出),下方渲一条
diff --git a/apps/desktop/src/renderer/i18n/locales/en/common.json b/apps/desktop/src/renderer/i18n/locales/en/common.json
index 14b136ecee..7436beb82c 100644
--- a/apps/desktop/src/renderer/i18n/locales/en/common.json
+++ b/apps/desktop/src/renderer/i18n/locales/en/common.json
@@ -5072,7 +5072,6 @@
"openInSidebarFailed": "Failed to open in sidebar browser"
},
"ghostSummon": {
- "overline": "PLUGIN USE · GHOST",
"directiveLabel": "Directive appended for the model",
"legend": "Highlighted = injected from the plugin's manifest · the rest is the fixed system template",
"expandAria": "Show the directive appended for the model",
@@ -5082,7 +5081,12 @@
"mentionDirectiveLabel": "Hint appended for the model",
"semanticExpandAria": "Show how this plugin was used",
"semanticNote": "The AI used this plugin on its own based on the meaning of your message; no machine directive was appended to it.",
- "listSeparator": ", "
+ "listSeparator": ", ",
+ "status": {
+ "running": "Calling…",
+ "called": "Called",
+ "done": "Finished"
+ }
},
"userMessage": {
"attachmentPrefix": "Attachments: ",
diff --git a/apps/desktop/src/renderer/i18n/locales/ja/common.json b/apps/desktop/src/renderer/i18n/locales/ja/common.json
index bdca1d0c5d..02653db82f 100644
--- a/apps/desktop/src/renderer/i18n/locales/ja/common.json
+++ b/apps/desktop/src/renderer/i18n/locales/ja/common.json
@@ -5071,7 +5071,6 @@
"openInSidebarFailed": "サイドバーのブラウザで開けませんでした"
},
"ghostSummon": {
- "overline": "プラグイン呼び出し · GHOST",
"directiveLabel": "モデルに追加された指示",
"legend": "ハイライト = プラグインのマニフェスト由来の注入値 · それ以外はシステム固定テンプレート",
"expandAria": "モデルに追加された指示を表示",
@@ -5081,7 +5080,12 @@
"mentionDirectiveLabel": "モデルに追加されたヒント",
"semanticExpandAria": "この呼び出しの説明を表示",
"semanticNote": "AI がメッセージの意味に基づいてこのプラグインを自律的に呼び出しました。このメッセージに機械指示は追加されていません。",
- "listSeparator": "、"
+ "listSeparator": "、",
+ "status": {
+ "running": "呼び出し中…",
+ "called": "呼び出し済み",
+ "done": "完了"
+ }
},
"userMessage": {
"attachmentPrefix": "添付:",
diff --git a/apps/desktop/src/renderer/i18n/locales/ko/common.json b/apps/desktop/src/renderer/i18n/locales/ko/common.json
index 818ad828c1..8c38e632e7 100644
--- a/apps/desktop/src/renderer/i18n/locales/ko/common.json
+++ b/apps/desktop/src/renderer/i18n/locales/ko/common.json
@@ -5071,7 +5071,6 @@
"openInSidebarFailed": "사이드바 브라우저에서 열지 못했습니다"
},
"ghostSummon": {
- "overline": "플러그인 호출 · GHOST",
"directiveLabel": "모델에 추가된 지시문",
"legend": "강조 표시 = 플러그인 매니페스트에서 주입된 값 · 나머지는 시스템 고정 템플릿",
"expandAria": "모델에 추가된 지시문 보기",
@@ -5081,7 +5080,12 @@
"mentionDirectiveLabel": "모델에 추가된 힌트",
"semanticExpandAria": "이 호출에 대한 설명 보기",
"semanticNote": "AI가 메시지의 의미를 바탕으로 이 플러그인을 스스로 호출했습니다. 이 메시지에는 기계 지시문이 추가되지 않았습니다.",
- "listSeparator": ", "
+ "listSeparator": ", ",
+ "status": {
+ "running": "호출 중…",
+ "called": "호출됨",
+ "done": "완료됨"
+ }
},
"userMessage": {
"attachmentPrefix": "첨부: ",
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 5ca3fc44f8..02ad228322 100644
--- a/apps/desktop/src/renderer/i18n/locales/zh-CN/common.json
+++ b/apps/desktop/src/renderer/i18n/locales/zh-CN/common.json
@@ -5071,7 +5071,6 @@
"openInSidebarFailed": "在侧边栏浏览器中打开失败"
},
"ghostSummon": {
- "overline": "调用插件 · GHOST",
"directiveLabel": "追加给模型的指令",
"legend": "高亮 = 插件注入(来自身份卡)· 其余为系统固定模板",
"expandAria": "展开查看追加给模型的指令",
@@ -5081,7 +5080,12 @@
"mentionDirectiveLabel": "追加给模型的提示",
"semanticExpandAria": "查看本次调用说明",
"semanticNote": "AI 根据消息语义自主调用了这个插件;本条消息未追加任何机器指令。",
- "listSeparator": "、"
+ "listSeparator": "、",
+ "status": {
+ "running": "调用中…",
+ "called": "已调用",
+ "done": "已完成"
+ }
},
"userMessage": {
"attachmentPrefix": "附件:",
diff --git a/apps/desktop/src/renderer/styles/globals.css b/apps/desktop/src/renderer/styles/globals.css
index bd36a39b4d..c0cfa854b3 100644
--- a/apps/desktop/src/renderer/styles/globals.css
+++ b/apps/desktop/src/renderer/styles/globals.css
@@ -1032,6 +1032,54 @@ body.resizing-pane [data-ghost-webview] {
}
}
+/* 召唤法阵终态编舞(GhostSummonCard/SummonSeal,DESIGN.md §14.4 登记):
+ running 结束时两道弧在旋转中把缺口收拢至满圆(600ms 一次性 dasharray
+ 过渡,一次性瞬态允许非合成器属性)→ 光晕从法阵荡开一圈 + ✓ 弹出
+ (✓ 复用 Done 语义的唯一批准 overshoot 曲线,同 status-done-pop)。
+ motion-reduce 下全部禁用,直接落终态帧。 */
+.summon-seal-arc {
+ transition: stroke-dasharray 600ms var(--motion-ease-out), opacity 600ms var(--motion-ease-out);
+}
+@keyframes summon-seal-halo {
+ 0% {
+ transform: scale(1);
+ opacity: 0.85;
+ }
+ 100% {
+ transform: scale(1.65);
+ opacity: 0;
+ }
+}
+.summon-seal-halo {
+ animation: summon-seal-halo 0.9s var(--motion-ease-out) forwards;
+}
+@keyframes summon-seal-tick-pop {
+ 0% {
+ transform: scale(0);
+ }
+ 60% {
+ transform: scale(1.12);
+ }
+ 100% {
+ transform: scale(1);
+ }
+}
+.summon-seal-tick-pop {
+ animation: summon-seal-tick-pop 0.3s cubic-bezier(0.34, 1.56, 0.64, 1) both;
+}
+@media (prefers-reduced-motion: reduce) {
+ .summon-seal-arc {
+ transition: none;
+ }
+ .summon-seal-halo,
+ .summon-seal-tick-pop {
+ animation: none;
+ }
+ .summon-seal-halo {
+ opacity: 0;
+ }
+}
+
/* Done: pop bounce, stays orange */
.status-bar-done {
color: var(--status-bar-accent);
diff --git a/apps/desktop/src/renderer/themes/colors.ts b/apps/desktop/src/renderer/themes/colors.ts
index 092171a842..a627b7ade5 100644
--- a/apps/desktop/src/renderer/themes/colors.ts
+++ b/apps/desktop/src/renderer/themes/colors.ts
@@ -1664,6 +1664,10 @@ registerColor('card-status-done', {
light: '#2AAE5B',
dark: '#2AAE5B',
}, '状态点 — 完成未读 (设计定稿 2026-07-17 #2AAE5B,取代 #22c55e;普通/定时任务完成统一,橙专职 running)');
+registerColor('completion-badge-fg', {
+ light: '#1f1f1e',
+ dark: '#1f1f1e',
+}, '完成徽标(✓)前景 — 深墨前景压在 card-status-done 绿上,对比 5.29:1(白前景只有 2.88:1,不达 WCAG 1.4.11 非文字 3:1 门槛);light/dark 同值,与 surface-on-card 暗态的 checked icon 深前景惯例一致');
registerColor('remote-status-disconnected', {
light: 'var(--text-tertiary)',
dark: 'var(--text-tertiary)',
diff --git a/docs/design-rules/DESIGN.md b/docs/design-rules/DESIGN.md
index 1261d05293..682f2d7316 100644
--- a/docs/design-rules/DESIGN.md
+++ b/docs/design-rules/DESIGN.md
@@ -611,6 +611,10 @@ default into components.
- **Form** (finalized over four/five review rounds, 2026-07-23): **true parabolic toss + vanish on landing** — all particles launch simultaneously from the segment center in a ~**100° fan** (±50° of straight up) at equal speed, **constant horizontal velocity + constant vertical gravity** (decelerating up, accelerating down past the apex), so perceived speed is consistent from burst to fall; wider-angle particles fly lower arcs, travel farther, land earlier — the scatter comes from physics, not scripting. The final stretch before the ground line ends in a **short fade**: landing is fine, but lingering after landing ("corpsing") or vanishing without a fade is forbidden; the ground line jitters randomly so landing points don't queue up.
- **Parameter red lines**: a one-shot celebration — simultaneous launch, no stagger delay; per-particle duration follows arc physics clamped to 0.9s–1.6s, total ≈1.6s (the number roll settles at 1.2s, then the last confetti falls a few tenths more; arc scale and rhythm are user-tuned, finalized 2026-07-23); ≤18 particles, 3–5px, torn down when done, never looping or persistent; particles are HTML elements animating only `transform` / `opacity` (compositor-only, engineering conventions §7; x/y split across two nested spans keeps horizontal velocity constant); colors come only from the four status-dot hue exemptions (done green / awaiting teal / thinking orange / error red), same values in both modes; must skip entirely under `prefers-reduced-motion`.
- **Scope boundary**: this one spot only. Confetti must not leak into task completion, send success, or anywhere else — those stay on the §14.4 baseline (a new exemption requires a new entry here). Implementation: `apps/desktop/src/renderer/components/status/QuotaResetConfetti.tsx`.
+- **Summon-seal terminal choreography(召唤法阵终态编舞)** — the fourth sanctioned motion class (approved 2026-07-29), **only** for the plugin summon seal in `GhostSummonCard`/`SummonSeal` (the dual counter-arc "summoning circle" around the plugin avatar in user messages):
+ - **Definition**: the seal's signature running animation (two gapped arcs, outer 83/17 + inner 39/61, spinning as a whole at 2.4s linear on an HTML wrapper) is a beloved product signature and is preserved verbatim. What was missing was an ending: when the turn stops, the gaps used to freeze in place and read as "stuck mid-load". The choreography gives the animation a curtain call instead of replacing it: **while still spinning, both arcs close their gaps into full circles** (600ms one-shot `stroke-dasharray` transition — permitted as a one-shot transient per the red lines above); when the turn actually issued a `ghost_call` (fulfilled), a success-colored halo ring then dilates outward once (`summon-seal-halo`, 0.9s scale 1→1.65 + fade) while a ✓ badge pops at the avatar's corner (reusing the Done semantic's sanctioned overshoot curve, same as `status-done-pop`); the spin is removed only after the circles are closed — a spinning full circle is visually static, so the removal is seamless. Semantics stay self-consistent: gap = in progress, full circle = turn finished; ✓/halo appear **only on a fulfilled call** — a cancelled/never-issued call closes neutrally with no success badge (the ring must not fake success).
+ - **Parameter red lines**: close 600ms (`--motion-ease-out`; outside the duration tiers — sanctioned here, do not reuse elsewhere), halo 0.9s one-shot, tick pop 0.3s. Historic messages mount directly on the closed static frame with zero animation; the choreography plays only for a mount that actually witnessed `running` flip false. Halo/badge fill comes from the status-dot done-green exemption (`--card-status-done`); the ✓ glyph uses `--completion-badge-fg` (dark ink both modes, 5.29:1 on the done green — white would be 2.88:1, below the WCAG 1.4.11 non-text 3:1 floor). All keyframes are in the `prefers-reduced-motion` whitelist — reduced motion lands straight on the terminal frame.
+ - **Scope boundary**: this seal only. The closing-ring language must not leak into other spinners or progress indicators. Implementation: `apps/desktop/src/renderer/components/chat/GhostSummonCard.tsx` + `.summon-seal-*` in `globals.css`.
- **Retired: mobile-download QR brand edge** — a rotating app-icon edge on the `MobileDownloadDialog` QR card was briefly registered here as a fourth (persistent) motion class on 2026-07-25 and **removed the same day** at the user's request: read as a strange ring turning behind the code. There is **no sanctioned persistent decorative motion** — the red lines above hold without exception. The card is now a bare QR (no edge, no border, no shadow, no tilt); its only motion is the linked ↔ onboarding size tween. Do not re-add. Contract test: `mobileDownloadDialog.test.tsx` → `keeps the QR card flat with no brand edge`.
## 15. CINDY Skin Family(品牌化可选 family)