Skip to content

Open-source AI teammates in Slack, Teams, Discord, Telegram and Mattermost. Self-host it, with any agent harness and any model.

fix(console): send one mentioned agent as mentionAgentId too

raullopez-sandbox4a398cdafba6
diff --git a/console/apps/switch-console-desktop/src/main/core/chats/gateway.test.ts b/console/apps/switch-console-desktop/src/main/core/chats/gateway.test.ts
index 5155150a6..7e9cff642 100644
--- a/console/apps/switch-console-desktop/src/main/core/chats/gateway.test.ts
+++ b/console/apps/switch-console-desktop/src/main/core/chats/gateway.test.ts
@@ -228,6 +228,32 @@ describe('sendChatMessage', () => {
},
});
});
+
+ it('also sends a single agent as mentionAgentId, for a server that predates the list', async () => {
+ const server = { id: 'server-1' } as SwitchServer;
+ vi.mocked(gatewayFetch).mockResolvedValueOnce(
+ new Response(JSON.stringify({ messages: [] }), { status: 200 })
+ );
+ await sendChatMessage(server, 'room-1', {
+ requestId: 'req-1',
+ body: '@agent-1 hi',
+ threadRootId: null,
+ uploadIds: [],
+ mentionAgentIds: ['agent-1'],
+ });
+ expect(gatewayFetch).toHaveBeenCalledWith(server, '/chats/room-1/messages', {
+ authenticated: true,
+ method: 'POST',
+ body: {
+ requestId: 'req-1',
+ body: '@agent-1 hi',
+ threadRootId: null,
+ uploadIds: [],
+ mentionAgentIds: ['agent-1'],
+ mentionAgentId: 'agent-1',
+ },
+ });
+ });
});
describe('fetchThreadMessages', () => {
diff --git a/console/apps/switch-console-desktop/src/main/core/chats/gateway.ts b/console/apps/switch-console-desktop/src/main/core/chats/gateway.ts
index 0b267bb4b..05335810e 100644
--- a/console/apps/switch-console-desktop/src/main/core/chats/gateway.ts
+++ b/console/apps/switch-console-desktop/src/main/core/chats/gateway.ts
@@ -238,7 +238,12 @@ export async function sendChatMessage(
return (
await json(server, `${room(roomId)}/messages`, chatSentSchema, {
method: 'POST',
- body: input,
+ // One agent also goes as `mentionAgentId`, which a server from before
+ // `mentionAgentIds` reads, so a rolling deploy still addresses it.
+ body:
+ input.mentionAgentIds?.length === 1
+ ? { ...input, mentionAgentId: input.mentionAgentIds[0] }
+ : input,
})
).messages;
}