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(motion): 修复减弱动效切换后的状态栏呼吸

david206bdbe028c1
diff --git a/apps/desktop/src/renderer/__tests__/reducedMotionEscape.test.ts b/apps/desktop/src/renderer/__tests__/reducedMotionEscape.test.ts
index a23256d8d1..b695fa2bd7 100644
--- a/apps/desktop/src/renderer/__tests__/reducedMotionEscape.test.ts
+++ b/apps/desktop/src/renderer/__tests__/reducedMotionEscape.test.ts
@@ -24,6 +24,12 @@ const css = readFileSync(
fileURLToPath(new URL('../styles/globals.css', import.meta.url)),
'utf8',
);
+const sessionViewSource = readFileSync(
+ fileURLToPath(
+ new URL('../features/cc-agent/CCAgentSessionView.tsx', import.meta.url),
+ ),
+ 'utf8',
+);
/** 提取 @media (prefers-reduced-motion: reduce) 的所有块体(brace 平衡扫描)。 */
function collectReducedMotionBlocks(source: string): string[] {
@@ -86,3 +92,16 @@ describe('prefers-reduced-motion 覆盖面(globals.css)', () => {
);
});
});
+
+describe('RunningStatusBar cadenced shimmer 的运行期 reduced-motion 切换', () => {
+ it('动画被摘时清空 playing/pending,并把 reducedMotion 纳入 effect 依赖', () => {
+ expect(sessionViewSource).toContain("import { useReducedMotion } from '@/hooks/useReducedMotion'");
+ expect(sessionViewSource).toContain('const reducedMotion = useReducedMotion();');
+ expect(sessionViewSource).toContain('if (!visible || suppressContent || reducedMotion) {');
+ expect(sessionViewSource).toContain('shimmerPlayingRef.current = false;');
+ expect(sessionViewSource).toContain('shimmerPendingRef.current = false;');
+ expect(sessionViewSource).toContain(
+ '}, [visible, suppressContent, reducedMotion, status, tokenUsage]);',
+ );
+ });
+});
diff --git a/apps/desktop/src/renderer/features/cc-agent/CCAgentSessionView.tsx b/apps/desktop/src/renderer/features/cc-agent/CCAgentSessionView.tsx
index 7e6f37661f..c71f60ae4c 100644
--- a/apps/desktop/src/renderer/features/cc-agent/CCAgentSessionView.tsx
+++ b/apps/desktop/src/renderer/features/cc-agent/CCAgentSessionView.tsx
@@ -133,6 +133,7 @@ import {
useControlledBy,
} from '@/features/remote-device/ControlledBanner';
import { useAnimatedNumber } from '@/hooks/useAnimatedNumber';
+import { useReducedMotion } from '@/hooks/useReducedMotion';
import { loadAllCommands, dispatchCommand, type UnifiedCommand } from '@/lib/slashCommands';
import * as sessionService from '@/lib/sessionService';
import { emitRefresh } from '@/lib/sessionsBus';
@@ -4306,6 +4307,7 @@ function RunningStatusBar({
className?: string;
}) {
const { t } = useTranslation();
+ const reducedMotion = useReducedMotion();
// `showContent` controls whether real content is rendered. During the short
// linger/fade window we keep the row's height stable; once it is fully idle the
// component returns null below so the composer does not retain an empty line.
@@ -4386,9 +4388,10 @@ function RunningStatusBar({
}
}, []);
useEffect(() => {
- // suppressContent 期间 shimmer 类被摘、动画不会启动,onAnimationEnd 不来 ——
- // 一并清零,避免播放标记卡死后整轮 turn 不再呼吸。
- if (!visible || suppressContent) {
+ // suppressContent 或 reduced-motion 期间 shimmer 类/动画被摘,
+ // onAnimationEnd 不会到来。立即清零播放态,确保运行期关闭减弱动效后
+ // 下一次真实动静能重新触发呼吸,不必等 visible 先变 false。
+ if (!visible || suppressContent || reducedMotion) {
// 运行结束把播放态清零,下一轮 turn 的首次动静立即触发而不是误判在播。
shimmerPlayingRef.current = false;
shimmerPendingRef.current = false;
@@ -4400,7 +4403,7 @@ function RunningStatusBar({
}
shimmerPlayingRef.current = true;
setShimmerCycle((n) => n + 1);
- }, [visible, suppressContent, status, tokenUsage]);
+ }, [visible, suppressContent, reducedMotion, 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