Skip to content

🤯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.

✨ feat(settings): add Devices settings page behind Execution Device Switcher lab (#15315)

Arvin Xu21aceb6fee2f
diff --git a/locales/en-US/setting.json b/locales/en-US/setting.json
index 1902e84f8d6..52c34377e2f 100644
--- a/locales/en-US/setting.json
+++ b/locales/en-US/setting.json
@@ -268,6 +268,26 @@
"defaultAgent.model.desc": "Model used when creating new agents",
"defaultAgent.model.title": "Model",
"defaultAgent.title": "New Agent",
+ "devices.actions.edit": "Edit",
+ "devices.actions.remove": "Remove",
+ "devices.channel.connected": "Connected {{time}}",
+ "devices.edit.cancel": "Cancel",
+ "devices.edit.defaultCwd": "Default working directory",
+ "devices.edit.defaultCwdPlaceholder": "e.g. /Users/me/projects",
+ "devices.edit.friendlyName": "Name",
+ "devices.edit.friendlyNamePlaceholder": "A name to recognize this device",
+ "devices.edit.save": "Save",
+ "devices.edit.title": "Edit device",
+ "devices.empty": "No devices yet. Connect one with `lh connect` or by signing in to the desktop app.",
+ "devices.fallbackBadge": "Unstable identity",
+ "devices.fallbackTooltip": "This device couldn't be identified by its machine ID, so reinstalling the app may create a duplicate entry.",
+ "devices.lastSeen": "Last active {{time}}",
+ "devices.remove.confirm": "Remove this device?",
+ "devices.remove.confirmDesc": "This disconnects the device from your account. It does not sign the device out, and it can re-register on next connect.",
+ "devices.status.offline": "Offline",
+ "devices.status.online": "Online",
+ "devices.title": "My Devices",
+ "devices.workingDirectory": "Working dir: {{path}}",
"group.aiConfig": "Agent",
"group.common": "General",
"group.profile": "Account",
@@ -913,6 +933,7 @@
"tab.chatAppearance": "Chat Appearance",
"tab.common": "Appearance",
"tab.creds": "Credentials",
+ "tab.devices": "Devices",
"tab.experiment": "Experiment",
"tab.hotkey": "Hotkeys",
"tab.image": "Image Generation",
diff --git a/locales/zh-CN/setting.json b/locales/zh-CN/setting.json
index f6eb03fbf62..ec9ad855c70 100644
--- a/locales/zh-CN/setting.json
+++ b/locales/zh-CN/setting.json
@@ -268,6 +268,26 @@
"defaultAgent.model.desc": "创建新助理时使用的模型",
"defaultAgent.model.title": "模型",
"defaultAgent.title": "新建助理",
+ "devices.actions.edit": "编辑",
+ "devices.actions.remove": "移除",
+ "devices.channel.connected": "已连接 {{time}}",
+ "devices.edit.cancel": "取消",
+ "devices.edit.defaultCwd": "默认工作目录",
+ "devices.edit.defaultCwdPlaceholder": "例如 /Users/me/projects",
+ "devices.edit.friendlyName": "名称",
+ "devices.edit.friendlyNamePlaceholder": "便于识别此设备的名称",
+ "devices.edit.save": "保存",
+ "devices.edit.title": "编辑设备",
+ "devices.empty": "还没有设备。用 `lh connect` 连接,或登录桌面端应用。",
+ "devices.fallbackBadge": "身份不稳定",
+ "devices.fallbackTooltip": "未能通过机器 ID 识别此设备,重装应用可能会产生重复条目。",
+ "devices.lastSeen": "最近活跃 {{time}}",
+ "devices.remove.confirm": "移除此设备?",
+ "devices.remove.confirmDesc": "这会断开设备与你账户的关联,但不会让设备登出,下次连接时它可重新注册。",
+ "devices.status.offline": "离线",
+ "devices.status.online": "在线",
+ "devices.title": "我的设备",
+ "devices.workingDirectory": "工作目录:{{path}}",
"group.aiConfig": "智能体",
"group.common": "通用",
"group.profile": "账号",
@@ -913,6 +933,7 @@
"tab.chatAppearance": "聊天外观",
"tab.common": "外观",
"tab.creds": "凭证管理",
+ "tab.devices": "设备",
"tab.experiment": "实验",
"tab.hotkey": "快捷键",
"tab.image": "绘画服务",
diff --git a/src/locales/default/setting.ts b/src/locales/default/setting.ts
index 250d760d829..a2f3d68c888 100644
--- a/src/locales/default/setting.ts
+++ b/src/locales/default/setting.ts
@@ -325,6 +325,29 @@ export default {
'creds.view.title': 'View Credential: {{name}}',
'creds.view.values': 'Credential Values',
'creds.view.warning': 'These values are sensitive. Do not share them with others.',
+ 'devices.actions.edit': 'Edit',
+ 'devices.actions.remove': 'Remove',
+ 'devices.channel.connected': 'Connected {{time}}',
+ 'devices.edit.cancel': 'Cancel',
+ 'devices.edit.defaultCwd': 'Default working directory',
+ 'devices.edit.defaultCwdPlaceholder': 'e.g. /Users/me/projects',
+ 'devices.edit.friendlyName': 'Name',
+ 'devices.edit.friendlyNamePlaceholder': 'A name to recognize this device',
+ 'devices.edit.save': 'Save',
+ 'devices.edit.title': 'Edit device',
+ 'devices.empty':
+ 'No devices yet. Connect one with `lh connect` or by signing in to the desktop app.',
+ 'devices.fallbackBadge': 'Unstable identity',
+ 'devices.fallbackTooltip':
+ "This device couldn't be identified by its machine ID, so reinstalling the app may create a duplicate entry.",
+ 'devices.lastSeen': 'Last active {{time}}',
+ 'devices.remove.confirm': 'Remove this device?',
+ 'devices.remove.confirmDesc':
+ 'This disconnects the device from your account. It does not sign the device out, and it can re-register on next connect.',
+ 'devices.status.offline': 'Offline',
+ 'devices.status.online': 'Online',
+ 'devices.title': 'My Devices',
+ 'devices.workingDirectory': 'Working dir: {{path}}',
'checkingPermissions': 'Checking permissions...',
'danger.clear.action': 'Clear Now',
'danger.clear.confirm': "Clear all chat data? This can't be undone.",
@@ -1054,6 +1077,7 @@ When I am ___, I need ___
'tab.chatAppearance': 'Chat Appearance',
'tab.common': 'Appearance',
'tab.creds': 'Credentials',
+ 'tab.devices': 'Devices',
'tab.experiment': 'Experiment',
'tab.hotkey': 'Hotkeys',
'tab.image': 'Image Generation',
diff --git a/src/routes/(main)/settings/devices/features/DeviceItem.tsx b/src/routes/(main)/settings/devices/features/DeviceItem.tsx
new file mode 100644
index 00000000000..2c1e56ebe55
--- /dev/null
+++ b/src/routes/(main)/settings/devices/features/DeviceItem.tsx
@@ -0,0 +1,235 @@
+'use client';
+
+import { ActionIcon, DropdownMenu, Flexbox, Icon, Input, Tag, Text, Tooltip } from '@lobehub/ui';
+import { confirmModal, Modal } from '@lobehub/ui/base-ui';
+import { createStaticStyles, cssVar } from 'antd-style';
+import dayjs from 'dayjs';
+import {
+ FolderIcon,
+ MoreVerticalIcon,
+ PencilLineIcon,
+ Trash2Icon,
+ TriangleAlertIcon,
+} from 'lucide-react';
+import { memo, useState } from 'react';
+import { useTranslation } from 'react-i18next';
+
+import { lambdaQuery } from '@/libs/trpc/client';
+
+import { getDeviceIcon } from './getDeviceIcon';
+
+export interface DeviceChannel {
+ connectedAt: string;
+ hostname: string | null;
+ platform: string | null;
+}
+
+export interface DeviceListItem {
+ channels?: DeviceChannel[];
+ defaultCwd: string | null;
+ deviceId: string;
+ friendlyName: string | null;
+ hostname: string | null;
+ identitySource: string | null;
+ lastSeen: string;
+ online: boolean;
+ platform: string | null;
+ recentCwds: string[];
+ registered: boolean;
+}
+
+const styles = createStaticStyles(({ css }) => ({
+ channels: css`
+ margin-block-start: 4px;
+ padding-inline-start: 30px;
+ `,
+ cwd: css`
+ overflow: hidden;
+ font-family: ${cssVar.fontFamilyCode};
+ text-overflow: ellipsis;
+ white-space: nowrap;
+ `,
+ dotOffline: css`
+ width: 6px;
+ height: 6px;
+ border-radius: 50%;
+ background: ${cssVar.colorTextQuaternary};
+ `,
+ dotOnline: css`
+ width: 6px;
+ height: 6px;
+ border-radius: 50%;
+ background: ${cssVar.colorSuccess};
+ `,
+ icon: css`
+ flex: none;
+ color: ${cssVar.colorTextSecondary};
+ `,
+ row: css`
+ padding-block: 12px;
+ padding-inline: 12px;
+ border-radius: ${cssVar.borderRadiusLG};
+
+ &:hover {
+ background: ${cssVar.colorFillTertiary};
+ }
+ `,
+}));
+
+const DeviceItem = memo<{ device: DeviceListItem }>(({ device }) => {
+ const { t } = useTranslation('setting');
+ const utils = lambdaQuery.useUtils();
+
+ const [editOpen, setEditOpen] = useState(false);
+ const [name, setName] = useState('');
+ const [cwd, setCwd] = useState('');
+
+ const updateDevice = lambdaQuery.device.updateDevice.useMutation({
+ onSuccess: () => utils.device.listDevices.invalidate(),
+ });
+ const removeDevice = lambdaQuery.device.removeDevice.useMutation({
+ onSuccess: () => utils.device.listDevices.invalidate(),
+ });
+
+ const displayName = device.friendlyName || device.hostname || device.deviceId;
+ const isFallback = device.identitySource === 'fallback';
+ // `channels` may be absent when the backend predates the channel-aware
+ // `listDevices` shape; fall back to a single synthetic channel when online.
+ const channels =
+ device.channels ??
+ (device.online ? [{ connectedAt: device.lastSeen, hostname: null, platform: null }] : []);
+
+ const openEdit = () => {
+ setName(device.friendlyName ?? '');
+ setCwd(device.defaultCwd ?? '');
+ setEditOpen(true);
+ };
+
+ const handleSave = async () => {
+ await updateDevice.mutateAsync({
+ defaultCwd: cwd.trim() || null,
+ deviceId: device.deviceId,
+ friendlyName: name.trim() || null,
+ });
+ setEditOpen(false);
+ };
+
+ const handleRemove = () =>
+ confirmModal({
+ content: t('devices.remove.confirmDesc'),
+ okButtonProps: { danger: true },
+ okText: t('devices.actions.remove'),
+ onOk: async () => {
+ await removeDevice.mutateAsync({ deviceId: device.deviceId });
+ },
+ title: t('devices.remove.confirm'),
+ });
+
+ return (
+ <>
+ <Flexbox horizontal align={'flex-start'} className={styles.row} gap={12}>
+ <span className={styles.icon} style={{ marginBlockStart: 2 }}>
+ {getDeviceIcon(device.platform)}
+ </span>
+ <Flexbox flex={1} gap={2} style={{ minWidth: 0 }}>
+ <Flexbox horizontal align={'center'} gap={8}>
+ <Text ellipsis weight={500}>
+ {displayName}
+ </Text>
+ {isFallback && (
+ <Tooltip title={t('devices.fallbackTooltip')}>
+ <Tag icon={<Icon icon={TriangleAlertIcon} />}>{t('devices.fallbackBadge')}</Tag>
+ </Tooltip>
+ )}
+ </Flexbox>
+ {device.defaultCwd && (
+ <Flexbox horizontal align={'center'} gap={6}>
+ <Icon icon={FolderIcon} size={12} style={{ color: cssVar.colorTextQuaternary }} />
+ <Text className={styles.cwd} style={{ fontSize: 12 }} type={'secondary'}>
+ {device.defaultCwd}
+ </Text>
+ </Flexbox>
+ )}
+ <Flexbox className={styles.channels} gap={6}>
+ {channels.length > 0 ? (
+ channels.map((channel, index) => (
+ <Flexbox
+ horizontal
+ align={'center'}
+ gap={6}
+ key={`${channel.connectedAt}-${index}`}
+ >
+ <span className={styles.dotOnline} />
+ <Text style={{ fontSize: 12 }} type={'secondary'}>
+ {t('devices.channel.connected', { time: dayjs(channel.connectedAt).fromNow() })}
+ </Text>
+ </Flexbox>
+ ))
+ ) : (
+ <Flexbox horizontal align={'center'} gap={6}>
+ <span className={styles.dotOffline} />
+ <Text style={{ fontSize: 12 }} type={'secondary'}>
+ {t('devices.status.offline')} ·{' '}
+ {t('devices.lastSeen', { time: dayjs(device.lastSeen).fromNow() })}
+ </Text>
+ </Flexbox>
+ )}
+ </Flexbox>
+ </Flexbox>
+ <DropdownMenu
+ items={[
+ {
+ icon: <Icon icon={PencilLineIcon} />,
+ key: 'edit',
+ label: t('devices.actions.edit'),
+ onClick: openEdit,
+ },
+ { type: 'divider' },
+ {
+ danger: true,
+ icon: <Icon icon={Trash2Icon} />,
+ key: 'remove',
+ label: t('devices.actions.remove'),
+ onClick: handleRemove,
+ },
+ ]}
+ >
+ <ActionIcon icon={MoreVerticalIcon} />
+ </DropdownMenu>
+ </Flexbox>
+ <Modal
+ cancelText={t('devices.edit.cancel')}
+ confirmLoading={updateDevice.isPending}
+ okText={t('devices.edit.save')}
+ open={editOpen}
+ title={t('devices.edit.title')}
+ width={440}
+ onCancel={() => setEditOpen(false)}
+ onOk={handleSave}
+ >
+ <Flexbox gap={16} paddingBlock={8}>
+ <Flexbox gap={6}>
+ <Text weight={500}>{t('devices.edit.friendlyName')}</Text>
+ <Input
+ placeholder={t('devices.edit.friendlyNamePlaceholder')}
+ value={name}
+ onChange={(e) => setName(e.target.value)}
+ />
+ </Flexbox>
+ <Flexbox gap={6}>
+ <Text weight={500}>{t('devices.edit.defaultCwd')}</Text>
+ <Input
+ placeholder={t('devices.edit.defaultCwdPlaceholder')}
+ value={cwd}
+ onChange={(e) => setCwd(e.target.value)}
+ />
+ </Flexbox>
+ </Flexbox>
+ </Modal>
+ </>
+ );
+});
+
+DeviceItem.displayName = 'DeviceItem';
+
+export default DeviceItem;
diff --git a/src/routes/(main)/settings/devices/features/DeviceList.tsx b/src/routes/(main)/settings/devices/features/DeviceList.tsx
new file mode 100644
index 00000000000..853465c08c2
--- /dev/null
+++ b/src/routes/(main)/settings/devices/features/DeviceList.tsx
@@ -0,0 +1,50 @@
+'use client';
+
+import { Flexbox, Skeleton, Text } from '@lobehub/ui';
+import { createStaticStyles, cssVar } from 'antd-style';
+import { memo } from 'react';
+import { useTranslation } from 'react-i18next';
+
+import { lambdaQuery } from '@/libs/trpc/client';
+
+import DeviceItem from './DeviceItem';
+
+const styles = createStaticStyles(({ css }) => ({
+ container: css`
+ border: 1px solid ${cssVar.colorBorderSecondary};
+ border-radius: ${cssVar.borderRadiusLG};
+ `,
+ empty: css`
+ padding-block: 48px;
+ color: ${cssVar.colorTextTertiary};
+ text-align: center;
+ `,
+}));
+
+const DeviceList = memo(() => {
+ const { t } = useTranslation('setting');
+ const { data: devices, isLoading } = lambdaQuery.device.listDevices.useQuery(undefined, {
+ staleTime: 30_000,
+ });
+
+ if (isLoading) return <Skeleton active paragraph={{ rows: 4 }} title={false} />;
+
+ if (!devices || devices.length === 0)
+ return (
+ <Flexbox align={'center'} className={styles.empty} justify={'center'}>
+ <Text type={'secondary'}>{t('devices.empty')}</Text>
+ </Flexbox>
+ );
+
+ return (
+ <Flexbox className={styles.container} padding={4}>
+ {devices.map((device) => (
+ <DeviceItem device={device} key={device.deviceId} />
+ ))}
+ </Flexbox>
+ );
+});
+
+DeviceList.displayName = 'DeviceList';
+
+export default DeviceList;
diff --git a/src/routes/(main)/settings/devices/features/getDeviceIcon.tsx b/src/routes/(main)/settings/devices/features/getDeviceIcon.tsx
new file mode 100644
index 00000000000..276982de34d
--- /dev/null
+++ b/src/routes/(main)/settings/devices/features/getDeviceIcon.tsx
@@ -0,0 +1,22 @@
+import { SiApple, SiLinux } from '@icons-pack/react-simple-icons';
+import { Microsoft } from '@lobehub/icons';
+import { Icon } from '@lobehub/ui';
+import { MonitorIcon } from 'lucide-react';
+import { type ReactNode } from 'react';
+
+export const getDeviceIcon = (platform: string | null | undefined, size = 18): ReactNode => {
+ switch (platform) {
+ case 'darwin': {
+ return <SiApple color="currentColor" size={size} />;
+ }
+ case 'linux': {
+ return <SiLinux color="currentColor" size={size} />;
+ }
+ case 'win32': {
+ return <Microsoft color="currentColor" size={size} />;
+ }
+ default: {
+ return <Icon icon={MonitorIcon} size={size} />;
+ }
+ }
+};
diff --git a/src/routes/(main)/settings/devices/index.tsx b/src/routes/(main)/settings/devices/index.tsx
new file mode 100644
index 00000000000..f728bdd5fad
--- /dev/null
+++ b/src/routes/(main)/settings/devices/index.tsx
@@ -0,0 +1,23 @@
+'use client';
+
+import { memo } from 'react';
+import { useTranslation } from 'react-i18next';
+
+import SettingHeader from '@/routes/(main)/settings/features/SettingHeader';
+
+import DeviceList from './features/DeviceList';
+
+const Page = memo(() => {
+ const { t } = useTranslation('setting');
+
+ return (
+ <>
+ <SettingHeader title={t('devices.title')} />
+ <DeviceList />
+ </>
+ );
+});
+
+Page.displayName = 'DevicesSettings';
+
+export default Page;
diff --git a/src/routes/(main)/settings/features/componentMap.desktop.ts b/src/routes/(main)/settings/features/componentMap.desktop.ts
index 4eb60e97010..443eb2b37e8 100644
--- a/src/routes/(main)/settings/features/componentMap.desktop.ts
+++ b/src/routes/(main)/settings/features/componentMap.desktop.ts
@@ -11,6 +11,7 @@ import Advanced from '../advanced';
import APIKey from '../apikey';
import Appearance from '../appearance';
import Creds from '../creds';
+import Devices from '../devices';
import Hotkey from '../hotkey';
import Memory from '../memory';
import Messenger from '../messenger';
@@ -37,6 +38,7 @@ export const componentMap = {
[SettingsTabs.Proxy]: Proxy,
[SettingsTabs.SystemTools]: SystemTools,
[SettingsTabs.Storage]: Storage,
+ [SettingsTabs.Devices]: Devices,
// Profile related tabs
[SettingsTabs.Profile]: Profile,
[SettingsTabs.Stats]: Stats,
diff --git a/src/routes/(main)/settings/features/componentMap.ts b/src/routes/(main)/settings/features/componentMap.ts
index b33d9d44602..d4c9e42d716 100644
--- a/src/routes/(main)/settings/features/componentMap.ts
+++ b/src/routes/(main)/settings/features/componentMap.ts
@@ -46,6 +46,9 @@ export const componentMap = {
[SettingsTabs.Storage]: dynamic(() => import('../storage'), {
loading: loading('Settings > Storage'),
}),
+ [SettingsTabs.Devices]: dynamic(() => import('../devices'), {
+ loading: loading('Settings > Devices'),
+ }),
// Profile related tabs
[SettingsTabs.Profile]: dynamic(() => import('../profile'), {
loading: loading('Settings > Profile'),
diff --git a/src/routes/(main)/settings/hooks/useCategory.tsx b/src/routes/(main)/settings/hooks/useCategory.tsx
index eb8f29aa2c7..bea2bfe16d3 100644
--- a/src/routes/(main)/settings/hooks/useCategory.tsx
+++ b/src/routes/(main)/settings/hooks/useCategory.tsx
@@ -18,6 +18,7 @@ import {
KeyRound,
Map,
MessageCircleIcon,
+ MonitorSmartphoneIcon,
PaletteIcon,
Sparkles,
TerminalSquare,
@@ -34,6 +35,7 @@ import {
useServerConfigStore,
} from '@/store/serverConfig';
import { useUserStore } from '@/store/user';
+import { labPreferSelectors } from '@/store/user/selectors';
import { userProfileSelectors } from '@/store/user/slices/auth/selectors';
import { userGeneralSettingsSelectors } from '@/store/user/slices/settings/selectors';
@@ -68,6 +70,9 @@ export const useCategory = () => {
]);
const remoteServerUrl = useElectronStore(electronSyncSelectors.remoteServerUrl);
const isDevMode = useUserStore((s) => userGeneralSettingsSelectors.config(s).isDevMode);
+ const enableExecutionDeviceSwitcher = useUserStore(
+ labPreferSelectors.enableExecutionDeviceSwitcher,
+ );
const avatarUrl = useMemo(() => {
if (!avatar) return undefined;
@@ -97,6 +102,11 @@ export const useCategory = () => {
key: SettingsTabs.Appearance,
label: t('tab.appearance'),
},
+ enableExecutionDeviceSwitcher && {
+ icon: MonitorSmartphoneIcon,
+ key: SettingsTabs.Devices,
+ label: t('tab.devices'),
+ },
!mobile && {
icon: KeyboardIcon,
key: SettingsTabs.Hotkey,
@@ -225,6 +235,7 @@ export const useCategory = () => {
tAuth,
tSubscription,
enableBusinessFeatures,
+ enableExecutionDeviceSwitcher,
hideDocs,
mobile,
showApiKeyManage,
diff --git a/src/server/routers/lambda/device.ts b/src/server/routers/lambda/device.ts
index a68237748af..b838f310d40 100644
--- a/src/server/routers/lambda/device.ts
+++ b/src/server/routers/lambda/device.ts
@@ -18,6 +18,13 @@ const remotePlatformEnum = z.enum(
const CAPABILITY_TIMEOUT_MS = 5_000;
const PROFILE_TIMEOUT_MS = 5_000;
+/** A single live gateway WebSocket connection belonging to a device. */
+interface DeviceChannel {
+ connectedAt: string;
+ hostname: string | null;
+ platform: string | null;
+}
+
const deviceProcedure = authedProcedure.use(serverDatabase).use(async (opts) => {
const { ctx } = opts;
@@ -108,8 +115,11 @@ export const deviceRouter = router({
}),
/**
- * All devices the user has ever registered (incl. offline), each enriched
- * with a live `online` flag from the gateway's in-memory WS sessions.
+ * All devices the user has ever registered (incl. offline). A device is keyed
+ * by its `deviceId`; the gateway's live WS sessions are NOT separate devices —
+ * each session is surfaced as a `channel` nested under its device. A single
+ * device may therefore hold multiple channels (e.g. desktop app + CLI both
+ * connected at once), and `online` is simply "has at least one live channel".
*
* A union, not just the DB rows: a device may be connected but not yet in
* the DB (old client that predates auto-register, or registration still in
@@ -122,20 +132,33 @@ export const deviceRouter = router({
deviceProxy.queryDeviceList(ctx.userId),
]);
- const onlineMap = new Map(onlineList.map((d) => [d.deviceId, d]));
+ // Group live gateway connections (channels) by the device they belong to.
+ const channelsByDevice = new Map<string, DeviceChannel[]>();
+ for (const conn of onlineList) {
+ const list = channelsByDevice.get(conn.deviceId) ?? [];
+ list.push({
+ connectedAt: conn.lastSeen,
+ hostname: conn.hostname ?? null,
+ platform: conn.platform ?? null,
+ });
+ channelsByDevice.set(conn.deviceId, list);
+ }
+
const seen = new Set<string>();
const fromDb = registered.map((d) => {
seen.add(d.deviceId);
- const live = onlineMap.get(d.deviceId);
+ const channels = channelsByDevice.get(d.deviceId) ?? [];
+ const live = channels[0];
return {
+ channels,
defaultCwd: d.defaultCwd,
deviceId: d.deviceId,
friendlyName: d.friendlyName,
hostname: d.hostname ?? live?.hostname ?? null,
identitySource: d.identitySource,
lastSeen: d.lastSeenAt.toISOString(),
- online: onlineMap.has(d.deviceId),
+ online: channels.length > 0,
platform: d.platform ?? live?.platform ?? null,
recentCwds: d.recentCwds,
registered: true,
@@ -143,17 +166,18 @@ export const deviceRouter = router({
});
// Online but not yet persisted — transient until the client auto-registers.
- const ghosts = onlineList
- .filter((d) => !seen.has(d.deviceId))
- .map((d) => ({
+ const ghosts = [...channelsByDevice.entries()]
+ .filter(([deviceId]) => !seen.has(deviceId))
+ .map(([deviceId, channels]) => ({
+ channels,
defaultCwd: null,
- deviceId: d.deviceId,
+ deviceId,
friendlyName: null,
- hostname: d.hostname ?? null,
+ hostname: channels[0]?.hostname ?? null,
identitySource: null,
- lastSeen: d.lastSeen,
+ lastSeen: channels[0]?.connectedAt ?? new Date().toISOString(),
online: true,
- platform: d.platform ?? null,
+ platform: channels[0]?.platform ?? null,
recentCwds: [] as string[],
registered: false,
}));
diff --git a/src/store/global/initialState.ts b/src/store/global/initialState.ts
index 5baa4477eec..75a24fefa3a 100644
--- a/src/store/global/initialState.ts
+++ b/src/store/global/initialState.ts
@@ -51,6 +51,7 @@ export enum SettingsTabs {
Common = 'common',
Credits = 'credits',
Creds = 'creds',
+ Devices = 'devices',
Hotkey = 'hotkey',
/** @deprecated Use ServiceModel instead */
Image = 'image',