Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
fix(desktop): simplify completion attention settlement
Dash4438d52cf8f1
diff --git a/apps/desktop/src/renderer/__tests__/makerChatStoreTextDeltaBatching.test.ts b/apps/desktop/src/renderer/__tests__/makerChatStoreTextDeltaBatching.test.tsindex e27ab1a68f..53c444c9a4 100644--- a/apps/desktop/src/renderer/__tests__/makerChatStoreTextDeltaBatching.test.ts+++ b/apps/desktop/src/renderer/__tests__/makerChatStoreTextDeltaBatching.test.ts@@ -561,40 +561,6 @@ describe('makerChatStore text delta batching', () => {unsubscribe();});- it('records an unexpected annotation materialization failure as a terminal error', async () => {- let annotationReads = 0;- const attachment = {- id: 'broken-annotation',- name: 'broken.png',- path: '',- ext: '.png',- size: 1,- category: 'image',- mimeType: 'image/png',- url: 'xdt-image://source/broken.png',- get annotationStrokes() {- annotationReads += 1;- if (annotationReads === 1) return [{}];- throw new Error('annotation materialization failed');- },- } as AttachedFile;-- await expect(- makerChatStore.sendMessage(- SESSION_ID,- 'annotated send',- MODEL,- EFFORT,- PERMISSION_MODE,- WORKING_DIR,- [attachment],- ),- ).rejects.toThrow('annotation materialization failed');-- expect(makerChatStore.getSnapshot(SESSION_ID).error).toBe('annotation materialization failed');- expect(makerChatStore.hasSessionTerminalError(SESSION_ID)).toBe(true);- });-it('drops stale ghost pushes before they mutate the current owner slice', () => {const staleOwnerStamp = { dataOwnerId: 'owner-b', ownerGeneration: 1 };const currentOwnerStamp = { dataOwnerId: 'owner-a', ownerGeneration: 1 };diff --git a/apps/desktop/src/renderer/__tests__/sessionStartingStore.test.ts b/apps/desktop/src/renderer/__tests__/sessionStartingStore.test.tsindex 96640b6aa9..21202d6ff8 100644--- a/apps/desktop/src/renderer/__tests__/sessionStartingStore.test.ts+++ b/apps/desktop/src/renderer/__tests__/sessionStartingStore.test.ts@@ -16,27 +16,16 @@ import {resetSessionStartingStoreForTests,SESSION_STARTING_TTL_MS,} from '@/lib/sessionStartingStore';-import {- isSessionDoneSilenced,- isSessionTerminalNotificationOwnedByScheduler,- markNextSessionDoneSilenced,- markNextSessionTerminalNotificationOwnedByScheduler,- resetSilencedSessionDoneStoreForTests,- scheduleClearSchedulerOwnedRun,- scheduleClearSilencedRun,-} from '@/lib/silencedSessionDoneStore';describe('sessionStartingStore', () => {beforeEach(() => {resetSessionStartingStoreForTests();- resetSilencedSessionDoneStoreForTests();clearRemoteSessionActivity();vi.useFakeTimers();});afterEach(() => {resetSessionStartingStoreForTests();- resetSilencedSessionDoneStoreForTests();clearRemoteSessionActivity();vi.useRealTimers();});@@ -89,22 +78,6 @@ describe('sessionStartingStore', () => {expect([...getStartingSessionIds()]).toEqual([]);});- it('clears only terminal-linger run markers on the first starting mark', () => {- markNextSessionDoneSilenced('old-silent-run', 's1');- markNextSessionTerminalNotificationOwnedByScheduler('old-owned-run', 's1');- scheduleClearSilencedRun('old-silent-run', 2_000);- scheduleClearSchedulerOwnedRun('old-owned-run', 2_000);-- markSessionStarting('s1');-- expect(isSessionDoneSilenced('s1')).toBe(false);- expect(isSessionTerminalNotificationOwnedByScheduler('s1')).toBe(false);-- markNextSessionTerminalNotificationOwnedByScheduler('current-run', 's2');- markSessionStarting('s2');- expect(isSessionTerminalNotificationOwnedByScheduler('s2')).toBe(true);- });-it('expires a starting mark that never becomes running', () => {markSessionStarting('stuck');vi.advanceTimersByTime(SESSION_STARTING_TTL_MS - 1);diff --git a/apps/desktop/src/renderer/__tests__/useSessionRunningStatusSilence.test.ts b/apps/desktop/src/renderer/__tests__/useSessionRunningStatusSilence.test.tsindex ce30545d94..7afa3152d8 100644--- a/apps/desktop/src/renderer/__tests__/useSessionRunningStatusSilence.test.ts+++ b/apps/desktop/src/renderer/__tests__/useSessionRunningStatusSilence.test.ts@@ -48,7 +48,6 @@ vi.mock('@/lib/sessionAttentionStore', () => ({vi.mock('@/lib/sessionStartingStore', () => ({getStartingSessionIds: () => startingMock.sessionIds,- useStartingSessionIds: () => startingMock.sessionIds,}));function status(isRunning: boolean, hasError = false, sideTask?: boolean): SessionStatusInfo {@@ -76,7 +75,7 @@ describe('useSessionRunningStatus silenced completion handling', () => {storeMock.listeners.clear();storeMock.terminalErrorSessions.clear();storeMock.sideTaskStopSessions.clear();- startingMock.sessionIds = new Set();+ startingMock.sessionIds.clear();resetSilencedSessionDoneStoreForTests();vi.clearAllMocks();vi.restoreAllMocks();@@ -315,13 +314,17 @@ describe('useSessionRunningStatus silenced completion handling', () => {await emitSnapshot(new Map([['session-active', status(true)]]));await emitSnapshot(new Map([['session-active', status(false)]]));+ await act(async () => {+ await vi.advanceTimersByTimeAsync(200);+ });rerender({ activeSessionId: 'session-active' });+ rerender({ activeSessionId: undefined });await act(async () => {- await vi.advanceTimersByTimeAsync(500);+ await vi.advanceTimersByTimeAsync(300);});expect(vi.mocked(addSessionAttention)).not.toHaveBeenCalledWith('session-active', 'done');- expect(onSessionDone).toHaveBeenCalledWith('session-active');+ expect(onSessionDone).not.toHaveBeenCalled();});it('does not restore done attention after leaving a session that was active when it completed', async () => {@@ -368,7 +371,7 @@ describe('useSessionRunningStatus silenced completion handling', () => {});expect(vi.mocked(addSessionAttention)).not.toHaveBeenCalledWith('session-running', 'done');- expect(onSessionDone).not.toHaveBeenCalled();+ expect(onSessionDone).toHaveBeenCalledWith('session-running');});it('does not restore done attention while the next turn is starting', async () => {@@ -384,108 +387,7 @@ describe('useSessionRunningStatus silenced completion handling', () => {});expect(vi.mocked(addSessionAttention)).not.toHaveBeenCalledWith('session-starting', 'done');- expect(onSessionDone).not.toHaveBeenCalled();- });-- it('restores deferred done attention when starting clears without a new run', async () => {- vi.useFakeTimers();- const onSessionDone = vi.fn();- const { rerender } = renderHook(() => useSessionRunningStatus(undefined, { onSessionDone }));-- await emitSnapshot(new Map([['session-failed-start', status(true)]]));- await emitSnapshot(new Map([['session-failed-start', status(false)]]));- startingMock.sessionIds.add('session-failed-start');- await act(async () => {- await vi.advanceTimersByTimeAsync(500);- });- expect(vi.mocked(addSessionAttention)).not.toHaveBeenCalledWith('session-failed-start', 'done');-- startingMock.sessionIds = new Set();- rerender();-- expect(vi.mocked(addSessionAttention)).toHaveBeenCalledWith('session-failed-start', 'done');- expect(onSessionDone).toHaveBeenCalledTimes(1);- });-- it('restores deferred attention as error when the attempted start fails terminally', async () => {- vi.useFakeTimers();- const onSessionDone = vi.fn();- const onSessionError = vi.fn();- const { rerender } = renderHook(() =>- useSessionRunningStatus(undefined, { onSessionDone, onSessionError }),- );-- await emitSnapshot(new Map([['session-terminal-start-failure', status(true)]]));- await emitSnapshot(new Map([['session-terminal-start-failure', status(false)]]));- startingMock.sessionIds.add('session-terminal-start-failure');- await act(async () => {- await vi.advanceTimersByTimeAsync(500);- });- expect(vi.mocked(addSessionAttention)).not.toHaveBeenCalledWith(- 'session-terminal-start-failure',- 'done',- );-- storeMock.terminalErrorSessions.add('session-terminal-start-failure');- startingMock.sessionIds = new Set();- rerender();-- expect(vi.mocked(addSessionAttention)).toHaveBeenCalledWith(- 'session-terminal-start-failure',- 'error',- );- expect(vi.mocked(addSessionAttention)).not.toHaveBeenCalledWith(- 'session-terminal-start-failure',- 'done',- );- expect(onSessionDone).not.toHaveBeenCalled();- expect(onSessionError).toHaveBeenCalledOnce();- expect(onSessionError).toHaveBeenCalledWith('session-terminal-start-failure');- });-- it('drops deferred done attention when starting becomes a real run', async () => {- vi.useFakeTimers();- const onSessionDone = vi.fn();- renderHook(() => useSessionRunningStatus(undefined, { onSessionDone }));-- await emitSnapshot(new Map([['session-started', status(true)]]));- await emitSnapshot(new Map([['session-started', status(false)]]));- startingMock.sessionIds.add('session-started');- await act(async () => {- await vi.advanceTimersByTimeAsync(500);- });-- startingMock.sessionIds = new Set();- await emitSnapshot(new Map([['session-started', status(true)]]));-- expect(vi.mocked(addSessionAttention)).not.toHaveBeenCalledWith('session-started', 'done');- expect(onSessionDone).not.toHaveBeenCalled();- });-- it('does not emit stale done when a failed start has already recorded a terminal error', async () => {- vi.useFakeTimers();- const onSessionDone = vi.fn();- const onSessionError = vi.fn();- renderHook(() => useSessionRunningStatus(undefined, { onSessionDone, onSessionError }));-- await emitSnapshot(new Map([['session-preparation-error', status(true)]]));- await emitSnapshot(new Map([['session-preparation-error', status(false)]]));- storeMock.terminalErrorSessions.add('session-preparation-error');- await act(async () => {- await vi.advanceTimersByTimeAsync(500);- });-- expect(vi.mocked(addSessionAttention)).toHaveBeenCalledWith(- 'session-preparation-error',- 'error',- );- expect(vi.mocked(addSessionAttention)).not.toHaveBeenCalledWith(- 'session-preparation-error',- 'done',- );- expect(onSessionDone).not.toHaveBeenCalled();- expect(onSessionError).toHaveBeenCalledOnce();- expect(onSessionError).toHaveBeenCalledWith('session-preparation-error');+ expect(onSessionDone).toHaveBeenCalledWith('session-starting');});it('coalesces multiple queue-drain transitions into a single final notification', async () => {diff --git a/apps/desktop/src/renderer/hooks/useSessionRunningStatus.ts b/apps/desktop/src/renderer/hooks/useSessionRunningStatus.tsindex 8562e73cda..3e725c18da 100644--- a/apps/desktop/src/renderer/hooks/useSessionRunningStatus.ts+++ b/apps/desktop/src/renderer/hooks/useSessionRunningStatus.ts@@ -48,11 +48,12 @@ import {useSessionAttentionSnapshot,} from '@/lib/sessionAttentionStore';import {- clearCompletedRunMarkersForNewActivity,+ clearCompletedSchedulerOwnedRunForNewActivity,+ clearCompletedSilencedRunForNewActivity,isSessionTerminalNotificationOwnedByScheduler,isSessionDoneSilenced,} from '@/lib/silencedSessionDoneStore';-import { getStartingSessionIds, useStartingSessionIds } from '@/lib/sessionStartingStore';+import { getStartingSessionIds } from '@/lib/sessionStartingStore';// Codex maker 化后, codex session 也走 makerChatStore;// 不再需要双 store 合并 —— 直接订阅 makerChatStore 即可。@@ -64,22 +65,13 @@ import { getStartingSessionIds, useStartingSessionIds } from '@/lib/sessionStart*/const QUEUE_DEBOUNCE_MS = 500;-function hasPendingInteraction(info: SessionStatusInfo | undefined): boolean {- return !!info && (- info.hasPendingAskUser ||- info.hasPendingPermission ||- info.hasPendingPlanReview ||- info.hasPendingPluginSetup- );-}-interface UseSessionRunningStatusOptions {/**- * Fired after a session transitions running → done and remains idle through- * the queue debounce. A next turn that is already running or starting- * suppresses the stale completion; a failed optimistic start restores it.- * Active-session focus remains the consumer's decision, while the in-app dot- * separately skips completions the user already viewed.+ * Fired when a session transitions running → done. Filters out errored+ * sessions only — does NOT filter out the active session, because the+ * "should we actually notify the user" decision (focus state, etc.) is+ * the consumer's. The in-app dot still skips active session via its own+ * branch; the callback fires for any non-error done.*/onSessionDone?: (sessionId: string) => void;/**@@ -98,13 +90,6 @@ interface UseSessionRunningStatusOptions {onSessionNeedsReply?: (sessionId: string) => void;}-interface DeferredStartingCompletion {- /** Whether the in-app done attention was still eligible when debounce expired. */- restoreAttention: boolean;- /** Scheduler-owned runs keep their external completion notification suppressed. */- notify: boolean;-}-/*** @param activeSessionId - The currently viewed session ID (from URL match).* @param options - Optional callbacks for transition side effects.@@ -120,7 +105,6 @@ export function useSessionRunningStatus(makerChatStore.getRunningSnapshot,makerChatStore.getRunningSnapshot,);- const startingSessionIds = useStartingSessionIds();// Latest callbacks — kept in refs so the transition effect doesn't// re-run when the caller passes inline lambdas each render.@@ -135,13 +119,6 @@ export function useSessionRunningStatus(onSessionNeedsReplyRef.current = options?.onSessionNeedsReply;}, [options?.onSessionDone, options?.onSessionError, options?.onSessionNeedsReply]);- const settleSessionError = useCallback((sessionId: string) => {- addSessionAttention(sessionId, 'error');- if (!isSessionTerminalNotificationOwnedByScheduler(sessionId)) {- onSessionErrorRef.current?.(sessionId);- }- }, []);-// Track previous running set to detect running -> done transitionsconst prevRunningRef = useRef(new Set<string>());@@ -161,13 +138,6 @@ export function useSessionRunningStatus(new Map<string, ReturnType<typeof setTimeout>>(),);- // debounce 到期时下一轮仍处于 starting,把上一轮 done 角标与系统通知一起- // 暂缓。starting 若随后失败 / 暂停 / TTL 清除且没有权威运行态,再恢复;- // 成功进入 running 则两者一起丢弃,避免新一轮已经开始后补发旧完成通知。- const pendingStartingCompletionsRef = useRef(- new Map<string, DeferredStartingCompletion>(),- );-const notifications = useSessionAttentionSnapshot();// Detect transitions that should add or remove notifications.@@ -175,41 +145,14 @@ export function useSessionRunningStatus(const currentRunningSet = deriveRunningSet(statusMap);const prevRunning = prevRunningRef.current;- // starting 是乐观态,可能以失败 / 暂停结束而从未进入 running。若 debounce- // 期间因此抑制了上一轮 done,starting 清除后必须按当前权威状态收口。- for (const [sessionId, deferred] of pendingStartingCompletionsRef.current) {- const cur = statusMap.get(sessionId);- const hasError = makerChatStore.hasSessionTerminalError(sessionId);- const isActive = sessionId === activeSessionId;- const isRunning = cur?.isRunning === true;- const stillPending = hasPendingInteraction(cur);- // 启动失败可能从未进入 running,因此不会再有 running→stopped 转换来把- // deferred done 升级成 error。权威终止错误一旦存在就立即收口为红点,- // 也不受 active / starting 抑制(done 才有「正在看就不亮」语义)。- if (hasError) {- pendingStartingCompletionsRef.current.delete(sessionId);- settleSessionError(sessionId);- continue;- }- if (isRunning) {- pendingStartingCompletionsRef.current.delete(sessionId);- continue;- }- if (startingSessionIds.has(sessionId)) continue;- pendingStartingCompletionsRef.current.delete(sessionId);- if (deferred.restoreAttention && !isActive && !stillPending) {- addSessionAttention(sessionId, 'done');- }- if (deferred.notify) onSessionDoneRef.current?.(sessionId);- }-// --- 1. Detect new turn starts ---for (const sessionId of currentRunningSet) {if (!prevRunning.has(sessionId)) {// 只清「run 已终态」的标记(用户手动起的新对话或下一个 run);run 还在跑时// 是 subagent 续 turn / silent-stop 自动续跑,标记必须留着。兜底定时器不在// 这里动 —— 统一由本 effect 末尾的对账按当前 running 状态处理。- clearCompletedRunMarkersForNewActivity(sessionId);+ clearCompletedSilencedRunForNewActivity(sessionId);+ clearCompletedSchedulerOwnedRunForNewActivity(sessionId);// error 红角标与真实错误态同步:新 turn 启动会清掉 store 的终止错误// (staleErrorClearedOnTurnStart),若此时角标还是 'error' 就成了 orphan——// 活跃会话的 done 分支不覆写它,角标会永久残留。错误已不存在,这里显式清除@@ -268,7 +211,8 @@ export function useSessionRunningStatus(// 即使是当前活跃会话也挂红角标:红点跟随「告警未处理」而非「是否看到」,// 横幅就在眼前时列表同样亮点(2026-07 统一决策)。不能沿用「活跃会话不亮」// 的 done 语义。清除只能来自用户处置横幅或 pending-alerts 派生收敛。- settleSessionError(sessionId);+ addSessionAttention(sessionId, 'error');+ if (!notificationOwnedByScheduler) onSessionErrorRef.current?.(sessionId);continue;}@@ -296,22 +240,21 @@ export function useSessionRunningStatus(const isActive = sessionId === activeSessionIdRef.current;const isRunning = cur?.isRunning === true;const isStarting = getStartingSessionIds().has(sessionId);- const stillPending = hasPendingInteraction(cur);- const hasError = makerChatStore.hasSessionTerminalError(sessionId);- if (hasError) {- settleSessionError(sessionId);- return;+ const stillPending =+ !!cur &&+ (cur.hasPendingAskUser ||+ cur.hasPendingPermission ||+ cur.hasPendingPlanReview ||+ cur.hasPendingPluginSetup);+ if (+ !wasActiveAtCompletion &&+ !isActive &&+ !isRunning &&+ !isStarting &&+ !stillPending+ ) {+ addSessionAttention(sessionId, 'done');}- if (isRunning) return;- const restoreAttention = !wasActiveAtCompletion && !isActive && !stillPending;- if (isStarting) {- pendingStartingCompletionsRef.current.set(sessionId, {- restoreAttention,- notify: !notificationOwnedByScheduler,- });- return;- }- if (restoreAttention) addSessionAttention(sessionId, 'done');if (!notificationOwnedByScheduler) onSessionDoneRef.current?.(sessionId);}, QUEUE_DEBOUNCE_MS);pendingDoneTimersRef.current.set(sessionId, timer);@@ -321,7 +264,12 @@ export function useSessionRunningStatus(// --- 3. Detect pending ask-user / permission / plan-review / plugin-setup ---const currentPendingSet = new Set<string>();for (const [id, info] of statusMap) {- if (hasPendingInteraction(info)) {+ if (+ info.hasPendingAskUser ||+ info.hasPendingPermission ||+ info.hasPendingPlanReview ||+ info.hasPendingPluginSetup+ ) {currentPendingSet.add(id);const isActive = id === activeSessionId;const wasAlreadyPending = prevPendingRef.current.has(id);@@ -369,7 +317,7 @@ export function useSessionRunningStatus(prevRunningRef.current = new Set(currentRunningSet);prevPendingRef.current = currentPendingSet;- }, [statusMap, activeSessionId, startingSessionIds, settleSessionError]);+ }, [statusMap, activeSessionId]);// Unmount cleanup:清掉所有还没 fire 的 done debounce 定时器,避免 hook 卸载后// 定时器仍触发 addSessionAttention / onSessionDone(referring stale refs 后果小,@@ -379,7 +327,6 @@ export function useSessionRunningStatus(return () => {for (const t of timers.values()) clearTimeout(t);timers.clear();- pendingStartingCompletionsRef.current.clear();};}, []);@@ -387,7 +334,15 @@ export function useSessionRunningStatus(// 默认 passive:切到会话 ≠ 处置了报错。store 会保住 'error' 红角标,// 只有用户处置横幅或告警本身消失才清。useEffect(() => {- if (activeSessionId) clearSessionAttention(activeSessionId);+ if (!activeSessionId) return;+ clearSessionAttention(activeSessionId);+ // 完成后的 debounce 窗口内用户已经点进任务,说明这次完成已被消费。+ // 直接取消待落地的 done,避免用户很快切走后定时器再补橙点并抬升排序。+ const pendingTimer = pendingDoneTimersRef.current.get(activeSessionId);+ if (pendingTimer !== undefined) {+ clearTimeout(pendingTimer);+ pendingDoneTimersRef.current.delete(activeSessionId);+ }}, [activeSessionId]);const clearNotification = useCallback(diff --git a/apps/desktop/src/renderer/lib/makerChatStore.ts b/apps/desktop/src/renderer/lib/makerChatStore.tsindex 6582478bf6..e3051bc4af 100644--- a/apps/desktop/src/renderer/lib/makerChatStore.ts+++ b/apps/desktop/src/renderer/lib/makerChatStore.ts@@ -12309,19 +12309,6 @@ function isRemoteMediaSession(sessionId: string): boolean {return Boolean(getOrCreateState(sessionId).remoteHostId ?? getStickySessionDeviceId(sessionId));}-/** 发送前准备失败也属于本轮终止错误,供错误横幅与侧栏红点读取。 */-function recordSendPreparationError(sessionId: string, error: unknown): void {- const message = decodeRemoteErrorMessage(error instanceof Error ? error.message : String(error));- setState(sessionId, (s) => ({- ...s,- error: message,- usageLimitRecovery: null,- errorReason: null,- recoverableError: null,- errorRetryText: null,- }));-}-/*** 共享发送边界:同步完成「无切换在途」检查与发送 token 登记,并保证同步抛错和* Promise settle 两条路径都会释放。`task` 仍在当前调用栈内启动,保留 sendMessage@@ -12460,9 +12447,6 @@ function sendMessage(null,materializeAnnotatedAttachmentsForSend(files, sessionId, {stripAnnotationMeta: isRemoteMediaSession(sessionId),- }).catch((error) => {- recordSendPreparationError(sessionId, error);- throw error;}),(prepared) =>sendMessageCore(diff --git a/apps/desktop/src/renderer/lib/sessionStartingStore.ts b/apps/desktop/src/renderer/lib/sessionStartingStore.tsindex d8a58d48b5..1e3e1776ba 100644--- a/apps/desktop/src/renderer/lib/sessionStartingStore.ts+++ b/apps/desktop/src/renderer/lib/sessionStartingStore.ts@@ -15,7 +15,6 @@import { useEffect, useSyncExternalStore } from 'react';import { dropStaleRemoteTerminalActivity } from '@/features/device-link/remoteSessionActivityStore';-import { clearCompletedRunMarkersForNewActivity } from '@/lib/silencedSessionDoneStore';/** 发送失败 / 状态一直不到时的兜底;正常路径应在 agent 开跑时就被吸收。 */export const SESSION_STARTING_TTL_MS = 120_000;@@ -54,11 +53,8 @@ export function markSessionStarting(sessionId: string): void {if (!sessionId) return;const already = startingIds.has(sessionId);if (!already) {- // starting 是早于真实 running 的新 activity 边界。先清上一轮已终态 marker,- // 避免它在 linger 内把本轮准备失败误认成 scheduler-owned / silenced;仍在- // 飞行的 marker 没有 linger timer,不会被清。重复 mark 只刷新 TTL,不能再- // 删除本轮后续建立的新 run marker 或新到达的远程终态。- clearCompletedRunMarkersForNewActivity(sessionId);+ // 先丢掉上一轮远程终态,再置 starting。否则 absorb 会把旧 completed/error+ // 当成新权威立刻清掉。重复 mark 只刷新 TTL,不能再删本轮新到达的终态。dropStaleRemoteTerminalActivity(sessionId);startingIds.add(sessionId);}diff --git a/apps/desktop/src/renderer/lib/silencedSessionDoneStore.ts b/apps/desktop/src/renderer/lib/silencedSessionDoneStore.tsindex fe1763ed6d..3bfd893e6b 100644--- a/apps/desktop/src/renderer/lib/silencedSessionDoneStore.ts+++ b/apps/desktop/src/renderer/lib/silencedSessionDoneStore.ts@@ -17,7 +17,7 @@* 次真 done 会当成普通完成,把 macOS toast / 飞书 / 手机推送全发一遍。** 清除只有三条路径:scheduler 的 completed / failed / notified 事件、run 已终态后该- * session 又起新 activity、以及对账权威 run 状态(`reconcileRunMarkers`,治事件丢失)。前两条+ * session 又起新 turn、以及对账权威 run 状态(`reconcileRunMarkers`,治事件丢失)。前两条* 与第三条统一走 `MARKER_TERMINAL_LINGER_MS` 的退场窗口。main 侧灵动岛* (`main/agent-island/service.ts` 的 `isCompletionEventSilenced`)是同一套语义,* 两边不要再分叉。@@ -231,7 +231,7 @@ export function clearSchedulerOwnedRun(runId: string): string | undefined {}/**- * run 已终态(completed/failed 排了 linger)后该 session 又起新 activity:那是用户手动+ * run 已终态(completed/failed 排了 linger)后该 session 又起新 turn:那是用户手动* 对话或下一个 run,立刻交回普通通知路径。run 还在跑时不清 —— 判据是* `schedulerOwnedClearTimers` 有没有 linger 定时器,而不是任何时间或 running 推断。*/@@ -258,16 +258,6 @@ export function clearCompletedSilencedRunForNewActivity(sessionId: string): voidclearSilencedRun(runId);}-/**- * 新 activity 的统一边界。starting 在真实 running 之前调用,因此也覆盖附件准备- * 失败等永远不会进入 running 的尝试;仍在飞行的 marker 没有 linger timer,- * 两个 clear 函数都会保持它。- */-export function clearCompletedRunMarkersForNewActivity(sessionId: string): void {- clearCompletedSilencedRunForNewActivity(sessionId);- clearCompletedSchedulerOwnedRunForNewActivity(sessionId);-}-export function clearSilencedRun(runId: string): string | undefined {clearPendingTimer(runId);const sessionId = silencedRunSessionIds.get(runId);@@ -321,6 +311,3 @@ function clearSchedulerOwnedTimer(runId: string | undefined): void {clearTimeout(timer);schedulerOwnedClearTimers.delete(runId);}---