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(sidebar): 置顶收起时才显示运行闪烁

Dash5ddbee421283
diff --git a/apps/desktop/src/renderer/features/cc-agent/sidebar/__tests__/pinnedRunningActivity.test.tsx b/apps/desktop/src/renderer/features/cc-agent/sidebar/__tests__/pinnedRunningActivity.test.tsx
index 0559d990eb..6252cd638f 100644
--- a/apps/desktop/src/renderer/features/cc-agent/sidebar/__tests__/pinnedRunningActivity.test.tsx
+++ b/apps/desktop/src/renderer/features/cc-agent/sidebar/__tests__/pinnedRunningActivity.test.tsx
@@ -68,7 +68,9 @@ afterEach(() => {
});
describe('pinned section running indicator', () => {
- it.each(['text', 'list', 'card'])('updates while expanded or collapsed in %s mode', (mode) => {
+ // Regression: an expanded PinnedSection with one running task must stay still.
+ // Existing unit coverage expected breathing in both states; exercise the real header toggle.
+ it.each(['text', 'list', 'card'])('only pulses while collapsed in %s mode', (mode) => {
view.mode = mode;
const entries = [entry(session('pinned'))];
const { container, rerender } = render(<PinnedSection {...props(entries)} />);
@@ -76,9 +78,13 @@ describe('pinned section running indicator', () => {
rerender(<PinnedSection {...props(entries, ['other'])} />);
expect(isRunning(container)).toBe(false);
rerender(<PinnedSection {...props(entries, ['pinned'])} />);
+ expect(isRunning(container)).toBe(false);
+ fireEvent.click(screen.getByRole('button', { name: 'ccAgent.sidebar.pinned' }));
expect(isRunning(container)).toBe(true);
expect(container.querySelector('svg.session-status-breathing')).toBeNull();
fireEvent.click(screen.getByRole('button', { name: 'ccAgent.sidebar.pinned' }));
+ expect(isRunning(container)).toBe(false);
+ fireEvent.click(screen.getByRole('button', { name: 'ccAgent.sidebar.pinned' }));
expect(isRunning(container)).toBe(true);
rerender(<PinnedSection {...props(entries)} />);
expect(isRunning(container)).toBe(false);
@@ -96,6 +102,8 @@ describe('pinned section running indicator', () => {
const { container, rerender } = render(
<PinnedSection {...props([projectEntry], ['child-24'])} />,
);
+ expect(isRunning(container)).toBe(false);
+ fireEvent.click(screen.getByRole('button', { name: 'ccAgent.sidebar.pinned' }));
expect(isRunning(container)).toBe(true);
rerender(<PinnedSection {...props([], ['child-24'])} />);
expect(container.innerHTML).toBe('');
@@ -110,6 +118,10 @@ describe('pinned section running indicator', () => {
expect(isRunning(container)).toBe(false);
act(() => applyRemoteSessionActivity('device-a', { sessionId: 'same', phase: 'running' }));
expect(isRunning(container)).toBe(true);
+ fireEvent.click(screen.getByRole('button', { name: 'ccAgent.sidebar.pinned' }));
+ expect(isRunning(container)).toBe(false);
+ fireEvent.click(screen.getByRole('button', { name: 'ccAgent.sidebar.pinned' }));
+ expect(isRunning(container)).toBe(true);
act(() =>
applyRemoteSessionActivity('device-a', { sessionId: 'same', phase: 'needs-interaction' }),
);
@@ -142,8 +154,9 @@ describe('pinned section running indicator', () => {
}
markSessionStarting(task.id);
const { container } = render(<StartingPinned />);
- expect(isRunning(container)).toBe(true);
+ expect(isRunning(container)).toBe(false);
fireEvent.click(screen.getByRole('button', { name: 'ccAgent.sidebar.pinned' }));
+ expect(isRunning(container)).toBe(true);
act(() => applyRemoteSessionActivity('device-b', { sessionId: task.id, phase: 'running' }));
expect(getStartingSessionIds().has(task.id)).toBe(true);
act(() => applyRemoteSessionActivity('device-a', { sessionId: task.id, phase: 'running' }));
diff --git a/apps/desktop/src/renderer/features/cc-agent/sidebar/sections/PinnedSection.tsx b/apps/desktop/src/renderer/features/cc-agent/sidebar/sections/PinnedSection.tsx
index 050c044d84..374ee15289 100644
--- a/apps/desktop/src/renderer/features/cc-agent/sidebar/sections/PinnedSection.tsx
+++ b/apps/desktop/src/renderer/features/cc-agent/sidebar/sections/PinnedSection.tsx
@@ -363,7 +363,7 @@ export function PinnedSection({
aria-hidden
className={cn(
'absolute left-1.5 inline-flex shrink-0',
- hasRunningSession
+ collapsed && hasRunningSession
? 'text-[var(--status-bar-accent)] session-status-breathing'
: 'text-[var(--sidebar-list-muted)]',
)}