Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
fix(orca): align worker list attention and running counts
fmfsaisai7231189b259b
diff --git a/apps/desktop/scripts/fixtures/orca-worker-project/ui-page.mjs b/apps/desktop/scripts/fixtures/orca-worker-project/ui-page.mjsindex 446f6e798c..556d4bb3b5 100644--- a/apps/desktop/scripts/fixtures/orca-worker-project/ui-page.mjs+++ b/apps/desktop/scripts/fixtures/orca-worker-project/ui-page.mjs@@ -7,6 +7,16 @@ export default {notCovered:'Full Worker creation popover, model/device selection, native folder dialog, filesystem discovery, IPC and actual worktree creation',cases: {+ 'attention-error': {+ about: 'Idle Worker with unhandled task error in tabs, both menus and collapsed trigger',+ },+ 'attention-awaiting': {+ about: 'Waiting confirmation shown as blue avatar dots including collapsed trigger',+ },+ 'attention-done': {+ about:+ 'Completion unread stays green for unselected Worker and does not aggregate on trigger',+ },default: {about:'Inherited Lead worktree, new-worktree branch chooser, project search and dirty other project',@@ -28,6 +38,32 @@ export default {await page.getByRole('button').first().waitFor();},async check(page, ui) {+ if (ui.case.startsWith('attention-')) {+ const key =+ ui.case === 'attention-error'+ ? 'errorBadgeAria'+ : ui.case === 'attention-awaiting'+ ? 'awaitingBadgeAria'+ : 'unread';+ const label = await ui.t(`orca.rolePill.${key}`);+ await page.getByTestId('attention-tabs').getByLabel(label).waitFor();+ const dropdown = page.getByTestId('attention-dropdown');+ if (ui.case !== 'attention-done') await dropdown.getByLabel(label).waitFor();+ await ui.capture('tabs-and-collapsed');+ await dropdown.getByRole('button', { name: /frontend/ }).click();+ // ERR 是行按钮的相邻徽章;蓝 / 绿点在按钮头像里。+ if (ui.case === 'attention-error') assert.equal(await dropdown.getByLabel(label).count(), 2);+ else+ await dropdown+ .getByRole('button', { name: /reviewer/ })+ .getByLabel(label)+ .waitFor();+ await ui.capture('dropdown-list');+ await page.keyboard.press('Escape');+ await page.getByRole('button', { name: await ui.t('orca.rolePill.layoutMenuLabel') }).click();+ await ui.capture('layout-menu-list');+ return;+ }if (ui.case === 'workers') {await page.getByRole('button', { name: /frontend/ }).click();await page.getByText('design-system', { exact: true }).first().waitFor();diff --git a/apps/desktop/scripts/fixtures/orca-worker-project/worker-project-fixture.tsx b/apps/desktop/scripts/fixtures/orca-worker-project/worker-project-fixture.tsxindex 43b5a1dfb2..6d7c3a899f 100644--- a/apps/desktop/scripts/fixtures/orca-worker-project/worker-project-fixture.tsx+++ b/apps/desktop/scripts/fixtures/orca-worker-project/worker-project-fixture.tsx@@ -1,4 +1,16 @@-import { RolePillDropdown } from '../../../src/renderer/features/cc-agent/RolePillDropdown';+import { useEffect } from 'react';+import {+ addSessionAttention,+ clearSessionAttention,+} from '../../../src/renderer/lib/sessionAttentionStore';+import {+ markWorkerAttention,+ clearWorkerAttention,+} from '../../../src/renderer/features/cc-agent/lib/workerAttentionStore';+import {+ RolePillDropdown,+ WorkerListToolbar,+} from '../../../src/renderer/features/cc-agent/RolePillDropdown';import type { WorkerInfo } from '../../../src/renderer/features/cc-agent/hooks/useWorkers';import { mountPage } from '../../ui-page/harness';import {@@ -68,8 +80,50 @@ function WorkersFixture() {</main>);}+/** 真实 store 驱动提醒,Worker 运行状态始终 idle,以覆盖原来的漏报。 */+function AttentionFixture({ kind }: { kind: 'error' | 'awaiting' | 'done' }) {+ useEffect(() => {+ if (kind === 'done') markWorkerAttention('reviewer');+ else addSessionAttention('reviewer', kind);+ return () => {+ clearSessionAttention('reviewer', { intent: 'explicit' });+ clearWorkerAttention('reviewer');+ };+ }, [kind]);+ return (+ <main className="mx-auto w-full max-w-[480px] space-y-12 p-5">+ <section data-testid="attention-tabs">+ <WorkerListToolbar+ worker={workers[0]}+ workers={workers}+ selectedWorkerId="frontend"+ activeWorkerCount={2}+ softLimit={5}+ hardLimit={8}+ clearAttentionWhenVisible={false}+ onSwitchFocus={() => {}}+ onArchiveWorker={() => {}}+ onOpenCreate={() => {}}+ onOpenSettings={() => {}}+ />+ </section>+ <section data-testid="attention-dropdown">+ <RolePillDropdown+ worker={workers[0]}+ workers={workers}+ selectedWorkerId="frontend"+ activeWorkerCount={2}+ onSwitchFocus={() => {}}+ onArchiveWorker={() => {}}+ />+ </section>+ </main>+ );+}void mountPage({host: (ctx) => ({+ notificationMarkSessionAttention: async () => {},+ notificationClearSessionAttention: async () => {},showOpenDirectoryDialog: async () => {if (ctx.case === 'same-repo') return { canceled: false, path: '/projects/cindy' };throw new Error('fixture dialog unavailable');@@ -141,5 +195,21 @@ void mountPage({branches: ['main', 'feat/worker-project-picker', 'release/v2'],}),}),- render: (ctx) => (ctx.case === 'workers' ? <WorkersFixture /> : <Fixture />),+ render: (ctx) => {+ if (ctx.case.startsWith('attention-')) {+ localStorage.setItem('orca-worker-list-layout-v1', 'tabs');+ return (+ <AttentionFixture+ kind={+ ctx.case === 'attention-error'+ ? 'error'+ : ctx.case === 'attention-awaiting'+ ? 'awaiting'+ : 'done'+ }+ />+ );+ }+ return ctx.case === 'workers' ? <WorkersFixture /> : <Fixture />;+ },});diff --git a/apps/desktop/src/renderer/__tests__/rolePillWorkerCountSummary.test.ts b/apps/desktop/src/renderer/__tests__/rolePillWorkerCountSummary.test.tsindex 2c00eeb9f9..0c27c13e7f 100644--- a/apps/desktop/src/renderer/__tests__/rolePillWorkerCountSummary.test.ts+++ b/apps/desktop/src/renderer/__tests__/rolePillWorkerCountSummary.test.ts@@ -13,7 +13,7 @@ describe('RolePillDropdown worker count summary', () => {expect(source).toContain('const activeCount = activeWorkerCount;');expect(source).toContain("t('orca.rolePill.workerCountSummary', {");expect(source).toContain('totalCount: totalWorkerCount');- expect(source).toContain('activeCount,');+ expect(source).toContain('activeCount: runningCount,');// count 必须传给 i18next 以驱动复数选择 (en _one/_other)expect(source).toContain('count: totalWorkerCount');expect(source).not.toContain('{count} / {softLimit}');diff --git a/apps/desktop/src/renderer/features/cc-agent/RolePillDropdown.tsx b/apps/desktop/src/renderer/features/cc-agent/RolePillDropdown.tsxindex a19d870e5b..34cb418f26 100644--- a/apps/desktop/src/renderer/features/cc-agent/RolePillDropdown.tsx+++ b/apps/desktop/src/renderer/features/cc-agent/RolePillDropdown.tsx@@ -1,3 +1,4 @@+import { isRunningWorkerStatus } from '../../../shared/orca-worker-status';import { isRemoteSessionSticky } from '@/lib/makerTransport';import { getDataOwnerGeneration } from '@/contexts/dataOwnerGeneration';/**@@ -23,12 +24,36 @@ import { useAppShortcutDisplay } from '@/hooks/useAppShortcut';import { useReducedMotion } from '@/hooks/useReducedMotion';import { useConfirmDialog } from '@/components/ui/confirm-dialog-provider';import { Tip } from '@/components/ui/tooltip';+import { AttentionDot } from '@/components/sidebar/AttentionDot';+import { useSessionsAttentionKindMap, type AttentionKind } from '@/lib/sessionAttentionStore';import { VendorIcon, agentKindToVendor } from '@/components/sidebar/VendorIcon';import type { WorkerInfo } from './hooks/useWorkers';import type { WorkerExecutionDevice } from './hooks/workerProjectionStore';import { shouldShowWorkerLabel } from './workerLabel';import { clearWorkerAttention, useWorkerAttentionSnapshot } from './lib/workerAttentionStore';+/** 列表保留运行态 error 的旧表达,并补读任务告警;完成未读仍只认 Worker 自己的未读记录。 */+export function resolveWorkerListAttention(+ worker: Pick<WorkerInfo, 'status' | 'executionDevice'>,+ taskKind: AttentionKind | undefined,+ focused: boolean,+ hasUnread: boolean,+): AttentionKind | undefined {+ const localKind = worker.executionDevice ? undefined : taskKind;+ if (worker.status === 'error' || localKind === 'error') return 'error';+ if (localKind === 'awaiting') return 'awaiting';+ return !focused && hasUnread ? 'done' : undefined;+}++/** 只订阅本列表本机任务的子映射:底层以 primitive key 比较,其他任务的广播不会重渲染列表。 */+function useWorkerTaskAttention(workers: readonly WorkerInfo[]) {+ return useSessionsAttentionKindMap(+ workers+ .filter((worker) => !worker.executionDevice && !isRemoteSessionSticky(worker.sessionId))+ .map((worker) => worker.sessionId),+ );+}+// Strip provider prefix: 'deepseek/deepseek-v4-pro' → 'deepseek-v4-pro'.// 通用代理网关返回的 model id 经常带 'provider/model' 形式, UI 里只显末段更清爽.function simplifyModelName(model: string): string {@@ -124,27 +149,33 @@ function WorkerModelLine({// (ERR 药丸) + tab 整体描红承担, 这里只图标染红, 不再叠红点// (红点在多数 app 里=下级有新消息, 与"出错"语义不符, 故 error 不用点)// - idle / done: 走 VendorIcon 默认 sidebar-muted 灰 (跟 sidebar idle 一致, 不 dim)-// - showAttentionDot=true: 右上叠 6×6 绿 dot(完成未读,全端统一色表:绿=完成未读,+// - attentionKind=awaiting: 右上叠 6×6 蓝点,选中时也保留;优先于完成未读。+// - attentionKind=done: 右上叠 6×6 绿 dot(完成未读,全端统一色表:绿=完成未读,// 橙专职 running;跟 sidebar hasAttentionNotification 同款) —— done 未读用点是合适的// (点=有新结果可看); 只有 error 不该用点function WorkerAvatar({agent,status,- showAttentionDot = false,+ attentionKind,selected = false,remote = false,}: {agent: WorkerInfo['agent'];status: WorkerInfo['status'];- showAttentionDot?: boolean;+ attentionKind?: AttentionKind;selected?: boolean;/** Worker 的 Agent 在另一台电脑或分享上运行(远程供应商):与侧栏远程任务同款波纹。 */remote?: boolean;}) {const { t } = useTranslation();const vendor = agentKindToVendor(agent);+ const isError = attentionKind === 'error' || status === 'error';+ const dotTone =+ !isError && (attentionKind === 'awaiting' || attentionKind === 'done')+ ? attentionKind+ : undefined;const selectedIdleClassName =- selected && status !== 'running' && status !== 'error'+ selected && status !== 'running' && !isError? 'text-[var(--surface-on-card)]': undefined;return (@@ -152,20 +183,19 @@ function WorkerAvatar({<VendorIconvendor={vendor}size={vendor === 'cc' ? 14 : 13}- running={status === 'running'}+ running={status === 'running' && !isError}// 右上角正显示未读点时由未读点占位,波纹暂不画(与侧栏任务图标同规则)。- remote={remote && !showAttentionDot}- className={status === 'error' ? 'text-[var(--error-flat)]' : selectedIdleClassName}+ remote={remote && !dotTone}+ className={isError ? 'text-[var(--error-flat)]' : selectedIdleClassName}/>- {showAttentionDot && (+ {dotTone && (<span- className="absolute -top-[1px] -right-[1px] inline-block h-[6px] w-[6px] rounded-full"- style={{- backgroundColor: 'var(--card-status-done)',- boxShadow: '0 0 0 1.5px var(--surface-elevated)',- }}- aria-label={t('orca.rolePill.unread')}- />+ className="absolute -top-[1px] -right-[1px] inline-flex rounded-full"+ style={{ boxShadow: '0 0 0 1.5px var(--surface-elevated)' }}+ aria-label={t(dotTone === 'awaiting' ? 'orca.rolePill.awaitingBadgeAria' : 'orca.rolePill.unread')}+ >+ <AttentionDot tone={dotTone} size={6} />+ </span>)}</span>);@@ -297,12 +327,12 @@ function clearTimerRef(ref: { current: number | null }): void {function WorkerSummary({worker,- showAttentionDot,+ attentionKind,selected = false,compact = false,}: {worker: WorkerInfo;- showAttentionDot?: boolean;+ attentionKind?: AttentionKind;selected?: boolean;compact?: boolean;}) {@@ -312,7 +342,7 @@ function WorkerSummary({<WorkerAvataragent={worker.agent}status={worker.status}- showAttentionDot={showAttentionDot}+ attentionKind={attentionKind}selected={selected}remote={Boolean(worker.agentDeviceId)}/>@@ -358,6 +388,7 @@ export interface RolePillDropdownProps {worker: WorkerInfo | null;workers: WorkerInfo[];selectedWorkerId: string | null;+ /** 未归档、占槽的 Worker 数,仅用于创建上限;标题的运行数另按 status 计算。 */activeWorkerCount: number;onSwitchFocus: (workerId: string) => void;onArchiveWorker: (workerId: string) => void;@@ -490,7 +521,6 @@ function WorkerLayoutMenu({onLayoutChange,workers,selectedWorkerId,- activeWorkerCount,onSwitchFocus,onArchiveWorker,clearAttentionWhenVisible = true,@@ -499,7 +529,6 @@ function WorkerLayoutMenu({onLayoutChange: (layout: WorkerListLayout) => void;workers: WorkerInfo[];selectedWorkerId: string | null;- activeWorkerCount: number;onSwitchFocus: (workerId: string) => void;onArchiveWorker: (workerId: string) => void;clearAttentionWhenVisible?: boolean;@@ -512,9 +541,10 @@ function WorkerLayoutMenu({const hoverOpenTimerRef = useRef<number | null>(null);const hoverCloseTimerRef = useRef<number | null>(null);const attention = useWorkerAttentionSnapshot();+ const taskAttention = useWorkerTaskAttention(workers);const requestArchiveWorker = useRequestArchiveWorker(onArchiveWorker);const totalWorkerCount = workers.length;- const activeCount = activeWorkerCount;+ const runningCount = workers.filter((item) => isRunningWorkerStatus(item.status)).length;const open = openMode !== null;const menuPlacement = useAnchorMenuMaxHeight(wrapperRef, open);const menuMaxWidth = useAnchorMenuMaxWidth(wrapperRef, open, 'right');@@ -633,7 +663,7 @@ function WorkerLayoutMenu({{t('orca.rolePill.workerCountSummary', {count: totalWorkerCount,totalCount: totalWorkerCount,- activeCount,+ activeCount: runningCount,})}</span></div>@@ -642,7 +672,13 @@ function WorkerLayoutMenu({<div className="flex flex-col">{workers.map((w) => {const isFocused = w.workerId === selectedWorkerId || w.focused;- const isError = w.status === 'error';+ const attentionKind = resolveWorkerListAttention(+ w,+ taskAttention.get(w.sessionId),+ isFocused,+ attention.has(w.workerId),+ );+ const isError = attentionKind === 'error';return (<div key={w.workerId} className="group relative"><button@@ -664,7 +700,7 @@ function WorkerLayoutMenu({<WorkerAvataragent={w.agent}status={w.status}- showAttentionDot={!isFocused && attention.has(w.workerId)}+ attentionKind={attentionKind}remote={Boolean(w.agentDeviceId)}/><span className="font-medium text-[var(--text-primary)]">{w.role}</span>@@ -818,6 +854,7 @@ function WorkerTabsList({const focusedTabRef = useRef<HTMLButtonElement | null>(null);const [scrollState, setScrollState] = useState({ left: false, right: false });const attention = useWorkerAttentionSnapshot();+ const taskAttention = useWorkerTaskAttention(workers);const reducedMotion = useReducedMotion();const requestArchiveWorker = useRequestArchiveWorker(onArchiveWorker);const focusedWorkerId =@@ -920,10 +957,15 @@ function WorkerTabsList({>{workers.map((worker) => {const selected = worker.workerId === focusedWorkerId;- const showAttentionDot = !selected && attention.has(worker.workerId);+ const attentionKind = resolveWorkerListAttention(+ worker,+ taskAttention.get(worker.sessionId),+ selected,+ attention.has(worker.workerId),+ );// error 终态整体描红: 选中态保留 accent 底 (标明当前 tab) 但换红边, 非选中态// 走软红底 + 红边 + 红字, 让出错 worker 的 tab 一眼可定位。- const isError = worker.status === 'error';+ const isError = attentionKind === 'error';return (<Tipkey={worker.workerId}@@ -932,7 +974,7 @@ function WorkerTabsList({contentClassName="min-w-[220px] max-w-[260px] border-[var(--border-default)] bg-[var(--surface-elevated)] text-[var(--text-primary)] shadow-[var(--shadow-menu)]"text={<div className="py-0.5">- <WorkerSummary worker={worker} showAttentionDot={showAttentionDot} />+ <WorkerSummary worker={worker} attentionKind={attentionKind} /></div>}>@@ -956,7 +998,7 @@ function WorkerTabsList({><WorkerSummaryworker={worker}- showAttentionDot={showAttentionDot}+ attentionKind={attentionKind}selected={selected}compact/>@@ -1083,7 +1125,6 @@ export function WorkerListToolbar({onLayoutChange={handleLayoutChange}workers={workers}selectedWorkerId={selectedWorkerId}- activeWorkerCount={activeWorkerCount}onSwitchFocus={onSwitchFocus}onArchiveWorker={onArchiveWorker}clearAttentionWhenVisible={clearAttentionWhenVisible}@@ -1139,7 +1180,6 @@ export function WorkerListToolbar({onLayoutChange={handleLayoutChange}workers={workers}selectedWorkerId={selectedWorkerId}- activeWorkerCount={activeWorkerCount}onSwitchFocus={onSwitchFocus}onArchiveWorker={onArchiveWorker}clearAttentionWhenVisible={clearAttentionWhenVisible}@@ -1153,7 +1193,6 @@ export function RolePillDropdown({worker,workers,selectedWorkerId,- activeWorkerCount,onSwitchFocus,onArchiveWorker,clearAttentionWhenVisible = true,@@ -1166,6 +1205,7 @@ export function RolePillDropdown({const hoverOpenTimerRef = useRef<number | null>(null);const hoverCloseTimerRef = useRef<number | null>(null);const attention = useWorkerAttentionSnapshot();+ const taskAttention = useWorkerTaskAttention(workers);const requestArchiveWorker = useRequestArchiveWorker(onArchiveWorker);const open = openMode !== null;const menuPlacement = useAnchorMenuMaxHeight(triggerRef, open);@@ -1248,15 +1288,25 @@ export function RolePillDropdown({}const totalWorkerCount = workers.length;- const activeCount = activeWorkerCount;- // dropdown 折叠态 trigger 只显 focused worker。若其它(折叠后看不见的)worker 处于- // error, 折叠入口必须也能看出来 —— 否则违反可见性原则(展开才发现问题太迟)。这里- // 聚合出"存在非当前显示的出错 worker", 在 trigger 右上叠一个 error 角标(static,- // 聚合未读语义, 同侧栏聚合入口)。当前 worker 自己出错已由药丸整体描红表达, 故这里- // 排除当前 worker, 只提示"还有你没看到的错误"。- const hasHiddenWorkerError = workers.some(- (w) => w.status === 'error' && w.workerId !== worker.workerId,+ const runningCount = workers.filter((item) => isRunningWorkerStatus(item.status)).length;+ // 折叠入口汇总所有 Worker 的紧急提醒,保证隐藏的错误 / 确认也可见;不汇总完成未读。+ const currentAttention = resolveWorkerListAttention(+ worker,+ taskAttention.get(worker.sessionId),+ true,+ false,+ );+ const workerAttention = workers.map((item) =>+ resolveWorkerListAttention(item, taskAttention.get(item.sessionId), true, false),);+ const triggerAttention =+ currentAttention === 'error' || workerAttention.includes('error')+ ? 'error'+ : currentAttention === 'awaiting' || workerAttention.includes('awaiting')+ ? 'awaiting'+ : undefined;+ const avatarAttention =+ currentAttention === 'error' ? 'error' : triggerAttention === 'awaiting' ? 'awaiting' : undefined;return (<div className="relative" onMouseEnter={handleMouseEnter} onMouseLeave={handleMouseLeave}>@@ -1271,7 +1321,7 @@ export function RolePillDropdown({'inline-flex items-center gap-1.5 rounded-full border py-[3px] px-2.5','text-11 leading-none',// focused worker 出错时 trigger 也描红(dropdown 布局下它是常驻可见的当前 worker)- worker.status === 'error'+ currentAttention === 'error'? 'border-[var(--error-border)] bg-[var(--error-bg)] hover:bg-[var(--error-bg)]': cn('border-[var(--border-default)]',@@ -1286,12 +1336,17 @@ export function RolePillDropdown({setOpenMode((mode) => (mode === 'pinned' ? null : 'pinned'));}}>- <WorkerAvatar agent={worker.agent} status={worker.status} remote={Boolean(worker.agentDeviceId)} />+ <WorkerAvatar+ agent={worker.agent}+ status={worker.status}+ attentionKind={avatarAttention}+ remote={Boolean(worker.agentDeviceId)}+ /><span className="font-medium text-[var(--text-primary)]">{worker.role}</span>{/* 折叠入口错误徽章(内联, 而非溢出角标 —— trigger 处在会裁剪的容器里, 角标会被切)。两种情形都显: (1) 当前 focused worker 自己出错; (2) 有"当前没显示出来的"出错worker(折叠只显 focused, 描红盖不到隐藏的出错 worker)—— 满足可见性原则。 */}- {(worker.status === 'error' || hasHiddenWorkerError) && (+ {triggerAttention === 'error' && (<WorkerErrorBadge className="ml-0.5" />)}{open ? (@@ -1326,7 +1381,7 @@ export function RolePillDropdown({// totalCount/activeCount 仍用于插值。count: totalWorkerCount,totalCount: totalWorkerCount,- activeCount,+ activeCount: runningCount,})}</span></div>@@ -1336,7 +1391,13 @@ export function RolePillDropdown({{workers.map((w) => {const isFocused = w.workerId === selectedWorkerId || w.focused;// error 行整体描红(优先于 focused 高亮), 软红底 + 红左边, 与 tabs 布局一致。- const isError = w.status === 'error';+ const attentionKind = resolveWorkerListAttention(+ w,+ taskAttention.get(w.sessionId),+ isFocused,+ attention.has(w.workerId),+ );+ const isError = attentionKind === 'error';return (<div key={w.workerId} className="group relative"><button@@ -1359,7 +1420,7 @@ export function RolePillDropdown({<WorkerAvataragent={w.agent}status={w.status}- showAttentionDot={!isFocused && attention.has(w.workerId)}+ attentionKind={attentionKind}remote={Boolean(w.agentDeviceId)}/><span className="font-medium text-[var(--text-primary)]">{w.role}</span>diff --git a/apps/desktop/src/renderer/features/cc-agent/__tests__/RolePillDropdown.layoutMenu.test.tsx b/apps/desktop/src/renderer/features/cc-agent/__tests__/RolePillDropdown.layoutMenu.test.tsxindex 83dfb9f683..0324fa79d1 100644--- a/apps/desktop/src/renderer/features/cc-agent/__tests__/RolePillDropdown.layoutMenu.test.tsx+++ b/apps/desktop/src/renderer/features/cc-agent/__tests__/RolePillDropdown.layoutMenu.test.tsx@@ -1,13 +1,28 @@// @vitest-environment jsdom-import { act, cleanup, fireEvent, render, screen } from '@testing-library/react';+import { Profiler } from 'react';+import { act, cleanup, fireEvent, render, screen, within } from '@testing-library/react';import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';import type { WorkerInfo } from '../hooks/useWorkers';import { WorkerListToolbar } from '../RolePillDropdown';+import {+ addSessionAttention,+ clearSessionAttention,+ getSessionAttentionKinds,+} from '@/lib/sessionAttentionStore';+import {+ markWorkerAttention,+ __resetWorkerAttentionStoreForTest,+} from '../lib/workerAttentionStore';vi.mock('react-i18next', () => ({- useTranslation: () => ({ t: (key: string) => key }),+ useTranslation: () => ({+ t: (key: string, values?: { totalCount: number; activeCount: number }) =>+ key === 'orca.rolePill.workerCountSummary' && values+ ? `${values.totalCount} workers · ${values.activeCount} running`+ : key,+ }),}));vi.mock('@/hooks/useAppShortcut', () => ({@@ -77,6 +92,41 @@ describe('WorkerLayoutMenu hover interaction', () => {cleanup();});+ it.each(['tabs', 'dropdown'])(+ '%s 标题只数 running,但创建上限仍计入空闲、完成和出错 Worker',+ (layout) => {+ localStorage.setItem('orca-worker-list-layout-v1', layout);+ const workers = (['running', 'running', 'idle', 'done', 'error'] as const).map(+ (status, index) =>+ worker({+ workerId: `worker-${index}`,+ sessionId: `session-${index}`,+ status,+ focused: index === 0,+ }),+ );+ const onOpenCreate = vi.fn();+ const onOpenSettings = vi.fn();+ renderToolbar({+ worker: workers[0],+ workers,+ selectedWorkerId: workers[0].workerId,+ activeWorkerCount: 5,+ softLimit: 3,+ hardLimit: 5,+ onOpenCreate,+ onOpenSettings,+ });+ fireEvent.click(screen.getByRole('button', { name: 'orca.rolePill.settingsCollaboration' }));+ expect(onOpenSettings).toHaveBeenCalledOnce();+ expect(onOpenCreate).not.toHaveBeenCalled();+ fireEvent.click(+ layout === 'tabs' ? menuButton() : screen.getByRole('button', { name: /^developer/ }),+ );+ expect(screen.getByText('5 workers · 2 running')).toBeTruthy();+ },+ );+it('hover 后经打开延迟临时展开菜单', () => {renderToolbar();const wrapper = wrapperOf(menuButton());@@ -157,3 +207,148 @@ describe('WorkerLayoutMenu hover interaction', () => {expect(screen.queryByText('orca.rolePill.workersHeader')).toBeNull();});});++// 使用真实提醒 store 驱动四个展示入口;防止只修 helper 却漏接其中一份列表。+describe('Worker list task attention', () => {+ beforeEach(() => localStorage.clear());+ afterEach(() => {+ cleanup();+ for (const id of getSessionAttentionKinds().keys())+ clearSessionAttention(id, { intent: 'explicit' });+ __resetWorkerAttentionStoreForTest();+ });++ it.each(['tabs', 'dropdown'] as const)(+ '%s:idle Worker 的错误、等待确认与清除同步到行和折叠入口',+ (layout) => {+ localStorage.setItem('orca-worker-list-layout-v1', layout);+ const current = worker();+ const hidden = worker({+ workerId: 'worker-b',+ sessionId: 'session-b',+ role: 'reviewer',+ focused: false,+ status: 'done',+ });+ const view = renderToolbar({ worker: current, workers: [current, hidden] });+ const openList = () =>+ fireEvent.click(+ layout === 'tabs' ? menuButton() : screen.getByRole('button', { name: /^developer/ }),+ );++ act(() => addSessionAttention(hidden.sessionId, 'error'));+ // 未展开时:平铺 tab 或折叠入口都必须能看出隐藏 Worker 出错。+ expect(screen.getByLabelText('orca.rolePill.errorBadgeAria')).toBeTruthy();+ openList();+ const row = screen.getAllByRole('button', { name: /reviewer.*gpt-5.4/ })[0];+ expect(row.className).toContain('border-[var(--error-fg)]');+ expect(+ within(row.parentElement!).getByLabelText('orca.rolePill.errorBadgeAria'),+ ).toBeTruthy();++ act(() => {+ clearSessionAttention(hidden.sessionId, { intent: 'explicit' });+ addSessionAttention(hidden.sessionId, 'awaiting');+ markWorkerAttention(hidden.workerId);+ });+ expect(screen.queryByLabelText('orca.rolePill.errorBadgeAria')).toBeNull();+ expect(within(row).getByLabelText('orca.rolePill.awaitingBadgeAria')).toBeTruthy();+ expect(screen.queryByLabelText('orca.rolePill.unread')).toBeNull();+ fireEvent.keyDown(document, { key: 'Escape' });+ expect(screen.getByLabelText('orca.rolePill.awaitingBadgeAria')).toBeTruthy();++ // 当前 Worker 等确认仍显示;错误优先于当前/隐藏 Worker 的蓝点。+ act(() => addSessionAttention(current.sessionId, 'awaiting'));+ expect(screen.getAllByLabelText('orca.rolePill.awaitingBadgeAria').length).toBe(+ layout === 'tabs' ? 2 : 1,+ );+ act(() => addSessionAttention(current.sessionId, 'error'));+ expect(screen.getByRole('button', { name: /^developer/ }).className).toContain(+ 'border-[var(--error-',+ );+ if (layout === 'dropdown')+ expect(screen.queryByLabelText('orca.rolePill.awaitingBadgeAria')).toBeNull();+ act(() => {+ clearSessionAttention(current.sessionId, { intent: 'explicit' });+ clearSessionAttention(hidden.sessionId, { intent: 'explicit' });+ });+ expect(screen.queryByLabelText('orca.rolePill.errorBadgeAria')).toBeNull();+ expect(screen.queryByLabelText('orca.rolePill.awaitingBadgeAria')).toBeNull();+ openList();+ expect(screen.getAllByLabelText('orca.rolePill.unread').length).toBeGreaterThan(0);+ // 选中完成 Worker 后绿点隐藏,原来的「完成未读」语义不变。+ view.rerender(+ <WorkerListToolbar+ worker={hidden}+ workers={[+ { ...current, focused: false },+ { ...hidden, focused: true },+ ]}+ selectedWorkerId={hidden.workerId}+ activeWorkerCount={1}+ softLimit={5}+ hardLimit={8}+ onSwitchFocus={vi.fn()}+ onOpenCreate={vi.fn()}+ onOpenSettings={vi.fn()}+ onArchiveWorker={vi.fn()}+ />,+ );+ expect(screen.queryByLabelText('orca.rolePill.unread')).toBeNull();+ },+ );++ it('运行设备 Worker 不读本机同 id 的任务提醒,仍保留运行态 error;错误压过完成未读', () => {+ const remote = worker({+ executionDevice: {+ deviceId: 'other-device',+ remoteSessionId: 'remote-session',+ deviceName: 'Other Mac',+ reachable: true,+ workingDir: null,+ },+ });+ addSessionAttention(remote.sessionId, 'error');+ const view = renderToolbar({ worker: remote, workers: [remote] });+ expect(screen.queryByLabelText('orca.rolePill.errorBadgeAria')).toBeNull();+ act(() => addSessionAttention(remote.sessionId, 'awaiting'));+ expect(screen.queryByLabelText('orca.rolePill.awaitingBadgeAria')).toBeNull();+ view.unmount();+ markWorkerAttention(remote.workerId);+ renderToolbar({+ worker: remote,+ workers: [{ ...remote, focused: false, status: 'error' }],+ selectedWorkerId: null,+ clearAttentionWhenVisible: false,+ });+ expect(screen.getByLabelText('orca.rolePill.errorBadgeAria')).toBeTruthy();+ expect(screen.queryByLabelText('orca.rolePill.unread')).toBeNull();+ });++ it('其他任务的提醒变化不重新渲染 Worker 列表', () => {+ const onRender = vi.fn();+ const current = worker();+ render(+ <Profiler id="workers" onRender={onRender}>+ <WorkerListToolbar+ worker={current}+ workers={[current]}+ selectedWorkerId={current.workerId}+ activeWorkerCount={1}+ softLimit={5}+ hardLimit={8}+ onSwitchFocus={vi.fn()}+ onOpenCreate={vi.fn()}+ onOpenSettings={vi.fn()}+ onArchiveWorker={vi.fn()}+ />+ </Profiler>,+ );+ onRender.mockClear();+ act(() => addSessionAttention('unrelated-session', 'error'));+ expect(onRender).not.toHaveBeenCalled();+ act(() => addSessionAttention(current.sessionId, 'awaiting'));+ expect(onRender).toHaveBeenCalled();+ expect(screen.getByLabelText('orca.rolePill.awaitingBadgeAria')).toBeTruthy();+ });+});diff --git a/apps/desktop/src/renderer/i18n/locales/en/common.json b/apps/desktop/src/renderer/i18n/locales/en/common.jsonindex eff8d2e207..ec697ec28d 100644--- a/apps/desktop/src/renderer/i18n/locales/en/common.json+++ b/apps/desktop/src/renderer/i18n/locales/en/common.json@@ -15357,8 +15357,8 @@"unread": "Unread update","worker": "Worker","workersHeader": "Workers",- "workerCountSummary_one": "{{totalCount}} worker · {{activeCount}} active",- "workerCountSummary_other": "{{totalCount}} workers · {{activeCount}} active",+ "workerCountSummary_one": "{{totalCount}} worker · {{activeCount}} running",+ "workerCountSummary_other": "{{totalCount}} workers · {{activeCount}} running","statusAria": "status {{status}}","archiveWorkerAria": "Archive worker {{name}}","createWorker": "Create new worker",diff --git a/apps/desktop/src/renderer/i18n/locales/ko/common.json b/apps/desktop/src/renderer/i18n/locales/ko/common.jsonindex e0bdf41b61..811daaf92a 100644--- a/apps/desktop/src/renderer/i18n/locales/ko/common.json+++ b/apps/desktop/src/renderer/i18n/locales/ko/common.json@@ -15308,7 +15308,7 @@"unread": "읽지 않은 업데이트","worker": "Worker","workersHeader": "Workers",- "workerCountSummary_other": "전체 Worker {{totalCount}} · 활성 {{activeCount}}",+ "workerCountSummary_other": "전체 Worker {{totalCount}} · 실행 중 {{activeCount}}","statusAria": "상태 {{status}}","archiveWorkerAria": "Worker {{name}} 아카이브","createWorker": "새 Worker 만들기",diff --git a/docs/dev-rules/orca-team-architecture.md b/docs/dev-rules/orca-team-architecture.mdindex c12a83a8c5..e315a538e5 100644--- a/docs/dev-rules/orca-team-architecture.md+++ b/docs/dev-rules/orca-team-architecture.md@@ -450,7 +450,16 @@ Worker turn 被 vendor 报终止型 error,但 interrupted-turn auto-resume 仍创建 worker、`enableOrca` 创建首个 worker、任意真实 worker turn 开始后的 running、idle、archive、terminal done/error 都必须广播 `ORCA_WORKER_CHANGED`。worker DB `status` 跟随真实 turn 生命周期:Lead 派活或用户直接对话 worker 时,只有真实 turn 开始才置 `running`,**产品** terminal 才置 `done/error`(auto-resume 仍 pending/deferred 的 vendor 终态不是产品终态,见消息派发与 auto-bridge 5a);`switch_focus` / resume / restore 只能恢复可访问性,不能凭空置 `running`。实现指针:`orcaLifecycleService.ts` 的 `createWorker` / `enableTeam`、`orcaWorkerCreationService.ts` 的 `createWorkerInTeam`、`orcaTeamService.ts` 的 `dispatchWorkerTask` / `handleWorkerTurnStarted` / `handleWorkerTerminalTurn`、`register.ts` 的 status event adapter、`useWorkers.ts` 的 `useWorkers`。5. **切换 session 不重置 worker 未读状态(状态:不变量)**- worker done 的红点由 renderer 进程级 edge-trigger attention store 维护,而不是跟随组件切换重置的局部 state。worker 状态跳变进 `done` 才标 attention;正在查看该 worker 时清除 attention;只切走 / 切回不应让同一轮 done 重新变未读。协同 tab 图标另外显示 Worker 的出错(红)与等待确认(蓝),取自 Worker 自己在 `sessionAttentionStore` 的 attention;多个 Worker 时按 红 > 蓝 > 绿(完成未读)取最高一档,红 / 蓝在 tab 激活时也显示,绿点仍是激活即视为看到。实现指针:`useOrcaWorkerAttentionWatcher.ts` 的 `computeWorkerAttentionUpdates`,`RolePillDropdown.tsx` 的 selected worker clear effect,`workerAttentionStore.ts` 的 `attentionWorkerIds`,`OrcaWorkersAttentionIcon.tsx` 的 `resolveOrcaWorkersTabTone`。+ worker done 的绿点由 renderer 进程级 edge-trigger attention store 维护,而不是跟随组件切换重置的局部 state。worker 状态跳变进 `done` 才标 attention;正在查看该 worker 时清除 attention;只切走 / 切回不应让同一轮 done 重新变未读。协同 tab 图标另外显示 Worker 的出错(红)与等待确认(蓝),取自 Worker 自己在 `sessionAttentionStore` 的 attention;多个 Worker 时按 红 > 蓝 > 绿(完成未读)取最高一档,红 / 蓝在 tab 激活时也显示,绿点仍是激活即视为看到。实现指针:`useOrcaWorkerAttentionWatcher.ts` 的 `computeWorkerAttentionUpdates`,`RolePillDropdown.tsx` 的 selected worker clear effect,`workerAttentionStore.ts` 的 `attentionWorkerIds`,`OrcaWorkersAttentionIcon.tsx` 的 `resolveOrcaWorkersTabTone`。++ Worker 列表(`RolePillDropdown.tsx` 的下拉行、平铺 tab、折叠入口)同样读取本机 Worker+ 自己的任务提醒:任务为 `error` 或运行状态为 `error` 时沿用红色描边与 ERR 徽章;没有错误时,+ `awaiting` 在头像右上显示蓝点,选中也保留;完成未读绿点仍只在未选中时显示。优先级为+ 出错 > 等待确认 > 完成未读。折叠入口也提示被隐藏 Worker 的错误或等待确认,不汇总完成。+ 「运行设备」Worker 不读取本机任务提醒,保留运行状态为 `error` 的既有表达。判定统一为+ `resolveWorkerListAttention`,订阅使用 `useSessionsAttentionKindMap` 的本列表子映射,+ 不写回任何提醒状态,不改变 Worker 的运行状态。列表标题的「运行中」仅按+ `isRunningWorkerStatus` 计数;创建 Worker 的软、硬上限仍使用未归档的占槽数 `activeWorkerCount`。6. **重启后对 known worker 懒登记(状态:不变量)**app 重启后内存里的 known worker / vendorOptions 都会丢。恢复时不能只信内存 cache,必须通过 DB 的 `sessions.orca_role`、`orca_workers`、`orca_teams` 懒合成 Orca vendorOptions / worker link,保证手动 stop、terminal turn、worker 列表仍能识别已存在 worker;手动中断跟踪只能作为运行时优化,不能作为唯一事实源。刚开启协同但 worker 尚未对话时,也必须先写出可恢复的 agent 侧历史;当前通过 ready placeholder 触发 worker 首次 send,避免 Codex worker 因 rollout 缺失在重启后无法 resume。实现指针:`register.ts` 的 `synthesizeOrcaVendorOptionsFromDb`、`sessionCreateHandler.ts` 的 `sendWorkerReadyMessage`、`orcaLifecycleService.ts` 的 `enableTeam` / `sendWorkerReadyPlaceholder` 依赖、`orcaTeamStore.ts` 的 `listWorkersByLead` / `getWorkerLink`、`orcaManualInterrupt.ts` 的 known worker / manual interrupt store。