Skip to content

Shared task board where people and AI coding agents work as teammates. Source-available, self-hostable.

Go

feat(desktop): add verified device list and rich confirm dialog

yushenfcbe96645c35
diff --git a/apps/desktop/electron/electron-env.d.ts b/apps/desktop/electron/electron-env.d.ts
index 4cb6355084..c36269671a 100644
--- a/apps/desktop/electron/electron-env.d.ts
+++ b/apps/desktop/electron/electron-env.d.ts
@@ -58,6 +58,19 @@ interface SkillInfo {
triggers: string[]
}
+interface DeviceMeta {
+ userAgent?: string
+ platform?: string
+ language?: string
+}
+
+interface DeviceEntryInfo {
+ deviceId: string
+ agentId: string
+ addedAt: number
+ meta?: DeviceMeta
+}
+
interface SkillAddResult {
ok: boolean
message: string
@@ -78,8 +91,10 @@ interface ElectronAPI {
closeAgent: (id: string) => Promise<unknown>
sendMessage: (agentId: string, content: string) => Promise<unknown>
registerToken: (token: string, agentId: string, expiresAt: number) => Promise<unknown>
- onDeviceConfirmRequest: (callback: (deviceId: string) => void) => void
+ onDeviceConfirmRequest: (callback: (deviceId: string, meta?: DeviceMeta) => void) => void
deviceConfirmResponse: (deviceId: string, allowed: boolean) => void
+ listDevices: () => Promise<DeviceEntryInfo[]>
+ revokeDevice: (deviceId: string) => Promise<{ ok: boolean }>
}
tools: {
list: () => Promise<ToolInfo[]>
diff --git a/apps/desktop/electron/ipc/hub.ts b/apps/desktop/electron/ipc/hub.ts
index 1aa9671c5b..028e20158a 100644
--- a/apps/desktop/electron/ipc/hub.ts
+++ b/apps/desktop/electron/ipc/hub.ts
@@ -232,6 +232,22 @@ export function registerHubIpcHandlers(): void {
return { ok: true }
})
+ /**
+ * List all verified (whitelisted) devices.
+ */
+ ipcMain.handle('hub:listDevices', async () => {
+ const h = getHub()
+ return h.deviceStore.listDevices()
+ })
+
+ /**
+ * Revoke a device from the whitelist.
+ */
+ ipcMain.handle('hub:revokeDevice', async (_event, deviceId: string) => {
+ const h = getHub()
+ return { ok: h.deviceStore.revokeDevice(deviceId) }
+ })
+
}
/**
@@ -252,10 +268,10 @@ export function setupDeviceConfirmation(mainWindow: Electron.BrowserWindow): voi
})
// Register confirm handler on Hub — sends request to renderer, awaits response
- h.setConfirmHandler((deviceId: string, _agentId: string) => {
+ h.setConfirmHandler((deviceId: string, _agentId: string, meta) => {
return new Promise<boolean>((resolve) => {
pendingConfirms.set(deviceId, resolve)
- mainWindow.webContents.send('hub:device-confirm-request', deviceId)
+ mainWindow.webContents.send('hub:device-confirm-request', deviceId, meta)
})
})
}
diff --git a/apps/desktop/electron/preload.ts b/apps/desktop/electron/preload.ts
index b439cd56e6..4212c611a9 100644
--- a/apps/desktop/electron/preload.ts
+++ b/apps/desktop/electron/preload.ts
@@ -57,12 +57,14 @@ const electronAPI = {
ipcRenderer.invoke('hub:sendMessage', agentId, content),
registerToken: (token: string, agentId: string, expiresAt: number) =>
ipcRenderer.invoke('hub:registerToken', token, agentId, expiresAt),
- onDeviceConfirmRequest: (callback: (deviceId: string) => void) => {
- ipcRenderer.on('hub:device-confirm-request', (_event, deviceId: string) => callback(deviceId))
+ onDeviceConfirmRequest: (callback: (deviceId: string, meta?: { userAgent?: string; platform?: string; language?: string }) => void) => {
+ ipcRenderer.on('hub:device-confirm-request', (_event, deviceId: string, meta?: { userAgent?: string; platform?: string; language?: string }) => callback(deviceId, meta))
},
deviceConfirmResponse: (deviceId: string, allowed: boolean) => {
ipcRenderer.send('hub:device-confirm-response', deviceId, allowed)
},
+ listDevices: () => ipcRenderer.invoke('hub:listDevices'),
+ revokeDevice: (deviceId: string) => ipcRenderer.invoke('hub:revokeDevice', deviceId),
},
// Tools management
diff --git a/apps/desktop/src/components/device-confirm-dialog.tsx b/apps/desktop/src/components/device-confirm-dialog.tsx
index 30e81f0f8e..a204e8cf4d 100644
--- a/apps/desktop/src/components/device-confirm-dialog.tsx
+++ b/apps/desktop/src/components/device-confirm-dialog.tsx
@@ -10,8 +10,37 @@ import {
AlertDialogTitle,
} from '@multica/ui/components/ui/alert-dialog'
+interface DeviceMeta {
+ userAgent?: string
+ platform?: string
+ language?: string
+}
+
interface PendingConfirm {
deviceId: string
+ meta?: DeviceMeta
+}
+
+function parseUserAgent(ua: string): { browser: string; os: string } {
+ let os = 'Unknown'
+ if (/Mac OS X/.test(ua)) os = 'macOS'
+ else if (/Windows/.test(ua)) os = 'Windows'
+ else if (/Android/.test(ua)) os = 'Android'
+ else if (/iPhone|iPad/.test(ua)) os = 'iOS'
+ else if (/Linux/.test(ua)) os = 'Linux'
+
+ let browser = 'Unknown'
+ const edgeMatch = ua.match(/Edg\/(\d+)/)
+ const chromeMatch = ua.match(/Chrome\/(\d+)/)
+ const safariMatch = ua.match(/Version\/(\d+).*Safari/)
+ const firefoxMatch = ua.match(/Firefox\/(\d+)/)
+
+ if (edgeMatch) browser = `Edge ${edgeMatch[1]}`
+ else if (firefoxMatch) browser = `Firefox ${firefoxMatch[1]}`
+ else if (chromeMatch) browser = `Chrome ${chromeMatch[1]}`
+ else if (safariMatch) browser = `Safari ${safariMatch[1]}`
+
+ return { browser, os }
}
/**
@@ -23,8 +52,8 @@ export function DeviceConfirmDialog() {
const [pending, setPending] = useState<PendingConfirm | null>(null)
useEffect(() => {
- window.electronAPI?.hub.onDeviceConfirmRequest((deviceId: string) => {
- setPending({ deviceId })
+ window.electronAPI?.hub.onDeviceConfirmRequest((deviceId: string, meta?: DeviceMeta) => {
+ setPending({ deviceId, meta })
})
}, [])
@@ -40,14 +69,31 @@ export function DeviceConfirmDialog() {
setPending(null)
}, [pending])
+ const parsed = pending?.meta?.userAgent
+ ? parseUserAgent(pending.meta.userAgent)
+ : null
+
+ const deviceLabel = parsed
+ ? `${parsed.browser} on ${parsed.os}`
+ : pending?.deviceId
+
return (
<AlertDialog open={pending !== null}>
<AlertDialogContent>
<AlertDialogHeader>
<AlertDialogTitle>New Device Connection</AlertDialogTitle>
- <AlertDialogDescription>
- Device <span className="font-mono font-medium">{pending?.deviceId}</span> wants to connect.
- Allow this device?
+ <AlertDialogDescription asChild>
+ <div className="space-y-2">
+ <p>
+ <span className="font-medium">{deviceLabel}</span> wants to connect.
+ </p>
+ {parsed && (
+ <p className="text-xs font-mono text-muted-foreground truncate">
+ {pending?.deviceId}
+ </p>
+ )}
+ <p>Allow this device?</p>
+ </div>
</AlertDialogDescription>
</AlertDialogHeader>
<AlertDialogFooter>
diff --git a/apps/desktop/src/components/device-list.tsx b/apps/desktop/src/components/device-list.tsx
new file mode 100644
index 0000000000..a6bd5b2dae
--- /dev/null
+++ b/apps/desktop/src/components/device-list.tsx
@@ -0,0 +1,157 @@
+import { useState } from 'react'
+import { Button } from '@multica/ui/components/ui/button'
+import { HugeiconsIcon } from '@hugeicons/react'
+import {
+ SmartPhone01Icon,
+ Delete02Icon,
+ Loading03Icon,
+ RotateClockwiseIcon,
+} from '@hugeicons/core-free-icons'
+import { useDevices, type DeviceEntry } from '../hooks/use-devices'
+
+// ============ UA Parser ============
+
+interface ParsedUA {
+ browser: string
+ os: string
+}
+
+function parseUserAgent(ua: string): ParsedUA {
+ let os = 'Unknown'
+ if (/Mac OS X/.test(ua)) os = 'macOS'
+ else if (/Windows/.test(ua)) os = 'Windows'
+ else if (/Android/.test(ua)) os = 'Android'
+ else if (/iPhone|iPad/.test(ua)) os = 'iOS'
+ else if (/CrOS/.test(ua)) os = 'ChromeOS'
+ else if (/Linux/.test(ua)) os = 'Linux'
+
+ let browser = 'Unknown'
+ const edgeMatch = ua.match(/Edg\/(\d+)/)
+ const chromeMatch = ua.match(/Chrome\/(\d+)/)
+ const safariMatch = ua.match(/Version\/(\d+).*Safari/)
+ const firefoxMatch = ua.match(/Firefox\/(\d+)/)
+
+ if (edgeMatch) browser = `Edge ${edgeMatch[1]}`
+ else if (firefoxMatch) browser = `Firefox ${firefoxMatch[1]}`
+ else if (chromeMatch) browser = `Chrome ${chromeMatch[1]}`
+ else if (safariMatch) browser = `Safari ${safariMatch[1]}`
+
+ return { browser, os }
+}
+
+// ============ Relative Time ============
+
+function relativeTime(timestamp: number): string {
+ const seconds = Math.floor((Date.now() - timestamp) / 1000)
+ if (seconds < 60) return 'just now'
+
+ const minutes = Math.floor(seconds / 60)
+ if (minutes < 60) return `${minutes}m ago`
+
+ const hours = Math.floor(minutes / 60)
+ if (hours < 24) return `${hours}h ago`
+
+ const days = Math.floor(hours / 24)
+ if (days < 30) return `${days}d ago`
+
+ const months = Math.floor(days / 30)
+ return `${months}mo ago`
+}
+
+// ============ Component ============
+
+function DeviceItem({
+ device,
+ onRevoke,
+}: {
+ device: DeviceEntry
+ onRevoke: (deviceId: string) => Promise<boolean>
+}) {
+ const [revoking, setRevoking] = useState(false)
+
+ const parsed = device.meta?.userAgent
+ ? parseUserAgent(device.meta.userAgent)
+ : null
+
+ const displayName = parsed
+ ? `${parsed.browser} on ${parsed.os}`
+ : device.deviceId
+
+ const handleRevoke = async () => {
+ setRevoking(true)
+ try {
+ await onRevoke(device.deviceId)
+ } finally {
+ setRevoking(false)
+ }
+ }
+
+ return (
+ <div className="flex items-center justify-between px-4 py-3 hover:bg-muted/20 transition-colors">
+ <div className="flex items-center gap-3 min-w-0 flex-1">
+ <HugeiconsIcon icon={SmartPhone01Icon} className="size-4 text-muted-foreground shrink-0" />
+ <div className="min-w-0">
+ <div className="text-sm font-medium truncate">{displayName}</div>
+ <div className="flex items-center gap-2 text-xs text-muted-foreground">
+ <span className="font-mono truncate max-w-[180px]">{device.deviceId}</span>
+ <span>·</span>
+ <span>{relativeTime(device.addedAt)}</span>
+ </div>
+ </div>
+ </div>
+ <Button
+ variant="ghost"
+ size="sm"
+ className="text-muted-foreground hover:text-destructive shrink-0"
+ onClick={handleRevoke}
+ disabled={revoking}
+ >
+ {revoking ? (
+ <HugeiconsIcon icon={Loading03Icon} className="size-4 animate-spin" />
+ ) : (
+ <HugeiconsIcon icon={Delete02Icon} className="size-4" />
+ )}
+ </Button>
+ </div>
+ )
+}
+
+export function DeviceList() {
+ const { devices, loading, refresh, revokeDevice } = useDevices()
+
+ if (loading) {
+ return null
+ }
+
+ if (devices.length === 0) {
+ return null
+ }
+
+ return (
+ <div className="space-y-2">
+ <div className="flex items-center justify-between">
+ <h3 className="text-sm font-medium text-muted-foreground">
+ Verified Devices ({devices.length})
+ </h3>
+ <Button
+ variant="ghost"
+ size="sm"
+ className="h-7 px-2 text-xs gap-1"
+ onClick={refresh}
+ >
+ <HugeiconsIcon icon={RotateClockwiseIcon} className="size-3" />
+ Refresh
+ </Button>
+ </div>
+ <div className="border rounded-lg divide-y overflow-hidden">
+ {devices.map((device) => (
+ <DeviceItem
+ key={device.deviceId}
+ device={device}
+ onRevoke={revokeDevice}
+ />
+ ))}
+ </div>
+ </div>
+ )
+}
diff --git a/apps/desktop/src/hooks/use-devices.ts b/apps/desktop/src/hooks/use-devices.ts
new file mode 100644
index 0000000000..189e2a67c5
--- /dev/null
+++ b/apps/desktop/src/hooks/use-devices.ts
@@ -0,0 +1,57 @@
+import { useState, useEffect, useCallback } from 'react'
+
+export interface DeviceMeta {
+ userAgent?: string
+ platform?: string
+ language?: string
+}
+
+export interface DeviceEntry {
+ deviceId: string
+ agentId: string
+ addedAt: number
+ meta?: DeviceMeta
+}
+
+export interface UseDevicesReturn {
+ devices: DeviceEntry[]
+ loading: boolean
+ refresh: () => Promise<void>
+ revokeDevice: (deviceId: string) => Promise<boolean>
+}
+
+export function useDevices(): UseDevicesReturn {
+ const [devices, setDevices] = useState<DeviceEntry[]>([])
+ const [loading, setLoading] = useState(true)
+
+ const refresh = useCallback(async () => {
+ try {
+ const list = await window.electronAPI?.hub.listDevices()
+ setDevices((list as DeviceEntry[]) ?? [])
+ } catch (err) {
+ console.error('Failed to load devices:', err)
+ } finally {
+ setLoading(false)
+ }
+ }, [])
+
+ const revokeDevice = useCallback(async (deviceId: string): Promise<boolean> => {
+ try {
+ const result = await window.electronAPI?.hub.revokeDevice(deviceId)
+ if (result?.ok) {
+ setDevices((prev) => prev.filter((d) => d.deviceId !== deviceId))
+ return true
+ }
+ return false
+ } catch (err) {
+ console.error('Failed to revoke device:', err)
+ return false
+ }
+ }, [])
+
+ useEffect(() => {
+ refresh()
+ }, [refresh])
+
+ return { devices, loading, refresh, revokeDevice }
+}
diff --git a/apps/desktop/src/pages/home.tsx b/apps/desktop/src/pages/home.tsx
index 029bff946d..be7257f702 100644
--- a/apps/desktop/src/pages/home.tsx
+++ b/apps/desktop/src/pages/home.tsx
@@ -8,6 +8,7 @@ import {
AlertCircleIcon,
} from '@hugeicons/core-free-icons'
import { ConnectionQRCode } from '../components/qr-code'
+import { DeviceList } from '../components/device-list'
import { useHub } from '../hooks/use-hub'
export default function HomePage() {
@@ -53,13 +54,13 @@ export default function HomePage() {
<div className="flex-1 flex gap-8 p-2">
{/* Left: QR Code */}
<div className="flex-1 flex flex-col items-center justify-center">
- <ConnectionQRCode
- gateway={hubInfo?.url ?? 'http://localhost:3000'}
- hubId={hubInfo?.hubId ?? 'unknown'}
- agentId={primaryAgent?.id}
- expirySeconds={30}
- size={180}
- />
+ <ConnectionQRCode
+ gateway={hubInfo?.url ?? 'http://localhost:3000'}
+ hubId={hubInfo?.hubId ?? 'unknown'}
+ agentId={primaryAgent?.id}
+ expirySeconds={30}
+ size={180}
+ />
</div>
{/* Right: Hub Status */}
@@ -142,6 +143,11 @@ export default function HomePage() {
</div>
</div>
+ {/* Verified Devices */}
+ <div className="px-4 pb-2">
+ <DeviceList />
+ </div>
+
{/* Bottom: Actions */}
<div className="border-t p-4">
<div className="flex items-center justify-between">