Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
fix(desktop): avoid duplicate handoff Feishu notices
guyongdc17ffa7df42
diff --git a/apps/desktop/src/renderer/__tests__/sessionEventNotification.test.ts b/apps/desktop/src/renderer/__tests__/sessionEventNotification.test.tsindex 91f48d563f..aeb3ade135 100644--- a/apps/desktop/src/renderer/__tests__/sessionEventNotification.test.ts+++ b/apps/desktop/src/renderer/__tests__/sessionEventNotification.test.ts@@ -95,17 +95,17 @@ describe('shared session event notifications', () => {});});- it('keeps desktop and Feishu reminders but skips generic phone delivery for an input handoff', () => {+ it('keeps the desktop reminder but skips duplicate phone and Feishu delivery for an input handoff', () => {gates.feishu = true;- sendSessionEventNotification('handoff-session', 'Task', 'needs-reply', { mobile: false });+ sendSessionEventNotification('handoff-session', 'Task', 'needs-reply', { mobile: false, feishu: false });expect(markAttention).toHaveBeenCalledWith('handoff-session');expect(showSessionEvent).toHaveBeenCalledWith({sessionId: 'handoff-session',title: 'Task',kind: 'needs-reply',- channels: { desktop: true, feishu: true, mobile: false },+ channels: { desktop: true, feishu: false, mobile: false },});});diff --git a/apps/desktop/src/renderer/__tests__/useSessionRunningStatusSilence.test.ts b/apps/desktop/src/renderer/__tests__/useSessionRunningStatusSilence.test.tsindex 88764e40ad..6e25095c2d 100644--- a/apps/desktop/src/renderer/__tests__/useSessionRunningStatusSilence.test.ts+++ b/apps/desktop/src/renderer/__tests__/useSessionRunningStatusSilence.test.ts@@ -673,7 +673,7 @@ describe('useSessionRunningStatus silenced completion handling', () => {});await emitSnapshot(new Map([['s-handoff', handoffStatus(1)]]));- expect(onSessionNeedsReply).toHaveBeenCalledExactlyOnceWith('s-handoff', { mobile: false });+ expect(onSessionNeedsReply).toHaveBeenCalledExactlyOnceWith('s-handoff', { mobile: false, feishu: false });first.result.current.clearNotification('s-handoff');first.unmount();vi.mocked(addSessionAttention).mockClear();@@ -693,7 +693,7 @@ describe('useSessionRunningStatus silenced completion handling', () => {await emitSnapshot(new Map([['s-handoff', handoffStatus(2)]]));expect(onSessionNeedsReply).toHaveBeenCalledTimes(2);- expect(onSessionNeedsReply).toHaveBeenLastCalledWith('s-handoff', { mobile: false });+ expect(onSessionNeedsReply).toHaveBeenLastCalledWith('s-handoff', { mobile: false, feishu: false });expect(addSessionAttention).toHaveBeenCalledWith('s-handoff', 'awaiting');await emitSnapshot(new Map([['s-handoff', handoffStatus(2)]]));expect(onSessionNeedsReply).toHaveBeenCalledTimes(2);@@ -708,7 +708,7 @@ describe('useSessionRunningStatus silenced completion handling', () => {...status(false), hasPendingInputHandoff: true, hasActionableInputHandoff: true,pendingRequestKeys: ['handoff:same-request:1'],}]]));- expect(onSessionNeedsReply).toHaveBeenLastCalledWith('s-mixed', { mobile: false });+ expect(onSessionNeedsReply).toHaveBeenLastCalledWith('s-mixed', { mobile: false, feishu: false });await emitSnapshot(new Map([['s-mixed', {...status(false), hasPendingInputHandoff: true, hasActionableInputHandoff: true,diff --git a/apps/desktop/src/renderer/features/cc-agent/CCAgentSidebarUpper.tsx b/apps/desktop/src/renderer/features/cc-agent/CCAgentSidebarUpper.tsxindex ee2405e0da..97895fc256 100644--- a/apps/desktop/src/renderer/features/cc-agent/CCAgentSidebarUpper.tsx+++ b/apps/desktop/src/renderer/features/cc-agent/CCAgentSidebarUpper.tsx@@ -1206,7 +1206,7 @@ function ExpandedView({const unnamedLabelRef = useRef('');unnamedLabelRef.current = t('ccAgent.common.unnamedSession');const fireSessionNotification = useCallback(- (sessionId: string, kind: 'done' | 'error' | 'needs-reply', options?: { mobile: false }) => {+ (sessionId: string, kind: 'done' | 'error' | 'needs-reply', options?: { mobile: false; feishu: false }) => {const session = findSessionNotificationSession(sessionId, [sessionsRef.current,allSessionsForNotificationRef.current,@@ -1264,7 +1264,7 @@ function ExpandedView({[fireSessionNotification],);const handleSessionNeedsReply = useCallback(- (sessionId: string, options?: { mobile: false }) => fireSessionNotification(sessionId, 'needs-reply', options),+ (sessionId: string, options?: { mobile: false; feishu: false }) => fireSessionNotification(sessionId, 'needs-reply', options),[fireSessionNotification],);diff --git a/apps/desktop/src/renderer/hooks/useSessionRunningStatus.ts b/apps/desktop/src/renderer/hooks/useSessionRunningStatus.tsindex abbacde465..ea62b6b007 100644--- a/apps/desktop/src/renderer/hooks/useSessionRunningStatus.ts+++ b/apps/desktop/src/renderer/hooks/useSessionRunningStatus.ts@@ -103,7 +103,7 @@ interface UseSessionRunningStatusOptions {* edge fires for a new request (or new input-handoff step) in the session.* Like onSessionDone, no active-session filter; the consumer decides.*/- onSessionNeedsReply?: (sessionId: string, options?: { mobile: false }) => void;+ onSessionNeedsReply?: (sessionId: string, options?: { mobile: false; feishu: false }) => void;}/**@@ -383,8 +383,9 @@ export function useSessionRunningStatus(addSessionAttention(id, 'awaiting');}if (!wasAlreadyPending) {- // Main already sends each actionable handoff step its fixed-copy phone- // push. Keep the desktop reminder without sending a second generic one.+ // Main sends each actionable step its fixed-copy phone push and one+ // Feishu/channel pointer per request (including desktop /ctr). Keep+ // the desktop reminder without repeating those external notices.const handoffOnly = newKeys?.length? newKeys.every((key) => key.startsWith('handoff:')): info.hasActionableInputHandoff === true@@ -392,7 +393,7 @@ export function useSessionRunningStatus(&& !info.hasPendingPermission&& !info.hasPendingPlanReview&& !info.hasPendingPluginSetup;- if (handoffOnly) onSessionNeedsReplyRef.current?.(id, { mobile: false });+ if (handoffOnly) onSessionNeedsReplyRef.current?.(id, { mobile: false, feishu: false });else onSessionNeedsReplyRef.current?.(id);}// Other hook consumers only read running status. They may add thediff --git a/apps/desktop/src/renderer/lib/sessionEventNotification.ts b/apps/desktop/src/renderer/lib/sessionEventNotification.tsindex 4f7f7e7649..ead32ababd 100644--- a/apps/desktop/src/renderer/lib/sessionEventNotification.ts+++ b/apps/desktop/src/renderer/lib/sessionEventNotification.ts@@ -110,6 +110,8 @@ export function sendSessionEventNotification(remoteDeviceId?: string | null;/** Main owns the fixed-copy phone push for input-handoff steps. */mobile?: boolean;+ /** Main owns the one-time Feishu/channel pointer for input handoffs. */+ feishu?: boolean;} = {},): void {// The user is already looking at Cindy. In-app attention remains available,@@ -118,11 +120,11 @@ export function sendSessionEventNotification(if (kind === 'done' && options.remoteDeviceId) {sendRemoteCompletionNotification(sessionId, options.remoteDeviceId, () =>- deliverSessionEventNotification(sessionId, title, kind, true, options.mobile !== false));+ deliverSessionEventNotification(sessionId, title, kind, true, options));return;}- deliverSessionEventNotification(sessionId, title, kind, options.remoteDevice === true, options.mobile !== false);+ deliverSessionEventNotification(sessionId, title, kind, options.remoteDevice === true, options);}const pendingRemoteCompletions = new Map<string, () => void>();@@ -160,7 +162,13 @@ function sendRemoteCompletionNotification(sessionId: string, deviceId: string, dpendingRemoteCompletions.set(key, cancel);}-function deliverSessionEventNotification(sessionId: string, title: string, kind: SessionEventNotificationKind, remoteDevice: boolean, mobile: boolean): void {+function deliverSessionEventNotification(+ sessionId: string,+ title: string,+ kind: SessionEventNotificationKind,+ remoteDevice: boolean,+ options: { mobile?: boolean; feishu?: boolean },+): void {// A handoff can finish after the user has opened Cindy or changed preferences.if (typeof document !== 'undefined' && document.hasFocus()) return;@@ -173,10 +181,10 @@ function deliverSessionEventNotification(sessionId: string, title: string, kind:...(remoteDevice ? { markAttention: false } : {}),channels: {desktop: !remoteDevice && getNotificationsEnabled() && !islandActive,- feishu: getFeishuNotificationsEnabled(),+ feishu: options.feishu !== false && getFeishuNotificationsEnabled(),// Mobile owns registration/unregistration of its push token. There is// deliberately no second desktop setting for the same channel.- mobile,+ mobile: options.mobile !== false,},});}