Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
fix(desktop): 免打扰只作用于本机任务,静音任务不占阻塞卡仲裁
WZBbiaobd98675e601c
diff --git a/apps/desktop/src/main/__tests__/notificationService.test.ts b/apps/desktop/src/main/__tests__/notificationService.test.tsindex 83914ac6cd..14fffe7cca 100644--- a/apps/desktop/src/main/__tests__/notificationService.test.ts+++ b/apps/desktop/src/main/__tests__/notificationService.test.ts@@ -280,6 +280,29 @@ describe('notificationService — channels 分发', () => {expect(notificationCtor).toHaveBeenCalledOnce();});+ it('keeps remote-device notifications when a local task with the same id is muted', async () => {+ const { initNotificationService } = await freshService();+ const feishuIm = makeFeishuIm('owner');+ initNotificationService(baseDeps(feishuIm));+ isSessionNotificationsMutedSync.mockReturnValue(true);++ // 还原/复制过的库里可能留着同 id 的本地任务行,那是另一条任务:它的静音标记+ // 不得把其它设备发来的事件压掉(renderer 对远端任务传 markAttention: false)。+ await invokeHandler({+ sessionId: 'collision',+ title: 'Remote',+ kind: 'needs-reply',+ markAttention: false,+ channels: { desktop: true, feishu: true, mobile: true },+ });++ expect(notificationCtor).toHaveBeenCalledOnce();+ expect(feishuIm.sendMarkdownText).toHaveBeenCalledOnce();+ expect(sendMobileSessionNotify).toHaveBeenCalledWith(+ expect.objectContaining({ sessionId: 'collision', muteExempt: true }),+ );+ });+it('keeps every channel for a task that is not muted', async () => {const { initNotificationService } = await freshService();const feishuIm = makeFeishuIm('owner');diff --git a/apps/desktop/src/main/agent-island/__tests__/state.test.ts b/apps/desktop/src/main/agent-island/__tests__/state.test.tsindex d9425374e2..df700c4158 100644--- a/apps/desktop/src/main/agent-island/__tests__/state.test.ts+++ b/apps/desktop/src/main/agent-island/__tests__/state.test.ts@@ -1655,6 +1655,29 @@ describe('Agent Island display state', () => {expect(restoredOlder.currentSessionId).toBe('older');});+ it('keeps a muted pending task out of the blocking-card arbitration so outside clicks still dismiss the visible card', () => {+ const state = createAgentIslandState();+ applyAgentIslandInteractionRequest(state, { sessionId: 'visible', title: 'Visible' }, permissionRequest('r1'), 1_000);+ applyAgentIslandInteractionRequest(state, { sessionId: 'muted', title: 'Muted' }, permissionRequest('r2'), 1_100);+ setAgentIslandSessionDisplaySuppressed(state, 'muted', true);++ const display = buildAgentIslandDisplayState(state, 1_200);+ expect(display.mode).toBe('expanded');+ expect(display.displaySurface).toBe('interactionCard');+ expect(display.currentSessionId).toBe('visible');++ // 静音任务更新、排序靠前,但不上岛面:点岛外必须落实到那张真的可见的确认卡上。+ expect(dismissAgentIslandActiveReveal(state, 2_300)).toBe(true);+ expect(buildAgentIslandDisplayState(state, 2_350).mode).toBe('compact');+ expect(dismissAgentIslandActiveReveal(state, 2_360)).toBe(false);++ // 静音任务自己的确认卡不受影响,取消静音后照旧上岛。+ expect(setAgentIslandSessionDisplaySuppressed(state, 'muted', false)).toBe(true);+ const unmuted = buildAgentIslandDisplayState(state, 2_400);+ expect(unmuted.mode).toBe('expanded');+ expect(unmuted.currentSessionId).toBe('muted');+ });+it('keeps completion reminders on their card when the pointer hovers the expanded panel', () => {const state = createAgentIslandState();applyAgentIslandEvent(state, { sessionId: 'running', title: 'Running' }, statusEvent(true, 'Working'), 1_000);diff --git a/apps/desktop/src/main/agent-island/state.ts b/apps/desktop/src/main/agent-island/state.tsindex 98dcc2ee62..0dfdca4d52 100644--- a/apps/desktop/src/main/agent-island/state.ts+++ b/apps/desktop/src/main/agent-island/state.ts@@ -2101,6 +2101,10 @@ function hasActiveBlockingReveal(state: AgentIslandState, now: number): booleanfunction getActiveBlockingReveal(state: AgentIslandState, now: number): AgentIslandSessionState | null {return Array.from(state.sessions.values()).filter((session) => isBlockingSession(session) && !isBlockingRevealSuppressed(state, session))+ // 静音任务不上岛面,也不能占着「当前阻塞卡」的位:否则这里会选中它,随后+ // dismissPublishedBlockingReveal 发现 id 与真实展示卡不一致而拒绝 dismiss,+ // 用户点岛外只收起 hover,确认卡一直展开。和 hasBlockingSession 同一集合。+ .filter((session) => !state.displaySuppressedSessionIds.has(session.sessionId)).sort((a, b) => compareSessionsForDisplay(state, a, b, now))[0] ?? null;}diff --git a/apps/desktop/src/main/device-link/index.ts b/apps/desktop/src/main/device-link/index.tsindex e04c5849fb..d5cfa1bae0 100644--- a/apps/desktop/src/main/device-link/index.ts+++ b/apps/desktop/src/main/device-link/index.ts@@ -2137,11 +2137,16 @@ export function sendMobileSessionNotify(payload: {* 过期丢弃,不得把旧账号的通知发进新账号的链路。*/generation?: number;+ /**+ * 这条提醒来自其它设备(device-link)的任务:本机上可能恰有同 id 的无关任务行,+ * 那一行的静音标记管不到这条远端事件,不参与手机通道的免打扰判定。+ */+ muteExempt?: boolean;}): boolean {if (!client) return false;// 「消息免打扰」任务不推手机。放在这里而不是各调用方:代输入等旁路不经过// notification:show-session-event,这里是所有发起方的唯一出口。- if (isSessionNotificationsMutedSync(payload.sessionId)) return false;+ if (!payload.muteExempt && isSessionNotificationsMutedSync(payload.sessionId)) return false;if (payload.generation !== undefined && payload.generation !== mobileNotifyGeneration) {log.debug(`mobile notify dropped: link generation changed (account/ownership boundary), session=${payload.sessionId.slice(0, 8)}`,diff --git a/apps/desktop/src/main/notificationService.ts b/apps/desktop/src/main/notificationService.tsindex a67f533c27..501a25e363 100644--- a/apps/desktop/src/main/notificationService.ts+++ b/apps/desktop/src/main/notificationService.ts@@ -272,8 +272,9 @@ export function initNotificationService(deps: NotificationServiceDeps): void {const wantFeishu = channels?.feishu === true;if (markAttention) markSessionNeedsAttention(sessionId);// 「消息免打扰」任务不再走任何外向提醒通道(系统 toast / 灵动岛 / 手机 / 飞书);- // 未读与角标已在上一行照常记账,任务内的提醒不受影响。- if (isSessionNotificationsMutedSync(sessionId)) return;+ // 未读与角标已在上一行照常记账,任务内的提醒不受影响。静音标记属于本机那行任务,+ // 其它设备的任务(markAttention === false)可能与本机有同 id 的无关任务行,不查。+ if (markAttention && isSessionNotificationsMutedSync(sessionId)) return;// Content is read from main's transcript. Bound only enrichment, not delivery;// a timeout is not a dedupe window and never causes a second late toast.@@ -373,7 +374,7 @@ export function initNotificationService(deps: NotificationServiceDeps): void {}// 取正文 / 等交接判定期间用户可能刚开了免打扰:真正发之前再确认一次。// 手机通道在 sendMobileSessionNotify 内另有同一道门。- if (isSessionNotificationsMutedSync(sessionId)) return;+ if (markAttention && isSessionNotificationsMutedSync(sessionId)) return;if (kind === 'done' && handledByTeammate) {// Consume this event in the existing per-channel ledger. Removing a// delegation later must not replay a completion already handed off.@@ -405,6 +406,7 @@ export function initNotificationService(deps: NotificationServiceDeps): void {...(fallbackBody ? { fallbackBody } : {}), ...(mobileEventId ? { eventId: mobileEventId } : {}),...(mobileTeammateBotId ? { teammateBotId: mobileTeammateBotId } : {}),...(preview?.teammateAvatar ? { teammateAvatar: preview.teammateAvatar } : {}),+ ...(markAttention ? {} : { muteExempt: true }),});if (kind === 'done' && accepted) {notifiedReplies.set(mobileKey, eventId ? { eventId } : { fallbackSentAt: Date.now() });