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): 仅收起分组时显示汇总状态

Liziee103d473aac
diff --git a/apps/desktop/src/renderer/__tests__/botGroupLampRendering.test.tsx b/apps/desktop/src/renderer/__tests__/botGroupLampRendering.test.tsx
index 1943ec402e..685daad20d 100644
--- a/apps/desktop/src/renderer/__tests__/botGroupLampRendering.test.tsx
+++ b/apps/desktop/src/renderer/__tests__/botGroupLampRendering.test.tsx
@@ -85,11 +85,13 @@ function activity(phase: typeof phases[number]) {
}
describe.each([false, true])('Bot groups with device grouping %s', (groupDevice) => {
- it.each(phases)('renders the Bot header lamp for remote %s', (phase) => {
+ it.each(phases)('renders the collapsed Bot header lamp for remote %s', (phase) => {
activity(phase);
render(<ProjectsSection {...props(groupDevice)} />);
expect(Boolean(screen.queryByText('Remote device'))).toBe(groupDevice);
const header = screen.getByText('Demo Bot').closest('[role="button"]')!;
+ expectLamp(header, null);
+ fireEvent.click(header);
if (phase === 'running') {
expect(header.querySelector('.session-status-breathing')).not.toBeNull();
// 伙伴头像不吃 wrapper 的 currentColor,运行色必须以静态描边落在 wrapper 上,
@@ -113,18 +115,20 @@ describe.each([false, true])('Bot groups with device grouping %s', (groupDevice)
expect(screen.getByText('ccAgent.sidebar.showAllSessions')).toBeTruthy();
});
- it('updates the rendered group on remote activity and retains its lamp across collapse/expand', () => {
+ it('updates the rendered group on remote activity and shows its header lamp only while collapsed', () => {
render(<ProjectsSection {...props(groupDevice)} />);
expect(screen.queryByTestId('row-lit')).toBeNull();
const header = screen.getByText('Demo Bot').closest('[role="button"]')!;
expect(header.querySelector('.session-status-breathing')).toBeNull();
act(() => activity('running'));
expect(screen.queryByTestId('row-lit')).not.toBeNull();
+ expectLamp(header, null);
fireEvent.click(header);
expect(header.getAttribute('aria-expanded')).toBe('false');
expect(header.querySelector('.session-status-breathing')).not.toBeNull();
fireEvent.click(header);
expect(header.getAttribute('aria-expanded')).toBe('true');
+ expectLamp(header, null);
expect(screen.queryByTestId('row-lit')).not.toBeNull();
act(() => clearRemoteSessionActivity());
expect(screen.queryByTestId('row-lit')).toBeNull();
@@ -158,12 +162,16 @@ describe.each([false, true])('Bot starting lifecycle, device grouping %s', (grou
remoteProjectsStore.pinSessionOrigin('remote', 'lit');
markSessionStarting('lit');
render(<StartingSidebar {...p} />);
+ expectLamp(botHeader(), null);
+ fireEvent.click(botHeader());
expectLamp(botHeader(), 'running');
act(() => activity(first));
expect.soft(getStartingSessionIds().has('lit')).toBe(false);
act(() => activity(terminal));
expectLamp(botHeader(), terminal);
if (groupDevice) expectLamp(deviceHeader('Remote device'), null);
+ fireEvent.click(botHeader());
+ expectLamp(botHeader(), null);
expect(screen.getByTestId('row-lit')).toBeTruthy();
// No timer advancement: the terminal UI must be correct immediately.
});
@@ -178,6 +186,7 @@ describe.each([false, true])('Bot starting lifecycle, device grouping %s', (grou
expect(getStartingSessionIds().has('lit')).toBe(true);
view.rerender(<StartingSidebar {...p} />);
expect(getStartingSessionIds().has('lit')).toBe(false);
+ fireEvent.click(botHeader());
act(() => activity('completed'));
expectLamp(botHeader(), 'completed');
});
@@ -247,7 +256,11 @@ describe('Bot groups across devices', () => {
const b = deviceHeader('Device B').parentElement!;
expectLamp(deviceHeader('Device B'), null);
expectLamp(botHeader(a), null);
+ expectLamp(botHeader(b), null);
+ fireEvent.click(botHeader(b));
expectLamp(botHeader(b), phase);
+ fireEvent.click(botHeader(b));
+ expectLamp(botHeader(b), null);
expect(within(a).queryByTestId('row-lit')).toBeNull();
expect(within(b).getByTestId('row-lit')).toBeTruthy();
expect(screen.getAllByText('Demo Bot')).toHaveLength(2);
diff --git a/apps/desktop/src/renderer/features/cc-agent/sidebar/sections/ProjectsSection.tsx b/apps/desktop/src/renderer/features/cc-agent/sidebar/sections/ProjectsSection.tsx
index f64e6b59d3..b113d268a3 100644
--- a/apps/desktop/src/renderer/features/cc-agent/sidebar/sections/ProjectsSection.tsx
+++ b/apps/desktop/src/renderer/features/cc-agent/sidebar/sections/ProjectsSection.tsx
@@ -960,6 +960,7 @@ export function ProjectsSection({
/>
}
groupTitle={entry.bot.displayName}
+ groupRunningMarker="ring"
createLabel={t('bots.sidebar.newTaskWith', { name: entry.bot.displayName })}
collapsed={isCollapsed}
onToggle={() => setDialogueCollapsed([groupKey], !isCollapsed)}
@@ -1279,6 +1280,7 @@ export function SessionGroupNode({
onToggle,
onCreateDialogue,
groupIcon,
+ groupRunningMarker = 'icon',
groupTitle,
createLabel,
isCreateDisabled,
@@ -1301,7 +1303,7 @@ export function SessionGroupNode({
sessionVariant,
}: {
sessions: Session[];
- /** 组头聚合灯(ProjectNode.lamp 同款语义):running → 图标呼吸橙;
+ /** 仅收起时显示组头聚合灯(ProjectNode.lamp 同款语义):running → 图标呼吸橙;
* dotTone → 标题右侧 AttentionDot。聚合集合 = 组内会话(与渲染一致)。 */
lamp?: SessionLampAggregate;
/** 透传给组内 SessionEntryList 的折叠豁免追加集合(语义见其 prop 注释)。 */
@@ -1315,6 +1317,8 @@ export function SessionGroupNode({
* 而不是复制一份 100 行的组件出来。
*/
groupIcon?: ReactNode;
+ /** 仅不继承 currentColor 的头像需要运行色描边;线条图标直接变色。 */
+ groupRunningMarker?: 'icon' | 'ring';
groupTitle?: string;
/** 新建按钮的 tooltip / aria 文案。省略 = 「新建对话」。 */
createLabel?: string;
@@ -1346,6 +1350,7 @@ export function SessionGroupNode({
const { t } = useTranslation();
// 与 ProjectNode 同款:标题右侧 hover 渐显的展开/收起指示箭头。
const Chevron = collapsed ? ChevronRight : ChevronDown;
+ const showRunning = collapsed && lamp?.running;
return (
<div className="relative flex w-full select-none flex-col" data-no-drag>
{/* 段头:与 ProjectNode Header 同款规格(h-8 药丸 hover / pl-3 pr-1 /
@@ -1368,21 +1373,20 @@ export function SessionGroupNode({
'transition-colors hover:bg-sidebar-item-hover',
)}
>
- {/* 灯语与 ProjectNode 表头同款:running → 呼吸橙(动画挂 wrapper)。
- 伙伴组头的 groupIcon 是 BotAvatar:头像自带内联身份色与文字色,不继承
- wrapper 的 currentColor,呼吸也只是身份色头像在闪;reduce-motion 停掉动画后
- 就什么运行标记都没有(Codex review)。因此有 groupIcon 时另加一圈运行色
- 描边——静态、走 --status-bar-accent、与减弱动效无关;线条图标路径仍靠
- currentColor,不需要描边。 */}
+ {/* 与 ProjectNode 一致,仅收起时汇总运行态(动画挂 wrapper)。
+ 伙伴头像不继承 currentColor,显式使用静态运行色描边以兼容减弱动效;
+ Cindy Make 等线条图标直接继承运行色,不加描边。 */}
<span
className={cn(
'inline-flex shrink-0',
- lamp?.running
+ showRunning
? 'text-[var(--status-bar-accent)] session-status-breathing'
: 'text-[var(--sidebar-list-muted)]',
- lamp?.running && groupIcon && 'rounded-full ring-2 ring-[var(--status-bar-accent)]',
+ showRunning &&
+ groupRunningMarker === 'ring' &&
+ 'rounded-full ring-2 ring-[var(--status-bar-accent)]',
)}
- data-running-marker={lamp?.running ? (groupIcon ? 'ring' : 'icon') : undefined}
+ data-running-marker={showRunning ? groupRunningMarker : undefined}
>
{groupIcon ?? <MessagesSquare size={15} strokeWidth={1.8} aria-hidden />}
</span>
@@ -1390,8 +1394,10 @@ export function SessionGroupNode({
<span className="min-w-0 shrink truncate">
{groupTitle ?? t('ccAgent.sidebar.dialogues')}
</span>
- {/* 聚合未读点:ProjectNode 表头同款(size 5,静态,常驻可见)。 */}
- {lamp?.dotTone && <AttentionDot size={5} tone={lamp.dotTone} className="shrink-0" />}
+ {/* 聚合未读点与 ProjectNode 一致,仅收起时显示。 */}
+ {collapsed && lamp?.dotTone && (
+ <AttentionDot size={5} tone={lamp.dotTone} className="shrink-0" />
+ )}
<Chevron
size={13}
strokeWidth={2}