Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
fix(desktop): clear resolved interaction attention (#5461)
Stella-xixidafce28b37d8
diff --git a/apps/desktop/src/renderer/__tests__/useSessionRunningStatusSilence.test.ts b/apps/desktop/src/renderer/__tests__/useSessionRunningStatusSilence.test.tsindex d66463d370..87c3808925 100644--- a/apps/desktop/src/renderer/__tests__/useSessionRunningStatusSilence.test.ts+++ b/apps/desktop/src/renderer/__tests__/useSessionRunningStatusSilence.test.ts@@ -18,6 +18,7 @@ import {addSessionAttention,clearSessionAttention,getSessionAttentionKind,+ hasSessionAttention,} from '@/lib/sessionAttentionStore';const storeMock = vi.hoisted(() => ({@@ -640,6 +641,34 @@ describe('useSessionRunningStatus silenced completion handling', () => {expect(onSessionNeedsReply).toHaveBeenCalledWith('s-setup');});+ it('clears awaiting attention when resolving a card immediately starts a continuation', async () => {+ vi.mocked(getSessionAttentionKind).mockReturnValue('awaiting');+ vi.mocked(hasSessionAttention).mockReturnValue(true);+ renderHook(() => useSessionRunningStatus(undefined));++ await emitSnapshot(new Map([['s-confirm', {+ ...status(false),+ hasPendingAskUser: true,+ }]]));+ vi.mocked(clearSessionAttention).mockClear();++ // Resolving ask/plan can start its continuation in the same projection+ // that removes the card. The awaiting badge must not survive that run.+ await emitSnapshot(new Map([['s-confirm', status(true)]]));++ expect(clearSessionAttention).toHaveBeenCalledExactlyOnceWith('s-confirm');++ vi.mocked(getSessionAttentionKind).mockReturnValue('done');+ await emitSnapshot(new Map([['s-confirm', {+ ...status(true),+ hasPendingPermission: true,+ }]]));+ vi.mocked(clearSessionAttention).mockClear();+ await emitSnapshot(new Map([['s-confirm', status(true)]]));++ expect(clearSessionAttention).not.toHaveBeenCalled();+ });+it('clears an orphaned error badge when a new turn starts and the terminal error is gone', async () => {// 回归(#592 review):失焦时报错挂了 error 角标、用户从未处置 → scheduler 起新// turn 把 store 的终止错误顶掉。running 上升沿必须把 orphan 角标 explicit 清掉,diff --git a/apps/desktop/src/renderer/hooks/useSessionRunningStatus.ts b/apps/desktop/src/renderer/hooks/useSessionRunningStatus.tsindex 30f440bc0c..63f7ba71dd 100644--- a/apps/desktop/src/renderer/hooks/useSessionRunningStatus.ts+++ b/apps/desktop/src/renderer/hooks/useSessionRunningStatus.ts@@ -341,22 +341,19 @@ export function useSessionRunningStatus(}// --- 4. Auto-clear notifications when pending state disappears ---- // If a session previously had a pending state but no longer does, and- // it's not running (i.e. the notification wasn't from a done transition),- // remove the notification. We only auto-clear for sessions that were- // in the previous pending set — done notifications are sticky until clicked.+ // If a session previously had a pending state but no longer does, remove+ // the matching awaiting notification. Do this even when resolving the card+ // immediately starts a continuation: otherwise the pending falling edge is+ // consumed while running, and no later snapshot can clear the stale badge.+ // Done/error notifications have separate owners and remain sticky.for (const sessionId of prevPendingRef.current) {if (!currentPendingSet.has(sessionId) &&- !currentRunningSet.has(sessionId) &&- hasSessionAttention(sessionId)+ hasSessionAttention(sessionId) &&+ getSessionAttentionKind(sessionId) === 'awaiting') {- // The pending state is gone — the session was answered/resolved elsewhere.- // Only auto-clear if it's not also a done-transition notification.- // Since we can't distinguish, we clear it: if it truly just finished,- // the done transition would have re-added it above.- // 默认 passive:store 会保住 'error' 红角标(pending 消失往往正是 run 以- // error 终止,branch 2 刚挂上的红角标不能被这条自动清理吞掉)。+ // 默认 passive 即可:这里只会命中 awaiting,且 clear 通知仍需同步给+ // Main / 远端,使 Windows 任务栏角标与任务行一起收敛。clearSessionAttention(sessionId);}}