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。

feat(sidebar): 未读聚合灯补全到项目行/对话组/设备段头 (#2938)

FicoWang2fb198027177
diff --git a/apps/desktop/src/renderer/__tests__/automationGeneratedSessions.test.ts b/apps/desktop/src/renderer/__tests__/automationGeneratedSessions.test.ts
index e7a075882a..456a1b40d9 100644
--- a/apps/desktop/src/renderer/__tests__/automationGeneratedSessions.test.ts
+++ b/apps/desktop/src/renderer/__tests__/automationGeneratedSessions.test.ts
@@ -595,6 +595,77 @@ describe('automation-generated sessions', () => {
).toEqual(['jira-3', 'jira-2', 'jira-1']);
});
+ // review P2(#2938):上层聚合灯为远程活动点亮的子运行,不能藏在「显示全部」后。
+ // 远程 running / 未读不在本地 notifications / runningSessionIds 里,父层通过
+ // foldExemptSessionIds 并入,自动化组的展开态折叠也要认这份豁免。
+ it('keeps remote-lamp exempt automation children visible in the expanded fold', () => {
+ const sessions = Array.from({ length: 7 }, (_, index) =>
+ makeSession({ id: `run-${index}`, title: `RUN-${index}`, source: 'scheduler' }),
+ );
+ const group = { id: 'schedule:sched-remote', title: 'Remote', sessions, attentionSessionIds: [] };
+
+ const withoutExempt = getAutomationGroupChildView(group, {
+ notifications: new Set(),
+ runningSessionIds: new Set(),
+ showAll: false,
+ });
+ expect(withoutExempt.visibleSessions.map((session) => session.id)).not.toContain('run-6');
+
+ const view = getAutomationGroupChildView(group, {
+ notifications: new Set(),
+ runningSessionIds: new Set(),
+ foldExemptSessionIds: new Set(['run-6']),
+ showAll: false,
+ });
+ expect(view.visibleSessions.map((session) => session.id)).toContain('run-6');
+ expect(view.isOverflowing).toBe(true);
+ expect(view.hiddenCount).toBe(1);
+ });
+
+ it('merges newly exempt remote runs into a frozen layout without moving its clicked rows', () => {
+ const sessions = Array.from({ length: 7 }, (_, index) =>
+ makeSession({ id: `run-${index}`, source: 'scheduler' }),
+ );
+ const group = { id: 'schedule:remote-frozen', title: 'Remote', sessions, attentionSessionIds: [] };
+ const options = { notifications: new Set<string>(), showAll: false,
+ frozenVisibleSessionIds: ['run-2', 'run-0'], activeSessionId: 'run-2' };
+ const before = getAutomationGroupChildView(group, options);
+ expect(before.visibleSessions.map((session) => session.id)).toEqual(['run-2', 'run-0']);
+ const view = getAutomationGroupChildView(group, {
+ ...options, foldExemptSessionIds: new Set(['run-0', 'run-6', 'other-group']),
+ });
+ expect(view.visibleSessions.map((session) => session.id)).toEqual(['run-2', 'run-0', 'run-6']);
+ expect(view.isOverflowing).toBe(true);
+ expect(view.hiddenCount).toBe(4);
+ expect(view.totalCount).toBe(7);
+ expect(getAutomationGroupChildView(group, { ...options, showAll: true }).visibleSessions)
+ .toEqual(sessions);
+ });
+
+ it.each(['unread', 'running'])('keeps newly %s local runs visible in frozen layouts without remote exemptions', (activity) => {
+ const sessions = ['clicked', 'idle', 'active'].map((id) => makeSession({ id, source: 'scheduler' }));
+ const group = { id: 'schedule:local-frozen', title: 'Local', sessions, attentionSessionIds: [] };
+ const view = getAutomationGroupChildView(group, {
+ notifications: new Set(activity === 'unread' ? ['clicked', 'active', 'other-group'] : []),
+ runningSessionIds: new Set(activity === 'running' ? ['clicked', 'active', 'other-group'] : []),
+ showAll: false, frozenVisibleSessionIds: ['clicked'],
+ });
+ expect(view.visibleSessions.map((session) => session.id)).toEqual(['clicked', 'active']);
+ expect(view.hiddenCount).toBe(1);
+ expect(view.isOverflowing).toBe(true);
+ });
+
+ it('keeps overflow available when a frozen layout still hides idle runs', () => {
+ const sessions = ['visible', 'hidden'].map((id) => makeSession({ id, source: 'scheduler' }));
+ const group = { id: 'schedule:frozen-overflow', title: 'Frozen', sessions, attentionSessionIds: [] };
+ const view = getAutomationGroupChildView(group, {
+ notifications: new Set(), showAll: false, frozenVisibleSessionIds: ['visible', 'removed'],
+ });
+ expect(view.visibleSessions).toEqual([sessions[0]]);
+ expect(view.isOverflowing).toBe(true);
+ expect(view.hiddenCount).toBe(1);
+ });
+
it('caps collapsed automation children at five and overflows the rest like the dialogue list', () => {
const sessions = Array.from({ length: 7 }, (_, index) =>
makeSession({ id: `run-${index}`, title: `RUN-${index}`, source: 'scheduler' }),
@@ -794,7 +865,7 @@ describe('automation-generated sessions', () => {
activeSessionId: 'manual',
frozenVisibleSessionIds: ['jira-1'],
}).map((session) => session.id),
- ).toEqual(['jira-1']);
+ ).toEqual(['jira-1', 'jira-2']);
expect(
getAutomationGroupPrimarySession(group, new Set(['jira-2']), {
preferredSessionId: 'jira-2',
@@ -808,7 +879,7 @@ describe('automation-generated sessions', () => {
activeSessionId: 'jira-1',
frozenVisibleSessionIds: ['jira-1'],
}).map((session) => session.id),
- ).toEqual(['jira-1']);
+ ).toEqual(['jira-1', 'jira-2']);
});
it('freezes the group primary while the clicked automation session is active', () => {
diff --git a/apps/desktop/src/renderer/__tests__/botGroupLampRendering.test.tsx b/apps/desktop/src/renderer/__tests__/botGroupLampRendering.test.tsx
new file mode 100644
index 0000000000..74631314e2
--- /dev/null
+++ b/apps/desktop/src/renderer/__tests__/botGroupLampRendering.test.tsx
@@ -0,0 +1,276 @@
+// @vitest-environment jsdom
+
+import type { ReactNode } from 'react';
+import { act, cleanup, fireEvent, render, screen, within } from '@testing-library/react';
+import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
+import { getStartingSessionIds, markSessionStarting, resetSessionStartingStoreForTests, useStartingSessionIds } from '@/lib/sessionStartingStore';
+import { remoteProjectsStore } from '@/features/device-link/remoteProjectsStore';
+import type { Session } from '@/lib/ccAgent.types';
+import {
+ applyRemoteSessionActivity,
+ clearRemoteSessionActivity,
+} from '@/features/device-link/remoteSessionActivityStore';
+import { ProjectsSection, type ProjectsSectionProps } from '../features/cc-agent/sidebar/sections/ProjectsSection';
+
+vi.mock('react-i18next', () => ({ useTranslation: () => ({ t: (key: string) => key }) }));
+vi.mock('@/components/ui/tooltip', () => ({ Tip: ({ children }: { children: ReactNode }) => children }));
+vi.mock('@/features/device-link/useMachineSwitcher', () => ({ useEffectiveSelectedMachineId: () => 'all' }));
+vi.mock('@/hooks/useReducedMotion', () => ({ useReducedMotion: () => true }));
+vi.mock('@/hooks/useSidebarCardMode', () => ({ useSidebarMainViewMode: () => ({ mode: 'text' }) }));
+vi.mock('../features/cc-agent/hooks/useRemoteHostProjectOrders', () => ({
+ projectOrderWriteScopeForSelection: () => ({ kind: 'viewer' }),
+ useLocalHostProjectOrder: () => ({ snapshot: { manualProjectOrder: [] } }),
+ useRemoteHostProjectOrders: () => ({ orders: new Map() }),
+}));
+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', () => ({
+ DeviceSectionHeader: ({ children }: { children: ReactNode }) => <>{children}</>,
+}));
+vi.mock('../features/cc-agent/sidebar/sections/UnclassifiedSection', () => ({ UnclassifiedSection: () => null }));
+vi.mock('@/features/bots/BotAvatar', () => ({ BotAvatar: () => <span>Bot avatar</span> }));
+// Keep ProjectsSection, its private SessionGroupNode, SessionEntryList, collapse model,
+// lamp aggregation and remote store real. Only unrelated services/leaf rows are stubbed.
+vi.mock('../features/cc-agent/sidebar/SessionItem', () => ({
+ SessionItem: ({ session, onClick }: { session: Session; onClick: (id: string) => void }) => <button data-testid={`row-${session.id}`} onClick={() => onClick(session.id)}>{session.title}</button>,
+}));
+vi.mock('../features/cc-agent/sidebar/SessionCard', () => ({ SessionCard: () => null }));
+vi.mock('../features/cc-agent/sidebar/AutomationSessionGroupItem', () => ({ AutomationSessionGroupItem: () => null }));
+
+function props(groupDevice: boolean): ProjectsSectionProps {
+ const sessions = ['first', 'idle', 'lit'].map((id, i) => ({
+ id, title: id, status: 'active', createdAt: `2026-09-0${3 - i}T00:00:00Z`,
+ updatedAt: `2026-09-0${3 - i}T00:00:00Z`, deviceLinkDeviceId: 'remote',
+ } as Session));
+ return {
+ unclassified: [], projects: [], dialogues: [], allKnownProjects: [], allProjectKeysForOrder: ['local:known-project'],
+ bots: [{ botId: 'demo', displayName: 'Demo Bot', avatar: '', avatarColor: '', sessions, latestActivityAt: sessions[0].updatedAt }],
+ filter: {
+ groupBy: 'project', groupDialogue: true, groupDevice, sortBy: 'recency',
+ projectOrder: 'activity', manualProjectOrder: [], projects: 'all', status: 'active', isFilterActive: false,
+ projectsAsSet: null, isSessionContentFiltered: false, vendor: 'all', lastActivity: 'all', manualPinnedOrder: [],
+ setStatus: vi.fn(), toggleProject: vi.fn(), ensureProjectIncluded: vi.fn(), setProjectsAll: vi.fn(), gc: vi.fn(),
+ setVendor: vi.fn(), setLastActivity: vi.fn(), setGroupBy: vi.fn(), setGroupDialogue: vi.fn(), setGroupDevice: vi.fn(),
+ setSortBy: vi.fn(), setProjectOrder: vi.fn(), resetContentFilters: vi.fn(), setManualProjectOrder: vi.fn(),
+ setManualPinnedOrder: vi.fn(), promotePin: vi.fn(), removePin: vi.fn(),
+ },
+ collapsed: new Set(), isAllCollapsed: false, runningSessionIds: new Set(), attachedSessionIds: new Set(),
+ notifications: new Set(), scheduleSessionIndex: new Map(),
+ remoteDeviceIndex: new Map([['remote', { name: 'Remote device', online: true }]]),
+ onSessionClick: vi.fn(), onAction: vi.fn(), onRename: vi.fn(), onTogglePin: vi.fn(), onScheduleAction: vi.fn(),
+ onToggleProject: vi.fn(), onToggleProjectPin: vi.fn(), onRenameProject: vi.fn(), onRemoveFromSidebar: vi.fn(),
+ onCollapseAll: vi.fn(), onExpandAll: vi.fn(), onCreateInProject: vi.fn(), onOpenConversationSearch: vi.fn(),
+ onOpenInExplorer: vi.fn(), onLinkCodexProject: vi.fn(), linkingCodexProject: null, onBrowseFiles: vi.fn(),
+ onArchiveAll: vi.fn(), onCreateDialogue: vi.fn(),
+ };
+}
+
+beforeEach(() => {
+ localStorage.clear();
+ localStorage.setItem('sidebar.collapse.projectSessionLimit', '1');
+ // ProjectsSection 渲染时读 window.electronAPI.platform 做项目键比较(main 897de9031);
+ // jsdom 没有 preload 桥,这里只补 platform 字段,与 windowCloseBehavior 用例同法。
+ Object.defineProperty(window, 'electronAPI', {
+ configurable: true,
+ value: { platform: 'darwin' } as unknown as Window['electronAPI'],
+ });
+});
+afterEach(() => { remoteProjectsStore.__resetPinnedOriginsForTest(); cleanup(); resetSessionStartingStoreForTests(); vi.useRealTimers(); clearRemoteSessionActivity(); localStorage.clear(); });
+
+const phases = ['running', 'needs-interaction', 'error', 'completed'] as const;
+function activity(phase: typeof phases[number]) {
+ applyRemoteSessionActivity('remote', { sessionId: 'lit', phase, attention: true, compactDetail: '' });
+}
+
+describe.each([false, true])('Bot groups with device grouping %s', (groupDevice) => {
+ it.each(phases)('renders the 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"]')!;
+ if (phase === 'running') {
+ expect(header.querySelector('.session-status-breathing')).not.toBeNull();
+ // 伙伴头像不吃 wrapper 的 currentColor,运行色必须以静态描边落在 wrapper 上,
+ // 减弱动效(动画被全局关掉)时仍可见(Codex review)。
+ const marker = header.querySelector('[data-running-marker]')!;
+ expect(marker.getAttribute('data-running-marker')).toBe('ring');
+ expect(marker.className).toContain('ring-[var(--status-bar-accent)]');
+ } else {
+ expect(header.querySelector('[data-running-marker]')).toBeNull();
+ const tone = phase === 'needs-interaction' ? 'awaiting' : phase === 'error' ? 'error' : 'done';
+ expect(header.querySelector(`[class*="--card-status-${tone}"]`)).not.toBeNull();
+ }
+ });
+
+ it.each(phases)('reveals the remote %s row beyond the group limit without Show all', (phase) => {
+ activity(phase);
+ render(<ProjectsSection {...props(groupDevice)} />);
+ expect(screen.getByTestId('row-first')).toBeTruthy();
+ expect(screen.queryByTestId('row-idle')).toBeNull();
+ expect(screen.queryByTestId('row-lit')).not.toBeNull();
+ expect(screen.getByText('ccAgent.sidebar.showAllSessions')).toBeTruthy();
+ });
+
+ it('updates the rendered group on remote activity and retains its lamp across collapse/expand', () => {
+ 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();
+ 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');
+ expect(screen.queryByTestId('row-lit')).not.toBeNull();
+ act(() => clearRemoteSessionActivity());
+ expect(screen.queryByTestId('row-lit')).toBeNull();
+ expect(header.querySelector('.session-status-breathing')).toBeNull();
+ });
+});
+
+// Use the real starting store/hook as the parent display-running source. No fake
+// absorption or direct prop replacement: ProjectsSection must settle it itself.
+function StartingSidebar(p: ProjectsSectionProps) {
+ const starting = useStartingSessionIds(p.runningSessionIds);
+ return <ProjectsSection {...p} runningSessionIds={new Set([...p.runningSessionIds, ...starting])} />;
+}
+function botHeader(root: HTMLElement = document.body) {
+ return within(root).getByText('Demo Bot').closest<HTMLElement>('[role="button"]')!;
+}
+function deviceHeader(name: string) { return screen.getByText(name).closest('button')!; }
+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);
+ }
+}
+
+describe.each([false, true])('Bot starting lifecycle, device grouping %s', (groupDevice) => {
+ for (const first of ['running', 'needs-interaction'] as const) {
+ it.each(['completed', 'error'] as const)(`${first} settles starting before %s without waiting for TTL`, (terminal) => {
+ vi.useFakeTimers();
+ const p = props(groupDevice);
+ remoteProjectsStore.pinSessionOrigin('remote', 'lit');
+ markSessionStarting('lit');
+ render(<StartingSidebar {...p} />);
+ 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'), terminal);
+ expect(screen.getByTestId('row-lit')).toBeTruthy();
+ // No timer advancement: the terminal UI must be correct immediately.
+ });
+ }
+
+ it('settles when only the bots prop arrives after the remote activity', () => {
+ vi.useFakeTimers();
+ const p = props(groupDevice);
+ markSessionStarting('lit');
+ activity('running');
+ const view = render(<StartingSidebar {...p} bots={[]} />);
+ expect(getStartingSessionIds().has('lit')).toBe(true);
+ view.rerender(<StartingSidebar {...p} />);
+ expect(getStartingSessionIds().has('lit')).toBe(false);
+ act(() => activity('completed'));
+ expectLamp(botHeader(), 'completed');
+ });
+
+ it('keeps the existing no-in-flight terminal fallback and local running settlement', () => {
+ vi.useFakeTimers();
+ const p = props(groupDevice);
+ markSessionStarting('lit');
+ activity('completed');
+ const view = render(<StartingSidebar {...p} />);
+ expect(getStartingSessionIds().has('lit')).toBe(true);
+ view.rerender(<StartingSidebar {...p} runningSessionIds={new Set(['lit'])} />);
+ expect(getStartingSessionIds().has('lit')).toBe(false);
+ });
+});
+
+function multiDeviceProps(): ProjectsSectionProps {
+ const p = props(true);
+ const bot = p.bots![0];
+ p.bots = [{ ...bot, sessions: [
+ { ...bot.sessions[0], id: 'a-first', deviceLinkDeviceId: 'a' },
+ { ...bot.sessions[1], id: 'a-idle', deviceLinkDeviceId: 'a' },
+ { ...bot.sessions[0], id: 'b-first', deviceLinkDeviceId: 'b' },
+ { ...bot.sessions[1], id: 'b-idle', deviceLinkDeviceId: 'b' },
+ { ...bot.sessions[2], id: 'lit', deviceLinkDeviceId: 'b' },
+ ] }];
+ p.remoteDeviceIndex = new Map([['a', { name: 'Device A', online: true }], ['b', { name: 'Device B', online: true }]]);
+ p.onOpenBot = vi.fn();
+ return p;
+}
+
+describe('Bot groups across devices', () => {
+ it.each(phases)('keeps %s lamps and exempt rows on the owning device', (phase) => {
+ const p = multiDeviceProps();
+ render(<ProjectsSection {...p} />);
+ act(() => applyRemoteSessionActivity('b', { sessionId: 'lit', phase, attention: true, compactDetail: '' }));
+ expectLamp(deviceHeader('Device A'), null);
+ const a = deviceHeader('Device A').parentElement!;
+ const b = deviceHeader('Device B').parentElement!;
+ expectLamp(deviceHeader('Device B'), phase);
+ expectLamp(botHeader(a), null);
+ expectLamp(botHeader(b), phase);
+ expect(within(a).queryByTestId('row-lit')).toBeNull();
+ expect(within(b).getByTestId('row-lit')).toBeTruthy();
+ expect(screen.getAllByText('Demo Bot')).toHaveLength(2);
+ expect(within(a).getAllByTestId(/^row-/)).toHaveLength(1);
+ expect(within(b).getAllByTestId(/^row-/)).toHaveLength(2);
+ fireEvent.click(within(b).getByTestId('row-lit'));
+ expect(p.onSessionClick).toHaveBeenCalledWith('lit');
+ fireEvent.click(within(b).getByRole('button', { name: 'bots.sidebar.newTaskWith' }));
+ expect(p.onOpenBot).toHaveBeenCalledWith('demo');
+ });
+
+ it('keeps show-all state per device and stable across task reorder and Bot rename', () => {
+ const p = multiDeviceProps();
+ const view = render(<ProjectsSection {...p} />);
+ const a = deviceHeader('Device A').parentElement!;
+ const b = deviceHeader('Device B').parentElement!;
+ fireEvent.click(within(b).getByText('ccAgent.sidebar.showAllSessions'));
+ expect(within(b).getAllByTestId(/^row-/)).toHaveLength(3);
+ expect(within(a).getAllByTestId(/^row-/)).toHaveLength(1);
+ const bHeader = botHeader(b);
+ view.rerender(<ProjectsSection {...p} bots={[{ ...p.bots![0], displayName: 'Renamed Bot', sessions: [...p.bots![0].sessions].reverse() }]} />);
+ expect(within(b).getByText('Renamed Bot').closest('[role="button"]')).toBe(bHeader);
+ expect(within(b).getAllByTestId(/^row-/)).toHaveLength(3);
+ expect(within(a).getAllByTestId(/^row-/)).toHaveLength(1);
+ });
+
+ it('folds Bot groups independently per device and includes them in fold-all', () => {
+ vi.useFakeTimers();
+ render(<ProjectsSection {...multiDeviceProps()} />);
+ const a = deviceHeader('Device A').parentElement!;
+ const b = deviceHeader('Device B').parentElement!;
+ fireEvent.click(botHeader(a));
+ expect(botHeader(a).getAttribute('aria-expanded')).toBe('false');
+ expect(botHeader(b).getAttribute('aria-expanded')).toBe('true');
+ fireEvent.click(screen.getByText('ccAgent.sidebar.foldAll.collapseProjects'));
+ expect(botHeader(b).getAttribute('aria-expanded')).toBe('false');
+ fireEvent.click(screen.getByText('ccAgent.sidebar.foldAll.collapseDevices'));
+ expect(deviceHeader('Device A').getAttribute('aria-expanded')).toBe('false');
+ fireEvent.click(screen.getByText('ccAgent.sidebar.foldAll.expandAll'));
+ expect(botHeader(a).getAttribute('aria-expanded')).toBe('true');
+ expect(botHeader(b).getAttribute('aria-expanded')).toBe('true');
+ });
+
+ it('keeps one Bot group with every task when device grouping is off', () => {
+ const p = multiDeviceProps();
+ p.filter.groupDevice = false;
+ render(<ProjectsSection {...p} />);
+ expect(screen.getAllByText('Demo Bot')).toHaveLength(1);
+ expect(screen.queryByText('Device A')).toBeNull();
+ fireEvent.click(screen.getByText('ccAgent.sidebar.showAllSessions'));
+ expect(screen.getAllByTestId(/^row-/)).toHaveLength(5);
+ });
+});
diff --git a/apps/desktop/src/renderer/__tests__/mainListModel.test.ts b/apps/desktop/src/renderer/__tests__/mainListModel.test.ts
index 2c5d13f5e7..d0683d1a70 100644
--- a/apps/desktop/src/renderer/__tests__/mainListModel.test.ts
+++ b/apps/desktop/src/renderer/__tests__/mainListModel.test.ts
@@ -1045,6 +1045,44 @@ it('keeps manual project order while creation-time tasks stay stable inside each
expect(getMainListEntrySessions(activityOrder[1]).map((s) => s.id)).toEqual(['old', 'recent']);
});
+describe('splitEntriesByDevice — Bot ownership', () => {
+ it('partitions local, known and cached devices without mutating Bot identity or task order', () => {
+ const sessions = [
+ session({ id: 'b-new', deviceLinkDeviceId: 'b', updatedAt: '2026-09-09T12:00:00Z' }),
+ session({ id: 'local', updatedAt: '2026-09-09T10:00:00Z' }),
+ session({ id: 'cached', deviceLinkDeviceId: 'cached', updatedAt: '2026-09-09T09:00:00Z' }),
+ session({ id: 'a', deviceLinkDeviceId: 'a', updatedAt: '2026-09-09T08:00:00Z' }),
+ session({ id: 'b-old', deviceLinkDeviceId: 'b', updatedAt: '2026-09-09T07:00:00Z' }),
+ ];
+ const bot = { botId: 'demo', displayName: 'Demo', avatar: 'avatar', avatarColor: 'color', sessions, latestActivityAt: sessions[0].updatedAt };
+ const result = splitEntriesByDevice([{ kind: 'bot-group', bot }], ['a', 'b'], { sortBy: 'recency' });
+ expect(result.map((section) => section.deviceId)).toEqual([null, 'a', 'b', 'cached']);
+ expect(result.map((section) => section.entries.flatMap((entry) => getMainListEntrySessions(entry).map((s) => s.id))))
+ .toEqual([['local'], ['a'], ['b-new', 'b-old'], ['cached']]);
+ for (const section of result) {
+ expect(section.entries).toHaveLength(1);
+ expect(section.entries[0]).toMatchObject({ kind: 'bot-group', bot: { botId: 'demo', displayName: 'Demo', avatar: 'avatar', avatarColor: 'color' } });
+ }
+ expect(bot.sessions).toBe(sessions);
+ expect(bot.sessions.map((s) => s.id)).toEqual(['b-new', 'local', 'cached', 'a', 'b-old']);
+ });
+
+ it('ranks each device fragment from its own sessions alongside dialogue groups', () => {
+ const local = session({ id: 'local', updatedAt: '2026-09-09T01:00:00Z' });
+ const remote = session({ id: 'remote', deviceLinkDeviceId: 'remote', updatedAt: '2026-09-09T12:00:00Z' });
+ const entries: MainListEntry[] = [
+ { kind: 'bot-group', bot: { botId: 'demo', displayName: 'Demo', avatar: '', avatarColor: '', sessions: [remote, local], latestActivityAt: remote.updatedAt } },
+ { kind: 'dialogue-group', sessions: [
+ session({ id: 'dlg-local', updatedAt: '2026-09-09T06:00:00Z' }),
+ session({ id: 'dlg-remote', deviceLinkDeviceId: 'remote', updatedAt: '2026-09-09T06:00:00Z' }),
+ ] },
+ ];
+ const result = splitEntriesByDevice(entries, ['remote'], { sortBy: 'recency' });
+ expect(result.map((section) => labels(section.entries))).toEqual([
+ ['dlg-group', 'bot:Demo'], ['bot:Demo', 'dlg-group'],
+ ]);
+ });
+});
describe('per-sort numeric keys', () => {
it('reads each activity key a bounded number of times and observes later in-place updates', () => {
diff --git a/apps/desktop/src/renderer/__tests__/projectLampMerge.test.tsx b/apps/desktop/src/renderer/__tests__/projectLampMerge.test.tsx
new file mode 100644
index 0000000000..4a7fab6c41
--- /dev/null
+++ b/apps/desktop/src/renderer/__tests__/projectLampMerge.test.tsx
@@ -0,0 +1,93 @@
+// @vitest-environment jsdom
+
+import { cleanup, render } from '@testing-library/react';
+import { afterEach, describe, expect, it, vi } from 'vitest';
+import {
+ ProjectNode,
+ type ProjectNodeProps,
+} from '../features/cc-agent/sidebar/sections/ProjectNode';
+
+vi.mock('react-i18next', () => ({ useTranslation: () => ({ t: (key: string) => key }) }));
+vi.mock('@/components/ui/tooltip', () => ({
+ Tip: ({ children }: { children: React.ReactNode }) => children,
+}));
+vi.mock('../features/cc-agent/sidebar/SessionEntryList', () => ({ SessionEntryList: () => null }));
+
+afterEach(cleanup);
+
+function props(): ProjectNodeProps {
+ return {
+ project: {
+ projectKey: 'local:demo',
+ displayName: 'Demo project',
+ workingDir: '/demo',
+ scope: 'local',
+ sessions: [],
+ remoteHostId: null,
+ deviceLinkDeviceId: null,
+ deviceLinkDeviceName: null,
+ deviceLinkConnectionStatus: null,
+ segments: 1,
+ latestActivityAt: '2026-09-10T00:00:00Z',
+ },
+ statusFilter: 'active',
+ isCollapsed: true,
+ parentSectionCollapsed: false,
+ runningSessionIds: new Set(),
+ attachedSessionIds: new Set(),
+ notifications: new Set(),
+ scheduleSessionIndex: new Map(),
+ disableSessionCollapse: false,
+ isProjectPinned: false,
+ onToggle: vi.fn(),
+ onToggleProjectPin: vi.fn(),
+ onRenameProject: vi.fn(),
+ onRemoveFromSidebar: vi.fn(),
+ onSessionClick: vi.fn(),
+ onAction: vi.fn(),
+ onRename: vi.fn(),
+ onTogglePin: vi.fn(),
+ onMoveSession: vi.fn(),
+ projectOptions: [],
+ onScheduleAction: vi.fn(),
+ onCreateInProject: vi.fn(),
+ onOpenConversationSearch: vi.fn(),
+ onOpenInExplorer: vi.fn(),
+ onLinkCodexProject: vi.fn(),
+ linkingCodexProject: false,
+ onBrowseFiles: vi.fn(),
+ onArchiveAll: vi.fn(),
+ };
+}
+
+describe('project lamp after upstream sidebar merge', () => {
+ it('keeps one unread indicator in the trailing slot while a sibling task runs', () => {
+ const { container } = render(
+ <ProjectNode
+ {...props()}
+ collapsedAttentionTone="done"
+ lamp={{ running: true, dotTone: 'done' }}
+ />,
+ );
+ const header = container.querySelector('[data-project-header]')!;
+ const slot = header.querySelector('.group\\/slot')!;
+ const titleGroup = header.querySelector('.flex-1')!;
+ expect(slot.querySelectorAll('.rounded-full').length).toBe(1);
+ expect(titleGroup.querySelectorAll('.rounded-full').length).toBe(0);
+ expect(header.querySelector('.session-status-breathing')).not.toBeNull();
+ });
+
+ it('leaves expanded project attention to its child rows', () => {
+ const { container } = render(
+ <ProjectNode
+ {...props()}
+ isCollapsed={false}
+ collapsedAttentionTone="error"
+ lamp={{ running: false, dotTone: 'error' }}
+ />,
+ );
+ const header = container.querySelector('[data-project-header]')!;
+ expect(header.querySelectorAll('.rounded-full').length).toBe(0);
+ expect(header.querySelector('.session-status-breathing')).toBeNull();
+ });
+});
diff --git a/apps/desktop/src/renderer/__tests__/projectsSidebarSection.test.ts b/apps/desktop/src/renderer/__tests__/projectsSidebarSection.test.ts
index 0dd4231cc4..d8789040d7 100644
--- a/apps/desktop/src/renderer/__tests__/projectsSidebarSection.test.ts
+++ b/apps/desktop/src/renderer/__tests__/projectsSidebarSection.test.ts
@@ -117,9 +117,17 @@ describe('Projects sidebar section', () => {
expect(projectsSectionSource).toContain('useViewedPriorityHold(');
expect(projectsSectionSource).toContain('holdViewedPriorityRank(');
expect(projectsSectionSource).toContain('viewedSessionId ?? activeSessionId');
- // 折叠豁免与排序同一口径(含远程),不再用只有本地的 notifications。
+ // 折叠豁免与排序、聚合灯同一口径(含远程):attention ∪ running
+ // (Greptile P1:running-only 会话不能被折进「显示全部」,否则上层
+ // 呼吸灯指向不可见条目),不再用只有本地的 notifications。
expect(projectsSectionSource).toContain(
- 'entrySessions(entry).some((s) => priorityContext.attentionSessionIds.has(s.id))',
+ 'const next = new Set(priorityContext.attentionSessionIds)',
+ );
+ expect(projectsSectionSource).toContain(
+ 'for (const id of priorityContext.runningSessionIds) next.add(id)',
+ );
+ expect(projectsSectionSource).toContain(
+ 'entrySessions(entry).some((s) => lampFoldExemptIds.has(s.id))',
);
});
diff --git a/apps/desktop/src/renderer/__tests__/railActivityOrigin.test.ts b/apps/desktop/src/renderer/__tests__/railActivityOrigin.test.ts
index ffe12613a4..377cb6b16b 100644
--- a/apps/desktop/src/renderer/__tests__/railActivityOrigin.test.ts
+++ b/apps/desktop/src/renderer/__tests__/railActivityOrigin.test.ts
@@ -4,11 +4,15 @@ import {
applyRemoteSessionActivity,
clearRemoteSessionActivity,
} from '@/features/device-link/remoteSessionActivityStore';
+import { remoteProjectsStore } from '@/features/device-link/remoteProjectsStore';
+import { markSessionStarting, clearSessionStarting, resetSessionStartingStoreForTests } from '@/lib/sessionStartingStore';
import { aggregateRailActivity } from '@/features/cc-agent/sidebar/railActivity';
import { railPanelStore, type RailLampSession } from '@/features/cc-agent/sidebar/railPanelStore';
afterEach(() => {
clearRemoteSessionActivity();
+ resetSessionStartingStoreForTests();
+ remoteProjectsStore.__resetPinnedOriginsForTest();
railPanelStore.setLampScope(null);
});
@@ -48,3 +52,22 @@ it('publishes a source-only scope change but keeps equal snapshots stable', () =
expect(aggregate(railPanelStore.getSnapshot().lampScope!.projectSessions).running).toBe(false);
expect(aggregate([{ id: 'same' }]).running).toBe(false);
});
+
+
+it('lights the remote rail during optimistic start only for the known device, then clears', () => {
+ const remote = { id: 'starting', deviceLinkDeviceId: 'a' };
+ remoteProjectsStore.pinSessionOrigin('a', 'starting');
+ markSessionStarting('starting');
+ expect(aggregate([remote]).running).toBe(true);
+ expect(aggregate([{ id: 'starting', deviceLinkDeviceId: 'b' }]).running).toBe(false);
+ expect(aggregate([{ id: 'starting' }]).running).toBe(false);
+ clearSessionStarting('starting');
+ expect(aggregate([remote]).running).toBe(false);
+});
+
+it('does not treat an unowned starting ID or local display-running as remote activity', () => {
+ markSessionStarting('unknown');
+ expect(aggregate([{ id: 'unknown', deviceLinkDeviceId: 'a' }]).running).toBe(false);
+ expect(aggregateRailActivity([{ id: 'local', deviceLinkDeviceId: 'a' }],
+ new Set(['local']), new Set(), new Map(), new Set()).running).toBe(false);
+});
diff --git a/apps/desktop/src/renderer/__tests__/remoteBotLampFoldExemption.test.tsx b/apps/desktop/src/renderer/__tests__/remoteBotLampFoldExemption.test.tsx
new file mode 100644
index 0000000000..cc018465e5
--- /dev/null
+++ b/apps/desktop/src/renderer/__tests__/remoteBotLampFoldExemption.test.tsx
@@ -0,0 +1,80 @@
+// @vitest-environment jsdom
+import { readFileSync } from 'node:fs';
+import { resolve } from 'node:path';
+import { useMemo } from 'react';
+import { cleanup, renderHook } from '@testing-library/react';
+import { afterEach, describe, expect, it } from 'vitest';
+import { transpileModule, ScriptTarget } from 'typescript';
+import type { Session } from '@/lib/ccAgent.types';
+import type { BotGroupNode } from '../features/cc-agent/lib/projectGrouping';
+import {
+ getMainListEntrySessions,
+ type MainListEntry,
+ type MainListPriorityContext,
+} from '../features/cc-agent/lib/mainListModel';
+import { sidebarPriorityContext } from '../features/cc-agent/lib/sidebarPriorityContext';
+import { getSessionListCollapseView } from '../features/cc-agent/lib/sessionListCollapse';
+
+// Execute the production memo and its dependency list, then the real collapse model.
+// This catches both missing Bot scans and stale memo results when only Bots change.
+const source = readFileSync(resolve(__dirname, '../features/cc-agent/sidebar/sections/ProjectsSection.tsx'), 'utf8');
+const declaration = source.match(/const naturalPriorityContext = useMemo\([\s\S]+?\n \]\);/);
+if (!declaration) throw new Error('ProjectsSection priority memo not found');
+const compiled = transpileModule(declaration[0], { compilerOptions: { target: ScriptTarget.ES2022 } }).outputText;
+const runMemo = new Function('useMemo', 'input', `
+ const { runningSessionIds, notifications, urgentSet, attentionKinds, projects, dialogues,
+ unclassified, bots, remoteActivityRevision, viewedIdForSort, viewedPriorityHold,
+ getRemoteSessionActivity, sidebarPriorityContext } = input;
+ ${compiled}
+ return naturalPriorityContext;
+`) as (memo: typeof useMemo, input: ReturnType<typeof inputs>) => MainListPriorityContext;
+
+afterEach(cleanup);
+
+function bot(id: string): BotGroupNode {
+ return {
+ botId: id, displayName: id, avatar: '', avatarColor: '', latestActivityAt: '2020-01-01',
+ sessions: [{ id, title: id, createdAt: '2020-01-01', updatedAt: '2020-01-01', status: 'active' } as Session],
+ };
+}
+
+function inputs(bots: BotGroupNode[], activity: Map<string, { phase: string }>) {
+ return {
+ runningSessionIds: new Set<string>(), notifications: new Set<string>(), urgentSet: new Set<string>(),
+ attentionKinds: new Map(), projects: [], dialogues: [], unclassified: [], bots,
+ remoteActivityRevision: 1, viewedIdForSort: undefined,
+ viewedPriorityHold: { heldPriorityRanks: new Map(), recentlyViewedAtMs: new Map() },
+ getRemoteSessionActivity: (id: string) => activity.get(id), sidebarPriorityContext,
+ };
+}
+
+function visibleBots(bots: BotGroupNode[], context: MainListPriorityContext) {
+ const exempt = new Set([...context.attentionSessionIds, ...context.runningSessionIds]);
+ const entries: MainListEntry[] = bots.map((item) => ({ kind: 'bot-group', bot: item }));
+ return getSessionListCollapseView({
+ entries, minVisibleCount: 1, showAll: false, disableCollapse: false, isFiltering: false,
+ isActiveEntry: () => false,
+ hasAttentionEntry: (entry) => getMainListEntrySessions(entry).some((s) => exempt.has(s.id)),
+ }).visibleEntries;
+}
+
+describe('remote Bot lamp fold exemptions', () => {
+ it.each(['running', 'needs-interaction', 'error', 'completed'])(
+ 'keeps a Bot beyond the section limit visible for remote %s activity', (phase) => {
+ const bots = [bot('first'), bot('idle'), bot('lit')];
+ const input = inputs(bots, new Map([['lit', { phase }]]));
+ const { result } = renderHook(() => runMemo(useMemo, input));
+ expect(visibleBots(bots, result.current).map((entry) => getMainListEntrySessions(entry)[0].id))
+ .toEqual(['first', 'lit']);
+ },
+ );
+
+ it('recomputes when Bot rows change without another remote activity revision', () => {
+ const lit = bot('lit');
+ const input = inputs([], new Map([['lit', { phase: 'running' }]]));
+ const { result, rerender } = renderHook((props) => runMemo(useMemo, props), { initialProps: input });
+ expect(result.current.runningSessionIds.has('lit')).toBe(false);
+ rerender({ ...input, bots: [lit] });
+ expect(result.current.runningSessionIds.has('lit')).toBe(true);
+ });
+});
diff --git a/apps/desktop/src/renderer/__tests__/sidebarRemoteProjectIcon.test.ts b/apps/desktop/src/renderer/__tests__/sidebarRemoteProjectIcon.test.ts
index c27d6a5512..933058fe98 100644
--- a/apps/desktop/src/renderer/__tests__/sidebarRemoteProjectIcon.test.ts
+++ b/apps/desktop/src/renderer/__tests__/sidebarRemoteProjectIcon.test.ts
@@ -87,11 +87,15 @@ describe('sidebar remote project icon', () => {
});
// 2026-08-12 用户裁决:设备段头的条数去掉——它数的是顶层条目(项目行 + 散排对话
- // + 对话组)而非任务数,读起来只会误导;「离线」标签接手 ml-auto 保持靠右。
+ // + 对话组)而非任务数,读起来只会误导。右侧后来改为灯组容器(聚合未读点 +
+ // 「离线」标注,2026-08 未读聚合灯),ml-auto 靠右语义由容器承接。
it('drops the entry count from the device group header', () => {
expect(projectsSectionSource).not.toContain('{section.entries.length}');
expect(projectsSectionSource).toContain(
- '<span className="ml-auto shrink-0 text-xs text-[var(--cmd-palette-item-meta)]">',
+ '<span className="ml-auto flex shrink-0 items-center gap-1.5">',
+ );
+ expect(projectsSectionSource).toContain(
+ '<span className="shrink-0 text-xs text-[var(--cmd-palette-item-meta)]">',
);
});
diff --git a/apps/desktop/src/renderer/features/cc-agent/CCAgentSidebarUpper.tsx b/apps/desktop/src/renderer/features/cc-agent/CCAgentSidebarUpper.tsx
index 3424b56bbb..22b595c629 100644
--- a/apps/desktop/src/renderer/features/cc-agent/CCAgentSidebarUpper.tsx
+++ b/apps/desktop/src/renderer/features/cc-agent/CCAgentSidebarUpper.tsx
@@ -209,7 +209,8 @@ import {
SidebarIconButton,
SIDEBAR_RAIL_ICON_BUTTON_CLASS,
} from '@/components/sidebar/SidebarIconButton';
-import { RailNav, remoteLampOf } from './sidebar/RailNav';
+import { RailNav } from './sidebar/RailNav';
+import { aggregateSessionLamps, remoteLampOf } from './lib/sessionLampAggregation';
import {
panelHasBlockingOverlay,
panelHasEditingFocus,
@@ -1156,6 +1157,31 @@ function ExpandedView({
],
);
+ // 置顶区项目行的聚合灯(ProjectsSection.lampAgg / rail projectAgg 同款口径):
+ // 聚合集合 = 该行下实际渲染的会话(displaySessions ?? project.sessions),
+ // 灯亮进去一定找得到亮的行。revision 订阅让 device-link 远程镜像推送能触发重算。
+ const pinnedRemoteActivityRevision = useRemoteSessionActivityRevision();
+ const pinnedProjectLamp = useCallback(
+ (list: readonly Session[]) =>
+ aggregateSessionLamps(
+ list,
+ {
+ runningSessionIds: displayRunningSessionIds,
+ notifications: sidebarNotifications,
+ attentionKinds,
+ urgentSessionIds: urgentSet,
+ },
+ ),
+ // eslint-disable-next-line react-hooks/exhaustive-deps -- pinnedRemoteActivityRevision 代表 remoteLampOf 读到的整表内容
+ [
+ displayRunningSessionIds,
+ sidebarNotifications,
+ attentionKinds,
+ urgentSet,
+ pinnedRemoteActivityRevision,
+ ],
+ );
+
// 本地会话用 effectiveIncludeArchived(snapshot 实际所属桶)避免切桶时先闪空;
// device-link 远程镜像同时持有 active / archived 两桶,必须独立按 filter.status 筛选,
// 否则本地 archived/all 请求慢或失败时会把已加载的远程归档行持续隐藏。
@@ -1658,6 +1684,23 @@ function ExpandedView({
});
}, [visiblePinnedSessions, visiblePinnedProjects, filter.manualPinnedOrder, localPlatform]);
+ // 置顶项目行的折叠豁免追加集合:base 豁免(notifications ∪ runningSessionIds)
+ // 只覆盖本地链路,device-link 远程 running/未读只活在远程镜像里——灯为它们
+ // 点亮时,行不能被折进「显示全部」(codex review;与 ProjectsSection 的
+ // lampFoldExemptIds、rail 面板的 panelNotifications 同语义)。只扫置顶项目
+ // 下实际渲染的会话,集合与灯的聚合来源一致。
+ const pinnedFoldExemptIds = useMemo(() => {
+ const next = new Set<string>();
+ for (const entry of visiblePinnedEntries) {
+ if (entry.kind !== 'project') continue;
+ for (const s of entry.displaySessions ?? entry.project.sessions) {
+ if (remoteLampOf(s.id, s.deviceLinkDeviceId)) next.add(s.id);
+ }
+ }
+ return next;
+ // eslint-disable-next-line react-hooks/exhaustive-deps -- pinnedRemoteActivityRevision 代表 remoteLampOf 读到的整表内容
+ }, [visiblePinnedEntries, pinnedRemoteActivityRevision]);
+
const visibleUnclassified = useMemo(() => {
const sessions = vendorPredicate
? groups.unclassified.filter(vendorPredicate)
@@ -3613,6 +3656,8 @@ function ExpandedView({
: null
}
parentSectionCollapsed={parentSectionCollapsed}
+ lamp={pinnedProjectLamp(displaySessions ?? project.sessions)}
+ foldExemptSessionIds={pinnedFoldExemptIds}
activeSessionId={activeSessionId}
runningSessionIds={displayRunningSessionIds}
attachedSessionIds={attachedSessionIds}
@@ -4288,35 +4333,14 @@ function RailPanels({
// 只喂给折叠豁免(isActiveEntry)与行高亮;点击导航仍走真实 activeSessionId。
const visibilityActiveId = activeSessionId ?? viewedSessionId;
+ // 聚合口径的唯一事实源(sessionLampAggregation):本地链路 + device-link 远程
+ // 镜像。远程不并入会出现「段灯亮、项目行不亮」(codex review)。
const projectAgg = useCallback(
- (list: readonly Session[]) => {
- let running = false;
- let best: 'error' | 'awaiting' | 'done' | null = null;
- const rank = { error: 3, awaiting: 2, done: 1 } as const;
- const consider = (tone: 'error' | 'awaiting' | 'done' | null) => {
- if (tone && (!best || rank[tone] > rank[best])) best = tone;
- };
- for (const s of list) {
- if (!s.deviceLinkDeviceId && runningSessionIds.has(s.id)) running = true;
- // 远程会话灯语与 rail 段灯同源(remoteLampOf):本地 running/attention
- // 对被控端后台会话是盲区,不并入会出现「段灯亮、项目行不亮」(codex review)。
- const remote = remoteLampOf(s.id, s.deviceLinkDeviceId);
- if (remote) {
- if (remote.running) running = true;
- consider(remote.tone);
- }
- if (!notifications.has(s.id)) continue;
- const kind = attentionKinds.get(s.id);
- consider(
- kind === 'error' || urgentSet.has(s.id)
- ? 'error'
- : kind === 'awaiting'
- ? 'awaiting'
- : 'done',
- );
- }
- return { running, dotTone: best };
- },
+ (list: readonly Session[]) =>
+ aggregateSessionLamps(
+ list,
+ { runningSessionIds, notifications, attentionKinds, urgentSessionIds: urgentSet },
+ ),
// eslint-disable-next-line react-hooks/exhaustive-deps -- remoteActivityRevision 代表 remoteLampOf 读到的整表内容
[runningSessionIds, notifications, attentionKinds, urgentSet, remoteActivityRevision],
);
diff --git a/apps/desktop/src/renderer/features/cc-agent/lib/__tests__/sessionLampAggregation.test.ts b/apps/desktop/src/renderer/features/cc-agent/lib/__tests__/sessionLampAggregation.test.ts
new file mode 100644
index 0000000000..004a29a1a6
--- /dev/null
+++ b/apps/desktop/src/renderer/features/cc-agent/lib/__tests__/sessionLampAggregation.test.ts
@@ -0,0 +1,125 @@
+/**
+ * sessionLampAggregation — 聚合灯语的口径测试
+ * ---------------------------------------------------------------------------
+ * 该 helper 是 rail 段钮 / rail 浮层面板项目行 / 展开态项目行 / 「对话」组行 /
+ * 设备段头共用的唯一事实源。这里钉住三件事:
+ * 1. tone 优先级:error > awaiting > done;urgent(定时任务失败未读)提升为 error;
+ * 2. 未读集合之外的会话不点灯(attention kind 存在也不行);
+ * 3. device-link 远程镜像并入:running / needs-interaction / error / 完成未读
+ * 与本地链路合并取最高档(否则远程「行亮而上层入口不亮」)。
+ */
+
+import { afterEach, describe, expect, it } from 'vitest';
+
+import {
+ applyRemoteSessionActivity,
+ clearRemoteSessionActivity,
+} from '@/features/device-link/remoteSessionActivityStore';
+import type { AttentionKind } from '@/lib/sessionAttentionStore';
+import { aggregateSessionLamps, dotToneOf, remoteLampOf } from '../sessionLampAggregation';
+
+const ctx = (over: {
+ running?: string[];
+ notifications?: string[];
+ kinds?: Record<string, AttentionKind>;
+ urgent?: string[];
+}) => ({
+ runningSessionIds: new Set(over.running ?? []),
+ notifications: new Set(over.notifications ?? []),
+ attentionKinds: new Map(Object.entries(over.kinds ?? {})),
+ urgentSessionIds: new Set(over.urgent ?? []),
+});
+
+afterEach(() => {
+ clearRemoteSessionActivity();
+});
+
+describe('dotToneOf', () => {
+ it('未读集合之外不点灯,即便 attention kind 存在', () => {
+ const c = ctx({ kinds: { a: 'error' } });
+ expect(dotToneOf('a', c.notifications, c.attentionKinds, c.urgentSessionIds)).toBeNull();
+ });
+
+ it('urgent 会话提升为 error(定时任务失败未读兜底)', () => {
+ const c = ctx({ notifications: ['a'], urgent: ['a'] });
+ expect(dotToneOf('a', c.notifications, c.attentionKinds, c.urgentSessionIds)).toBe('error');
+ });
+
+ it('kind 缺失的未读回落绿 done', () => {
+ const c = ctx({ notifications: ['a'] });
+ expect(dotToneOf('a', c.notifications, c.attentionKinds, c.urgentSessionIds)).toBe('done');
+ });
+});
+
+describe('aggregateSessionLamps', () => {
+ it('空集合 → 无灯', () => {
+ expect(aggregateSessionLamps([], ctx({}))).toEqual({ running: false, dotTone: null });
+ });
+
+ it('tone 取聚合最高档:done < awaiting < error', () => {
+ const c = ctx({
+ notifications: ['a', 'b', 'c'],
+ kinds: { b: 'awaiting', c: 'error' },
+ });
+ expect(aggregateSessionLamps([{ id: 'a' }], c).dotTone).toBe('done');
+ expect(aggregateSessionLamps([{ id: 'a' }, { id: 'b' }], c).dotTone).toBe('awaiting');
+ expect(aggregateSessionLamps([{ id: 'a' }, { id: 'b' }, { id: 'c' }], c).dotTone).toBe('error');
+ });
+
+ it('running 与未读点相互独立,可同时成立', () => {
+ const c = ctx({ running: ['r'], notifications: ['a'] });
+ expect(aggregateSessionLamps([{ id: 'r' }, { id: 'a' }], c)).toEqual({ running: true, dotTone: 'done' });
+ });
+
+ it('device-link 远程镜像并入:running 与 needs-interaction 合并取最高档', () => {
+ applyRemoteSessionActivity('device-1', {
+ sessionId: 'remote-run',
+ phase: 'running',
+ compactDetail: '',
+ });
+ applyRemoteSessionActivity('device-1', {
+ sessionId: 'remote-wait',
+ phase: 'needs-interaction',
+ compactDetail: '',
+ });
+ const agg = aggregateSessionLamps([{ id: 'remote-run', deviceLinkDeviceId: 'device-1' }, { id: 'remote-wait', deviceLinkDeviceId: 'device-1' }], ctx({}));
+ expect(agg).toEqual({ running: true, dotTone: 'awaiting' });
+ });
+
+ it('远程完成未读(attention 存续期条目)记绿 done;本地 error 仍压过它', () => {
+ applyRemoteSessionActivity('device-1', {
+ sessionId: 'remote-done',
+ phase: 'completed',
+ attention: true,
+ compactDetail: '',
+ });
+ expect(aggregateSessionLamps([{ id: 'remote-done', deviceLinkDeviceId: 'device-1' }], ctx({})).dotTone).toBe('done');
+ const c = ctx({ notifications: ['local-err'], kinds: { 'local-err': 'error' } });
+ expect(aggregateSessionLamps([{ id: 'remote-done', deviceLinkDeviceId: 'device-1' }, { id: 'local-err' }], c).dotTone).toBe('error');
+ });
+});
+
+describe('remoteLampOf', () => {
+ it('无镜像条目 → null;error phase → error tone', () => {
+ expect(remoteLampOf('nope', undefined)).toBeNull();
+ applyRemoteSessionActivity('device-1', {
+ sessionId: 'remote-err',
+ phase: 'error',
+ attention: true,
+ compactDetail: '',
+ });
+ expect(remoteLampOf('remote-err', 'device-1')).toEqual({ running: false, tone: 'error' });
+ });
+});
+
+ describe('设备隔离', () => {
+ it('同名本地任务及另一设备不读取 device-1 镜像', () => {
+ applyRemoteSessionActivity('device-1', { sessionId: 'same', phase: 'running' });
+ expect(aggregateSessionLamps([{ id: 'same' }], ctx({})).running).toBe(false);
+ expect(aggregateSessionLamps([{ id: 'same', deviceLinkDeviceId: 'device-2' }], ctx({})).running).toBe(false);
+ expect(aggregateSessionLamps([{ id: 'same', deviceLinkDeviceId: 'device-1' }], ctx({})).running).toBe(true);
+ });
+ it('本地同名 running 不污染远程任务', () => {
+ expect(aggregateSessionLamps([{ id: 'same', deviceLinkDeviceId: 'device-2' }], ctx({ running: ['same'] })).running).toBe(false);
+ });
+});
diff --git a/apps/desktop/src/renderer/features/cc-agent/lib/automationSidebarGrouping.ts b/apps/desktop/src/renderer/features/cc-agent/lib/automationSidebarGrouping.ts
index 026fb244a2..14f82af3d6 100644
--- a/apps/desktop/src/renderer/features/cc-agent/lib/automationSidebarGrouping.ts
+++ b/apps/desktop/src/renderer/features/cc-agent/lib/automationSidebarGrouping.ts
@@ -219,6 +219,12 @@ export interface AutomationGroupChildViewOptions {
* —— 与组头红点、项目折叠头红点同一份判据。
*/
alertSessionIds?: ReadonlySet<string>;
+ /**
+ * 展开态折叠的追加豁免集合(只影响折叠),语义同 SessionEntryList 的同名 prop:
+ * 父层把 device-link 远程活动镜像并进来,保证项目行 / 对话组 / 设备段头聚合灯
+ * 为之点亮的远程子运行不会藏在「显示全部」后(review P2)。
+ */
+ foldExemptSessionIds?: ReadonlySet<string>;
}
/**
@@ -281,7 +287,17 @@ export function getAutomationGroupChildView(
const frozenSessions = options.frozenVisibleSessionIds
.map((sessionId) => byId.get(sessionId))
.filter((session): session is Session => Boolean(session));
- return withoutOverflow(frozenSessions);
+ // 冻结只固定已点选布局,不能藏住后来变为运行/未读的本地或远程子运行。
+ const visibleIds = new Set(frozenSessions.map((session) => session.id));
+ const visibleSessions = [
+ ...frozenSessions,
+ ...allRuns.filter((session) => !visibleIds.has(session.id) &&
+ (options.notifications.has(session.id) ||
+ options.runningSessionIds?.has(session.id) ||
+ options.foldExemptSessionIds?.has(session.id))),
+ ];
+ const hiddenCount = allRuns.length - visibleSessions.length;
+ return { visibleSessions, isOverflowing: hiddenCount > 0, totalCount: allRuns.length, hiddenCount };
}
// 默认展开态:全部运行套用普通对话同款折叠,每条(含被组头代表的最新一条)各自成行。
@@ -296,7 +312,8 @@ export function getAutomationGroupChildView(
isActiveEntry: (session) => session.id === options.activeSessionId,
hasAttentionEntry: (session) =>
options.notifications.has(session.id) ||
- (options.runningSessionIds?.has(session.id) ?? false),
+ (options.runningSessionIds?.has(session.id) ?? false) ||
+ (options.foldExemptSessionIds?.has(session.id) ?? false),
});
return {
visibleSessions: [...view.visibleEntries],
diff --git a/apps/desktop/src/renderer/features/cc-agent/lib/mainListModel.ts b/apps/desktop/src/renderer/features/cc-agent/lib/mainListModel.ts
index e2830ee853..5230498548 100644
--- a/apps/desktop/src/renderer/features/cc-agent/lib/mainListModel.ts
+++ b/apps/desktop/src/renderer/features/cc-agent/lib/mainListModel.ts
@@ -429,13 +429,11 @@ function entryDeviceId(entry: MainListEntry): string | null {
if (entry.kind === 'automation-group') {
return entry.group.sessions[0]?.deviceLinkDeviceId ?? null;
}
- // 伙伴组:同样按组内首条会话归属。伙伴本身不绑设备 —— 它的任务可以分布在
- // 本机与远端,设备切段只看会话自己在哪。
+ // 对话组与伙伴组已经按成员设备拆分,此时首条会话代表整个片段。
if (entry.kind === 'bot-group') {
return entry.bot.sessions[0]?.deviceLinkDeviceId ?? null;
}
- // 对话组条目:按组内首条会话归属(散排对话在设备分组下由调用方按设备切分后
- // 再分别成组,这里只是兜底)。
+ // 对话组同样已拆成单设备片段。
return entry.sessions[0]?.deviceLinkDeviceId ?? null;
}
@@ -444,8 +442,8 @@ function entryDeviceId(entry: MainListEntry): string | null {
* - 段顺序:本机在前,远程设备按 deviceOrder(设备切换栏同序);
* 不在 deviceOrder 里的设备(断线缓存等)按段内最新活动排在其后。
* - 段内按当前 sortBy 重排(跨设备对话组拆开后,不能再沿用整组位置)。
- * - 「对话归为一组」开启时,跨设备的对话组会被拆成每设备一组——调用方无需
- * 预切分,这里对 dialogue-group 条目按成员设备拆分。
+ * - 「对话归为一组」开启时,跨设备的对话组和伙伴组会被拆成每设备一组——调用方无需
+ * 预切分,分组身份不变,成员只保留本设备的任务。
*/
export function splitEntriesByDevice(
entries: readonly MainListEntry[],
@@ -457,22 +455,24 @@ export function splitEntriesByDevice(
priorityContext?: MainListPriorityContext;
} = {},
): MainListDeviceSection[] {
- // 先把跨设备对话组拆开(组内成员可能来自不同设备)。
+ // 先把跨设备会话组拆开,再按每个片段的成员计算排序和设备聚合灯。
const flattened: MainListEntry[] = [];
for (const entry of entries) {
- if (entry.kind !== 'dialogue-group') {
+ if (entry.kind !== 'dialogue-group' && entry.kind !== 'bot-group') {
flattened.push(entry);
continue;
}
const byDevice = new Map<string | null, Session[]>();
- for (const s of entry.sessions) {
+ for (const s of getMainListEntrySessions(entry)) {
const key = s.deviceLinkDeviceId ?? null;
const list = byDevice.get(key);
if (list) list.push(s);
else byDevice.set(key, [s]);
}
for (const sessions of byDevice.values()) {
- flattened.push({ kind: 'dialogue-group', sessions });
+ flattened.push(entry.kind === 'bot-group'
+ ? { kind: 'bot-group', bot: { ...entry.bot, sessions } }
+ : { kind: 'dialogue-group', sessions });
}
}
diff --git a/apps/desktop/src/renderer/features/cc-agent/lib/sessionLampAggregation.ts b/apps/desktop/src/renderer/features/cc-agent/lib/sessionLampAggregation.ts
new file mode 100644
index 0000000000..f851abbff0
--- /dev/null
+++ b/apps/desktop/src/renderer/features/cc-agent/lib/sessionLampAggregation.ts
@@ -0,0 +1,90 @@
+/**
+ * sessionLampAggregation — 会话「灯语」聚合的唯一事实源
+ * ---------------------------------------------------------------------------
+ * 灯语 = running(呼吸橙)+ 未读点 tone(红 error > 蓝 awaiting > 绿 done,
+ * AttentionDot 色表)。聚合口径:
+ * - 本地链路:runningSessionIds / notifications + attentionKinds + urgent
+ * (定时任务失败未读按 error 提升,与 SessionItem.isUrgentFromContext 同语义);
+ * - device-link 远程镜像(remoteLampOf):本地链路对被控端后台会话是盲区,
+ * 必须并入,否则「行亮而入口不亮」(codex review,rail 聚合灯先例)。
+ *
+ * 消费方:rail 段钮 / rail 浮层面板项目行(先例),以及展开态的项目行、
+ * 「对话」组行、设备段头(2026-08 用户反馈:未读绿点只在最底层会话行,上层
+ * 文件夹与顶层设备头没有灯,多设备下找未读要逐层展开翻找)。三处聚合必须
+ * 与其下**实际渲染的行集合**一致——灯亮进去一定找得到亮的行。
+ *
+ * 注意:remoteLampOf 直接读 remoteSessionActivityStore(非 React 状态),
+ * 组件里调用聚合时必须把 useRemoteSessionActivityRevision() 纳入 memo/callback
+ * 依赖,否则跟不上被控端 relay 推送(RailNav / CCAgentSidebarUpper 同款先例)。
+ */
+
+import { getRemoteSessionActivity } from '@/features/device-link/remoteSessionActivityStore';
+import { getStartingSessionIds } from '@/lib/sessionStartingStore';
+import { getSessionDeviceId } from '@/features/device-link/remoteProjectsStore';
+import type { AttentionKind } from '@/lib/sessionAttentionStore';
+
+const TONE_RANK: Record<AttentionKind, number> = { error: 3, awaiting: 2, done: 1 };
+
+/** device-link 远程会话的灯语补充。phase → 灯语映射与 SessionItem.remoteRightStatus
+ * 同一张表;镜像里 completed/error 条目仅在未读(attention)期间存在,存在即未读。 */
+export function remoteLampOf(id: string, deviceId: string | null | undefined): { running: boolean; tone: AttentionKind | null } | null {
+ const remote = getRemoteSessionActivity(id, deviceId);
+ if (!remote) return null;
+ if (remote.phase === 'running') return { running: true, tone: null };
+ return {
+ running: false,
+ tone:
+ remote.phase === 'error' ? 'error' : remote.phase === 'needs-interaction' ? 'awaiting' : 'done',
+ };
+}
+
+/** 单会话本地未读点 tone;未读集合之外返回 null。 */
+export function dotToneOf(
+ id: string,
+ notifications: ReadonlySet<string>,
+ attentionKinds: ReadonlyMap<string, AttentionKind>,
+ urgentSessionIds: ReadonlySet<string>,
+): AttentionKind | null {
+ if (!notifications.has(id)) return null;
+ const kind = attentionKinds.get(id);
+ if (kind === 'error' || urgentSessionIds.has(id)) return 'error';
+ if (kind === 'awaiting') return 'awaiting';
+ return 'done';
+}
+
+export interface SessionLampContext {
+ runningSessionIds: ReadonlySet<string>;
+ notifications: ReadonlySet<string>;
+ attentionKinds: ReadonlyMap<string, AttentionKind>;
+ urgentSessionIds: ReadonlySet<string>;
+}
+
+export interface SessionLampAggregate {
+ running: boolean;
+ dotTone: AttentionKind | null;
+}
+
+/** 聚合一组会话 id 的灯语:任一 running → running;未读点取最高优先级 tone。 */
+export function aggregateSessionLamps(
+ rows: Iterable<{ id: string; deviceLinkDeviceId?: string | null }>,
+ ctx: SessionLampContext,
+): SessionLampAggregate {
+ let running = false;
+ let best: AttentionKind | null = null;
+ const consider = (tone: AttentionKind | null) => {
+ if (tone && (!best || TONE_RANK[tone] > TONE_RANK[best])) best = tone;
+ };
+ for (const { id, deviceLinkDeviceId } of rows) {
+ if (!deviceLinkDeviceId && ctx.runningSessionIds.has(id)) running = true;
+ // A locally initiated remote send is optimistic activity only for its known owner.
+ if (deviceLinkDeviceId && getSessionDeviceId(id) === deviceLinkDeviceId &&
+ getStartingSessionIds().has(id)) running = true;
+ consider(dotToneOf(id, ctx.notifications, ctx.attentionKinds, ctx.urgentSessionIds));
+ const remote = remoteLampOf(id, deviceLinkDeviceId);
+ if (remote) {
+ if (remote.running) running = true;
+ consider(remote.tone);
+ }
+ }
+ return { running, dotTone: best };
+}
diff --git a/apps/desktop/src/renderer/features/cc-agent/sidebar/AutomationSessionGroupItem.tsx b/apps/desktop/src/renderer/features/cc-agent/sidebar/AutomationSessionGroupItem.tsx
index dc617fe8a8..3961481e45 100644
--- a/apps/desktop/src/renderer/features/cc-agent/sidebar/AutomationSessionGroupItem.tsx
+++ b/apps/desktop/src/renderer/features/cc-agent/sidebar/AutomationSessionGroupItem.tsx
@@ -72,6 +72,8 @@ export interface AutomationSessionGroupItemProps {
/** 平铺列表由段头批量折叠状态机控制时传入;其它场景继续使用组件自身持久化状态。 */
collapsed?: boolean;
onCollapsedChange?: (collapsed: boolean) => void;
+ /** 远程活动镜像提供的子运行折叠豁免集合。 */
+ foldExemptSessionIds?: ReadonlySet<string>;
indented?: boolean;
/**
* 展开的子 SessionItem 行 hover 时右侧浮层展示的"项目来源"标签映射(sessionId →
@@ -118,6 +120,7 @@ export const AutomationSessionGroupItem = withSidebarNavigation<AutomationSessio
onScheduleAction,
collapsed: controlledCollapsed,
onCollapsedChange,
+ foldExemptSessionIds,
indented = false,
sourceLabelMap,
matchMap,
@@ -209,6 +212,7 @@ export const AutomationSessionGroupItem = withSidebarNavigation<AutomationSessio
nowMs: Date.now(),
collapsed,
alertSessionIds,
+ foldExemptSessionIds,
});
// 轴 1 收起时只留组头 + 被提上来的告警行;展开时交给轴 2 的「前 5 / 显示全部」。
// 两种形态都由 getAutomationGroupChildView 一处决定(见该函数的 ⚠️)。
diff --git a/apps/desktop/src/renderer/features/cc-agent/sidebar/SessionEntryList.tsx b/apps/desktop/src/renderer/features/cc-agent/sidebar/SessionEntryList.tsx
index b73e429f71..b06790ba71 100644
--- a/apps/desktop/src/renderer/features/cc-agent/sidebar/SessionEntryList.tsx
+++ b/apps/desktop/src/renderer/features/cc-agent/sidebar/SessionEntryList.tsx
@@ -65,6 +65,13 @@ export interface SessionEntryListProps {
collapseLimit?: number;
/** collapsible 时临时禁用(如按内容搜索/筛选中,应展开全部命中)。 */
disableCollapse?: boolean;
+ /**
+ * 折叠豁免的追加会话集合(只影响折叠,不影响行内视觉)。基础豁免 =
+ * notifications ∪ runningSessionIds;展开态父层用它并入 device-link 远程
+ * 活动镜像(远程 running/未读不在上面两个本地集合里),保证上层聚合灯
+ * 点亮的会话不被折进「显示全部」。
+ */
+ foldExemptSessionIds?: ReadonlySet<string>;
/** 父级 SectionCollapse 的折叠态;用于收起动画结束后复位「显示全部」。 */
sectionCollapsed?: boolean;
/** 项目置顶到列表模式时,项目内会话复用满宽列表卡片;其它场景保持紧凑文字行。 */
@@ -108,6 +115,7 @@ export function SessionEntryRows({
showFirstDivider = true,
automationGroupCollapsed,
onAutomationGroupCollapsedChange,
+ foldExemptSessionIds,
}: SessionEntryRowsProps) {
return (
<>
@@ -170,6 +178,7 @@ export function SessionEntryRows({
projectOptions={projectOptions}
onScheduleAction={onScheduleAction}
collapsed={automationGroupCollapsed?.(entry.group.id)}
+ foldExemptSessionIds={foldExemptSessionIds}
onCollapsedChange={
onAutomationGroupCollapsedChange
? (collapsed) => onAutomationGroupCollapsedChange(entry.group.id, collapsed)
@@ -194,6 +203,7 @@ export function SessionEntryList({
collapseLimit,
disableCollapse = false,
sectionCollapsed = false,
+ foldExemptSessionIds,
...props
}: SessionEntryListProps) {
const { t } = useTranslation();
@@ -204,11 +214,21 @@ export function SessionEntryList({
);
if (!collapsible) {
- return <SessionEntryRows entries={entries} notifications={notifications} {...props} />;
+ return (
+ <SessionEntryRows
+ entries={entries}
+ notifications={notifications}
+ foldExemptSessionIds={foldExemptSessionIds}
+ {...props}
+ />
+ );
}
// 对话段与项目内会话共用这套折叠:默认前 N 条 + 永远保留 24h 内活动 /
- // 需关注 / 当前打开的会话;超出收起,底部「显示全部 N 个」一次展开。
+ // 需关注 / 运行中 / 当前打开的会话;超出收起,底部「显示全部 N 个」一次展开。
+ // running 豁免与上层聚合灯同口径(Greptile P1):项目行/设备段头的呼吸灯为
+ // running 会话点亮,该会话就不能折进「显示全部」——灯亮进去必须找得到行。
+ // foldExemptSessionIds 供父层追加口径(如展开态并入 device-link 远程镜像)。
const { visibleEntries, isOverflowing, totalCount } = getSessionListCollapseView({
entries,
minVisibleCount: collapseLimit,
@@ -218,12 +238,20 @@ export function SessionEntryList({
nowMs: Date.now(),
getActivityMs: getEntryActivityMs,
isActiveEntry: (entry) => entryIsActive(entry, props.activeSessionId),
- hasAttentionEntry: (entry) => entryHasAttention(entry, notifications),
+ hasAttentionEntry: (entry) =>
+ entryHasAttention(entry, notifications) ||
+ entryHasAttention(entry, props.runningSessionIds) ||
+ (foldExemptSessionIds != null && entryHasAttention(entry, foldExemptSessionIds)),
});
return (
<>
- <SessionEntryRows entries={visibleEntries} notifications={notifications} {...props} />
+ <SessionEntryRows
+ entries={visibleEntries}
+ notifications={notifications}
+ foldExemptSessionIds={foldExemptSessionIds}
+ {...props}
+ />
{isOverflowing && (
<button
type="button"
diff --git a/apps/desktop/src/renderer/features/cc-agent/sidebar/railActivity.ts b/apps/desktop/src/renderer/features/cc-agent/sidebar/railActivity.ts
index 3288c8d6ec..3b649ec468 100644
--- a/apps/desktop/src/renderer/features/cc-agent/sidebar/railActivity.ts
+++ b/apps/desktop/src/renderer/features/cc-agent/sidebar/railActivity.ts
@@ -1,46 +1,10 @@
import type { AttentionKind } from '@/lib/sessionAttentionStore';
-import { getRemoteSessionActivity } from '@/features/device-link/remoteSessionActivityStore';
+import { aggregateSessionLamps } from '../lib/sessionLampAggregation';
import type { RailLampSession } from './railPanelStore';
-const TONE_RANK: Record<AttentionKind, number> = { error: 3, awaiting: 2, done: 1 };
+export { dotToneOf, remoteLampOf } from '../lib/sessionLampAggregation';
-export function dotToneOf(
- id: string,
- notifications: ReadonlySet<string>,
- attentionKinds: ReadonlyMap<string, AttentionKind>,
- urgentSessionIds: ReadonlySet<string>,
-): AttentionKind | null {
- if (!notifications.has(id)) return null;
- const kind = attentionKinds.get(id);
- if (kind === 'error' || urgentSessionIds.has(id)) return 'error';
- if (kind === 'awaiting') return 'awaiting';
- return 'done';
-}
-
-/** device-link 远程会话的灯语补充:本地 running/attention 链路对被控端后台会话
- * 是盲区,SessionItem 行内状态由 remoteSessionActivityStore 驱动 —— rail 聚合灯
- * 与置顶瓷砖必须并入同一镜像,否则远程会话「行亮而入口不亮」(codex review)。
- * phase → 灯语映射与 SessionItem.remoteRightStatus 同一张表;镜像里 completed/
- * error 条目仅在未读(attention)期间存在,存在即未读。 */
-export function remoteLampOf(
- id: string,
- deviceId: string | null | undefined,
-): { running: boolean; tone: AttentionKind | null } | null {
- const remote = getRemoteSessionActivity(id, deviceId);
- if (!remote) return null;
- if (remote.phase === 'running') return { running: true, tone: null };
- return {
- running: false,
- tone:
- remote.phase === 'error'
- ? 'error'
- : remote.phase === 'needs-interaction'
- ? 'awaiting'
- : 'done',
- };
-}
-
-/** 保留每行设备来源,禁止聚合前降为仅含任务 ID 的映射。 */
+/** 与展开态共用灯语口径;保留每行设备来源及已知归属的远程启动状态。 */
export function aggregateRailActivity(
rows: readonly RailLampSession[],
runningSessionIds: ReadonlySet<string>,
@@ -48,19 +12,7 @@ export function aggregateRailActivity(
attentionKinds: ReadonlyMap<string, AttentionKind>,
urgentSessionIds: ReadonlySet<string>,
): { running: boolean; dotTone: AttentionKind | null } {
- let running = false;
- let best: AttentionKind | null = null;
- const consider = (tone: AttentionKind | null) => {
- if (tone && (!best || TONE_RANK[tone] > TONE_RANK[best])) best = tone;
- };
- for (const { id, deviceLinkDeviceId } of rows) {
- if (!deviceLinkDeviceId && runningSessionIds.has(id)) running = true;
- consider(dotToneOf(id, notifications, attentionKinds, urgentSessionIds));
- const remote = remoteLampOf(id, deviceLinkDeviceId);
- if (remote) {
- if (remote.running) running = true;
- consider(remote.tone);
- }
- }
- return { running, dotTone: best };
+ return aggregateSessionLamps(rows, {
+ runningSessionIds, notifications, attentionKinds, urgentSessionIds,
+ });
}
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.tsx
index 110abe783a..85d852eb84 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
@@ -50,6 +50,7 @@ import type {
AutomationSessionGroup,
} from '../../lib/automationSidebarGrouping';
import { getProjectSessionCollapseLimit } from '../../lib/sidebarCollapseConfig';
+import type { SessionLampAggregate } from '../../lib/sessionLampAggregation';
import type { FolderPickerOption } from '@/components/new-chat/FolderPickerPopover';
import type { SessionMoveTarget } from '../sessionMoveTarget';
import type { FilterStatus } from '../../hooks/useSidebarFilter';
@@ -92,6 +93,13 @@ export interface ProjectNodeProps {
* 不重复归属信息。置顶区不受分组影响,照常显示。
*/
hideRemoteMachineLabel?: boolean;
+ /**
+ * 项目行运行灯:文件夹图标呼吸橙。未读仍走上游既定的 collapsedAttentionTone
+ * 右侧状态槽,不在标题旁重复显示。聚合集合由父层按实际渲染的会话提供。
+ */
+ lamp?: SessionLampAggregate;
+ /** 透传给项目内 SessionEntryList 的折叠豁免追加集合(语义见其 prop 注释)。 */
+ foldExemptSessionIds?: ReadonlySet<string>;
onToggle: (projectKey: string) => void;
/** Project pin is independent from conversation pin state. */
isProjectPinned: boolean;
@@ -138,6 +146,8 @@ export const ProjectNode = memo(function ProjectNode({
selectedSessionIds,
disableSessionCollapse,
hideRemoteMachineLabel = false,
+ lamp,
+ foldExemptSessionIds,
onToggle,
isProjectPinned,
onToggleProjectPin,
@@ -175,6 +185,7 @@ export const ProjectNode = memo(function ProjectNode({
isCollapsed={isCollapsed}
collapsedAttentionTone={collapsedAttentionTone}
hideRemoteMachineLabel={hideRemoteMachineLabel}
+ lamp={lamp}
onToggle={onToggle}
isProjectPinned={isProjectPinned}
onToggleProjectPin={onToggleProjectPin}
@@ -214,6 +225,7 @@ export const ProjectNode = memo(function ProjectNode({
collapsible
collapseLimit={getProjectSessionCollapseLimit()}
disableCollapse={disableSessionCollapse}
+ foldExemptSessionIds={foldExemptSessionIds}
sectionCollapsed={isCollapsed || parentSectionCollapsed}
onSessionClick={onSessionClick}
onAction={onAction}
@@ -238,6 +250,7 @@ type ProjectHeaderProps = Pick<
| 'isCollapsed'
| 'collapsedAttentionTone'
| 'hideRemoteMachineLabel'
+ | 'lamp'
| 'onToggle'
| 'isProjectPinned'
| 'onToggleProjectPin'
@@ -253,6 +266,7 @@ type ProjectHeaderProps = Pick<
>;
const ProjectHeader = memo(function ProjectHeader({
+ lamp,
project,
statusFilter,
isCollapsed,
@@ -413,11 +427,17 @@ const ProjectHeader = memo(function ProjectHeader({
!isEditingName && 'hover:bg-sidebar-item-hover',
)}
>
- <FolderIcon
- size={15}
- strokeWidth={1.8}
- className="shrink-0 text-[var(--sidebar-list-muted)]"
- />
+ {/* 灯语与 rail 浮层面板项目行同款:running → 呼吸橙(动画挂 wrapper)。 */}
+ <span
+ className={cn(
+ 'inline-flex shrink-0',
+ lamp?.running
+ ? 'text-[var(--status-bar-accent)] session-status-breathing'
+ : 'text-[var(--sidebar-list-muted)]',
+ )}
+ >
+ <FolderIcon size={15} strokeWidth={1.8} aria-hidden />
+ </span>
{/* 名字 + remote identity 同组占据 flex-1。远程项目常态展示机器身份,
避免相同 workingDir 的项目只能靠 hover 才能区分。 */}
<div className="flex min-w-0 flex-1 items-center gap-1.5">
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 51200982e4..9ef2a111cd 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
@@ -80,6 +80,8 @@ import { sidebarPriorityContext } from '../../lib/sidebarPriorityContext';
import { useViewedPriorityHold } from '../../hooks/useViewedPriorityHold';
import { projectKeyComparisonKey, type BotGroupNode } from '../../lib/projectGrouping';
import { buildSessionSourceLabelMap } from '../../lib/sessionSourceLabel';
+import { aggregateSessionLamps, type SessionLampAggregate } from '../../lib/sessionLampAggregation';
+import { AttentionDot } from '@/components/sidebar/AttentionDot';
import { useSessionAttentionKinds } from '@/lib/sessionAttentionStore';
import { useSessionAttentionUrgencySet } from '../../contexts/SessionAttentionUrgencyContext';
import {
@@ -118,6 +120,9 @@ const MANUAL_PROJECT_SORT_FILTER = 'button, input, textarea, select, a, [data-no
/** 设备段折叠/对话组折叠共用的段 key:本机段 'local',远程段用 deviceId。 */
const deviceSectionKey = (deviceId: string | null) => deviceId ?? 'local';
+// 单段保留既有伙伴 key;设备分组与对话组同样按段独立记忆,不依赖任务顺序或组名。
+const botGroupKey = (botId: string, sectionKey: string) =>
+ sectionKey === DIALOGUE_GROUP_ALL_KEY ? `bot:${botId}` : `bot:${botId}:${sectionKey}`;
// 优先级排序的「看的时候钉住;只有从完成未读切走才置顶」是模块生命周期内的展示态,
// 不落盘。放模块级而不是组件 ref:ProjectsSection 重挂(含 React Strict Mode
@@ -481,7 +486,12 @@ export function ProjectsSection({
}
return sidebarPriorityContext(
{ runningSessionIds, attentionSessionIds: notifications, waitingSessionIds: waiting },
- [...projects.flatMap((project) => project.sessions), ...dialogues, ...unclassified],
+ [
+ ...projects.flatMap((project) => project.sessions),
+ ...bots.flatMap((bot) => bot.sessions),
+ ...dialogues,
+ ...unclassified,
+ ],
(session) => getRemoteSessionActivity(session.id, session.deviceLinkDeviceId)?.phase,
);
// eslint-disable-next-line react-hooks/exhaustive-deps -- remoteActivityRevision 代表 getRemoteSessionActivity 读到的整表内容
@@ -493,6 +503,7 @@ export function ProjectsSection({
projects,
dialogues,
unclassified,
+ bots,
remoteActivityRevision,
]);
const hold = useViewedPriorityHold(viewedPriorityHold, viewedIdForSort, naturalPriorityContext);
@@ -505,6 +516,22 @@ export function ProjectsSection({
[naturalPriorityContext, hold],
);
+ // 聚合灯(2026-08 用户反馈:未读点只亮在最底层会话行,项目层与设备层没有
+ // 灯,多设备下找未读要逐层展开翻找)——项目行 / 对话组行 / 设备段头都从
+ // 各自下方**实际渲染的行集合**聚合灯语(sessionLampAggregation,rail 同源):
+ // running → 图标呼吸橙;未读 → AttentionDot(红 error > 蓝 awaiting > 绿 done)。
+ // remoteActivityRevision 已在上方订阅,依赖注释同 priorityContext。
+ const lampAgg = useCallback(
+ (list: readonly Session[]): SessionLampAggregate =>
+ aggregateSessionLamps(list, {
+ runningSessionIds,
+ notifications,
+ attentionKinds,
+ urgentSessionIds: urgentSet,
+ }),
+ // eslint-disable-next-line react-hooks/exhaustive-deps -- remoteActivityRevision 代表 remoteLampOf 读到的整表内容
+ [runningSessionIds, notifications, attentionKinds, urgentSet, remoteActivityRevision],
+ );
const sortingPriorityContext = filter.sortBy === 'priority' ? priorityContext : undefined;
// starting 只让位给真实 in-flight:本地 isRunning(见 useStartingSessionIds),
@@ -527,9 +554,10 @@ export function ProjectsSection({
}
for (const session of dialogues) considerRemote(session);
for (const session of unclassified) considerRemote(session);
+ for (const bot of bots) for (const session of bot.sessions) considerRemote(session);
absorbSessionStarting(settled);
// eslint-disable-next-line react-hooks/exhaustive-deps -- remoteActivityRevision 代表 getRemoteSessionActivity 读到的整表内容
- }, [projects, dialogues, unclassified, remoteActivityRevision]);
+ }, [projects, dialogues, unclassified, bots, remoteActivityRevision]);
// E 期「按设备分组」:有远程设备连接 + 开关开 → 按设备切段(本机在前,
// 远程按设备切换栏顺序);其余情况单段直渲。切段后按当前排序重排本段。
@@ -568,9 +596,15 @@ export function ProjectsSection({
// 条目;任何排序/筛选下都生效。
const entrySessions = getMainListEntrySessions;
// 折叠视图共用一份参数:非设备分组 = 全列表一份;设备分组 = 每段各一份(见
- // deviceSections)。attention 豁免用 priorityContext.attentionSessionIds——与
- // 排序同一口径(含远程活动镜像),远程 waiting/unread 的条目不能被折进
- // 「显示全部」。
+ // deviceSections)。豁免口径 = attention ∪ running(priorityContext,含远程
+ // 活动镜像)——与聚合灯同口径:上层灯为哪条会话点亮(未读或 running),
+ // 该条目就不能被折进「显示全部」(Greptile P1:此前只豁免 attention,
+ // running-only 会话会让呼吸灯指向不可见的条目)。
+ const lampFoldExemptIds = useMemo(() => {
+ const next = new Set(priorityContext.attentionSessionIds);
+ for (const id of priorityContext.runningSessionIds) next.add(id);
+ return next;
+ }, [priorityContext]);
const collapseEntries = useCallback(
(entries: readonly MainListEntry[], showAll: boolean) =>
getSessionListCollapseView({
@@ -580,10 +614,9 @@ export function ProjectsSection({
disableCollapse: false,
isFiltering: false,
isActiveEntry: (entry) => entrySessions(entry).some((s) => s.id === viewedIdForSort),
- hasAttentionEntry: (entry) =>
- entrySessions(entry).some((s) => priorityContext.attentionSessionIds.has(s.id)),
+ hasAttentionEntry: (entry) => entrySessions(entry).some((s) => lampFoldExemptIds.has(s.id)),
}),
- [viewedIdForSort, entrySessions, priorityContext],
+ [viewedIdForSort, entrySessions, lampFoldExemptIds],
);
const {
visibleEntries: visibleMixedEntries,
@@ -688,17 +721,19 @@ export function ProjectsSection({
// 组层 = 项目行 + 自动任务组 + 「对话」组行。项目侧复用 ProjectNode 折叠状态,
// 自动任务组复用 owner-scoped 持久化状态,对话组沿用本地显示偏好。
const hasGroupLayer = mixedEntries.some((entry) => entry.kind !== 'session');
- // 当前可见的对话组 key:设备分组下 = 各含对话组条目的设备段;否则单一组。
+ // 当前可见的对话/伙伴组 key:设备分组下按段记忆;否则保留单段 key。
// 「收起/展开所有分组」只作用于这些可见 key,不动其它模式下的记忆。
const visibleDialogueGroupKeys = useMemo<string[]>(() => {
- if (!deviceGroupingActive) {
- return visibleMixedEntries.some((entry) => entry.kind === 'dialogue-group')
- ? [DIALOGUE_GROUP_ALL_KEY]
- : [];
- }
- return deviceSections
- .filter((section) => section.entries.some((entry) => entry.kind === 'dialogue-group'))
- .map((section) => deviceSectionKey(section.deviceId));
+ const keysFor = (entries: readonly MainListEntry[], sectionKey: string) =>
+ entries.flatMap((entry) => {
+ if (entry.kind === 'dialogue-group') return [sectionKey];
+ if (entry.kind === 'bot-group') return [botGroupKey(entry.bot.botId, sectionKey)];
+ return [];
+ });
+ if (!deviceGroupingActive) return keysFor(visibleMixedEntries, DIALOGUE_GROUP_ALL_KEY);
+ return deviceSections.flatMap((section) =>
+ keysFor(section.entries, deviceSectionKey(section.deviceId)),
+ );
}, [deviceGroupingActive, visibleMixedEntries, deviceSections]);
const allDialogueGroupsCollapsed =
visibleDialogueGroupKeys.length === 0 ||
@@ -820,6 +855,8 @@ export function ProjectsSection({
collapsed.has(project.projectKey) ? collapsedAttentionToneFor(project.sessions) : null
}
parentSectionCollapsed={false}
+ lamp={lampAgg(project.sessions)}
+ foldExemptSessionIds={lampFoldExemptIds}
// Unrelated projects keep an undefined selection prop across navigation,
// so ProjectNode's memo need not rebuild every session list on a click.
activeSessionId={
@@ -887,6 +924,9 @@ export function ProjectsSection({
onScheduleAction={onScheduleAction}
automationGroupCollapsed={isAutomationGroupCollapsed}
onAutomationGroupCollapsedChange={setAutomationGroupCollapsed}
+ // 顶层自动化组的展开态子运行折叠也要认远程灯豁免(review P2):与项目内 /
+ // 对话组内的 SessionEntryList 同一份 lampFoldExemptIds。
+ foldExemptSessionIds={lampFoldExemptIds}
sourceLabelMap={dialogueSourceLabelMap}
sessionVariant={mainSessionVariant}
// 混排下每条散排对话各是一个单条列表,若都补顶线,会与上一行的底线叠成
@@ -896,12 +936,14 @@ export function ProjectsSection({
);
}
if (entry.kind === 'bot-group') {
- const groupKey = `bot:${entry.bot.botId}`;
+ const groupKey = botGroupKey(entry.bot.botId, dialogueGroupKey);
const isCollapsed = collapsedDialogueGroups.has(groupKey);
return (
<SessionGroupNode
- key={`bot-group:${entry.bot.botId}`}
+ key={groupKey}
sessions={entry.bot.sessions}
+ lamp={lampAgg(entry.bot.sessions)}
+ foldExemptSessionIds={lampFoldExemptIds}
groupIcon={
<BotAvatar
bot={{
@@ -954,6 +996,8 @@ export function ProjectsSection({
<SessionGroupNode
key={`dialogue-group:${dialogueGroupKey}`}
sessions={entry.sessions}
+ lamp={lampAgg(entry.sessions)}
+ foldExemptSessionIds={lampFoldExemptIds}
collapsed={isCollapsed}
onToggle={() => setDialogueCollapsed([dialogueGroupKey], !isCollapsed)}
onCreateDialogue={() => onCreateDialogue(dialogueDeviceTarget)}
@@ -1059,6 +1103,9 @@ 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">
{/* 设备分组头:可折叠。在线设备不画状态点;离线设备保留灰点与文字提示。 */}
@@ -1082,7 +1129,16 @@ export function ProjectsSection({
) : (
<ChevronDown size={12} strokeWidth={2} className="shrink-0" />
)}
- <MonitorSmartphone size={13} strokeWidth={2} className="shrink-0" />
+ {/* 段内任一 running → 设备图标呼吸橙(rail 段钮同款灯语)。 */}
+ <span
+ className={cn(
+ 'inline-flex shrink-0',
+ sectionLamp.running &&
+ 'text-[var(--status-bar-accent)] session-status-breathing',
+ )}
+ >
+ <MonitorSmartphone size={13} strokeWidth={2} aria-hidden />
+ </span>
<span className="min-w-0 truncate text-xs font-medium">{name}</span>
{!online && (
<span
@@ -1092,12 +1148,18 @@ export function ProjectsSection({
)}
{/* 条数已去掉(2026-08-12 用户裁决):它数的是顶层条目
(项目行 + 散排对话 + 对话组),不是任务数,读起来只会误导;
- 段展开后内容本身就是答案。「离线」接手 ml-auto 保持靠右。 */}
- {!online && (
- <span className="ml-auto shrink-0 text-xs text-[var(--cmd-palette-item-meta)]">
- {t('ccAgent.sidebar.deviceGroup.offline')}
- </span>
- )}
+ 段展开后内容本身就是答案。右侧改为灯组:聚合未读点
+ (段级 size 6,rail 段钮同款)+ 离线标注。 */}
+ <span className="ml-auto flex shrink-0 items-center gap-1.5">
+ {sectionLamp.dotTone && (
+ <AttentionDot size={6} tone={sectionLamp.dotTone} />
+ )}
+ {!online && (
+ <span className="shrink-0 text-xs text-[var(--cmd-palette-item-meta)]">
+ {t('ccAgent.sidebar.deviceGroup.offline')}
+ </span>
+ )}
+ </span>
</button>
</DeviceSectionHeader>
<SectionCollapse collapsed={sectionCollapsed}>
@@ -1201,6 +1263,8 @@ export function ProjectsSection({
*/
function SessionGroupNode({
sessions,
+ lamp,
+ foldExemptSessionIds,
collapsed,
onToggle,
onCreateDialogue,
@@ -1227,6 +1291,11 @@ function SessionGroupNode({
sessionVariant,
}: {
sessions: Session[];
+ /** 组头聚合灯(ProjectNode.lamp 同款语义):running → 图标呼吸橙;
+ * dotTone → 标题右侧 AttentionDot。聚合集合 = 组内会话(与渲染一致)。 */
+ lamp?: SessionLampAggregate;
+ /** 透传给组内 SessionEntryList 的折叠豁免追加集合(语义见其 prop 注释)。 */
+ foldExemptSessionIds?: ReadonlySet<string>;
collapsed: boolean;
onToggle: () => void;
/**
@@ -1289,17 +1358,30 @@ function SessionGroupNode({
'transition-colors hover:bg-sidebar-item-hover',
)}
>
- {groupIcon ?? (
- <MessagesSquare
- size={15}
- strokeWidth={1.8}
- className="shrink-0 text-[var(--sidebar-list-muted)]"
- />
- )}
+ {/* 灯语与 ProjectNode 表头同款:running → 呼吸橙(动画挂 wrapper)。
+ 伙伴组头的 groupIcon 是 BotAvatar:头像自带内联身份色与文字色,不继承
+ wrapper 的 currentColor,呼吸也只是身份色头像在闪;reduce-motion 停掉动画后
+ 就什么运行标记都没有(Codex review)。因此有 groupIcon 时另加一圈运行色
+ 描边——静态、走 --status-bar-accent、与减弱动效无关;线条图标路径仍靠
+ currentColor,不需要描边。 */}
+ <span
+ className={cn(
+ 'inline-flex shrink-0',
+ lamp?.running
+ ? '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)]',
+ )}
+ data-running-marker={lamp?.running ? (groupIcon ? 'ring' : 'icon') : undefined}
+ >
+ {groupIcon ?? <MessagesSquare size={15} strokeWidth={1.8} aria-hidden />}
+ </span>
<div className="flex min-w-0 flex-1 items-center gap-1.5">
- <span className="min-w-0 flex-1 truncate">
+ <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" />}
<Chevron
size={13}
strokeWidth={2}
@@ -1366,6 +1448,7 @@ function SessionGroupNode({
collapsible
collapseLimit={getProjectSessionCollapseLimit()}
disableCollapse={disableSessionCollapse}
+ foldExemptSessionIds={foldExemptSessionIds}
sectionCollapsed={parentSectionCollapsed || collapsed}
sessionVariant={sessionVariant}
/>
diff --git a/apps/desktop/src/renderer/features/right-sidebar/plugins/review/__tests__/ReviewTabBody.diffListLayout.test.tsx b/apps/desktop/src/renderer/features/right-sidebar/plugins/review/__tests__/ReviewTabBody.diffListLayout.test.tsx
index 0e6e5ecd20..feca6448ce 100644
--- a/apps/desktop/src/renderer/features/right-sidebar/plugins/review/__tests__/ReviewTabBody.diffListLayout.test.tsx
+++ b/apps/desktop/src/renderer/features/right-sidebar/plugins/review/__tests__/ReviewTabBody.diffListLayout.test.tsx
@@ -15,7 +15,7 @@
// 本回归关心的契约;真实组件在 loaded 分支用 rAF 触发同一个回调。
import { createElement, useEffect } from 'react';
-import { act, render } from '@testing-library/react';
+import { act, cleanup, render } from '@testing-library/react';
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
import type { FileDiff, Hunk } from '@/lib/gitReview.types';
@@ -155,6 +155,7 @@ let originalOffsetHeight: PropertyDescriptor | undefined;
let originalGetBoundingClientRect: typeof Element.prototype.getBoundingClientRect;
beforeEach(() => {
+ vi.useFakeTimers();
Object.assign(CARD_HEIGHTS, BASE_CARD_HEIGHTS);
pendingObservations = [];
observedTargets.clear();
@@ -188,11 +189,21 @@ beforeEach(() => {
};
});
-afterEach(() => {
- if (originalOffsetHeight) {
- Object.defineProperty(HTMLElement.prototype, 'offsetHeight', originalOffsetHeight);
+afterEach(async () => {
+ cleanup();
+ // virtual-core 的 scroll-end debounce 在卸载后仍可能待执行;
+ // 在 jsdom 还存活时清空回调,避免它逃到测试环境销毁之后。
+ try {
+ await act(async () => {
+ await vi.runOnlyPendingTimersAsync();
+ });
+ } finally {
+ vi.useRealTimers();
+ if (originalOffsetHeight) {
+ Object.defineProperty(HTMLElement.prototype, 'offsetHeight', originalOffsetHeight);
+ }
+ Element.prototype.getBoundingClientRect = originalGetBoundingClientRect;
}
- Element.prototype.getBoundingClientRect = originalGetBoundingClientRect;
});
function rowStarts(container: HTMLElement): number[] {
@@ -241,7 +252,7 @@ function renderDiffList() {
async function flushAsyncWork() {
await act(async () => {
- await new Promise((resolve) => setTimeout(resolve, 60));
+ await vi.advanceTimersByTimeAsync(60);
});
}
diff --git a/docs/design-rules/design-inventory.md b/docs/design-rules/design-inventory.md
index f9a27f7d32..7a57ec66af 100644
--- a/docs/design-rules/design-inventory.md
+++ b/docs/design-rules/design-inventory.md
@@ -39,7 +39,7 @@
| `desktop.plugins.app-main` | desktop | 插件主视图 | hash `/apps/:ghostId`(GhostMainViewFeatureLayout) | GhostMainViewFeatureLayout, GhostMainViewHost | apps/desktop/src/renderer/features/plugin/GhostMainViewFeatureLayout.tsx, apps/desktop/src/renderer/features/plugin/GhostMainViewHost.tsx | 0 | 0 | 0 |
| `desktop.plugins.installed` | desktop | 已装插件 | hash `/plugins`(GhostPluginPage) | AddMarketplaceDialog, GhostPluginDetailView, GhostPluginPage, MarketPluginDetailView, MyPublishesSection, PluginManagementLayout, PluginScopePicker, UpdateAllDialog | apps/desktop/src/renderer/features/plugin/AddMarketplaceDialog.tsx, apps/desktop/src/renderer/features/plugin/GhostPluginDetailView.tsx, apps/desktop/src/renderer/features/plugin/GhostPluginPage.tsx, apps/desktop/src/renderer/features/plugin/MarketPluginDetailView.tsx, apps/desktop/src/renderer/features/plugin/MyPublishesSection.tsx, apps/desktop/src/renderer/features/plugin/PluginManagementLayout.tsx, apps/desktop/src/renderer/features/plugin/PluginScopePicker.tsx, apps/desktop/src/renderer/features/plugin/UpdateAllDialog.tsx, apps/desktop/src/renderer/features/plugin/plugin-motion.css | 49 | 0 | 82 |
| `desktop.settings` | desktop | 设置 | hash `/settings`(SettingsView;tab 含 general / personalization / providers / billing / usage / voice-input / im-bot / shortcuts / agent-island / import / remote-control / ghosts / builtin-tools / computer-use / help / about) | SettingsView | apps/desktop/src/renderer/components/settings/AboutSection.tsx, apps/desktop/src/renderer/components/settings/AccountDeletionSection.tsx, apps/desktop/src/renderer/components/settings/AddProviderWizard.tsx, apps/desktop/src/renderer/components/settings/AgentIslandSection.tsx, apps/desktop/src/renderer/components/settings/AgentResourceSection.tsx, apps/desktop/src/renderer/components/settings/AppearanceSection.tsx, apps/desktop/src/renderer/components/settings/AuxiliaryModelSection.tsx, apps/desktop/src/renderer/components/settings/BetaChannelCell.tsx, apps/desktop/src/renderer/components/settings/BrowserBackendSubsection.tsx, apps/desktop/src/renderer/components/settings/BrowserRealProfileSubsection.tsx, apps/desktop/src/renderer/components/settings/BuiltinToolsSection.tsx, apps/desktop/src/renderer/components/settings/ChatEmbeddingCell.tsx, apps/desktop/src/renderer/components/settings/ChipMetricsSection.tsx, apps/desktop/src/renderer/components/settings/CindyMakeSection.tsx, apps/desktop/src/renderer/components/settings/CollaborationSection.tsx, apps/desktop/src/renderer/components/settings/CompactionSection.tsx, apps/desktop/src/renderer/components/settings/ComposerSendShortcutSection.tsx, apps/desktop/src/renderer/components/settings/ComputerPermissionGuideWindow.tsx, apps/desktop/src/renderer/components/settings/ComputerPermissionRow.tsx, apps/desktop/src/renderer/components/settings/ComputerUseSection.tsx, apps/desktop/src/renderer/components/settings/CustomProviderRuntimeFillOverlay.tsx, apps/desktop/src/renderer/components/settings/DefaultOverrideControls.tsx, apps/desktop/src/renderer/components/settings/DingTalkBotSection.tsx, apps/desktop/src/renderer/components/settings/DiscordBotSection.tsx, apps/desktop/src/renderer/components/settings/DownloadMeter.tsx, apps/desktop/src/renderer/components/settings/ExperimentalSection.tsx, apps/desktop/src/renderer/components/settings/FeishuBotNotificationSection.tsx, apps/desktop/src/renderer/components/settings/FeishuBotSection.tsx, apps/desktop/src/renderer/components/settings/FontFamilyPicker.tsx, apps/desktop/src/renderer/components/settings/GenericGamepadLayout.tsx, apps/desktop/src/renderer/components/settings/GitSafetySection.tsx, apps/desktop/src/renderer/components/settings/HelpAssistantPanel.tsx, apps/desktop/src/renderer/components/settings/HelpSection.tsx, apps/desktop/src/renderer/components/settings/HelpThreadView.tsx, apps/desktop/src/renderer/components/settings/HookConnectionsSection.tsx, apps/desktop/src/renderer/components/settings/HookWorkspacePrefsEditor.tsx, apps/desktop/src/renderer/components/settings/ImBotSection.tsx, apps/desktop/src/renderer/components/settings/ImChannelSettingsCard.tsx, apps/desktop/src/renderer/components/settings/ImDefaultSettingsSection.tsx, apps/desktop/src/renderer/components/settings/ImLifecycleAnnouncementSection.tsx, apps/desktop/src/renderer/components/settings/InputDeviceConnectionStatus.tsx, apps/desktop/src/renderer/components/settings/JoyConGamepadLayout.tsx, apps/desktop/src/renderer/components/settings/KeyboardShortcutsSection.tsx, apps/desktop/src/renderer/components/settings/LanguageSection.tsx, apps/desktop/src/renderer/components/settings/LayoutResetControl.tsx, apps/desktop/src/renderer/components/settings/LinkOpenSection.tsx, apps/desktop/src/renderer/components/settings/LocalOllamaInstall.tsx, apps/desktop/src/renderer/components/settings/LocalPackagingTag.tsx, apps/desktop/src/renderer/components/settings/LogoutSection.tsx, apps/desktop/src/renderer/components/settings/LspBetaCell.tsx, apps/desktop/src/renderer/components/settings/McpServerDialog.tsx, apps/desktop/src/renderer/components/settings/McpServersSection.tsx, apps/desktop/src/renderer/components/settings/MemorySection.tsx, apps/desktop/src/renderer/components/settings/MessageNavRailCell.tsx, apps/desktop/src/renderer/components/settings/ModelAdvancedDrawer.tsx, apps/desktop/src/renderer/components/settings/ModelPriceOverrideDialog.tsx, apps/desktop/src/renderer/components/settings/MyDevicesPanel.tsx, apps/desktop/src/renderer/components/settings/NotificationSection.tsx, apps/desktop/src/renderer/components/settings/OAuthDeviceCodeCard.tsx, apps/desktop/src/renderer/components/settings/OllamaProviderDetail.tsx, apps/desktop/src/renderer/components/settings/PiPackagesSection.tsx, apps/desktop/src/renderer/components/settings/PlayStationGamepadLayout.tsx, apps/desktop/src/renderer/components/settings/ProfileEditDialog.tsx, apps/desktop/src/renderer/components/settings/ProviderConnectionDialog.tsx, apps/desktop/src/renderer/components/settings/ProviderImportDialog.tsx, apps/desktop/src/renderer/components/settings/ProvidersSection.tsx, apps/desktop/src/renderer/components/settings/RemoteControlSection.tsx, apps/desktop/src/renderer/components/settings/RemoteDesktopPermissions.tsx, apps/desktop/src/renderer/components/settings/RemoteDesktopSetting.tsx, apps/desktop/src/renderer/components/settings/RemoteHostDetail.tsx, apps/desktop/src/renderer/components/settings/RemoteSection.tsx, apps/desktop/src/renderer/components/settings/SessionImportSection.tsx, apps/desktop/src/renderer/components/settings/SessionRuntimeFallbackCell.tsx, apps/desktop/src/renderer/components/settings/SessionShareImportWizard.tsx, apps/desktop/src/renderer/components/settings/SettingsCatalogPanel.tsx, apps/desktop/src/renderer/components/settings/SettingsSegmentedControl.tsx, apps/desktop/src/renderer/components/settings/SettingsSidebarNav.tsx, apps/desktop/src/renderer/components/settings/SettingsTextInput.tsx, apps/desktop/src/renderer/components/settings/SettingsView.tsx, apps/desktop/src/renderer/components/settings/SilentEncryptedRetryCell.tsx, apps/desktop/src/renderer/components/settings/SshKeySetupDialog.tsx, apps/desktop/src/renderer/components/settings/StorageManagementCard.tsx, apps/desktop/src/renderer/components/settings/StreamFadeSection.tsx, apps/desktop/src/renderer/components/settings/SubagentModelSection.tsx, apps/desktop/src/renderer/components/settings/SwitchProGamepadLayout.tsx, apps/desktop/src/renderer/components/settings/TelegramBehaviorSettings.tsx, apps/desktop/src/renderer/components/settings/TelegramBotSection.tsx, apps/desktop/src/renderer/components/settings/TelegramRemoteDevices.tsx, apps/desktop/src/renderer/components/settings/TerminalShellSection.tsx, apps/desktop/src/renderer/components/settings/TipsSection.tsx, apps/desktop/src/renderer/components/settings/UnifiedModelList.tsx, apps/desktop/src/renderer/components/settings/UserProfileCard.tsx, apps/desktop/src/renderer/components/settings/UserPromptSection.tsx, apps/desktop/src/renderer/components/settings/VisionBridgeSection.tsx, apps/desktop/src/renderer/components/settings/VoiceInputSection.tsx, apps/desktop/src/renderer/components/settings/WechatBotSection.tsx, apps/desktop/src/renderer/components/settings/WecomBotSection.tsx, apps/desktop/src/renderer/components/settings/WindowBehaviorSection.tsx, apps/desktop/src/renderer/components/settings/WorkLouderCodexKeyboardLayout.tsx, apps/desktop/src/renderer/components/settings/WorkLouderCodexKeycapGlyphs.tsx, apps/desktop/src/renderer/components/settings/WorkLouderCodexSettings.tsx, apps/desktop/src/renderer/components/settings/XUsageGuide.tsx, apps/desktop/src/renderer/components/settings/XboxGamepadLayout.tsx, apps/desktop/src/renderer/components/settings/XboxGamepadSettings.tsx, apps/desktop/src/renderer/components/settings/androidStatusPresentation.ts, apps/desktop/src/renderer/components/settings/billingVisibility.ts, apps/desktop/src/renderer/components/settings/browserOpenForLoginError.ts, apps/desktop/src/renderer/components/settings/cindyMakeVisibility.ts, apps/desktop/src/renderer/components/settings/computerPermissionFlow.ts, apps/desktop/src/renderer/components/settings/contacts/ContactDetailPane.tsx, apps/desktop/src/renderer/components/settings/contacts/ContactsImportDialog.tsx, apps/desktop/src/renderer/components/settings/contacts/ContactsListPane.tsx, apps/desktop/src/renderer/components/settings/contacts/ContactsManagerDialog.tsx, apps/desktop/src/renderer/components/settings/contacts/ContactsSection.tsx, apps/desktop/src/renderer/components/settings/contacts/startContactsAiSession.ts, apps/desktop/src/renderer/components/settings/dualSenseSilhouette.ts, apps/desktop/src/renderer/components/settings/feishuBotPresentation.ts, apps/desktop/src/renderer/components/settings/fontFamilyValue.ts, apps/desktop/src/renderer/components/settings/gamepadLayoutPrimitives.tsx, apps/desktop/src/renderer/components/settings/gamepadSilhouetteGeom.ts, apps/desktop/src/renderer/components/settings/hookWorkspacePrefsLogic.ts, apps/desktop/src/renderer/components/settings/imBotVisibility.ts, apps/desktop/src/renderer/components/settings/imDefaultSettingsLogic.ts, apps/desktop/src/renderer/components/settings/joyConSilhouette.ts, apps/desktop/src/renderer/components/settings/modelManagementPresentation.ts, apps/desktop/src/renderer/components/settings/modelManagementState.ts, apps/desktop/src/renderer/components/settings/myDevicesModel.ts, apps/desktop/src/renderer/components/settings/providerAssetModule.ts, apps/desktop/src/renderer/components/settings/realProfilePermissionGuide.ts, apps/desktop/src/renderer/components/settings/switchProSilhouette.ts, apps/desktop/src/renderer/components/settings/ultimateC1Silhouette.ts, apps/desktop/src/renderer/components/settings/usage/UsageBreakdownTables.tsx, apps/desktop/src/renderer/components/settings/usage/UsageHistorySection.tsx, apps/desktop/src/renderer/components/settings/usage/UsageStatRow.tsx, apps/desktop/src/renderer/components/settings/usage/UsageTaskTable.tsx, apps/desktop/src/renderer/components/settings/usage/UsageTokenBars.tsx, apps/desktop/src/renderer/components/settings/usage/formatUsagePercent.ts, apps/desktop/src/renderer/components/settings/usage/usageCharts.css, apps/desktop/src/renderer/components/settings/usage/usageHistoryColors.ts, apps/desktop/src/renderer/components/settings/usage/usageHistoryStats.ts, apps/desktop/src/renderer/components/settings/usageVisibility.ts, apps/desktop/src/renderer/components/settings/useProviderSubscriptionCard.ts, apps/desktop/src/renderer/components/settings/wizardRecommend.ts, apps/desktop/src/renderer/components/settings/workLouderCodexCommandCopy.ts, apps/desktop/src/renderer/components/settings/xboxSeriesSilhouette.ts, apps/desktop/src/renderer/styles/sortable.css | 154 | 109 | 734 |
-| `desktop.shell.main-layout` | desktop | 主窗口壳(标题栏 / 左右栏 / 内容区) | main BrowserWindow → renderer/index.tsx → main-entry.tsx → App → MainLayout (`#/` 受保护壳) | ChromeActions, DeviceSectionHeader, FeishuConflictDialogHost, GhostMediaLightboxHost, MainLayout, ProjectsSection, RightSidebar, RightSidebarShell, SessionShareImportWizard, Sidebar, UpdateNoticeDialog, WindowControls | apps/desktop/src/renderer/cindy-brain/GhostMediaLightboxHost.tsx, apps/desktop/src/renderer/components/UpdateNoticeDialog.tsx, apps/desktop/src/renderer/components/feishuBot/FeishuConflictDialog.tsx, apps/desktop/src/renderer/components/feishuBot/FeishuConflictDialogHost.tsx, apps/desktop/src/renderer/components/layout/AppBadgeAttentionSync.tsx, apps/desktop/src/renderer/components/layout/BrowserWebviewPool.tsx, apps/desktop/src/renderer/components/layout/ChromeActions.tsx, apps/desktop/src/renderer/components/layout/ContentHeader.tsx, apps/desktop/src/renderer/components/layout/CredentialStoreBanner.tsx, apps/desktop/src/renderer/components/layout/FadeSwitcher.tsx, apps/desktop/src/renderer/components/layout/GhostPanelWindowLayout.tsx, apps/desktop/src/renderer/components/layout/GlobalDropImportListener.tsx, apps/desktop/src/renderer/components/layout/MainEntryRedirect.tsx, apps/desktop/src/renderer/components/layout/MainLayout.tsx, apps/desktop/src/renderer/components/layout/RightSidebar.tsx, apps/desktop/src/renderer/components/layout/RightSidebarDetach.tsx, apps/desktop/src/renderer/components/layout/RightSidebarMaximize.tsx, apps/desktop/src/renderer/components/layout/RightSidebarToggle.tsx, apps/desktop/src/renderer/components/layout/SidebarWindowLayout.tsx, apps/desktop/src/renderer/components/layout/chromeActionsGeometry.ts, apps/desktop/src/renderer/components/layout/chromeActionsLayout.ts, apps/desktop/src/renderer/components/layout/railChromeActions.ts, apps/desktop/src/renderer/components/layout/windowDrag.tsx, apps/desktop/src/renderer/components/settings/SessionShareImportWizard.tsx, apps/desktop/src/renderer/components/sidebar/AccountSwitcherDialog.tsx, apps/desktop/src/renderer/components/sidebar/AttentionDot.tsx, apps/desktop/src/renderer/components/sidebar/DatabaseSizeWarningBanner.tsx, apps/desktop/src/renderer/components/sidebar/GhostMainViewNavEntries.tsx, apps/desktop/src/renderer/components/sidebar/MobileDownloadDialog.tsx, apps/desktop/src/renderer/components/sidebar/Sidebar.tsx, apps/desktop/src/renderer/components/sidebar/SidebarIconButton.tsx, apps/desktop/src/renderer/components/sidebar/SidebarTopNav.tsx, apps/desktop/src/renderer/components/sidebar/SortableList.tsx, apps/desktop/src/renderer/components/sidebar/UpdateBanner.tsx, apps/desktop/src/renderer/components/sidebar/UserInfoSection.tsx, apps/desktop/src/renderer/components/sidebar/VendorIcon.tsx, apps/desktop/src/renderer/components/sidebar/VendorReadinessBadge.tsx, apps/desktop/src/renderer/components/sidebar/WorktreeBadge.tsx, apps/desktop/src/renderer/components/title-bar/ChromeIconButton.tsx, apps/desktop/src/renderer/components/title-bar/MenuButton.tsx, apps/desktop/src/renderer/components/title-bar/WindowControls.tsx, apps/desktop/src/renderer/features/cc-agent/sidebar/DeviceSectionHeader.tsx, apps/desktop/src/renderer/features/cc-agent/sidebar/sections/ProjectsSection.tsx, apps/desktop/src/renderer/features/right-sidebar/AddTabDropdown.tsx, apps/desktop/src/renderer/features/right-sidebar/EmptyState.tsx, apps/desktop/src/renderer/features/right-sidebar/RightSidebarShell.tsx, apps/desktop/src/renderer/features/right-sidebar/TabBar.tsx, apps/desktop/src/renderer/features/right-sidebar/TabBodyErrorBoundary.tsx, apps/desktop/src/renderer/features/right-sidebar/hooks/useBrowserWebview.ts, apps/desktop/src/renderer/features/right-sidebar/hooks/useNativePopupSurface.ts, apps/desktop/src/renderer/features/right-sidebar/iosSimulatorPluginAvailability.ts, apps/desktop/src/renderer/features/right-sidebar/lib/browserPartition.ts, apps/desktop/src/renderer/features/right-sidebar/lib/browserWebviewPool.ts, apps/desktop/src/renderer/features/right-sidebar/lib/detachedSidebarRouting.ts, apps/desktop/src/renderer/features/right-sidebar/lib/executeSidebarCommand.ts, apps/desktop/src/renderer/features/right-sidebar/lib/iosSimulatorFocusBridge.ts, apps/desktop/src/renderer/features/right-sidebar/lib/lastTurnChangedFiles.ts, apps/desktop/src/renderer/features/right-sidebar/lib/nativePopupTabs.ts, apps/desktop/src/renderer/features/right-sidebar/lib/openBackgroundTasksTab.ts, apps/desktop/src/renderer/features/right-sidebar/lib/openInSidebarBrowser.ts, apps/desktop/src/renderer/features/right-sidebar/lib/openInSidebarFileBrowser.ts, apps/desktop/src/renderer/features/right-sidebar/lib/openRoutinesTab.ts, apps/desktop/src/renderer/features/right-sidebar/lib/openSubagentsTab.ts, apps/desktop/src/renderer/features/right-sidebar/lib/openTerminalShortcut.ts, apps/desktop/src/renderer/features/right-sidebar/lib/openTurnReview.ts, apps/desktop/src/renderer/features/right-sidebar/lib/popupRouter.ts, apps/desktop/src/renderer/features/right-sidebar/lib/popupTabs.ts, apps/desktop/src/renderer/features/right-sidebar/lib/rsbBrowserBridge.ts, apps/desktop/src/renderer/features/right-sidebar/lib/sidebarCommands.ts, apps/desktop/src/renderer/features/right-sidebar/lib/sidebarHostSession.tsx, apps/desktop/src/renderer/features/right-sidebar/plugins/background-tasks/BackgroundTasksBody.tsx, apps/desktop/src/renderer/features/right-sidebar/plugins/background-tasks/WorkflowAgentStrip.tsx, apps/desktop/src/renderer/features/right-sidebar/plugins/background-tasks/WorkflowProgressTree.tsx, apps/desktop/src/renderer/features/right-sidebar/plugins/background-tasks/chatTaskFocusIntent.ts, apps/desktop/src/renderer/features/right-sidebar/plugins/background-tasks/index.tsx, apps/desktop/src/renderer/features/right-sidebar/plugins/background-tasks/listSessionTasks.ts, apps/desktop/src/renderer/features/right-sidebar/plugins/background-tasks/workflowProgressModel.ts, apps/desktop/src/renderer/features/right-sidebar/plugins/cindy-make/CindyMakeTabBody.tsx, apps/desktop/src/renderer/features/right-sidebar/plugins/cindy-make/index.tsx, apps/desktop/src/renderer/features/right-sidebar/plugins/file-browser/FileBrowserBody.css, apps/desktop/src/renderer/features/right-sidebar/plugins/file-browser/FileBrowserBody.tsx, apps/desktop/src/renderer/features/right-sidebar/plugins/file-browser/dropExternalFile.ts, apps/desktop/src/renderer/features/right-sidebar/plugins/file-browser/fileTreeImagePreview.ts, apps/desktop/src/renderer/features/right-sidebar/plugins/file-browser/index.tsx, apps/desktop/src/renderer/features/right-sidebar/plugins/file-browser/useSessionScopedTreeWidth.ts, apps/desktop/src/renderer/features/right-sidebar/plugins/index.ts, apps/desktop/src/renderer/features/right-sidebar/plugins/ios-simulator/IOSSimulatorInstanceGrid.tsx, apps/desktop/src/renderer/features/right-sidebar/plugins/ios-simulator/IOSSimulatorTabBody.tsx, apps/desktop/src/renderer/features/right-sidebar/plugins/ios-simulator/index.tsx, apps/desktop/src/renderer/features/right-sidebar/plugins/ios-simulator/iosSimulatorH264Decoder.ts, apps/desktop/src/renderer/features/right-sidebar/plugins/orca-workers/OrcaWorkersAttentionIcon.tsx, apps/desktop/src/renderer/features/right-sidebar/plugins/orca-workers/OrcaWorkersTabBody.tsx, apps/desktop/src/renderer/features/right-sidebar/plugins/orca-workers/actions.ts, apps/desktop/src/renderer/features/right-sidebar/plugins/orca-workers/closeDecision.ts, apps/desktop/src/renderer/features/right-sidebar/plugins/orca-workers/index.tsx, apps/desktop/src/renderer/features/right-sidebar/plugins/resource-usage/ResourceUsageBody.tsx, apps/desktop/src/renderer/features/right-sidebar/plugins/resource-usage/index.tsx, apps/desktop/src/renderer/features/right-sidebar/plugins/resource-usage/resource-usage.css, apps/desktop/src/renderer/features/right-sidebar/plugins/resource-usage/subscription.ts, apps/desktop/src/renderer/features/right-sidebar/plugins/review/DiffViewer/ImageDiffPreview.tsx, apps/desktop/src/renderer/features/right-sidebar/plugins/review/DiffViewer/MarkdownDiffPreview.tsx, apps/desktop/src/renderer/features/right-sidebar/plugins/review/DiffViewer/PlainUnifiedDiff.tsx, apps/desktop/src/renderer/features/right-sidebar/plugins/review/DiffViewer/diffRows.ts, apps/desktop/src/renderer/features/right-sidebar/plugins/review/DiffViewer/highlight.ts, apps/desktop/src/renderer/features/right-sidebar/plugins/review/DiffViewer/inlineDiff.ts, apps/desktop/src/renderer/features/right-sidebar/plugins/review/DiffViewer/useDiffHighlights.ts, apps/desktop/src/renderer/features/right-sidebar/plugins/review/ReviewTabBody.tsx, apps/desktop/src/renderer/features/right-sidebar/plugins/review/diffExpansionPreference.ts, apps/desktop/src/renderer/features/right-sidebar/plugins/review/fileTree.ts, apps/desktop/src/renderer/features/right-sidebar/plugins/review/gitApplyCommand.ts, apps/desktop/src/renderer/features/right-sidebar/plugins/review/index.tsx, apps/desktop/src/renderer/features/right-sidebar/plugins/review/markdownPreview.ts, apps/desktop/src/renderer/features/right-sidebar/plugins/review/useLastTurnFilter.ts, apps/desktop/src/renderer/features/right-sidebar/plugins/review/useReviewGitState.ts, apps/desktop/src/renderer/features/right-sidebar/plugins/review/useReviewSource.ts, apps/desktop/src/renderer/features/right-sidebar/plugins/routines/index.tsx, apps/desktop/src/renderer/features/right-sidebar/plugins/subagents/ConversationStream.tsx, apps/desktop/src/renderer/features/right-sidebar/plugins/subagents/DetailView.tsx, apps/desktop/src/renderer/features/right-sidebar/plugins/subagents/RunList.tsx, apps/desktop/src/renderer/features/right-sidebar/plugins/subagents/SubagentChrome.tsx, apps/desktop/src/renderer/features/right-sidebar/plugins/subagents/SubagentToolCard.tsx, apps/desktop/src/renderer/features/right-sidebar/plugins/subagents/SubagentsBody.tsx, apps/desktop/src/renderer/features/right-sidebar/plugins/subagents/index.tsx, apps/desktop/src/renderer/features/right-sidebar/plugins/subagents/subagentChangeFence.ts, apps/desktop/src/renderer/features/right-sidebar/plugins/subagents/subagentConversation.ts, apps/desktop/src/renderer/features/right-sidebar/plugins/subagents/subagentFormat.ts, apps/desktop/src/renderer/features/right-sidebar/plugins/terminal/TerminalTabBody.tsx, apps/desktop/src/renderer/features/right-sidebar/plugins/terminal/index.tsx, apps/desktop/src/renderer/features/right-sidebar/plugins/terminal/lib/xtermPool.ts, apps/desktop/src/renderer/features/right-sidebar/plugins/web-browser/BrowserChrome.tsx, apps/desktop/src/renderer/features/right-sidebar/plugins/web-browser/BrowserCommentPopover.tsx, apps/desktop/src/renderer/features/right-sidebar/plugins/web-browser/BrowserTabBody.tsx, apps/desktop/src/renderer/features/right-sidebar/plugins/web-browser/browserCommentEditorDraft.ts, apps/desktop/src/renderer/features/right-sidebar/plugins/web-browser/index.tsx, apps/desktop/src/renderer/features/right-sidebar/plugins/web-browser/lib/parseOmnibox.ts, apps/desktop/src/renderer/features/right-sidebar/plugins/web-browser/useBrowserComment.ts, apps/desktop/src/renderer/features/right-sidebar/plugins/web-browser/useLocalHtmlAutoReload.ts, apps/desktop/src/renderer/features/right-sidebar/registry.ts, apps/desktop/src/renderer/features/right-sidebar/store.ts, apps/desktop/src/renderer/features/right-sidebar/types.ts, apps/desktop/src/renderer/layout/LayoutRoot.tsx, apps/desktop/src/renderer/layout/PanelDragController.tsx, apps/desktop/src/renderer/layout/PanelDragPrototype.tsx, apps/desktop/src/renderer/layout/collapsePrefs.ts, apps/desktop/src/renderer/layout/layoutDevTools.ts, apps/desktop/src/renderer/layout/panePlacement.tsx, apps/desktop/src/renderer/layout/paneWidths.tsx, apps/desktop/src/renderer/layout/panelMaximize.tsx, apps/desktop/src/renderer/styles/generated/tokens.css, apps/desktop/src/renderer/styles/globals.css | 153 | 46 | 296 |
+| `desktop.shell.main-layout` | desktop | 主窗口壳(标题栏 / 左右栏 / 内容区) | main BrowserWindow → renderer/index.tsx → main-entry.tsx → App → MainLayout (`#/` 受保护壳) | ChromeActions, DeviceSectionHeader, FeishuConflictDialogHost, GhostMediaLightboxHost, MainLayout, ProjectsSection, RightSidebar, RightSidebarShell, SessionShareImportWizard, Sidebar, UpdateNoticeDialog, WindowControls | apps/desktop/src/renderer/cindy-brain/GhostMediaLightboxHost.tsx, apps/desktop/src/renderer/components/UpdateNoticeDialog.tsx, apps/desktop/src/renderer/components/feishuBot/FeishuConflictDialog.tsx, apps/desktop/src/renderer/components/feishuBot/FeishuConflictDialogHost.tsx, apps/desktop/src/renderer/components/layout/AppBadgeAttentionSync.tsx, apps/desktop/src/renderer/components/layout/BrowserWebviewPool.tsx, apps/desktop/src/renderer/components/layout/ChromeActions.tsx, apps/desktop/src/renderer/components/layout/ContentHeader.tsx, apps/desktop/src/renderer/components/layout/CredentialStoreBanner.tsx, apps/desktop/src/renderer/components/layout/FadeSwitcher.tsx, apps/desktop/src/renderer/components/layout/GhostPanelWindowLayout.tsx, apps/desktop/src/renderer/components/layout/GlobalDropImportListener.tsx, apps/desktop/src/renderer/components/layout/MainEntryRedirect.tsx, apps/desktop/src/renderer/components/layout/MainLayout.tsx, apps/desktop/src/renderer/components/layout/RightSidebar.tsx, apps/desktop/src/renderer/components/layout/RightSidebarDetach.tsx, apps/desktop/src/renderer/components/layout/RightSidebarMaximize.tsx, apps/desktop/src/renderer/components/layout/RightSidebarToggle.tsx, apps/desktop/src/renderer/components/layout/SidebarWindowLayout.tsx, apps/desktop/src/renderer/components/layout/chromeActionsGeometry.ts, apps/desktop/src/renderer/components/layout/chromeActionsLayout.ts, apps/desktop/src/renderer/components/layout/railChromeActions.ts, apps/desktop/src/renderer/components/layout/windowDrag.tsx, apps/desktop/src/renderer/components/settings/SessionShareImportWizard.tsx, apps/desktop/src/renderer/components/sidebar/AccountSwitcherDialog.tsx, apps/desktop/src/renderer/components/sidebar/AttentionDot.tsx, apps/desktop/src/renderer/components/sidebar/DatabaseSizeWarningBanner.tsx, apps/desktop/src/renderer/components/sidebar/GhostMainViewNavEntries.tsx, apps/desktop/src/renderer/components/sidebar/MobileDownloadDialog.tsx, apps/desktop/src/renderer/components/sidebar/Sidebar.tsx, apps/desktop/src/renderer/components/sidebar/SidebarIconButton.tsx, apps/desktop/src/renderer/components/sidebar/SidebarTopNav.tsx, apps/desktop/src/renderer/components/sidebar/SortableList.tsx, apps/desktop/src/renderer/components/sidebar/UpdateBanner.tsx, apps/desktop/src/renderer/components/sidebar/UserInfoSection.tsx, apps/desktop/src/renderer/components/sidebar/VendorIcon.tsx, apps/desktop/src/renderer/components/sidebar/VendorReadinessBadge.tsx, apps/desktop/src/renderer/components/sidebar/WorktreeBadge.tsx, apps/desktop/src/renderer/components/title-bar/ChromeIconButton.tsx, apps/desktop/src/renderer/components/title-bar/MenuButton.tsx, apps/desktop/src/renderer/components/title-bar/WindowControls.tsx, apps/desktop/src/renderer/features/cc-agent/sidebar/DeviceSectionHeader.tsx, apps/desktop/src/renderer/features/cc-agent/sidebar/sections/ProjectsSection.tsx, apps/desktop/src/renderer/features/right-sidebar/AddTabDropdown.tsx, apps/desktop/src/renderer/features/right-sidebar/EmptyState.tsx, apps/desktop/src/renderer/features/right-sidebar/RightSidebarShell.tsx, apps/desktop/src/renderer/features/right-sidebar/TabBar.tsx, apps/desktop/src/renderer/features/right-sidebar/TabBodyErrorBoundary.tsx, apps/desktop/src/renderer/features/right-sidebar/hooks/useBrowserWebview.ts, apps/desktop/src/renderer/features/right-sidebar/hooks/useNativePopupSurface.ts, apps/desktop/src/renderer/features/right-sidebar/iosSimulatorPluginAvailability.ts, apps/desktop/src/renderer/features/right-sidebar/lib/browserPartition.ts, apps/desktop/src/renderer/features/right-sidebar/lib/browserWebviewPool.ts, apps/desktop/src/renderer/features/right-sidebar/lib/detachedSidebarRouting.ts, apps/desktop/src/renderer/features/right-sidebar/lib/executeSidebarCommand.ts, apps/desktop/src/renderer/features/right-sidebar/lib/iosSimulatorFocusBridge.ts, apps/desktop/src/renderer/features/right-sidebar/lib/lastTurnChangedFiles.ts, apps/desktop/src/renderer/features/right-sidebar/lib/nativePopupTabs.ts, apps/desktop/src/renderer/features/right-sidebar/lib/openBackgroundTasksTab.ts, apps/desktop/src/renderer/features/right-sidebar/lib/openInSidebarBrowser.ts, apps/desktop/src/renderer/features/right-sidebar/lib/openInSidebarFileBrowser.ts, apps/desktop/src/renderer/features/right-sidebar/lib/openRoutinesTab.ts, apps/desktop/src/renderer/features/right-sidebar/lib/openSubagentsTab.ts, apps/desktop/src/renderer/features/right-sidebar/lib/openTerminalShortcut.ts, apps/desktop/src/renderer/features/right-sidebar/lib/openTurnReview.ts, apps/desktop/src/renderer/features/right-sidebar/lib/popupRouter.ts, apps/desktop/src/renderer/features/right-sidebar/lib/popupTabs.ts, apps/desktop/src/renderer/features/right-sidebar/lib/rsbBrowserBridge.ts, apps/desktop/src/renderer/features/right-sidebar/lib/sidebarCommands.ts, apps/desktop/src/renderer/features/right-sidebar/lib/sidebarHostSession.tsx, apps/desktop/src/renderer/features/right-sidebar/plugins/background-tasks/BackgroundTasksBody.tsx, apps/desktop/src/renderer/features/right-sidebar/plugins/background-tasks/WorkflowAgentStrip.tsx, apps/desktop/src/renderer/features/right-sidebar/plugins/background-tasks/WorkflowProgressTree.tsx, apps/desktop/src/renderer/features/right-sidebar/plugins/background-tasks/chatTaskFocusIntent.ts, apps/desktop/src/renderer/features/right-sidebar/plugins/background-tasks/index.tsx, apps/desktop/src/renderer/features/right-sidebar/plugins/background-tasks/listSessionTasks.ts, apps/desktop/src/renderer/features/right-sidebar/plugins/background-tasks/workflowProgressModel.ts, apps/desktop/src/renderer/features/right-sidebar/plugins/cindy-make/CindyMakeTabBody.tsx, apps/desktop/src/renderer/features/right-sidebar/plugins/cindy-make/index.tsx, apps/desktop/src/renderer/features/right-sidebar/plugins/file-browser/FileBrowserBody.css, apps/desktop/src/renderer/features/right-sidebar/plugins/file-browser/FileBrowserBody.tsx, apps/desktop/src/renderer/features/right-sidebar/plugins/file-browser/dropExternalFile.ts, apps/desktop/src/renderer/features/right-sidebar/plugins/file-browser/fileTreeImagePreview.ts, apps/desktop/src/renderer/features/right-sidebar/plugins/file-browser/index.tsx, apps/desktop/src/renderer/features/right-sidebar/plugins/file-browser/useSessionScopedTreeWidth.ts, apps/desktop/src/renderer/features/right-sidebar/plugins/index.ts, apps/desktop/src/renderer/features/right-sidebar/plugins/ios-simulator/IOSSimulatorInstanceGrid.tsx, apps/desktop/src/renderer/features/right-sidebar/plugins/ios-simulator/IOSSimulatorTabBody.tsx, apps/desktop/src/renderer/features/right-sidebar/plugins/ios-simulator/index.tsx, apps/desktop/src/renderer/features/right-sidebar/plugins/ios-simulator/iosSimulatorH264Decoder.ts, apps/desktop/src/renderer/features/right-sidebar/plugins/orca-workers/OrcaWorkersAttentionIcon.tsx, apps/desktop/src/renderer/features/right-sidebar/plugins/orca-workers/OrcaWorkersTabBody.tsx, apps/desktop/src/renderer/features/right-sidebar/plugins/orca-workers/actions.ts, apps/desktop/src/renderer/features/right-sidebar/plugins/orca-workers/closeDecision.ts, apps/desktop/src/renderer/features/right-sidebar/plugins/orca-workers/index.tsx, apps/desktop/src/renderer/features/right-sidebar/plugins/resource-usage/ResourceUsageBody.tsx, apps/desktop/src/renderer/features/right-sidebar/plugins/resource-usage/index.tsx, apps/desktop/src/renderer/features/right-sidebar/plugins/resource-usage/resource-usage.css, apps/desktop/src/renderer/features/right-sidebar/plugins/resource-usage/subscription.ts, apps/desktop/src/renderer/features/right-sidebar/plugins/review/DiffViewer/ImageDiffPreview.tsx, apps/desktop/src/renderer/features/right-sidebar/plugins/review/DiffViewer/MarkdownDiffPreview.tsx, apps/desktop/src/renderer/features/right-sidebar/plugins/review/DiffViewer/PlainUnifiedDiff.tsx, apps/desktop/src/renderer/features/right-sidebar/plugins/review/DiffViewer/diffRows.ts, apps/desktop/src/renderer/features/right-sidebar/plugins/review/DiffViewer/highlight.ts, apps/desktop/src/renderer/features/right-sidebar/plugins/review/DiffViewer/inlineDiff.ts, apps/desktop/src/renderer/features/right-sidebar/plugins/review/DiffViewer/useDiffHighlights.ts, apps/desktop/src/renderer/features/right-sidebar/plugins/review/ReviewTabBody.tsx, apps/desktop/src/renderer/features/right-sidebar/plugins/review/diffExpansionPreference.ts, apps/desktop/src/renderer/features/right-sidebar/plugins/review/fileTree.ts, apps/desktop/src/renderer/features/right-sidebar/plugins/review/gitApplyCommand.ts, apps/desktop/src/renderer/features/right-sidebar/plugins/review/index.tsx, apps/desktop/src/renderer/features/right-sidebar/plugins/review/markdownPreview.ts, apps/desktop/src/renderer/features/right-sidebar/plugins/review/useLastTurnFilter.ts, apps/desktop/src/renderer/features/right-sidebar/plugins/review/useReviewGitState.ts, apps/desktop/src/renderer/features/right-sidebar/plugins/review/useReviewSource.ts, apps/desktop/src/renderer/features/right-sidebar/plugins/routines/index.tsx, apps/desktop/src/renderer/features/right-sidebar/plugins/subagents/ConversationStream.tsx, apps/desktop/src/renderer/features/right-sidebar/plugins/subagents/DetailView.tsx, apps/desktop/src/renderer/features/right-sidebar/plugins/subagents/RunList.tsx, apps/desktop/src/renderer/features/right-sidebar/plugins/subagents/SubagentChrome.tsx, apps/desktop/src/renderer/features/right-sidebar/plugins/subagents/SubagentToolCard.tsx, apps/desktop/src/renderer/features/right-sidebar/plugins/subagents/SubagentsBody.tsx, apps/desktop/src/renderer/features/right-sidebar/plugins/subagents/index.tsx, apps/desktop/src/renderer/features/right-sidebar/plugins/subagents/subagentChangeFence.ts, apps/desktop/src/renderer/features/right-sidebar/plugins/subagents/subagentConversation.ts, apps/desktop/src/renderer/features/right-sidebar/plugins/subagents/subagentFormat.ts, apps/desktop/src/renderer/features/right-sidebar/plugins/terminal/TerminalTabBody.tsx, apps/desktop/src/renderer/features/right-sidebar/plugins/terminal/index.tsx, apps/desktop/src/renderer/features/right-sidebar/plugins/terminal/lib/xtermPool.ts, apps/desktop/src/renderer/features/right-sidebar/plugins/web-browser/BrowserChrome.tsx, apps/desktop/src/renderer/features/right-sidebar/plugins/web-browser/BrowserCommentPopover.tsx, apps/desktop/src/renderer/features/right-sidebar/plugins/web-browser/BrowserTabBody.tsx, apps/desktop/src/renderer/features/right-sidebar/plugins/web-browser/browserCommentEditorDraft.ts, apps/desktop/src/renderer/features/right-sidebar/plugins/web-browser/index.tsx, apps/desktop/src/renderer/features/right-sidebar/plugins/web-browser/lib/parseOmnibox.ts, apps/desktop/src/renderer/features/right-sidebar/plugins/web-browser/useBrowserComment.ts, apps/desktop/src/renderer/features/right-sidebar/plugins/web-browser/useLocalHtmlAutoReload.ts, apps/desktop/src/renderer/features/right-sidebar/registry.ts, apps/desktop/src/renderer/features/right-sidebar/store.ts, apps/desktop/src/renderer/features/right-sidebar/types.ts, apps/desktop/src/renderer/layout/LayoutRoot.tsx, apps/desktop/src/renderer/layout/PanelDragController.tsx, apps/desktop/src/renderer/layout/PanelDragPrototype.tsx, apps/desktop/src/renderer/layout/collapsePrefs.ts, apps/desktop/src/renderer/layout/layoutDevTools.ts, apps/desktop/src/renderer/layout/panePlacement.tsx, apps/desktop/src/renderer/layout/paneWidths.tsx, apps/desktop/src/renderer/layout/panelMaximize.tsx, apps/desktop/src/renderer/styles/generated/tokens.css, apps/desktop/src/renderer/styles/globals.css | 153 | 46 | 297 |
| `desktop.skillhub.local` | desktop | SkillHub 本地技能 | hash `/skillhub/local` 及详情 `/skillhub/local/:kind/global/:name`、`/skillhub/local/:kind/project/:projectHash/:name` | InstallTargetPicker, PluginManagementLayout, SkillhubDetailView, SkillhubFeatureLayout, SkillhubHomeView, SkillhubMarketPreviewPanel | apps/desktop/src/renderer/features/plugin/PluginManagementLayout.tsx, apps/desktop/src/renderer/features/skillhub/SkillhubDetailView.tsx, apps/desktop/src/renderer/features/skillhub/SkillhubFeatureLayout.tsx, apps/desktop/src/renderer/features/skillhub/SkillhubHomeView.tsx, apps/desktop/src/renderer/features/skillhub/SkillhubMarketPreviewPanel.tsx, apps/desktop/src/renderer/features/skillhub/components/InstallTargetPicker.tsx | 46 | 0 | 66 |
| `desktop.skillhub.market` | desktop | SkillHub 市场 | hash `/skillhub/market`(SkillhubMarketListView) | InstallTargetPicker, MarketCard, MarketInfoEditDialog, SkillhubMarketListView, SkillhubMarketPreviewPanel, VisibilityEditorDialog | apps/desktop/src/renderer/features/skillhub/SkillhubMarketListView.tsx, apps/desktop/src/renderer/features/skillhub/SkillhubMarketPreviewPanel.tsx, apps/desktop/src/renderer/features/skillhub/components/HomeMarketCard.tsx, apps/desktop/src/renderer/features/skillhub/components/InstallTargetPicker.tsx, apps/desktop/src/renderer/features/skillhub/components/LocalSkillControls.tsx, apps/desktop/src/renderer/features/skillhub/components/MarketCard.tsx, apps/desktop/src/renderer/features/skillhub/components/MarketInfoEditDialog.tsx, apps/desktop/src/renderer/features/skillhub/components/MarketLocalSkills.tsx, apps/desktop/src/renderer/features/skillhub/components/MarketPreviewTree.tsx, apps/desktop/src/renderer/features/skillhub/components/PlatformTagSelector.tsx, apps/desktop/src/renderer/features/skillhub/components/SkillCategoryFilterBar.tsx, apps/desktop/src/renderer/features/skillhub/components/SkillIcon.tsx, apps/desktop/src/renderer/features/skillhub/components/SkillTagList.tsx, apps/desktop/src/renderer/features/skillhub/components/TeamScopePicker.tsx, apps/desktop/src/renderer/features/skillhub/components/VisibilityEditorDialog.tsx | 52 | 0 | 63 |
| `desktop.window.computer-permission-guide` | desktop | 电脑使用权限引导 | `?view=computer-permission-guide` → ComputerPermissionGuideWindow;backdrop 同文件 | ComputerPermissionBackdrop, ComputerPermissionGuideWindow | apps/desktop/src/main/computer-permission-guide/MacComputerPermissionGuideNativeHost.ts, apps/desktop/src/main/computer-permission-guide/placement.ts, apps/desktop/src/main/computer-permission-guide/request.ts, apps/desktop/src/main/computer-permission-guide/switch-target.ts, apps/desktop/src/main/computer-permission-guide/window.ts, apps/desktop/src/renderer/components/settings/ComputerPermissionGuideWindow.tsx | 7 | 2 | 9 |