Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
fix(desktop): keep viewed completions read
Dash79c545daada7
diff --git a/apps/desktop/src/renderer/__tests__/useSessionRunningStatusSilence.test.ts b/apps/desktop/src/renderer/__tests__/useSessionRunningStatusSilence.test.tsindex 5f803d2cb1..5ca6b82128 100644--- a/apps/desktop/src/renderer/__tests__/useSessionRunningStatusSilence.test.ts+++ b/apps/desktop/src/renderer/__tests__/useSessionRunningStatusSilence.test.ts@@ -324,6 +324,36 @@ describe('useSessionRunningStatus silenced completion handling', () => {expect(onSessionDone).toHaveBeenCalledWith('session-active');});+ it('does not restore done attention after leaving a session that was active when it completed', async () => {+ vi.useFakeTimers();+ const onSessionDone = vi.fn();+ const initialProps: { activeSessionId: string | undefined } = {+ activeSessionId: 'session-active-at-completion',+ };+ const { rerender } = renderHook(+ ({ activeSessionId }: { activeSessionId: string | undefined }) =>+ useSessionRunningStatus(activeSessionId, { onSessionDone }),+ { initialProps },+ );++ await emitSnapshot(new Map([['session-active-at-completion', status(true)]]));+ await emitSnapshot(new Map([['session-active-at-completion', status(false)]]));+ await act(async () => {+ await vi.advanceTimersByTimeAsync(200);+ });+ rerender({ activeSessionId: undefined });+ await act(async () => {+ await vi.advanceTimersByTimeAsync(300);+ });++ expect(vi.mocked(addSessionAttention)).not.toHaveBeenCalledWith(+ 'session-active-at-completion',+ 'done',+ );+ expect(onSessionDone).toHaveBeenCalledOnce();+ expect(onSessionDone).toHaveBeenCalledWith('session-active-at-completion');+ });+it('does not restore done attention if a new run is visible when debounce expires', async () => {vi.useFakeTimers();const onSessionDone = vi.fn();diff --git a/apps/desktop/src/renderer/hooks/useSessionRunningStatus.ts b/apps/desktop/src/renderer/hooks/useSessionRunningStatus.tsindex b74a017720..1456827c52 100644--- a/apps/desktop/src/renderer/hooks/useSessionRunningStatus.ts+++ b/apps/desktop/src/renderer/hooks/useSessionRunningStatus.ts@@ -259,6 +259,7 @@ export function useSessionRunningStatus(// 状态判断更 robust。存量 pending 若存在(理论上不会:起新 turn 就清了),覆盖掉。const existing = pendingDoneTimersRef.current.get(sessionId);if (existing !== undefined) clearTimeout(existing);+ const wasActiveAtCompletion = sessionId === activeSessionId;const timer = setTimeout(() => {pendingDoneTimersRef.current.delete(sessionId);// 落地前重查一次当前状态:若此刻会话正等待用户输入(ask-user / permission /@@ -271,7 +272,7 @@ export function useSessionRunningStatus(const isRunning = cur?.isRunning === true;const isStarting = getStartingSessionIds().has(sessionId);const stillPending = hasPendingInteraction(cur);- if (!isActive && !isRunning && !stillPending) {+ if (!wasActiveAtCompletion && !isActive && !isRunning && !stillPending) {if (isStarting) {pendingStartingDoneAttentionRef.current.add(sessionId);} else {