Skip to content

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

feat(switchdash): give Teams an icon, and link each platform's setup guide (CHOO-1784)

Louis Amaudruz759ce5638d0e
diff --git a/dash/apps/switchdash-desktop/src/assets/images/bridges/teams.svg b/dash/apps/switchdash-desktop/src/assets/images/bridges/teams.svg
new file mode 100644
index 000000000..184f941e2
--- /dev/null
+++ b/dash/apps/switchdash-desktop/src/assets/images/bridges/teams.svg
@@ -0,0 +1,8 @@
+<svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
+ <circle fill="#5059C9" cx="19.45" cy="6.15" r="1.85"/>
+ <path fill="#5059C9" d="M17.4 10.05h4.75c.47 0 .85.38.85.85v3.4a3.22 3.22 0 0 1-6.45 0v-3.4c0-.47.38-.85.85-.85z"/>
+ <circle fill="#7B83EB" cx="14.05" cy="5.5" r="2.65"/>
+ <path fill="#7B83EB" d="M10.4 10.05h7.3c.5 0 .9.4.9.9v4.5a4.55 4.55 0 0 1-9.1 0v-4.5c0-.5.4-.9.9-.9z"/>
+ <rect fill="#4B53BC" x="0.85" y="5.2" width="12.3" height="13.6" rx="1.2"/>
+ <path fill="#FFFFFF" d="M10.25 9.3H3.75v1.6h2.3v6.3h1.9v-6.3h2.3V9.3z"/>
+</svg>
diff --git a/dash/apps/switchdash-desktop/src/renderer/features/sidebar/sidebar-room-grouping.tsx b/dash/apps/switchdash-desktop/src/renderer/features/sidebar/sidebar-room-grouping.tsx
index 951975352..161728f9d 100644
--- a/dash/apps/switchdash-desktop/src/renderer/features/sidebar/sidebar-room-grouping.tsx
+++ b/dash/apps/switchdash-desktop/src/renderer/features/sidebar/sidebar-room-grouping.tsx
@@ -4,6 +4,7 @@ import { openRoomChannel, openRoomGatewayPage } from '@renderer/features/switch-
import { switchRoomsStore as roomConnectionsStore } from '@renderer/features/switch-rooms/switch-rooms-store';
import { switchRoomsStore } from '@renderer/features/switch-servers/switch-rooms-store';
import { BridgeIcon, hasBridgeIcon } from '@renderer/lib/components/bridge-icon';
+import { bridgePlatformLabel } from '@renderer/lib/components/bridge-platform';
import { appState } from '@renderer/lib/stores/app-state';
import { Tooltip, TooltipContent, TooltipTrigger } from '@renderer/lib/ui/tooltip';
import { cn } from '@renderer/utils/utils';
@@ -165,7 +166,7 @@ export function RoomRow({
render={
<SidebarItemMiniButton
type="button"
- aria-label={`Open ${label} in ${bridgeType}`}
+ aria-label={`Open ${label} in ${bridgePlatformLabel(bridgeType)}`}
className="opacity-0 transition-opacity duration-150 group-hover/room:opacity-100"
onClick={(e) => {
e.stopPropagation();
@@ -176,7 +177,7 @@ export function RoomRow({
</SidebarItemMiniButton>
}
/>
- <TooltipContent>Open in {bridgeType}</TooltipContent>
+ <TooltipContent>Open in {bridgePlatformLabel(bridgeType)}</TooltipContent>
</Tooltip>
)}
{onAddAgent && (
diff --git a/dash/apps/switchdash-desktop/src/renderer/features/switch-servers/ConnectMessagingAppModal.tsx b/dash/apps/switchdash-desktop/src/renderer/features/switch-servers/ConnectMessagingAppModal.tsx
index 6e6e0ee7f..f986e6cdf 100644
--- a/dash/apps/switchdash-desktop/src/renderer/features/switch-servers/ConnectMessagingAppModal.tsx
+++ b/dash/apps/switchdash-desktop/src/renderer/features/switch-servers/ConnectMessagingAppModal.tsx
@@ -1,7 +1,9 @@
import { useQuery } from '@tanstack/react-query';
+import { ExternalLink } from 'lucide-react';
import { observer } from 'mobx-react-lite';
import { useCallback, useMemo, useState } from 'react';
import { BridgeIcon, hasBridgeIcon } from '@renderer/lib/components/bridge-icon';
+import { bridgePlatformLabel, bridgeSetupDocsUrl } from '@renderer/lib/components/bridge-platform';
import { rpc } from '@renderer/lib/ipc';
import { type BaseModalProps, useModalContext } from '@renderer/lib/modal/modal-provider';
import { Button } from '@renderer/lib/ui/button';
@@ -32,20 +34,6 @@ type ConnectMessagingAppModalArgs = {
type Props = BaseModalProps<{ bridgeId: string }> & ConnectMessagingAppModalArgs;
-/** Platform names as their own docs write them, so the picker matches what the
- * user just read while creating the bot. Unknown keys (a bridge type added by a
- * newer switch-core) fall back to the raw key rather than being hidden. */
-const PLATFORM_LABELS: Record<string, string> = {
- slack: 'Slack',
- mattermost: 'Mattermost',
- discord: 'Discord',
- teams: 'Microsoft Teams',
-};
-
-function platformLabel(key: string): string {
- return PLATFORM_LABELS[key] ?? key;
-}
-
export const ConnectMessagingAppModal = observer(function ConnectMessagingAppModal({
serverId: overrideServerId,
onSuccess,
@@ -165,7 +153,7 @@ export const ConnectMessagingAppModal = observer(function ConnectMessagingAppMod
>
<SelectTrigger>
<SelectValue placeholder={typesQuery.isLoading ? 'Loading…' : 'Choose a platform'}>
- {selectedType ? platformLabel(selectedType.key) : undefined}
+ {selectedType ? bridgePlatformLabel(selectedType.key) : undefined}
</SelectValue>
</SelectTrigger>
<SelectContent>
@@ -173,7 +161,7 @@ export const ConnectMessagingAppModal = observer(function ConnectMessagingAppMod
<SelectItem key={type.key} value={type.key}>
<span className="flex items-center gap-2">
{hasBridgeIcon(type.key) && <BridgeIcon bridgeType={type.key} size={16} />}
- {platformLabel(type.key)}
+ {bridgePlatformLabel(type.key)}
</span>
</SelectItem>
))}
@@ -192,7 +180,7 @@ export const ConnectMessagingAppModal = observer(function ConnectMessagingAppMod
<FieldLabel>Name</FieldLabel>
<Input
autoFocus
- placeholder={`e.g. ${platformLabel(selectedType.key)}`}
+ placeholder={`e.g. ${bridgePlatformLabel(selectedType.key)}`}
value={displayName}
onChange={(e) => {
setDisplayName(e.target.value);
@@ -204,6 +192,18 @@ export const ConnectMessagingAppModal = observer(function ConnectMessagingAppMod
</p>
</Field>
+ {/* The fields below are asked for without explanation — what a
+ "bot token" is, and where to get one, lives in the platform's
+ setup guide. Link to it at the point the question arises. */}
+ <button
+ type="button"
+ className="-mt-2 flex w-fit items-center gap-1 text-xs text-foreground-muted underline underline-offset-2 hover:text-foreground"
+ onClick={() => void rpc.app.openExternal(bridgeSetupDocsUrl(selectedType.key))}
+ >
+ How to set up {bridgePlatformLabel(selectedType.key)}
+ <ExternalLink className="size-3" />
+ </button>
+
{selectedType.fields.map((field) => (
<Field key={field.key}>
<FieldLabel>
@@ -246,6 +246,9 @@ export const ConnectMessagingAppModal = observer(function ConnectMessagingAppMod
</span>
</label>
+ {/* Deliberate and requested: this is the only place the user is
+ told where the credentials they just typed end up, and that
+ attaching will not interrupt anything. Keep it. */}
<p className="text-xs text-foreground-muted">
Credentials are sent to {server?.name ?? 'the server'} and stored there. switchdash
does not keep a copy. The connection starts immediately — no restart, and running
diff --git a/dash/apps/switchdash-desktop/src/renderer/lib/components/bridge-platform.test.ts b/dash/apps/switchdash-desktop/src/renderer/lib/components/bridge-platform.test.ts
new file mode 100644
index 000000000..47e9f2579
--- /dev/null
+++ b/dash/apps/switchdash-desktop/src/renderer/lib/components/bridge-platform.test.ts
@@ -0,0 +1,79 @@
+import { existsSync, readdirSync } from 'node:fs';
+import { dirname, join } from 'node:path';
+import { fileURLToPath } from 'node:url';
+import { describe, expect, it } from 'vitest';
+import { bridgePlatformLabel, bridgeSetupDocsUrl } from './bridge-platform';
+
+/** Every bridge type switch-core registers today (`main.py` register_adapter). */
+const BRIDGE_TYPES = ['slack', 'mattermost', 'discord', 'teams'];
+
+const BRIDGE_ICON_DIR = join(
+ dirname(fileURLToPath(import.meta.url)),
+ '../../../assets/images/bridges'
+);
+
+/** Repo root, for checking the setup guides the docs links point at. */
+const REPO_ROOT = join(dirname(fileURLToPath(import.meta.url)), '../../../../../../..');
+
+describe('bridgePlatformLabel', () => {
+ it('names each platform the way its own docs do', () => {
+ expect(bridgePlatformLabel('slack')).toBe('Slack');
+ expect(bridgePlatformLabel('mattermost')).toBe('Mattermost');
+ expect(bridgePlatformLabel('discord')).toBe('Discord');
+ expect(bridgePlatformLabel('teams')).toBe('Microsoft Teams');
+ });
+
+ it('falls back to the raw key for a type this build does not know', () => {
+ // A newer switch-core can register a bridge type this app has never heard
+ // of. Showing the slug is wrong-looking but still identifies it.
+ expect(bridgePlatformLabel('zulip')).toBe('zulip');
+ });
+
+ it('has a generic word for an unbridged room', () => {
+ expect(bridgePlatformLabel(null)).toBe('messaging app');
+ expect(bridgePlatformLabel(undefined)).toBe('messaging app');
+ });
+});
+
+describe('bridgeSetupDocsUrl', () => {
+ it('points at the per-platform setup guide', () => {
+ expect(bridgeSetupDocsUrl('slack')).toMatch(/docs\/bridges\/SLACK_SETUP\.md$/);
+ expect(bridgeSetupDocsUrl('teams')).toMatch(/docs\/bridges\/TEAMS_SETUP\.md$/);
+ });
+
+ it('falls back to the index rather than a dead link', () => {
+ expect(bridgeSetupDocsUrl('zulip')).toMatch(/docs\/bridges\/README\.md$/);
+ });
+
+ it.each(BRIDGE_TYPES)('the guide linked for %s exists in the repo', (type) => {
+ // The links are repo paths for now, so a renamed or moved guide should
+ // fail here rather than 404 for a user mid-setup.
+ const path = bridgeSetupDocsUrl(type).replace(
+ 'https://github.com/sandbox-quantum/switch/blob/main/',
+ ''
+ );
+ expect(existsSync(join(REPO_ROOT, path))).toBe(true);
+ });
+});
+
+describe('bridge brand icons', () => {
+ it.each(BRIDGE_TYPES)('%s has an icon', (type) => {
+ // `bridge-icon.tsx` keys its glob on the filename, and several call sites
+ // gate behaviour on an icon existing — a room's "Open in <app>" button is
+ // hidden without one, even when the deeplink resolves. So a missing file
+ // is a functional gap, not just a cosmetic one (CHOO-1784).
+ expect(existsSync(join(BRIDGE_ICON_DIR, `${type}.svg`))).toBe(true);
+ });
+
+ it('has a label for every bundled icon', () => {
+ // The reverse direction: an icon with no label would render next to a raw
+ // slug in the picker.
+ const bundled = readdirSync(BRIDGE_ICON_DIR)
+ .filter((f) => f.endsWith('.svg'))
+ .map((f) => f.replace(/\.svg$/, ''));
+
+ for (const type of bundled) {
+ expect(bridgePlatformLabel(type)).not.toBe(type);
+ }
+ });
+});
diff --git a/dash/apps/switchdash-desktop/src/renderer/lib/components/bridge-platform.ts b/dash/apps/switchdash-desktop/src/renderer/lib/components/bridge-platform.ts
new file mode 100644
index 000000000..0e3008ad9
--- /dev/null
+++ b/dash/apps/switchdash-desktop/src/renderer/lib/components/bridge-platform.ts
@@ -0,0 +1,51 @@
+/**
+ * Display names and setup guides for collaboration bridge platforms, keyed by
+ * the gateway's `bridge_type`.
+ *
+ * The raw key is a lowercase slug (`teams`, `mattermost`), which reads badly in
+ * user-facing copy — "Open in teams" — so anything shown to a user goes through
+ * {@link bridgePlatformLabel} rather than interpolating the key.
+ */
+const PLATFORM_LABELS: Record<string, string> = {
+ slack: 'Slack',
+ mattermost: 'Mattermost',
+ discord: 'Discord',
+ teams: 'Microsoft Teams',
+};
+
+/**
+ * How to name a bridge platform in the UI. Falls back to the raw key for a type
+ * a newer switch-core added but this build has no name for — wrong-looking, but
+ * still identifying, which beats hiding it.
+ */
+export function bridgePlatformLabel(bridgeType: string | null | undefined): string {
+ if (!bridgeType) return 'messaging app';
+ return PLATFORM_LABELS[bridgeType] ?? bridgeType;
+}
+
+/** Where the setup guides live. */
+const DOCS_BASE = 'https://github.com/sandbox-quantum/switch/blob/main/docs/bridges';
+
+/**
+ * Per-platform setup guide, for the "how do I get these credentials" link on
+ * the attach form.
+ *
+ * These point at the repository's own markdown on `main`, which is a stopgap:
+ * they are expected to move to published documentation, so they are collected
+ * here rather than spread through the JSX — changing them later is one edit.
+ */
+const PLATFORM_DOCS: Record<string, string> = {
+ slack: `${DOCS_BASE}/SLACK_SETUP.md`,
+ mattermost: `${DOCS_BASE}/MATTERMOST_SETUP.md`,
+ discord: `${DOCS_BASE}/DISCORD_SETUP.md`,
+ teams: `${DOCS_BASE}/TEAMS_SETUP.md`,
+};
+
+/**
+ * The setup guide for a platform, or the index covering all of them when this
+ * build knows no specific page — so a bridge type added server-side still gets
+ * a link that lands somewhere useful instead of a 404.
+ */
+export function bridgeSetupDocsUrl(bridgeType: string): string {
+ return PLATFORM_DOCS[bridgeType] ?? `${DOCS_BASE}/README.md`;
+}