server: only emit attention notifications for ui agents
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user