Skip to content

armgit / cindy

Public Imported from GitHub
0

Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。

fix(review): 静音任务的完成卡也不能绕过展示面过滤

WZBbiaofa8da0e4eb81
diff --git a/apps/desktop/src/main/agent-island/__tests__/state.test.ts b/apps/desktop/src/main/agent-island/__tests__/state.test.ts
index 136386cde4..be82058a42 100644
--- a/apps/desktop/src/main/agent-island/__tests__/state.test.ts
+++ b/apps/desktop/src/main/agent-island/__tests__/state.test.ts
@@ -158,6 +158,40 @@ describe('Agent Island display state', () => {
]);
});
+ it('静音任务的完成卡不回到岛面,也不占 active transient / 揭示队列', () => {
+ const state = createAgentIslandState();
+ const meta = { sessionId: 'muted-done', title: 'Muted', agentKind: 'codex' };
+ applyAgentIslandEvent(state, meta, statusEvent(true, 'Working'), 1_000);
+ setAgentIslandSessionDisplaySuppressed(state, 'muted-done', true);
+
+ applyAgentIslandEvent(state, meta, doneEvent(), 2_000);
+
+ const display = buildAgentIslandDisplayState(state, 2_100);
+ expect(display.sessions).toEqual([]);
+ expect(display.currentSessionId).toBeNull();
+ expect(state.activeTransientSessionId).toBeNull();
+ expect(state.transientRevealQueue).toEqual([]);
+ // 侧栏活动照旧看得到它已经完成。
+ expect(buildAllSessionActivitySnapshots(state)).toEqual([
+ expect.objectContaining({ sessionId: 'muted-done', phase: 'completed' }),
+ ]);
+ });
+
+ it('完成卡已经在岛上时再静音,下一次展示面就不再包含它', () => {
+ const state = createAgentIslandState();
+ const meta = { sessionId: 'muted-live', title: 'Muted', agentKind: 'codex' };
+ applyAgentIslandEvent(state, meta, statusEvent(true, 'Working'), 1_000);
+ applyAgentIslandEvent(state, meta, doneEvent(), 1_100);
+ expect(buildAgentIslandDisplayState(state, 1_200).sessions.map((s) => s.sessionId)).toEqual([
+ 'muted-live',
+ ]);
+
+ setAgentIslandSessionDisplaySuppressed(state, 'muted-live', true);
+
+ expect(buildAgentIslandDisplayState(state, 1_300).sessions).toEqual([]);
+ expect(buildAgentIslandDisplayState(state, 1_300).currentSessionId).toBeNull();
+ });
+
it('does not complete the island on claimed SDK boundary events', () => {
const state = createAgentIslandState();
const meta = { sessionId: 'continuing', title: 'Continuing', agentKind: 'codex' };
diff --git a/apps/desktop/src/main/agent-island/state.ts b/apps/desktop/src/main/agent-island/state.ts
index df3f166632..1e5f2dceb9 100644
--- a/apps/desktop/src/main/agent-island/state.ts
+++ b/apps/desktop/src/main/agent-island/state.ts
@@ -582,6 +582,8 @@ function restoreSessionScopedReveal(
session: AgentIslandSessionState,
now: number,
): void {
+ // 静音任务的卡不该重新活过来(展示面才有的概念,活动快照不受影响)。
+ if (state.displaySuppressedSessionIds.has(session.sessionId)) return;
const sessionId = session.sessionId;
const wantsActive = session.revealUntil != null
&& session.revealUntil > now
@@ -1839,6 +1841,15 @@ function enqueueTransientReveal(
now: number,
dwellMs: number,
): void {
+ // 静音任务的完成 / 错误卡不揭示:它不该在岛面上出现,也不该带提示音。
+ // 活动快照与未读账本另路,静音不影响。
+ if (state.displaySuppressedSessionIds.has(session.sessionId)) {
+ session.revealUntil = null;
+ session.deferredReveal = false;
+ session.deferredRevealReason = null;
+ removeQueuedTransientReveal(state, session.sessionId);
+ return;
+ }
removeQueuedTransientReveal(state, session.sessionId);
if (state.activeTransientSessionId === session.sessionId) {
session.revealUntil = now + dwellMs;
@@ -1889,6 +1900,7 @@ function promoteNextTransientReveal(
if (!nextSessionId) continue;
const next = state.sessions.get(nextSessionId);
if (!next || !isSessionVisible(next, now)) continue;
+ if (state.displaySuppressedSessionIds.has(next.sessionId)) continue;
if (shouldSmartSuppressSession(state, next)) {
deferSessionReveal(state, next, 'visible-session');
continue;
@@ -1904,6 +1916,9 @@ function promoteNextTransientReveal(
function getActiveTransientSession(state: AgentIslandState, now: number): AgentIslandSessionState | null {
const activeSessionId = state.activeTransientSessionId;
if (!activeSessionId) return null;
+ // 静音任务即使被排成 active transient 也不上展示面:否则它会绕开
+ // shouldDisplaySession 的过滤被 prepend 回列表(完成/错误卡 + 提示音)。
+ if (state.displaySuppressedSessionIds.has(activeSessionId)) return null;
const active = state.sessions.get(activeSessionId);
if (!active?.revealUntil || active.revealUntil <= now) return null;
return active;