Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
feat(motion): 修复 reduced-motion 逃逸 + 三项动效改进(§14.4)
DavidShen81af46f381b1
diff --git a/apps/desktop/src/renderer/__tests__/reducedMotionEscape.test.ts b/apps/desktop/src/renderer/__tests__/reducedMotionEscape.test.tsnew file mode 100644index 0000000000..a23256d8d1--- /dev/null+++ b/apps/desktop/src/renderer/__tests__/reducedMotionEscape.test.ts@@ -0,0 +1,88 @@+/**+ * reducedMotionEscape.test.ts+ * ---------------------------------------------------------------------------+ * 减弱动效(prefers-reduced-motion)覆盖面的契约测试。+ *+ * 背景:globals.css 的 reduce 块曾只匹配 [class*='animate-spinner'],而字符串+ * "animate-spin" 不含 "animate-spinner" —— 37 处 Tailwind 裸 animate-spin 全部+ * 逃逸,其中十余处连组件级 motion-reduce:animate-none 兜底都没有,减弱动效下+ * 照转(无障碍缺陷)。修复是把选择器放宽为 [class*='animate-spin'](它是+ * spinner 的子串,一条覆盖两者)。本测试钉住修复,防止选择器回退。+ *+ * 降级策略分型(DESIGN.md §14.4 红线的补充,踩坑规则):+ * - infinite 循环动画(spin / pulse / shimmer)→ animation: none 安全;+ * - 带 forwards / both 的一次性入场动画 → 只能时长归零,不得 animation: none+ * (否则元素停在 0% 帧的 opacity:0 直接消失)。本仓通过 motion token 归零+ * 实现(reduce 块把 --motion-* 全档置 0ms),测试同时钉住这条路径。+ */++import { readFileSync } from 'node:fs';+import { fileURLToPath } from 'node:url';+import { describe, expect, it } from 'vitest';++const css = readFileSync(+ fileURLToPath(new URL('../styles/globals.css', import.meta.url)),+ 'utf8',+);++/** 提取 @media (prefers-reduced-motion: reduce) 的所有块体(brace 平衡扫描)。 */+function collectReducedMotionBlocks(source: string): string[] {+ const blocks: string[] = [];+ const re = /@media\s*\(prefers-reduced-motion:\s*reduce\)\s*\{/g;+ for (let m = re.exec(source); m; m = re.exec(source)) {+ let depth = 1;+ let i = re.lastIndex;+ while (i < source.length && depth > 0) {+ if (source[i] === '{') depth++;+ else if (source[i] === '}') depth--;+ i++;+ }+ blocks.push(source.slice(re.lastIndex, i - 1));+ }+ return blocks;+}++const reduceBlocks = collectReducedMotionBlocks(css);+const reduceCss = reduceBlocks.join('\n');++describe('prefers-reduced-motion 覆盖面(globals.css)', () => {+ it('扫描逻辑确实抓到了 reduce 块(防正则失效空跑)', () => {+ expect(reduceBlocks.length).toBeGreaterThan(0);+ expect(reduceCss).toContain('animation: none');+ });++ it("匹配 Tailwind spinner 的选择器必须是 [class*='animate-spin'](spinner 的子串,一条覆盖两者)", () => {+ // 'animate-spin' 是 'animate-spinner' 的子串:这一条同时命中裸 animate-spin+ // 与自定义 animate-spinner(含 motion-safe: 变体的转义类名)。+ expect(reduceCss).toContain("[class*='animate-spin']");+ });++ it("不得回退成只匹配 [class*='animate-spinner'](animate-spin 会逃逸)", () => {+ // 匹配到 'animate-spinner' 说明有人把选择器改窄了;宽选择器已覆盖它,+ // 单独出现即是回退信号。+ expect(reduceCss).not.toContain("[class*='animate-spinner']");+ });++ it('motion token 全档在 reduce 块里归零(变体形态的 animate-* 靠它失效)', () => {+ for (const token of [+ '--motion-instant',+ '--motion-fast',+ '--motion-base',+ '--motion-enter',+ '--motion-exit',+ '--motion-spinner-cycle',+ ]) {+ expect(reduceCss, `reduce 块缺少 ${token} 归零`).toMatch(+ new RegExp(`${token}:\\s*0ms`),+ );+ }+ });++ it('带 forwards/both 的一次性动画不得被 animation: none 整类扑杀(会停在 opacity:0)', () => {+ // reduce 块允许 animation: none 的只有循环装饰类;一次性 confirm 类走+ // duration 归零。这里钉住 confirm 类的降级方式不被改成 none。+ expect(reduceCss).toMatch(+ /\.animate-confirm-overlay-in[\s\S]*?animation-duration:\s*0ms\s*!important/,+ );+ });+});diff --git a/apps/desktop/src/renderer/components/chat/MarkdownRenderer.tsx b/apps/desktop/src/renderer/components/chat/MarkdownRenderer.tsxindex 712c939691..90c135fb31 100644--- a/apps/desktop/src/renderer/components/chat/MarkdownRenderer.tsx+++ b/apps/desktop/src/renderer/components/chat/MarkdownRenderer.tsx@@ -32,6 +32,8 @@ import remarkPreserveRawLocalDestinations, {import remarkSessionLinks from './remarkSessionLinks';import { rehypeMathBlockMarker } from './rehypeMathBlockMarker';import { FENCED_CODE_PROP, rehypeFencedCodeMarker } from './rehypeFencedCodeMarker';+import { createWordFadeState, rehypeStreamWordFade } from './rehypeStreamWordFade';+import { useReducedMotion } from '@/hooks/useReducedMotion';import { CopyAsImageBlock, mathBlockToLatex, tableToTsv } from './CopyAsImageBlock';import type { Components, UrlTransform } from 'react-markdown';import type { PluggableList } from 'unified';@@ -1621,6 +1623,17 @@ export const MarkdownRenderer = memo(function MarkdownRenderer({// Static callers (TextLightbox) leave isStreaming undefined → false,// so the throttle is fully bypassed — same behavior as before.const throttledContent = useStreamingThrottle(content, isStreaming);+ // 流式逐词淡入(rehypeStreamWordFade,§14.4 第五个 sanctioned motion class):+ // 仅 isStreaming + 非 reduced-motion 时把插件挂到 rehype 链尾。state 按渲染器+ // 实例持有(useMemo 键 isStreaming):流式期间跨 parse tick 记住每个词的 delay+ // 保证不重播;isStreaming 翻 false 时整段回落到模块级常量 REHYPE_PLUGINS ——+ // 终版渲染无任何 span 包装,插件与 state 一起被回收,静态路径零开销。+ const reducedMotion = useReducedMotion();+ const streamFade = isStreaming && !reducedMotion;+ const rehypePlugins = useMemo<PluggableList>(() => {+ if (!streamFade) return REHYPE_PLUGINS;+ return [...REHYPE_PLUGINS, [rehypeStreamWordFade, createWordFadeState()]];+ }, [streamFade]);// LaTeX 定界符归一化(`\(...\)` / `\[...\]` → `$...$` / `$$...$$`)。// emitSourceLines(TextLightbox 行锚点 doc 模式,依赖 data-source-line 与// 源文件行号一致)时走保行数模式:单行 inline 照常转换(同行替换不改行@@ -1825,7 +1838,7 @@ export const MarkdownRenderer = memo(function MarkdownRenderer({<div className="msg-markdown select-text"><ReactMarkdownremarkPlugins={allowPrivilegedLinks ? REMARK_PLUGINS_PRIVILEGED : REMARK_PLUGINS}- rehypePlugins={REHYPE_PLUGINS}+ rehypePlugins={rehypePlugins}components={components}urlTransform={allowPrivilegedLinks ? trustedUrlTransform : previewSafeUrlTransform}skipHtmldiff --git a/apps/desktop/src/renderer/components/chat/__tests__/rehypeStreamWordFade.test.ts b/apps/desktop/src/renderer/components/chat/__tests__/rehypeStreamWordFade.test.tsnew file mode 100644index 0000000000..e6c19bf6fb--- /dev/null+++ b/apps/desktop/src/renderer/components/chat/__tests__/rehypeStreamWordFade.test.ts@@ -0,0 +1,160 @@+/**+ * rehypeStreamWordFade.test.ts+ * ---------------------------------------------------------------------------+ * 流式逐词淡入插件的行为测试:切词、delay 分配(不重播)、背压压缩、+ * code/KaTeX 跳过,以及 CSS 侧动画本体的静态回归。+ */++import { readFileSync } from 'node:fs';+import { fileURLToPath } from 'node:url';+import { describe, expect, it } from 'vitest';+import type { Element, Root, Text } from 'hast';++import {+ createWordFadeState,+ rehypeStreamWordFade,+ splitWords,+ type WordFadeState,+} from '../rehypeStreamWordFade';++function textNode(value: string): Text {+ return { type: 'text', value };+}++function el(tagName: string, children: Element['children'], properties: Element['properties'] = {}): Element {+ return { type: 'element', tagName, properties, children };+}++function root(...children: Root['children']): Root {+ return { type: 'root', children };+}++function run(tree: Root, state: WordFadeState): Root {+ const transformer = (rehypeStreamWordFade as (s: WordFadeState) => (t: Root) => void)(state);+ transformer(tree);+ return tree;+}++/** 收集树里所有 stream-word span 的 (text, delay)。 */+function collectWords(node: Root | Element): { text: string; delay: number }[] {+ const out: { text: string; delay: number }[] = [];+ for (const child of node.children) {+ if (child.type !== 'element') continue;+ const cls = child.properties?.className;+ if (Array.isArray(cls) && cls.includes('stream-word')) {+ const t = child.children[0];+ const style = String(child.properties?.style ?? '');+ const m = /--wf-delay:(\d+)ms/.exec(style);+ out.push({+ text: t?.type === 'text' ? t.value : '',+ delay: m ? Number(m[1]) : NaN,+ });+ continue;+ }+ out.push(...collectWords(child));+ }+ return out;+}++describe('splitWords', () => {+ it('英文按空格切词,空白并入前一词', () => {+ expect(splitWords('hello world foo')).toEqual(['hello ', 'world ', 'foo']);+ });++ it('CJK 无空格也按词切(Intl.Segmenter),不整句一团', () => {+ const words = splitWords('今天天气很好');+ expect(words.length).toBeGreaterThan(1);+ expect(words.join('')).toBe('今天天气很好');+ });++ it('切词无损:任意混排拼回原文', () => {+ const src = 'mixed 中文 and English,标点。 done';+ expect(splitWords(src).join('')).toBe(src);+ });+});++describe('rehypeStreamWordFade', () => {+ it('文本节点被切成带 --wf-delay 的 stream-word span,16ms/词递进', () => {+ const state = createWordFadeState();+ const tree = root(el('p', [textNode('one two three')]));+ run(tree, state);+ const words = collectWords(tree);+ expect(words.map((w) => w.text)).toEqual(['one ', 'two ', 'three']);+ expect(words.map((w) => w.delay)).toEqual([16, 32, 48]);+ });++ it('同一 state 重跑(流式 re-parse)已见词拿回同一 delay —— 不重播', () => {+ const state = createWordFadeState();+ run(root(el('p', [textNode('one two')])), state);++ // 下一个 tick:全文重建 + 新词到达。+ const tree2 = root(el('p', [textNode('one two three four')]));+ run(tree2, state);+ const words = collectWords(tree2);+ // 旧词 delay 不变(1、2 号),新词从本 tick 的 0 起重新 stagger。+ expect(words[0].delay).toBe(16);+ expect(words[1].delay).toBe(32);+ expect(words[2].delay).toBe(16);+ expect(words[3].delay).toBe(32);+ });++ it('背压:单 tick 积压超过 96ms 后压缩到 4ms/词', () => {+ const state = createWordFadeState();+ const many = Array.from({ length: 12 }, (_, i) => `w${i}`).join(' ');+ const tree = root(el('p', [textNode(many)]));+ run(tree, state);+ const delays = collectWords(tree).map((w) => w.delay);+ // 前 6 词 16ms 步进到 96ms,之后 4ms 步进。+ expect(delays.slice(0, 6)).toEqual([16, 32, 48, 64, 80, 96]);+ expect(delays[6]).toBe(100);+ expect(delays[11]).toBe(120);+ });++ it('code / pre 子树跳过(路径 chip 与代码块保持整体形态)', () => {+ const state = createWordFadeState();+ const code = el('code', [textNode('src/foo bar.ts')]);+ const pre = el('pre', [el('code', [textNode('const a = 1')])]);+ const tree = root(el('p', [code]), pre);+ run(tree, state);+ expect(collectWords(tree)).toEqual([]);+ expect((code.children[0] as Text).value).toBe('src/foo bar.ts');+ });++ it('KaTeX 子树跳过(公式内部 span 不拆)', () => {+ const state = createWordFadeState();+ const katex = el('span', [el('span', [textNode('x + y')])], { className: ['katex'] });+ const tree = root(el('p', [katex]));+ run(tree, state);+ expect(collectWords(tree)).toEqual([]);+ });++ it('块间纯空白文本节点原样保留,不生成 span、不占词序号', () => {+ const state = createWordFadeState();+ const tree = root(el('p', [textNode('a')]), textNode('\n'), el('p', [textNode('b')]));+ run(tree, state);+ expect(tree.children[1]).toEqual(textNode('\n'));+ const words = collectWords(tree);+ expect(words.map((w) => w.text)).toEqual(['a', 'b']);+ });+});++describe('globals.css 的 stream-word 动画本体', () => {+ const css = readFileSync(+ fileURLToPath(new URL('../../../styles/globals.css', import.meta.url)),+ 'utf8',+ );++ it('引用 --motion-fast token + both 填充(delay 未到时保持透明)', () => {+ const rule = /\.stream-word\s*\{[\s\S]*?\}/.exec(css)?.[0] ?? '';+ expect(rule).toContain('var(--motion-fast)');+ expect(rule).toContain('var(--wf-delay');+ expect(rule).toContain('both');+ });++ it('关键帧只动 opacity(compositor-only,一次性非 infinite)', () => {+ const kf = /@keyframes stream-word-in\s*\{[\s\S]*?\n\}/.exec(css)?.[0] ?? '';+ expect(kf).toContain('opacity');+ expect(kf).not.toMatch(/transform|width|height|margin|top|left/);+ expect(/\.stream-word\s*\{[\s\S]*?\}/.exec(css)?.[0]).not.toContain('infinite');+ });+});diff --git a/apps/desktop/src/renderer/components/chat/rehypeStreamWordFade.ts b/apps/desktop/src/renderer/components/chat/rehypeStreamWordFade.tsnew file mode 100644index 0000000000..7441bb8bf1--- /dev/null+++ b/apps/desktop/src/renderer/components/chat/rehypeStreamWordFade.ts@@ -0,0 +1,133 @@+/**+ * rehypeStreamWordFade — 流式正文逐词淡入(DESIGN.md §14.4 第五个 sanctioned+ * motion class,2026-08-07)。+ *+ * 形态:流式输出时,每个新词以 150ms opacity 淡入「浮现」,而不是硬蹦出来。+ * 这**不是**被红线禁止的逐字打字机 —— 词整体已渲染就位,只有透明度渐变;+ * 设计裁决(2026-08-07)按「浮现 ≠ 打字」放行。+ *+ * 架构:CSS 管形态、JS 只管时序(对齐 Codex Desktop 的工程结论):+ * - 本插件仅在 isStreaming 且非 reduced-motion 时挂进 rehype 链尾,把文本节点+ * 切词并包 `<span class="stream-word" style="--wf-delay:Nms">`;动画本体是+ * globals.css 的 stream-word-in(--motion-fast 淡入,`both` 填充,delay 前隐藏)。+ * - **不重播**:每个词按全局文档序号在 WordFadeState.assigned 里只分配一次+ * delay。流式节流(100ms)每次 re-parse 重建整棵 hast 树,已见过的词拿回+ * 同一份 className/style → React 原位更新 span,不 remount → 动画不重播。+ * (pending 行 markdown 结构闭合时的局部 remount 会让那几个词快速重淡一次,+ * 150ms 幅度在打字节奏下属于自然观感,与 Codex 行为一致。)+ * - **背压**:每个 parse tick 内新词按 16ms/词 递进 stagger;当 tick 内积压+ * 排程超过 96ms(≈6 词)时压缩到 4ms/词,长段落一次性到达时不会排出+ * 秒级的"字幕机"队列。+ * - 流式结束(isStreaming 翻 false)由 MarkdownRenderer 切回无插件的常量链,+ * 终版渲染没有任何 span 包装,state 随 memo 一起被回收。+ *+ * 跳过:code / pre(路径 chip 与代码块保持整体形态)与 KaTeX 子树(公式内部+ * 是几十个定位 span,逐词包装会拆坏排版)。+ *+ * 切词用 Intl.Segmenter(granularity: 'word'):CJK 无空格也能按词切,避免整句+ * 中文一次性淡入退化成"逐句蹦"。空白并入前一词,不为纯空白生成 span。+ */++import type { Plugin } from 'unified';+import type { Element, ElementContent, Root, Text } from 'hast';++/** 每个 tick 内的逐词 stagger 步长。 */+const STEP_MS = 16;+/** tick 内排程积压超过该值后切换为压缩步长(背压)。 */+const BACKLOG_MS = 96;+const COMPRESSED_STEP_MS = 4;++export interface WordFadeState {+ /** 词的全局文档序号 → 首次出现时分配的 delay(ms)。只写一次,保证不重播。 */+ assigned: Map<number, number>;+}++export function createWordFadeState(): WordFadeState {+ return { assigned: new Map() };+}++const SKIP_TAGS = new Set(['code', 'pre', 'script', 'style', 'textarea']);++function isKatexSubtree(node: Element): boolean {+ const cls = node.properties?.className;+ return (+ Array.isArray(cls) && cls.some((c) => typeof c === 'string' && c.startsWith('katex'))+ );+}++// Chromium(Electron renderer)恒有 Intl.Segmenter;条件判断只为让 Node 测试+// 环境(vitest, Node ≥16 同样内置)与未来宿主差异不至于直接抛错。+const segmenter =+ typeof Intl !== 'undefined' && typeof Intl.Segmenter === 'function'+ ? new Intl.Segmenter(undefined, { granularity: 'word' })+ : null;++/** 切词:词段独立,空白段并入前一段(段首空白独立保留为纯文本)。 */+export function splitWords(text: string): string[] {+ const out: string[] = [];+ if (segmenter) {+ for (const seg of segmenter.segment(text)) {+ const s = seg.segment;+ if (!s.trim() && out.length > 0) out[out.length - 1] += s;+ else out.push(s);+ }+ return out;+ }+ for (const s of text.split(/(\s+)/)) {+ if (!s) continue;+ if (!s.trim() && out.length > 0) out[out.length - 1] += s;+ else out.push(s);+ }+ return out;+}++interface WalkCounter {+ index: number;+ cumDelay: number;+}++function makeWordNode(word: string, counter: WalkCounter, state: WordFadeState): ElementContent {+ // 纯空白段(只可能出现在段首)保持文本节点,不占词序号。+ if (!word.trim()) return { type: 'text', value: word } satisfies Text;+ const index = counter.index++;+ let delay = state.assigned.get(index);+ if (delay === undefined) {+ counter.cumDelay += counter.cumDelay >= BACKLOG_MS ? COMPRESSED_STEP_MS : STEP_MS;+ delay = counter.cumDelay;+ state.assigned.set(index, delay);+ }+ return {+ type: 'element',+ tagName: 'span',+ properties: { className: ['stream-word'], style: `--wf-delay:${delay}ms` },+ children: [{ type: 'text', value: word }],+ };+}++function walk(node: Root | Element, counter: WalkCounter, state: WordFadeState): void {+ const children = node.children;+ for (let i = 0; i < children.length; i++) {+ const child = children[i];+ if (child.type === 'element') {+ if (SKIP_TAGS.has(child.tagName) || isKatexSubtree(child)) continue;+ walk(child, counter, state);+ continue;+ }+ if (child.type !== 'text') continue;+ const words = splitWords(child.value);+ // 单段且是纯空白(块间换行等)→ 原样保留,不改树。+ if (words.length === 0 || (words.length === 1 && !words[0].trim())) continue;+ const nodes = words.map((w) => makeWordNode(w, counter, state));+ children.splice(i, 1, ...nodes);+ i += nodes.length - 1;+ }+}++export const rehypeStreamWordFade: Plugin<[WordFadeState], Root> = (state) => {+ return (tree) => {+ // 每次 parse 从 0 号词重走全文档:已分配的词命中 map 拿回旧 delay,+ // 计数器只被"本 tick 新词"推进 —— stagger 天然从本 tick 起算。+ const counter: WalkCounter = { index: 0, cumDelay: 0 };+ walk(tree, counter, state);+ };+};diff --git a/apps/desktop/src/renderer/features/cc-agent/CCAgentSessionView.tsx b/apps/desktop/src/renderer/features/cc-agent/CCAgentSessionView.tsxindex 04814c8cc3..dd01f21cac 100644--- a/apps/desktop/src/renderer/features/cc-agent/CCAgentSessionView.tsx+++ b/apps/desktop/src/renderer/features/cc-agent/CCAgentSessionView.tsx@@ -4368,6 +4368,40 @@ function RunningStatusBar({const seconds = elapsed % 60;const elapsedText = minutes > 0 ? `${minutes}m ${seconds}s` : `${seconds}s`;+ // Cadenced shimmer(DESIGN.md §14.4):status-shimmer 已是一次性动画,这里在+ // 每次真实动静(状态文案变化 / token 计数推进)时通过 key 重挂载触发一次呼吸。+ // 播放期间到达的动静只置 pending,onAnimationEnd 再连播一次 —— 产出密集时是+ // 连续呼吸(节奏 = 动画时长),静默期(长 thinking / 等待工具)常亮不动。+ // 视觉语义从「固定心跳 = 在运行」变为「呼吸 = 正在产出」,与 Codex 的+ // cadenced 扫光同构;也让运行指示不再依赖 infinite 循环。+ const [shimmerCycle, setShimmerCycle] = useState(0);+ const shimmerPlayingRef = useRef(false);+ const shimmerPendingRef = useRef(false);+ const handleShimmerEnd = useCallback(() => {+ shimmerPlayingRef.current = false;+ if (shimmerPendingRef.current) {+ shimmerPendingRef.current = false;+ shimmerPlayingRef.current = true;+ setShimmerCycle((n) => n + 1);+ }+ }, []);+ useEffect(() => {+ // suppressContent 期间 shimmer 类被摘、动画不会启动,onAnimationEnd 不来 ——+ // 一并清零,避免播放标记卡死后整轮 turn 不再呼吸。+ if (!visible || suppressContent) {+ // 运行结束把播放态清零,下一轮 turn 的首次动静立即触发而不是误判在播。+ shimmerPlayingRef.current = false;+ shimmerPendingRef.current = false;+ return;+ }+ if (shimmerPlayingRef.current) {+ shimmerPendingRef.current = true;+ return;+ }+ shimmerPlayingRef.current = true;+ setShimmerCycle((n) => n + 1);+ }, [visible, suppressContent, status, tokenUsage]);+// Animate the token counter so live mid-turn updates (from message_delta in// agentManager) feel like a smoothly-incrementing number, the same way claude// code's CLI status line ticks. The hook re-anchors from the displayed value@@ -4404,16 +4438,19 @@ function RunningStatusBar({style={{ width: inputWidth }}><div+ // cadenced shimmer:key 重挂载 = 重播一次呼吸(见上方 shimmerCycle 说明)。+ // 左段只有 icon + 一行文字,1.5s 一次的重挂载成本可忽略。+ key={shimmerCycle}+ onAnimationEnd={handleShimmerEnd}className={cn(// min-w-0(非 shrink-0):让内部 status span 的 truncate 真正生效 —— status 可变长// (turn-start 带用户名 / tool 进度长串),窄宽时左段截断而非把右段顶出界。'flex min-w-0 items-center gap-[6px]',- // 隐藏时一律摘所有动画类:infinite 动画即便 visibility:hidden 不画也照算- // 样式/合成层,长期累积会复刻 0f8fa84 那次 breathing 在 :root 的内存泄漏。+ // 隐藏时一律摘所有动画类:动画即便 visibility:hidden 不画也照算样式/合成层,+ // 长期累积会复刻 0f8fa84 那次 breathing 在 :root 的内存泄漏。// 非隐藏时 done 与 shimmer 区别对待:- // - shimmer 是 infinite opacity 呼吸,其 opacity 关键帧会盖过 fadeStyle 的- // inline opacity,使 visible 转 false 后不淡出、一直呼吸到突然消失,故仅- // 在真正 visible(运行中)时挂,linger / fade 阶段摘掉让其正常淡出。+ // - shimmer 现在是 cadenced 一次性呼吸(1 → 0.45 → 1),终态回满不会盖住+ // fadeStyle 的 inline opacity;linger / fade 阶段照旧摘掉,保证淡出干净。// - done 是 0.4s 一次性 pop(keyframe 已去掉 opacity、只动 transform),turn// 结束那一刻(isDone 必伴随 !visible)要弹一下,故保持 !isHidden gate;// 不动 opacity 所以不会盖 fade。diff --git a/apps/desktop/src/renderer/styles/globals.css b/apps/desktop/src/renderer/styles/globals.cssindex b4aab7955d..fd1bd2a931 100644--- a/apps/desktop/src/renderer/styles/globals.css+++ b/apps/desktop/src/renderer/styles/globals.css@@ -182,7 +182,12 @@--motion-sidebar-title-marquee-per-viewport: 0ms;}- [class*='animate-spinner'] {+ /* 'animate-spin' 是 'animate-spinner' 的子串,一条同时覆盖 Tailwind 的+ animate-spin 与自定义 animate-spinner(含 motion-safe: 等变体的转义类名)。+ 之前只匹配 'animate-spinner',37 处裸 animate-spin 全部逃逸——组件级的+ motion-reduce:animate-none 有兜底的不受影响,但十余处没写兜底的转圈在+ 减弱动效下照转(reducedMotionEscape.test.ts 回归)。 */+ [class*='animate-spin'] {animation: none !important;}@@ -855,10 +860,17 @@ body.resizing-pane [data-ghost-webview] {/* F-SDK-3: Running status bar — soft whole-line breathing.The old clipping animation was perceived as a subtle fade, but forced- continuous Paint/Composite work in Electron. Opacity keeps it compositor-only. */+ continuous Paint/Composite work in Electron. Opacity keeps it compositor-only.++ Cadenced(2026-08-07,DESIGN.md §14.4):不再 infinite 循环 —— RunningStatusBar+ 在每次真实动静(状态文案 / token 计数变化)时通过重挂载触发一次呼吸,静默期+ 保持常亮。呼吸节奏跟随实际产出而非固定心跳,「运行指示」不再需要在循环装饰+ 红线上开洞;一次性动画也天然不进 hiddenAnimationGate 冻结清单。+ steps(18, end):每半程 18 步 → 全程 36 步 / 1.5s = 24fps。常驻期合成帧减半以上,+ 低帧率的轻微颗粒感与纸面质感相合,肉眼近似无损(§14.4 低帧率原则)。 */.status-bar-shimmer {color: var(--status-bar-accent);- animation: status-shimmer 1.5s ease-in-out infinite;+ animation: status-shimmer 1.5s steps(18, end) 1;will-change: opacity;}@@ -895,7 +907,8 @@ body.resizing-pane [data-ghost-webview] {width: 36%;border-radius: 2px;background: var(--text-tertiary);- animation: session-card-prog 1.5s ease-in-out infinite;+ /* steps(36):1.5s / 36 步 = 24fps(§14.4 低帧率原则,同 ghost-card-sweep)。 */+ animation: session-card-prog 1.5s steps(36, end) infinite;}@keyframes session-card-prog {0% {@@ -985,6 +998,7 @@ body.resizing-pane [data-ghost-webview] {.session-card-dot::after,.session-running-dot,.thinking-dot,+ .stream-word,.card-col-fade {animation: none !important;will-change: auto;@@ -1018,7 +1032,8 @@ body.resizing-pane [data-ghost-webview] {循环动画必然带 infinite 字面量,而一次性的 animate-[xxx_200ms_ease-out] 不会。 */[data-app-hidden='true'] [data-voice-spinner-arc],[data-app-hidden='true'] [data-voice-mic-bar],-[data-app-hidden='true'] .status-bar-shimmer,+/* .status-bar-shimmer 已 cadenced 化为一次性动画(2026-08-07),按「一次性动画+ 不得纳入冻结清单」原则移出 —— 冻在中途帧会让状态栏停在半暗。 */[data-app-hidden='true'] .session-status-breathing,[data-app-hidden='true'] .session-card-bar::before,[data-app-hidden='true'] .session-card-dot::after,@@ -1083,12 +1098,36 @@ body.resizing-pane [data-ghost-webview] {}}+/* Cadenced 后的一次呼吸:静止态是全亮(无动画时 opacity 继承 fadeStyle 的 1),+ 每次触发从 1 下潜到 0.45 再回满 —— 幅度与旧 infinite 版一致,只是方向反转+ (旧版 0% 起点是 0.45,一次性播放会让常亮态在触发瞬间硬跳暗)。 */@keyframes status-shimmer {0%,100% {- opacity: 0.45;+ opacity: 1;}50% {+ opacity: 0.45;+ }+}++/* 流式正文逐词淡入(§14.4 第五个 sanctioned motion class,2026-08-07):+ 每个新词以 --motion-fast 从透明「浮现」,delay 由 rehypeStreamWordFade 按词序+ 写进 --wf-delay(16ms/词,积压超 96ms 压缩到 4ms/词)。不是逐字打字机 ——+ 词整体已就位,只有 opacity 渐变;pure-opacity 一次性动画,compositor-only。+ `both`:delay 未到时停在 0% 帧(透明),避免先闪现再淡入。+ reduced-motion 双保险:JS 侧短路(插件不挂载,span 不进 DOM)+ 下方 reduce+ 块的 animation: none(摘掉动画连同 both 填充,span 落回自然 opacity 1,+ 不会钉在透明帧 —— 与「forwards/both 入场动画只能时长归零」那条坑的区别在于+ 这里 0% 帧之外元素本身没有 opacity 声明)。 */+.stream-word {+ animation: stream-word-in var(--motion-fast) ease-out var(--wf-delay, 0ms) both;+}+@keyframes stream-word-in {+ from {+ opacity: 0;+ }+ to {opacity: 1;}}@@ -1105,7 +1144,9 @@ body.resizing-pane [data-ghost-webview] {}}.ghost-card-sweep {- animation: ghost-card-sweep 2.2s ease-in-out infinite;+ /* steps(53):2.2s / 53 步 ≈ 24fps(§14.4 低帧率原则)。常驻扫光锁到电影帧率,+ 合成帧减半以上;轻微颗粒感与纸面质感相合,肉眼近似无损。 */+ animation: ghost-card-sweep 2.2s steps(53, end) infinite;}@media (prefers-reduced-motion: reduce) {.ghost-card-sweep {diff --git a/docs/design-rules/DESIGN.md b/docs/design-rules/DESIGN.mdindex 3927889f9f..85e4db65fd 100644--- a/docs/design-rules/DESIGN.md+++ b/docs/design-rules/DESIGN.md@@ -660,7 +660,9 @@ long duration to leak into any other hover or transition.- Non-compositor properties (height/grid …) are allowed only in **one-shot transient animations** (user-triggered, with a definite end) — never persistent.- Every new `@keyframes` / `animate-*` class must be registered in the `prefers-reduced-motion` whitelist in `globals.css` (the global `* { transition: none }` does not catch keyframes).- Real-time direct-manipulation interactions (resizer drag, drag-follow) get **no easing** — following the hand IS the feedback.-- Forbidden: pointless displacement, bouncing, parallax, looping decoration, `transition-all`, and typewriter per-character animation on streamed text (streaming already is the motion). Interactions stay fast and direct.+- Forbidden: pointless displacement, bouncing, parallax, looping decoration, `transition-all`, and typewriter per-character animation on streamed text (streaming already is the motion). Interactions stay fast and direct. (Per-**word** opacity fade-in on streamed text is **not** the typewriter — see the sanctioned stream-word-fade class below: the word is fully laid out and only its opacity ramps; ruled distinct on 2026-08-07.)+- **Low-frame-rate principle for persistent sweeps (2026-08-07)**: looping sweep/progress indicators (`ghost-card-sweep`, `session-card-bar`) use `steps(N, end)` easing tuned to ≈24fps (N = duration-in-seconds × 24) instead of smooth 60fps interpolation. Halves compositor work for animations that run for minutes, and the faint stepped cadence reads as paper grain rather than glass gloss — visually near-lossless. Apply to new persistent translate/sweep loops; do **not** apply to one-shot enters/exits or opacity breathing (steps on a 2-keyframe opacity fade collapses it into a blink).+- **Cadenced running shimmer (2026-08-07)**: the running status bar's breathing (`status-bar-shimmer`) is **event-driven, not an infinite loop** — one 1.5s dip (1 → 0.45 → 1, `steps(18)`) plays per real sign of progress (status text change / token count advance; re-triggered via keyed remount in `RunningStatusBar`, back-to-back plays merge through an animation-end pending flag). Silence (long thinking, tool wait) holds steady full opacity. Semantics: *breathing = producing*, not *heartbeat = alive*. New loading/working indicators should prefer this cadenced pattern over a new infinite loop.#### Exception category: container transform (chip lifts off and grows)@@ -683,6 +685,11 @@ long duration to leak into any other hover or transition.- **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`.+- **Stream-word fade(流式正文逐词淡入)** — the fifth sanctioned motion class (approved 2026-08-07), **only** for streaming assistant prose in the chat message flow:+ - **Definition**: during streaming, each newly-arrived **word** fades in over `--motion-fast` (150ms, opacity only) instead of popping in — text appears to *surface*, not *type*. This is explicitly **not** the forbidden per-character typewriter: the word is fully rendered and positioned from its first frame; only opacity ramps. CJK is segmented per word via `Intl.Segmenter`, so Chinese prose flows word-by-word too.+ - **Architecture red lines**: CSS owns the form, JS owns only the timing — `rehypeStreamWordFade` wraps words in `span.stream-word` and writes a per-word `--wf-delay` (16ms/word stagger per parse tick; backlog past 96ms compresses to 4ms/word as backpressure); the animation itself is a pure-opacity one-shot keyframe in `globals.css` (compositor-only). Words must never replay on re-parse (delay assigned once per document word index). The final (non-streaming) render carries **zero** wrapper spans — the plugin only mounts while `isStreaming`.+ - **Degradation**: `prefers-reduced-motion` short-circuits in JS (plugin not mounted, no spans in DOM) *and* the CSS reduce block strips the animation — double coverage, and the CSS side is safe because `.stream-word` has no own opacity declaration to get stuck on.+ - **Scope boundary**: streaming chat prose only. Skips `code`/`pre` (chips and code blocks keep whole-form) and KaTeX subtrees. Must not be applied to static content, titles, toasts, or any non-streamed text. Implementation: `apps/desktop/src/renderer/components/chat/rehypeStreamWordFade.ts` + `.stream-word` in `globals.css`; tests: `rehypeStreamWordFade.test.ts`.- **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`.### 14.5 聊天正文的可点性信号(Clickability in message bodies)