Open-source AI teammates in Slack, Teams, Discord, Telegram and Mattermost. Self-host it, with any agent harness and any model.
Python agent-orchestrationaiai-agentschatopsdiscordlangchainmcpmicrosoft-teamsmulti-agentopen-sourceopenaiself-hostedslack
fix(console): send no people or spans without group chats
raullopez-sandbox1e6178000389
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.tsindex 7e9cff642..c7cac190d 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@@ -256,6 +256,48 @@ describe('sendChatMessage', () => {});});+describe('sendChatMessage people and spans', () => {+ const server = { id: 'server-1' } as SwitchServer;+ const base = { requestId: 'r', body: '@a1 hi', threadRootId: null, uploadIds: [] };++ it('leaves out empty people and spans, as a server without group chats needs', async () => {+ vi.mocked(gatewayFetch).mockResolvedValueOnce(+ new Response(JSON.stringify({ messages: [] }), { status: 200 })+ );+ await sendChatMessage(server, 'room-1', {+ ...base,+ mentionAgentIds: ['a1'],+ mentionUserIds: [],+ mentionSpans: [],+ });+ expect(vi.mocked(gatewayFetch).mock.lastCall![2]!.body).toEqual({+ ...base,+ mentionAgentIds: ['a1'],+ mentionAgentId: 'a1',+ });+ });++ it('sends people and spans when there are any', async () => {+ vi.mocked(gatewayFetch).mockResolvedValueOnce(+ new Response(JSON.stringify({ messages: [] }), { status: 200 })+ );+ const spans = [{ kind: 'agent' as const, id: 'a1', offset: 0, length: 3 }];+ await sendChatMessage(server, 'room-1', {+ ...base,+ mentionAgentIds: ['a1'],+ mentionUserIds: ['u1'],+ mentionSpans: spans,+ });+ expect(vi.mocked(gatewayFetch).mock.lastCall![2]!.body).toEqual({+ ...base,+ mentionAgentIds: ['a1'],+ mentionAgentId: 'a1',+ mentionUserIds: ['u1'],+ mentionSpans: spans,+ });+ });+});+describe('fetchThreadMessages', () => {it('fetches thread messages with pagination', async () => {const server = { id: 'server-1' } as SwitchServer;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.tsindex 6d235610d..5e39ac97e 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@@ -242,10 +242,18 @@ export async function sendChatMessage(method: 'POST',// 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,+ // People and spans go only when there are any: a server without group+ // chats refuses them even empty.+ body: {+ requestId: input.requestId,+ body: input.body,+ threadRootId: input.threadRootId,+ uploadIds: input.uploadIds,+ ...(input.mentionAgentIds && { mentionAgentIds: input.mentionAgentIds }),+ ...(input.mentionAgentIds?.length === 1 && { mentionAgentId: input.mentionAgentIds[0] }),+ ...(input.mentionUserIds?.length && { mentionUserIds: input.mentionUserIds }),+ ...(input.mentionSpans?.length && { mentionSpans: input.mentionSpans }),+ },})).messages;}diff --git a/console/apps/switch-console-desktop/src/renderer/features/chats/components/chat-composer.tsx b/console/apps/switch-console-desktop/src/renderer/features/chats/components/chat-composer.tsxindex f18e7d490..c27bbea4f 100644--- a/console/apps/switch-console-desktop/src/renderer/features/chats/components/chat-composer.tsx+++ b/console/apps/switch-console-desktop/src/renderer/features/chats/components/chat-composer.tsx@@ -18,13 +18,11 @@ import {editMentions,filterMentionAgents,filterMentionPeople,- mentionAgentIds,type MentionPerson,+ mentionPayload,mentionQuery,mentionSegments,- mentionSpans,type MentionToken,- mentionUserIds,type RememberedMention,withoutGroupMentions,personTargets,@@ -345,9 +343,7 @@ export const ChatComposer = observer(function ChatComposer({timeline.send({body,threadRootId: replyTo?.messageId ?? null,- mentionAgentIds: mentionAgentIds(sent),- mentionUserIds: mentionUserIds(sent),- mentionSpans: mentionSpans(sent),+ ...mentionPayload(sent, groupChats),files: files.map(({ file }) => chatFile(file)),});void chatTitler.sent(serverId, timeline.roomId, body);diff --git a/console/apps/switch-console-desktop/src/renderer/features/chats/mentions.ts b/console/apps/switch-console-desktop/src/renderer/features/chats/mentions.tsindex d1fe76351..144c51e24 100644--- a/console/apps/switch-console-desktop/src/renderer/features/chats/mentions.ts+++ b/console/apps/switch-console-desktop/src/renderer/features/chats/mentions.ts@@ -249,3 +249,19 @@ export function withoutGroupMentions(tokens: MentionToken[]): MentionToken[] {const first = tokens.find((token) => token.kind === 'agent');return first ? [first] : [];}++/**+ * What a send says about its mentions. Without group chats only the agents go:+ * a server without them refuses people and spans, and the first agent is all+ * it takes.+ */+export function mentionPayload(+ tokens: MentionToken[],+ groupChats: boolean+): { mentionAgentIds: string[]; mentionUserIds: string[]; mentionSpans: ChatMentionSpan[] } {+ return {+ mentionAgentIds: mentionAgentIds(tokens),+ mentionUserIds: groupChats ? mentionUserIds(tokens) : [],+ mentionSpans: groupChats ? mentionSpans(tokens) : [],+ };+}diff --git a/console/apps/switch-console-desktop/src/renderer/tests/chat-mentions.test.ts b/console/apps/switch-console-desktop/src/renderer/tests/chat-mentions.test.tsindex 1c8f69958..3b50c5454 100644--- a/console/apps/switch-console-desktop/src/renderer/tests/chat-mentions.test.ts+++ b/console/apps/switch-console-desktop/src/renderer/tests/chat-mentions.test.ts@@ -6,6 +6,7 @@ import {mentionSpans,tokensFromSpans,withoutGroupMentions,+ mentionPayload,shiftMentions,filterMentionAgents,filterMentionPeople,@@ -214,3 +215,29 @@ describe('withoutGroupMentions', () => {).toEqual([{ kind: 'agent', id: 'a1', start: 5, end: 9 }]);});});++describe('mentionPayload', () => {+ const tokens = [+ { kind: 'agent' as const, id: 'a1', start: 0, end: 10 },+ { kind: 'person' as const, id: 'u1', start: 11, end: 22 },+ ];++ it('sends only the agents without group chats', () => {+ expect(mentionPayload(tokens, false)).toEqual({+ mentionAgentIds: ['a1'],+ mentionUserIds: [],+ mentionSpans: [],+ });+ });++ it('sends people and spans with group chats', () => {+ expect(mentionPayload(tokens, true)).toEqual({+ mentionAgentIds: ['a1'],+ mentionUserIds: ['u1'],+ mentionSpans: [+ { kind: 'agent', id: 'a1', offset: 0, length: 10 },+ { kind: 'user', id: 'u1', offset: 11, length: 11 },+ ],+ });+ });+});