Skip to content

The agent that grows with you

feat(desktop): filter Messaging platforms by status

Brooklyn Nicholson1b8569f41f15
diff --git a/apps/desktop/src/app/messaging/index.test.tsx b/apps/desktop/src/app/messaging/index.test.tsx
index 39c07efe2ea..f4e98de252e 100644
--- a/apps/desktop/src/app/messaging/index.test.tsx
+++ b/apps/desktop/src/app/messaging/index.test.tsx
@@ -141,6 +141,30 @@ describe('MessagingView profile scope', () => {
})
})
+describe('MessagingView status filter', () => {
+ const rowNames = (container: HTMLElement) =>
+ [...container.querySelectorAll('ul > li > button')].map(row => row.querySelector('.truncate')?.textContent)
+
+ it('offers a tab only for tones some platform is in, and narrows the list to that tone', async () => {
+ getMessagingPlatforms.mockResolvedValue({
+ platforms: [
+ platform({ enabled: true, id: 'discord', name: 'Discord', state: 'connected' }),
+ platform({ enabled: true, id: 'slack', name: 'Slack', state: 'retrying' }),
+ platform({ id: 'teams', name: 'Microsoft Teams' })
+ ]
+ })
+
+ const { container } = await renderMessaging()
+
+ await waitFor(() => expect(rowNames(container)).toHaveLength(3))
+ expect(screen.queryByRole('button', { name: 'Errors' })).toBeNull()
+
+ fireEvent.click(screen.getAllByRole('button', { name: 'Needs attention' })[0])
+
+ expect(rowNames(container)).toEqual(['Slack'])
+ })
+})
+
describe('MessagingView enable switch', () => {
it('labels the enable switch with the platform state', async () => {
getMessagingPlatforms.mockResolvedValue({ platforms: [platform({ enabled: true })] })
diff --git a/apps/desktop/src/app/messaging/index.tsx b/apps/desktop/src/app/messaging/index.tsx
index f94f7849261..c33e0f048cd 100644
--- a/apps/desktop/src/app/messaging/index.tsx
+++ b/apps/desktop/src/app/messaging/index.tsx
@@ -11,6 +11,7 @@ import { DisclosureCaret } from '@/components/ui/disclosure-caret'
import { ErrorBanner } from '@/components/ui/error-state'
import { Input } from '@/components/ui/input'
import { Switch } from '@/components/ui/switch'
+import { ResponsiveTabs } from '@/components/ui/tab-dropdown'
import { Tip } from '@/components/ui/tooltip'
import {
approvePairing,
@@ -26,6 +27,7 @@ import {
import { type Translations, useI18n } from '@/i18n'
import { openExternalLink } from '@/lib/external-link'
import { AlertTriangle, ExternalLink, RefreshCw, Save, Trash2 } from '@/lib/icons'
+import { platformStatusTone } from '@/lib/platform-status'
import { normalize } from '@/lib/text'
import { cn } from '@/lib/utils'
import { $changeEventsAvailable, $pairingChangeTick, $platformsChangeTick } from '@/store/live-sync'
@@ -62,20 +64,19 @@ const PILL_TONE: Record<StatusTone, string> = {
const stateLabel = (state: null | string | undefined, m: Translations['messaging']) =>
state ? m.states[state] || state.replace(/_/g, ' ') : m.unknown
-function stateTone({ enabled, state }: MessagingPlatformInfo): StatusTone {
- if (!enabled) {
- return 'muted'
- }
-
- if (state === 'connected') {
- return 'good'
- }
+// Filter order: what needs you first, then what's fine, then what's off.
+const STATUS_FILTER_ORDER: StatusTone[] = ['bad', 'warn', 'good', 'muted']
- if (state === 'fatal' || state === 'startup_failed') {
- return 'bad'
- }
+function platformMatches(platform: MessagingPlatformInfo, tone: 'all' | StatusTone, query: string): boolean {
+ const q = normalize(query)
- return 'warn'
+ return (
+ (tone === 'all' || platformStatusTone(platform) === tone) &&
+ (!q ||
+ [platform.id, platform.name, platform.description, platform.state]
+ .filter(Boolean)
+ .some(value => String(value).toLowerCase().includes(q)))
+ )
}
const trimEdits = (edits: Record<string, string>): Record<string, string> =>
@@ -151,6 +152,7 @@ export function MessagingView({ setStatusbarItemGroup: _setStatusbarItemGroup, .
const [pendingRevoke, setPendingRevoke] = useState<null | PairingUser>(null)
const [edits, setEdits] = useState<EditMap>({})
const [query, setQuery] = useState('')
+ const [statusFilter, setStatusFilter] = useState<'all' | StatusTone>('all')
const [refreshing, setRefreshing] = useState(false)
const [saving, setSaving] = useState<string | null>(null)
const platformIds = useMemo(() => platforms?.map(p => p.id) ?? [], [platforms])
@@ -326,23 +328,33 @@ export function MessagingView({ setStatusbarItemGroup: _setStatusbarItemGroup, .
const pendingByPlatform = useMemo(() => byPlatform(pairing.pending), [pairing.pending])
const approvedByPlatform = useMemo(() => byPlatform(pairing.approved), [pairing.approved])
- const visiblePlatforms = useMemo(() => {
- if (!platforms) {
- return []
- }
+ // Only tones some platform is actually in get a tab; a filter whose last
+ // platform changed state falls back to All instead of an empty list.
+ const presentTones = useMemo(
+ () => STATUS_FILTER_ORDER.filter(tone => platforms?.some(platform => platformStatusTone(platform) === tone)),
+ [platforms]
+ )
- const q = normalize(query)
+ const activeStatusFilter = statusFilter !== 'all' && presentTones.includes(statusFilter) ? statusFilter : 'all'
- if (!q) {
- return platforms
- }
+ const visiblePlatforms = useMemo(
+ () => platforms?.filter(platform => platformMatches(platform, activeStatusFilter, query)) ?? [],
+ [activeStatusFilter, platforms, query]
+ )
- return platforms.filter(platform =>
- [platform.id, platform.name, platform.description, platform.state]
- .filter(Boolean)
- .some(value => String(value).toLowerCase().includes(q))
- )
- }, [platforms, query])
+ // Picking a filter moves the detail pane into it. Only on that click: a
+ // platform that leaves the filter because you just enabled it stays open.
+ function handleStatusFilter(next: 'all' | StatusTone) {
+ setStatusFilter(next)
+
+ if (selected && !platformMatches(selected, next, query)) {
+ const first = platforms?.find(platform => platformMatches(platform, next, query))
+
+ if (first) {
+ setSelectedId(first.id)
+ }
+ }
+ }
async function handleToggle(platform: MessagingPlatformInfo, enabled: boolean) {
setSaving(`enabled:${platform.id}`)
@@ -528,6 +540,16 @@ export function MessagingView({ setStatusbarItemGroup: _setStatusbarItemGroup, .
searchHidden={(platforms?.length ?? 0) === 0}
searchHints={platforms?.slice(0, 5).map(platform => t.common.tryHint(platform.name.toLowerCase()))}
searchPlaceholder={m.search}
+ searchTrailingAction={
+ presentTones.length > 1 && (
+ <ResponsiveTabs
+ align="end"
+ onChange={id => handleStatusFilter(id as 'all' | StatusTone)}
+ tabs={(['all', ...presentTones] as const).map(id => ({ id, label: m.statusFilter[id] }))}
+ value={activeStatusFilter}
+ />
+ )
+ }
searchValue={query}
>
{!platforms ? (
@@ -668,7 +690,7 @@ function PlatformRow({
{pendingCount}
</span>
)}
- <StatusDot tone={stateTone(platform)} />
+ <StatusDot tone={platformStatusTone(platform)} />
</span>
</span>
</button>
@@ -718,7 +740,7 @@ function PlatformDetail({
<div className="min-w-0 flex-1">
<div className="flex flex-wrap items-center gap-2">
<h3 className="min-w-0 truncate text-[0.9375rem] font-semibold tracking-tight">{platform.name}</h3>
- <StatePill tone={stateTone(platform)}>{stateLabel(platform.state, m)}</StatePill>
+ <StatePill tone={platformStatusTone(platform)}>{stateLabel(platform.state, m)}</StatePill>
{/* Resting states earn no pill — only actionable ones. */}
{!platform.configured && <SetupPill active={false}>{m.needsSetup}</SetupPill>}
{/* The state pill already reads "gateway stopped" when that is the
diff --git a/apps/desktop/src/app/shell/gateway-menu-panel.tsx b/apps/desktop/src/app/shell/gateway-menu-panel.tsx
index e7367c560ea..6dad80d977b 100644
--- a/apps/desktop/src/app/shell/gateway-menu-panel.tsx
+++ b/apps/desktop/src/app/shell/gateway-menu-panel.tsx
@@ -1,12 +1,13 @@
import { type ReactNode, useEffect, useRef, useState } from 'react'
-import { StatusDot, type StatusTone } from '@/components/status-dot'
+import { StatusDot } from '@/components/status-dot'
import { Button } from '@/components/ui/button'
import { LogView } from '@/components/ui/log-view'
import { Tip } from '@/components/ui/tooltip'
import { getLogs } from '@/hermes'
import { useI18n } from '@/i18n'
import { LayoutDashboard, Power, RefreshCw } from '@/lib/icons'
+import { platformStatusTone } from '@/lib/platform-status'
import type { RuntimeReadinessResult } from '@/lib/runtime-readiness'
import { cn } from '@/lib/utils'
import { reconnectGateway } from '@/store/gateway-reconnect'
@@ -72,15 +73,6 @@ function useGatewayLogTail(): string[] {
return lines
}
-const PLATFORM_TONE: Record<string, StatusTone> = {
- connected: 'good',
- connecting: 'warn',
- retrying: 'warn',
- pending_restart: 'warn',
- startup_failed: 'bad',
- fatal: 'bad'
-}
-
const prettyState = (state: string) => state.replace(/_/g, ' ').replace(/^./, c => c.toUpperCase())
// Strip leading "YYYY-MM-DD HH:MM:SS,mmm " and "[runtime_id] " prefixes from
@@ -247,7 +239,7 @@ export function GatewayMenuPanel({
<li className="flex items-center justify-between gap-2 text-xs" key={name}>
<span className="truncate capitalize">{name}</span>
<span className="flex items-center gap-1.5 text-[0.66rem] text-muted-foreground">
- <StatusDot tone={PLATFORM_TONE[platform.state] || 'muted'} />
+ <StatusDot tone={platformStatusTone({ state: platform.state })} />
{prettyState(platform.state)}
</span>
</li>
diff --git a/apps/desktop/src/i18n/ar.ts b/apps/desktop/src/i18n/ar.ts
index e5b54312ff7..09871062d46 100644
--- a/apps/desktop/src/i18n/ar.ts
+++ b/apps/desktop/src/i18n/ar.ts
@@ -1542,6 +1542,13 @@ export const ar = defineLocale({
},
messaging: {
search: 'بحث',
+ statusFilter: {
+ all: 'الكل',
+ bad: 'أخطاء',
+ good: 'متصل',
+ muted: 'غير نشط',
+ warn: 'يحتاج انتباهًا'
+ },
loading: 'جار التحميل...',
loadFailed: 'فشل التحميل',
states: {
diff --git a/apps/desktop/src/i18n/de.ts b/apps/desktop/src/i18n/de.ts
index c12c8a7195b..a275c5f372d 100644
--- a/apps/desktop/src/i18n/de.ts
+++ b/apps/desktop/src/i18n/de.ts
@@ -3225,6 +3225,13 @@ export const deOverrides = {
},
messaging: {
search: 'Messaging durchsuchen...',
+ statusFilter: {
+ all: 'Alle',
+ bad: 'Fehler',
+ good: 'Verbunden',
+ muted: 'Inaktiv',
+ warn: 'Handlungsbedarf'
+ },
loading: 'Messaging-Plattformen werden geladen...',
loadFailed: 'Messaging-Plattformen konnten nicht geladen werden',
states: {
diff --git a/apps/desktop/src/i18n/en.ts b/apps/desktop/src/i18n/en.ts
index 8094173077c..042afb91843 100644
--- a/apps/desktop/src/i18n/en.ts
+++ b/apps/desktop/src/i18n/en.ts
@@ -2896,6 +2896,13 @@ export const en: Translations = {
messaging: {
search: 'Search messaging...',
+ statusFilter: {
+ all: 'All',
+ bad: 'Errors',
+ good: 'Connected',
+ muted: 'Inactive',
+ warn: 'Needs attention'
+ },
loading: 'Loading messaging platforms...',
loadFailed: 'Messaging platforms failed to load',
states: {
diff --git a/apps/desktop/src/i18n/es.ts b/apps/desktop/src/i18n/es.ts
index 789ea789aac..9afe7669814 100644
--- a/apps/desktop/src/i18n/es.ts
+++ b/apps/desktop/src/i18n/es.ts
@@ -3218,6 +3218,13 @@ export const esOverrides = {
},
messaging: {
search: 'Buscar mensajería...',
+ statusFilter: {
+ all: 'Todos',
+ bad: 'Errores',
+ good: 'Conectados',
+ muted: 'Inactivos',
+ warn: 'Requiere atención'
+ },
loading: 'Cargando plataformas de mensajería...',
loadFailed: 'No se pudieron cargar las plataformas de mensajería',
states: {
diff --git a/apps/desktop/src/i18n/fr.ts b/apps/desktop/src/i18n/fr.ts
index e8a4a87a66f..7c79ce08be0 100644
--- a/apps/desktop/src/i18n/fr.ts
+++ b/apps/desktop/src/i18n/fr.ts
@@ -3236,6 +3236,13 @@ export const frOverrides = {
},
messaging: {
search: 'Rechercher dans la messagerie...',
+ statusFilter: {
+ all: 'Tous',
+ bad: 'Erreurs',
+ good: 'Connectés',
+ muted: 'Inactifs',
+ warn: 'Attention requise'
+ },
loading: 'Chargement des plateformes de messagerie...',
loadFailed: 'Échec du chargement des plateformes de messagerie',
states: {
diff --git a/apps/desktop/src/i18n/ja.ts b/apps/desktop/src/i18n/ja.ts
index abe4ae06f4e..607963f0aaf 100644
--- a/apps/desktop/src/i18n/ja.ts
+++ b/apps/desktop/src/i18n/ja.ts
@@ -1913,6 +1913,13 @@ export const ja = defineLocale({
messaging: {
search: 'メッセージングを検索...',
+ statusFilter: {
+ all: 'すべて',
+ bad: 'エラー',
+ good: '接続済み',
+ muted: '非アクティブ',
+ warn: '要対応'
+ },
loading: 'メッセージングプラットフォームを読み込み中...',
loadFailed: 'メッセージングプラットフォームの読み込みに失敗しました',
states: {
diff --git a/apps/desktop/src/i18n/ru.ts b/apps/desktop/src/i18n/ru.ts
index 2b5c3f66801..0d68d3031c2 100644
--- a/apps/desktop/src/i18n/ru.ts
+++ b/apps/desktop/src/i18n/ru.ts
@@ -2063,6 +2063,13 @@ export const ru = defineLocale({
},
messaging: {
search: 'Поиск в сообщениях...',
+ statusFilter: {
+ all: 'Все',
+ bad: 'Ошибки',
+ good: 'Подключено',
+ muted: 'Неактивно',
+ warn: 'Требует внимания'
+ },
loading: 'Загрузка платформ сообщений...',
loadFailed: 'Не удалось загрузить платформы сообщений',
states: {
diff --git a/apps/desktop/src/i18n/types.ts b/apps/desktop/src/i18n/types.ts
index 613ddab7580..eb904bcf728 100644
--- a/apps/desktop/src/i18n/types.ts
+++ b/apps/desktop/src/i18n/types.ts
@@ -2474,6 +2474,7 @@ export interface Translations {
messaging: {
search: string
+ statusFilter: Record<'all' | 'bad' | 'good' | 'muted' | 'warn', string>
loading: string
loadFailed: string
states: Record<string, string>
diff --git a/apps/desktop/src/i18n/zh-hant.ts b/apps/desktop/src/i18n/zh-hant.ts
index ead74e702fc..c795b950539 100644
--- a/apps/desktop/src/i18n/zh-hant.ts
+++ b/apps/desktop/src/i18n/zh-hant.ts
@@ -2156,6 +2156,13 @@ export const zhHant = defineLocale({
messaging: {
search: '搜尋訊息平台…',
+ statusFilter: {
+ all: '全部',
+ bad: '錯誤',
+ good: '已連線',
+ muted: '未啟用',
+ warn: '需要注意'
+ },
loading: '正在載入訊息平台…',
loadFailed: '訊息平台載入失敗',
states: {
diff --git a/apps/desktop/src/i18n/zh.ts b/apps/desktop/src/i18n/zh.ts
index 86ba1746634..cbb4bc4772e 100644
--- a/apps/desktop/src/i18n/zh.ts
+++ b/apps/desktop/src/i18n/zh.ts
@@ -2697,6 +2697,13 @@ export const zh = defineLocale({
messaging: {
search: '搜索消息平台…',
+ statusFilter: {
+ all: '全部',
+ bad: '错误',
+ good: '已连接',
+ muted: '未启用',
+ warn: '需要关注'
+ },
loading: '正在加载消息平台…',
loadFailed: '消息平台加载失败',
states: {
diff --git a/apps/desktop/src/lib/platform-status.ts b/apps/desktop/src/lib/platform-status.ts
new file mode 100644
index 00000000000..5f88c833d3e
--- /dev/null
+++ b/apps/desktop/src/lib/platform-status.ts
@@ -0,0 +1,25 @@
+import type { StatusTone } from '@/components/status-dot'
+
+// One reading of a messaging platform's runtime state, shared by the Messaging
+// page and the gateway menu so the same bot never shows two different tones.
+// Anything enabled that isn't connected or failed (connecting, retrying,
+// restart needed, gateway stopped, needs setup) is waiting on something: warn.
+const STATE_TONE: Record<string, StatusTone> = {
+ connected: 'good',
+ disabled: 'muted',
+ fatal: 'bad',
+ startup_failed: 'bad'
+}
+
+interface PlatformStatusInput {
+ enabled?: boolean
+ state?: null | string
+}
+
+export function platformStatusTone({ enabled = true, state }: PlatformStatusInput): StatusTone {
+ if (!enabled) {
+ return 'muted'
+ }
+
+ return (state && STATE_TONE[state]) || 'warn'
+}
diff --git a/contributors/emails/[email protected] b/contributors/emails/[email protected]
new file mode 100644
index 00000000000..b38aee55555
--- /dev/null
+++ b/contributors/emails/[email protected]
@@ -0,0 +1 @@
+Sonnenwerk