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。

Migrated from makecindy/cindy-temp#567 (#238)

Lizic79c0bc620b8
diff --git a/apps/desktop/src/main/agent-island/__tests__/service.test.ts b/apps/desktop/src/main/agent-island/__tests__/service.test.ts
index 416db4446a..8b36791786 100644
--- a/apps/desktop/src/main/agent-island/__tests__/service.test.ts
+++ b/apps/desktop/src/main/agent-island/__tests__/service.test.ts
@@ -1714,6 +1714,52 @@ describe('AgentIslandService native publishing', () => {
expect(playSound).toHaveBeenNthCalledWith(2, customSound('complete.wav'));
});
+ it('plays the completion sound when the completed visible session is smart-suppressed', async () => {
+ const { AgentIslandService } = await import('../service.js');
+ const publish = vi.fn((state: AgentIslandDisplayState, frameOrFrames: AgentIslandNativeFrame | AgentIslandNativeFrame[]) => {
+ void state;
+ void frameOrFrames;
+ return true;
+ });
+ const playSound = vi.fn<(sound: AgentIslandSoundChoice) => boolean>(() => true);
+ const service = new AgentIslandService({
+ getMainWindow: () => null,
+ nativeHost: { failed: false, publish, playSound },
+ });
+ syncEnabledForTest(service, publish);
+ service.setSoundSettings({
+ enabled: true,
+ sounds: {
+ ...DEFAULT_AGENT_ISLAND_SOUND_SETTINGS.sounds,
+ start: customSound('start.wav'),
+ complete: customSound('complete.wav'),
+ },
+ });
+ service.setAppFocused(true);
+ service.registerIpc();
+ const focusedWindow = {
+ isDestroyed: () => false,
+ isFocused: () => true,
+ } as unknown as BrowserWindow;
+ mocks.browserWindowFromWebContents.mockReturnValue(focusedWindow);
+ await registeredIpcHandler(AGENT_ISLAND_SET_VISIBLE_SESSION_CHANNEL)(
+ { sender: {} },
+ 's1',
+ );
+ playSound.mockClear();
+
+ service.handleUserPrompt({ sessionId: 's1', agentKind: 'codex' }, 'run tests');
+ service.handleAgentEvent({ sessionId: 's1', agentKind: 'codex' }, doneEvent());
+
+ expect(playSound).toHaveBeenNthCalledWith(1, customSound('start.wav'));
+ expect(playSound).toHaveBeenNthCalledWith(2, customSound('complete.wav'));
+ expect(publish.mock.calls.at(-1)?.[0].sessions[0]).toMatchObject({
+ sessionId: 's1',
+ phase: 'completed',
+ attention: false,
+ });
+ });
+
it('keeps an unplanned remote daemon close in error and does not play completion sound', async () => {
const { AgentIslandService } = await import('../service.js');
const publish = vi.fn((state: AgentIslandDisplayState, frameOrFrames: AgentIslandNativeFrame | AgentIslandNativeFrame[]) => {
diff --git a/apps/desktop/src/main/agent-island/service.ts b/apps/desktop/src/main/agent-island/service.ts
index e0e931d518..46a531820a 100644
--- a/apps/desktop/src/main/agent-island/service.ts
+++ b/apps/desktop/src/main/agent-island/service.ts
@@ -1802,8 +1802,9 @@ function getAgentIslandSoundEventForTransition(
const prev = previousById.get(session.sessionId);
if (prev?.phase !== 'error') return 'error';
}
+ // Visual smart suppression controls unread/reveal state, not configured completion sounds.
for (const session of next.sessions) {
- if (!session.attention || session.phase !== 'completed') continue;
+ if (session.phase !== 'completed') continue;
if (mutedCompletionSessionIds.has(session.sessionId)) continue;
const prev = previousById.get(session.sessionId);
if (prev?.phase !== 'completed') return 'complete';