server: only emit attention notifications for ui agents

This commit is contained in:
Mohamed Boudra
2026-02-22 11:16:57 +07:00
parent 0d28dae444
commit c1e4b0fcbf
2 changed files with 36 additions and 0 deletions
@@ -97,6 +97,7 @@ describe("VoiceAssistantWebSocketServer notification payloads", () => {
getAgent: vi.fn(() => ({
config: { title: null },
cwd: "/tmp/worktree",
labels: { ui: "true" },
timeline: [
{
type: "assistant_message",
@@ -126,4 +127,29 @@ describe("VoiceAssistantWebSocketServer notification payloads", () => {
}
);
});
it("skips push notifications for non-UI agents", () => {
const { server } = createServer({
getAgent: vi.fn(() => ({
config: { title: null },
cwd: "/tmp/worktree",
labels: {},
timeline: [
{
type: "assistant_message",
text: "Done.",
},
],
pendingPermissions: new Map(),
})),
});
(server as any).broadcastAgentAttention({
agentId: "agent-2",
provider: "claude",
reason: "finished",
});
expect(pushMocks.sendPush).not.toHaveBeenCalled();
});
});
@@ -1067,6 +1067,16 @@ export class VoiceAssistantWebSocketServer {
const allStates = clientEntries.map((e) => e.state);
const agent = this.agentManager.getAgent(params.agentId);
if (agent?.labels?.ui !== "true") {
this.logger.debug(
{
agentId: params.agentId,
labels: agent?.labels ?? null,
},
"Skipping attention notification for non-UI agent"
);
return;
}
const notification = buildAgentAttentionNotificationPayload({
reason: params.reason,
serverId: this.serverId,