Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
fix(sidebar): 收起时汇总状态点并保留待回复提示
Lizi9241529f1c3f
diff --git a/apps/desktop/src/renderer/__tests__/botGroupLampRendering.test.tsx b/apps/desktop/src/renderer/__tests__/botGroupLampRendering.test.tsxindex 416a07b447..1943ec402e 100644--- a/apps/desktop/src/renderer/__tests__/botGroupLampRendering.test.tsx+++ b/apps/desktop/src/renderer/__tests__/botGroupLampRendering.test.tsx@@ -24,7 +24,6 @@ vi.mock('../features/cc-agent/hooks/useRemoteHostProjectOrders', () => ({}));vi.mock('../features/cc-agent/sidebar/MainListScopeHeader', () => ({ MainListScopeHeader: ({ fold }: { fold: { label: string; onClick: () => void } | null }) => fold ? <button onClick={fold.onClick}>{fold.label}</button> : null }));vi.mock('@/components/sidebar/SortableList', () => ({ SortableList: () => null }));-vi.mock('../features/cc-agent/sidebar/sections/ProjectNode', () => ({ ProjectNode: () => null }));// main 633e27c76 起设备段头包了远程桌面快捷入口(挂 device-link presence 订阅,需要// preload 桥);本文件只验证段头灯语与折叠豁免,段头壳层直接透传子节点。vi.mock('../features/cc-agent/sidebar/DeviceSectionHeader', () => ({@@ -147,7 +146,7 @@ function expectLamp(header: Element, phase: typeof phases[number] | null) {expect(Boolean(header.querySelector('.session-status-breathing'))).toBe(phase === 'running');for (const tone of ['awaiting', 'error', 'done']) {const expected = phase === 'needs-interaction' ? 'awaiting' : phase === 'completed' ? 'done' : phase;- expect(Boolean(header.querySelector(`[class*="--card-status-${tone}"]`))).toBe(tone === expected);+ expect(Boolean(header.querySelector(`[class*="--card-status-${tone}"], [data-sidebar-right-status="${tone}"]`))).toBe(tone === expected);}}@@ -164,7 +163,7 @@ describe.each([false, true])('Bot starting lifecycle, device grouping %s', (grouexpect.soft(getStartingSessionIds().has('lit')).toBe(false);act(() => activity(terminal));expectLamp(botHeader(), terminal);- if (groupDevice) expectLamp(deviceHeader('Remote device'), terminal);+ if (groupDevice) expectLamp(deviceHeader('Remote device'), null);expect(screen.getByTestId('row-lit')).toBeTruthy();// No timer advancement: the terminal UI must be correct immediately.});@@ -211,6 +210,34 @@ function multiDeviceProps(): ProjectsSectionProps {}describe('Bot groups across devices', () => {+ it('keeps awaiting visible in a collapsed project while its device is expanded', () => {+ const p = props(true);+ const session = p.bots![0].sessions[2];+ const projectKey = 'device-link:remote:/demo';+ p.bots = [];+ p.projects = [{+ projectKey, displayName: 'Demo project', workingDir: '/demo', scope: 'local',+ sessions: [session], remoteHostId: null, deviceLinkDeviceId: 'remote',+ deviceLinkDeviceName: 'Remote device', deviceLinkConnectionStatus: 'connected',+ segments: 1, latestActivityAt: session.updatedAt,+ }];+ p.collapsed = new Set([projectKey]);+ activity('needs-interaction');+ const view = render(<ProjectsSection {...p} />);+ const projectHeader = () => screen.getByText('Demo project').closest('[data-project-header]')!;+ expectLamp(deviceHeader('Remote device'), null);+ expectLamp(projectHeader(), 'needs-interaction');+ expect(screen.queryByTestId('row-lit')).toBeNull();+ fireEvent.click(deviceHeader('Remote device'));+ expectLamp(deviceHeader('Remote device'), 'needs-interaction');+ fireEvent.click(deviceHeader('Remote device'));+ expectLamp(deviceHeader('Remote device'), null);+ expectLamp(projectHeader(), 'needs-interaction');+ view.rerender(<ProjectsSection {...p} collapsed={new Set()} />);+ expectLamp(projectHeader(), null);+ expect(screen.getByTestId('row-lit')).toBeTruthy();+ });+it.each(phases)('keeps %s lamps and exempt rows on the owning device', (phase) => {const p = multiDeviceProps();render(<ProjectsSection {...p} />);@@ -218,7 +245,7 @@ describe('Bot groups across devices', () => {expectLamp(deviceHeader('Device A'), null);const a = deviceHeader('Device A').parentElement!;const b = deviceHeader('Device B').parentElement!;- expectLamp(deviceHeader('Device B'), phase === 'running' ? null : phase);+ expectLamp(deviceHeader('Device B'), null);expectLamp(botHeader(a), null);expectLamp(botHeader(b), phase);expect(within(a).queryByTestId('row-lit')).toBeNull();@@ -235,7 +262,7 @@ describe('Bot groups across devices', () => {expectLamp(deviceHeader('Device B'), phase);fireEvent.click(deviceHeader('Device B'));expect(deviceHeader('Device B').getAttribute('aria-expanded')).toBe('true');- expectLamp(deviceHeader('Device B'), phase === 'running' ? null : phase);+ expectLamp(deviceHeader('Device B'), null);});it('keeps show-all state per device and stable across task reorder and Bot rename', () => {diff --git a/apps/desktop/src/renderer/__tests__/projectCollapsedAttention.test.ts b/apps/desktop/src/renderer/__tests__/projectCollapsedAttention.test.tsindex c53bb0ab57..dfe4bcb5e7 100644--- a/apps/desktop/src/renderer/__tests__/projectCollapsedAttention.test.ts+++ b/apps/desktop/src/renderer/__tests__/projectCollapsedAttention.test.ts@@ -210,9 +210,9 @@ describe('collapsed project attention wiring', () => {it('renders the aggregate status on the trailing slot while the project is collapsed', () => {const slotChrome = 'group/slot relative ml-auto flex h-6 shrink-0 items-center justify-end';const gridChrome = 'grid h-6 grid-cols-[max-content] items-center justify-items-end';- expect(projectNodeSource).toContain('isCollapsed && collapsedAttentionTone ? (');+ expect(projectNodeSource).toContain('isCollapsed && collapsedStatusTone ? (');expect(projectNodeSource).toContain(- '<SidebarRightStatusIndicator kind={collapsedAttentionTone} isActive={false} />',+ '<SidebarRightStatusIndicator kind={collapsedStatusTone} isActive={false} />',);expect(projectNodeSource).not.toContain('AttentionDot');expect(projectNodeSource).toContain(slotChrome);@@ -224,7 +224,7 @@ describe('collapsed project attention wiring', () => {);const trailingSlot = projectNodeSource.indexOf(slotChrome);const indicator = projectNodeSource.indexOf(- '<SidebarRightStatusIndicator kind={collapsedAttentionTone} isActive={false} />',+ '<SidebarRightStatusIndicator kind={collapsedStatusTone} isActive={false} />',);expect(nameSpan).toBeGreaterThan(0);expect(trailingSlot).toBeGreaterThan(nameSpan);diff --git a/apps/desktop/src/renderer/__tests__/projectLampMerge.test.tsx b/apps/desktop/src/renderer/__tests__/projectLampMerge.test.tsxindex 3b8150ba39..d354b10087 100644--- a/apps/desktop/src/renderer/__tests__/projectLampMerge.test.tsx+++ b/apps/desktop/src/renderer/__tests__/projectLampMerge.test.tsx@@ -77,13 +77,30 @@ describe('project lamp after upstream sidebar merge', () => {expect(header.querySelector('.session-status-breathing')).not.toBeNull();});- it('leaves expanded project attention and running state to its child rows', () => {+ it.each([null, 'done', 'error'] as const)(+ 'shows awaiting ahead of %s unless an error needs attention',+ (collapsedAttentionTone) => {+ const { container } = render(+ <ProjectNode+ {...props()}+ collapsedAttentionTone={collapsedAttentionTone}+ lamp={{ running: false, dotTone: 'awaiting' }}+ />,+ );+ const header = container.querySelector('[data-project-header]')!;+ const tone = collapsedAttentionTone === 'error' ? 'error' : 'awaiting';+ expect(header.querySelector(`[data-sidebar-right-status="${tone}"]`)).not.toBeNull();+ expect(header.querySelectorAll('.rounded-full')).toHaveLength(1);+ },+ );++ it.each(['error', 'awaiting', 'done'] as const)('leaves expanded project %s attention and running state to its child rows', (dotTone) => {const { container } = render(<ProjectNode{...props()}isCollapsed={false}collapsedAttentionTone="error"- lamp={{ running: true, dotTone: 'error' }}+ lamp={{ running: true, dotTone }}/>,);const header = container.querySelector('[data-project-header]')!;diff --git a/apps/desktop/src/renderer/features/cc-agent/lib/automationSidebarGrouping.ts b/apps/desktop/src/renderer/features/cc-agent/lib/automationSidebarGrouping.tsindex 14f82af3d6..1e867adfac 100644--- a/apps/desktop/src/renderer/features/cc-agent/lib/automationSidebarGrouping.ts+++ b/apps/desktop/src/renderer/features/cc-agent/lib/automationSidebarGrouping.ts@@ -214,9 +214,9 @@ export interface AutomationGroupChildViewOptions {/** 轴 1(文件夹开/关)的收起态。收起时只渲染 alertSessionIds 命中的运行,见下方 ⚠️。 */collapsed?: boolean;/**- * 收起态仍要保留可见的**未处理告警**运行 id,来源是+ * 收起态仍要保留可见的错误告警与待回复运行 id。错误来源是* `sidebar/projectCollapsedAttention.ts` 的 `resolveCollapsedAttention().errorSessionIds`- * —— 与组头红点、项目折叠头红点同一份判据。+ * —— 与组头红点、项目折叠头红点同一份判据;待回复由组件按本地/远程活动补入。*/alertSessionIds?: ReadonlySet<string>;/**@@ -241,7 +241,8 @@ export interface AutomationGroupChildViewOptions {* 成行。原因是「组头只代表最新一条」+「收起时子行整片不渲染」叠起来会藏掉告警 ——* 项目折叠头按全部子任务汇总出红点,用户展开项目却在任何一行上都看不到它* (实测:一条被 App 重启打断、turn 从未收尾的定时任务运行)。告警行与组头红点同源- * (alertSessionIds ← resolveCollapsedAttention),所以不可能出现「汇总说有、列表没有」。+ * (错误 id ← resolveCollapsedAttention),待回复运行也由组件并入 alertSessionIds,+ * 避免上层展开后提示消失。* 这也是折叠上限里「需关注的条目始终显示」那条不变量本来就该覆盖的路径。* 收起态刻意不套 24h / active 豁免:此时列表的语义是"只列要你处理的",* 把非告警运行放进来会让收起形同失效。diff --git a/apps/desktop/src/renderer/features/cc-agent/sidebar/AutomationSessionGroupItem.tsx b/apps/desktop/src/renderer/features/cc-agent/sidebar/AutomationSessionGroupItem.tsxindex 3961481e45..02e86a06ae 100644--- a/apps/desktop/src/renderer/features/cc-agent/sidebar/AutomationSessionGroupItem.tsx+++ b/apps/desktop/src/renderer/features/cc-agent/sidebar/AutomationSessionGroupItem.tsx@@ -192,10 +192,22 @@ export const AutomationSessionGroupItem = withSidebarNavigation<AutomationSessiorunningSessionIds,],);- const alertSessionIds = useMemo(- () => new Set(collapsedAttention.errorSessionIds),- [collapsedAttention],- );+ // 收起组还需露出等待回复的旧运行,承接上层展开后下放的提示;组头仍代理最新运行。+ const alertSessionIds = useMemo(() => {+ const ids = new Set(collapsedAttention.errorSessionIds);+ for (const session of group.sessions) {+ const remotePhase = groupRemotePhases.get(session.id);+ if (+ remotePhase === 'needs-interaction' ||+ (!remotePhase &&+ notifications.has(session.id) &&+ groupAttentionKinds.get(session.id) === 'awaiting')+ ) {+ ids.add(session.id);+ }+ }+ return ids;+ }, [collapsedAttention, group.sessions, groupRemotePhases, notifications, groupAttentionKinds]);// 与组头红/绿未读点同源:没有未读就不提供「标为已读」,避免空操作占菜单。const canMarkRead = collapsedAttention.tone != null;// childView 的 24h 豁免依赖实时 now,必须每次渲染直接算,不能进 useMemo —— 否则依赖项diff --git a/apps/desktop/src/renderer/features/cc-agent/sidebar/__tests__/automationGroupCollapsedAlerts.test.tsx b/apps/desktop/src/renderer/features/cc-agent/sidebar/__tests__/automationGroupCollapsedAlerts.test.tsxindex 089a2b2124..27b163118a 100644--- a/apps/desktop/src/renderer/features/cc-agent/sidebar/__tests__/automationGroupCollapsedAlerts.test.tsx+++ b/apps/desktop/src/renderer/features/cc-agent/sidebar/__tests__/automationGroupCollapsedAlerts.test.tsx@@ -15,11 +15,15 @@*/import { createElement, useState } from 'react';-import { cleanup, fireEvent, render, screen } from '@testing-library/react';+import { act, cleanup, fireEvent, render, screen } from '@testing-library/react';import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';import type { Session } from '@/lib/ccAgent.types';import { addSessionAttention, clearSessionAttention } from '@/lib/sessionAttentionStore';+import {+ applyRemoteSessionActivity,+ clearRemoteSessionActivity,+} from '@/features/device-link/remoteSessionActivityStore';// ── mocks:剥离与「收起态告警可见性」无关的重依赖 ─────────────────────────────@@ -177,6 +181,7 @@ const childRunIds = (container: HTMLElement): string[] =>afterEach(() => {cleanup();+ clearRemoteSessionActivity();for (const id of ALL_IDS) clearSessionAttention(id, { intent: 'explicit' });});@@ -232,12 +237,32 @@ describe('AutomationSessionGroupItem — 收起态的未处理告警', () => {expect(onSessionClick).not.toHaveBeenCalledWith('run-0');});- it('等待回复(蓝)不升格成组头状态,也不提行', () => {+ it('等待回复的旧运行单独成行,组头仍代表最新运行', () => {addSessionAttention('run-2', 'awaiting');const { container } = renderGroup({ notifications: ['run-2'] });expect(screen.queryByLabelText('Failed — click to view')).toBeNull();expect(screen.queryByLabelText('Awaiting your input')).toBeNull();+ expect(childRunIds(container)).toEqual(['run-2']);+ act(() => clearSessionAttention('run-2', { intent: 'explicit' }));+ expect(childRunIds(container)).toEqual([]);+ });++ it('远程旧运行等待回复时也成行,远程运行态压过本地残留的待回复', () => {+ const sessions = RUNS.map((run) => ({ ...run, deviceLinkDeviceId: 'remote' }));+ addSessionAttention('run-2', 'awaiting');+ applyRemoteSessionActivity('remote', {+ sessionId: 'run-2', phase: 'needs-interaction', attention: true, compactDetail: '',+ });+ const { container, rerender } = renderGroup({ sessions });+ expect(childRunIds(container)).toEqual(['run-2']);+ expect(screen.queryByLabelText('Awaiting your input')).toBeNull();+ act(() => applyRemoteSessionActivity('remote', {+ sessionId: 'run-2', phase: 'running', attention: false, compactDetail: '',+ }));+ rerender(createElement(GroupHarness, {+ sessions, notifications: ['run-2'], urgentSessionIds: new Set<string>(), initialCollapsed: true,+ }));expect(childRunIds(container)).toEqual([]);});diff --git a/apps/desktop/src/renderer/features/cc-agent/sidebar/sections/ProjectNode.tsx b/apps/desktop/src/renderer/features/cc-agent/sidebar/sections/ProjectNode.tsxindex dfdf99a3c1..f19f577b58 100644--- a/apps/desktop/src/renderer/features/cc-agent/sidebar/sections/ProjectNode.tsx+++ b/apps/desktop/src/renderer/features/cc-agent/sidebar/sections/ProjectNode.tsx@@ -95,7 +95,7 @@ export interface ProjectNodeProps {hideRemoteMachineLabel?: boolean;/*** 项目行运行灯:仅收起时文件夹图标呼吸橙,展开后由子任务提示运行状态。- * 未读仍走 collapsedAttentionTone 右侧状态槽,不在标题旁重复显示。+ * 未读仍走右侧状态槽;待回复蓝点由 lamp 补齐,不在标题旁重复显示。* 聚合集合由父层按实际渲染的会话提供。*/lamp?: SessionLampAggregate;@@ -300,6 +300,13 @@ const ProjectHeader = memo(function ProjectHeader({// 常驻在标题左侧;展开/收起指示箭头移到标题右侧、hover 才渐显(见下方 Chevron)。const FolderIcon = isCollapsed ? Folder : FolderOpen;const Chevron = isCollapsed ? ChevronRight : ChevronDown;+ // 红绿汇总保留既有判据;收起文件夹还需承接机器展开后下放的待回复提示。+ const collapsedStatusTone =+ collapsedAttentionTone === 'error'+ ? 'error'+ : lamp?.dotTone === 'awaiting'+ ? 'awaiting'+ : collapsedAttentionTone;// 右键菜单:参照 ChatImageView 的 controlled DropdownMenu + 隐形定位 trigger 模式,// 鼠标点击位置即菜单出现位置。const [menuPos, setMenuPos] = useState<{ x: number; y: number } | null>(null);@@ -512,7 +519,7 @@ const ProjectHeader = memo(function ProjectHeader({{!isEditingName && (<div className="group/slot relative ml-auto flex h-6 shrink-0 items-center justify-end"><div className="grid h-6 grid-cols-[max-content] items-center justify-items-end">- {isCollapsed && collapsedAttentionTone ? (+ {isCollapsed && collapsedStatusTone ? (<divclassName={cn('col-start-1 row-start-1 flex items-center gap-1',@@ -521,7 +528,7 @@ const ProjectHeader = memo(function ProjectHeader({menuPos !== null && 'opacity-0',)}>- <SidebarRightStatusIndicator kind={collapsedAttentionTone} isActive={false} />+ <SidebarRightStatusIndicator kind={collapsedStatusTone} isActive={false} /></div>) : null}<divdiff --git a/apps/desktop/src/renderer/features/cc-agent/sidebar/sections/ProjectsSection.tsx b/apps/desktop/src/renderer/features/cc-agent/sidebar/sections/ProjectsSection.tsxindex 70bc2149a9..f64e6b59d3 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@@ -1112,8 +1112,8 @@ export function ProjectsSection({: t('ccAgent.sidebar.deviceGroup.local');const online = section.deviceId ? (device?.online ?? false) : true;const sectionCollapsed = collapsedDevices.has(key);- // 设备层聚合灯:聚合本段全部条目的会话(与段内渲染一致)。顶层- // 也要有灯,否则未读藏在折叠段/折叠上限之外时只能逐段展开翻找。+ // 设备层聚合灯:聚合本段全部条目的会话(与段内渲染一致)。+ // 仅收起时显示运行态与未读点,展开后由下层内容提示。const sectionLamp = lampAgg(section.entries.flatMap(entrySessions));return (<div key={key} className="flex flex-col gap-1">@@ -1158,10 +1158,10 @@ export function ProjectsSection({)}{/* 条数已去掉(2026-08-12 用户裁决):它数的是顶层条目(项目行 + 散排对话 + 对话组),不是任务数,读起来只会误导;- 段展开后内容本身就是答案。右侧改为灯组:聚合未读点- (段级 size 6,rail 段钮同款)+ 离线标注。 */}+ 段展开后内容本身就是答案。右侧改为灯组:仅收起时显示聚合未读点+ (段级 size 6,rail 段钮同款);离线标注始终保留。 */}<span className="ml-auto flex shrink-0 items-center gap-1.5">- {sectionLamp.dotTone && (+ {sectionCollapsed && sectionLamp.dotTone && (<AttentionDot size={6} tone={sectionLamp.dotTone} />)}{!online && (