Skip to content

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

Offer Add people only where the platform lets Switch invite

Simon Flackdcc329b65b4c
diff --git a/console/apps/switch-console-desktop/src/renderer/features/switch-rooms/room-configuration-panel.tsx b/console/apps/switch-console-desktop/src/renderer/features/switch-rooms/room-configuration-panel.tsx
index 1fbaca12f..9b4a3efa9 100644
--- a/console/apps/switch-console-desktop/src/renderer/features/switch-rooms/room-configuration-panel.tsx
+++ b/console/apps/switch-console-desktop/src/renderer/features/switch-rooms/room-configuration-panel.tsx
@@ -58,6 +58,7 @@ import { roomAgentPresence } from './room-agent-presence';
import { channelOnDeleteSummary } from './room-delete-wording';
import { addableAgents, addablePeople, membershipSummary, roomTitle } from './room-labels';
import { openRoomChannel } from './room-links';
+import { roomInviteability } from './room-membership';
import {
AgentMark,
agentKindFor,
@@ -940,7 +941,8 @@ const ParticipantsSection = observer(function ParticipantsSection({
const remoteById = new Map((remoteAgents.data ?? []).map((agent) => [agent.id, agent]));
const detailQueryKey = roomDetailKey(workspaceId, room.id);
const canWrite = permissions.canWrite;
- const canInvitePeople = canWrite && room.bridgeId !== null;
+ const inviteability = roomInviteability(room, bridgePlatformLabel(room.bridgeType));
+ const canInvitePeople = canWrite && inviteability.canInvite;
async function refresh() {
await queryClient.invalidateQueries({ queryKey: detailQueryKey });
@@ -1009,6 +1011,9 @@ const ParticipantsSection = observer(function ParticipantsSection({
<AddPeoplePanel workspaceId={workspaceId} room={room} bridgeId={room.bridgeId} />
)}
{error !== null && <p className="text-xs text-destructive">{error}</p>}
+ {canWrite && !inviteability.canInvite && inviteability.reason !== null && (
+ <p className="text-xs text-foreground-muted">{inviteability.reason}</p>
+ )}
{room.agentIds.length === 0 && room.connectedUserNames.length === 0 ? (
<p className="text-sm text-foreground-muted">Nobody is in this room yet.</p>
diff --git a/console/apps/switch-console-desktop/src/renderer/features/switch-rooms/room-membership.test.ts b/console/apps/switch-console-desktop/src/renderer/features/switch-rooms/room-membership.test.ts
new file mode 100644
index 000000000..079d30f8f
--- /dev/null
+++ b/console/apps/switch-console-desktop/src/renderer/features/switch-rooms/room-membership.test.ts
@@ -0,0 +1,37 @@
+import { describe, expect, it } from 'vitest';
+import { roomInviteability } from './room-membership';
+
+const BRIDGED = { bridgeId: 'b-1', channelType: 'channel_public' };
+
+describe('roomInviteability', () => {
+ it('invites to a channel on Slack, Mattermost, Discord and Teams', () => {
+ for (const bridgeType of ['slack', 'mattermost', 'discord', 'teams']) {
+ expect(roomInviteability({ ...BRIDGED, bridgeType }, 'X')).toEqual({ canInvite: true });
+ }
+ });
+
+ it('says Telegram cannot add people', () => {
+ const result = roomInviteability({ ...BRIDGED, bridgeType: 'telegram' }, 'Telegram');
+ expect(result.canInvite).toBe(false);
+ expect(result).toMatchObject({ reason: expect.stringContaining('Telegram') });
+ });
+
+ it('leaves a group or direct-message channel’s membership to its platform', () => {
+ expect(
+ roomInviteability({ bridgeId: 'b-1', bridgeType: 'slack', channelType: 'group' }, 'Slack')
+ ).toEqual({ canInvite: false, reason: 'Who is in this group chat is managed in Slack.' });
+ expect(
+ roomInviteability(
+ { bridgeId: 'b-1', bridgeType: 'discord', channelType: 'direct' },
+ 'Discord'
+ )
+ ).toEqual({ canInvite: false, reason: 'Who is in this direct message is managed in Discord.' });
+ });
+
+ it('has nothing to invite to in a room with no messaging app', () => {
+ expect(roomInviteability({ bridgeId: null, bridgeType: null, channelType: null }, '')).toEqual({
+ canInvite: false,
+ reason: null,
+ });
+ });
+});
diff --git a/console/apps/switch-console-desktop/src/renderer/features/switch-rooms/room-membership.ts b/console/apps/switch-console-desktop/src/renderer/features/switch-rooms/room-membership.ts
new file mode 100644
index 000000000..8c9363104
--- /dev/null
+++ b/console/apps/switch-console-desktop/src/renderer/features/switch-rooms/room-membership.ts
@@ -0,0 +1,35 @@
+/**
+ * Whether people can be invited to a bridged room from Switch, and when not,
+ * why — in words the room's settings can show instead of the button.
+ *
+ * Group and direct-message channels have a fixed membership on every platform,
+ * managed on the platform itself (the gateway says the same). Telegram's Bot API
+ * has no call that adds a member to a chat at all: people join from a Telegram
+ * client or an invite link. Every other platform takes the invite, with its own
+ * limits the server reports per person (a Discord public channel needs no
+ * invite; a Teams channel needs its team known).
+ */
+export function roomInviteability(
+ room: {
+ bridgeId: string | null;
+ bridgeType: string | null;
+ channelType: string | null;
+ },
+ platform: string
+): { canInvite: true } | { canInvite: false; reason: string | null } {
+ if (room.bridgeId === null) return { canInvite: false, reason: null };
+ if (room.channelType === 'group' || room.channelType === 'direct') {
+ const kind = room.channelType === 'direct' ? 'direct message' : 'group chat';
+ return {
+ canInvite: false,
+ reason: `Who is in this ${kind} is managed in ${platform}.`,
+ };
+ }
+ if (room.bridgeType === 'telegram') {
+ return {
+ canInvite: false,
+ reason: 'Telegram does not let Switch add people. They join from Telegram or an invite link.',
+ };
+ }
+ return { canInvite: true };
+}