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.

πŸ’„ style(devices): render device settings as a form card (#19309)

Innei1ca0d48e61b2
diff --git a/src/features/DeviceManager/DeviceManager.tsx b/src/features/DeviceManager/DeviceManager.tsx
index 7ab1c2d9883..12cc8ff6af2 100644
--- a/src/features/DeviceManager/DeviceManager.tsx
+++ b/src/features/DeviceManager/DeviceManager.tsx
@@ -3,15 +3,13 @@
import { isDesktop } from '@lobechat/const';
import type { DeviceScope, DeviceVisibility } from '@lobechat/types';
import { Flexbox, Icon } from '@lobehub/ui';
-import { ActionIcon, Button, Skeleton, Text } from '@lobehub/ui/base-ui';
+import { Button, Text } from '@lobehub/ui/base-ui';
import { createStaticStyles, cssVar } from 'antd-style';
import {
ChevronRightIcon,
FolderCogIcon,
type LucideIcon,
MonitorDownIcon,
- MonitorUpIcon,
- RefreshCwIcon,
ServerIcon,
TerminalIcon,
ZapIcon,
@@ -65,6 +63,13 @@ const styles = createStaticStyles(({ css }) => ({
border-radius: ${cssVar.borderRadiusLG};
background: ${cssVar.colorBgContainer};
`,
+ // The personal page renders inside a settings form card, so the list and the
+ // onboarding state drop their own card chrome β€” one frame, not two nested.
+ plainCol: css`
+ overflow: hidden;
+ min-width: 0;
+ border-radius: ${cssVar.borderRadiusLG};
+ `,
emptyHero: css`
padding-block: 40px;
padding-inline: 32px;
@@ -145,12 +150,6 @@ const styles = createStaticStyles(({ css }) => ({
background: ${cssVar.colorBgContainer};
`,
- listHeader: css`
- min-height: 44px;
- padding-block: 8px;
- padding-inline: 12px;
- border-block-end: 1px solid ${cssVar.colorBorderSecondary};
- `,
listScroll: css`
overflow-y: auto;
@@ -245,16 +244,9 @@ const Capabilities = memo(() => {
// Loading placeholder that reuses the list-card chrome and only skeletonises the
// row text β€” loading β†’ loaded is a content swap, not a relayout (ux Β§4.1).
-// `withHeader` mirrors the personal page's count/connect header row; the
-// workspace page has no list header (its actions live in the page's tab row).
-const ListSkeleton = memo<{ withHeader?: boolean }>(({ withHeader }) => (
- <Flexbox className={styles.listCol} flex={1}>
- {withHeader && (
- <Flexbox horizontal align={'center'} className={styles.listHeader}>
- <Skeleton style={{ height: 16, minWidth: 80, width: 80 }} />
- </Flexbox>
- )}
- <Flexbox padding={4}>
+const ListSkeleton = memo<{ bordered?: boolean }>(({ bordered }) => (
+ <Flexbox className={bordered ? styles.listCol : styles.plainCol} flex={1}>
+ <Flexbox padding={bordered ? 4 : 0}>
<SharedListSkeleton />
</Flexbox>
</Flexbox>
@@ -285,7 +277,7 @@ const DeviceManager = memo<DeviceManagerProps>(({ onConnect, scope, visibility }
// Workspace-keyed SWR fetch β€” the shared hook every device-listing surface
// uses (see `useDeviceList` for why the raw TRPC React Query path is wrong).
- const { data, isLoading, error, mutate, isValidating } = useDeviceList();
+ const { data, isLoading, error, mutate } = useDeviceList();
// `listDevices` is workspace-aware and returns both pools β€” keep each surface
// to its own scope (and visibility tab). Ghost rows (`visibility: null`,
// online but unregistered) belong to the shared pool: the server already
@@ -315,7 +307,7 @@ const DeviceManager = memo<DeviceManagerProps>(({ onConnect, scope, visibility }
const isPrivatePool = isWorkspace && visibility === 'private';
const emptyState = (
<Flexbox gap={32}>
- <Flexbox className={styles.emptyCard}>
+ <Flexbox className={isWorkspace ? styles.emptyCard : styles.plainCol}>
<Flexbox align={'center'} className={styles.emptyHero} gap={12}>
<span className={styles.heroIcon}>
<Icon icon={isWorkspace && !isPrivatePool ? ServerIcon : MonitorDownIcon} size={28} />
@@ -372,42 +364,12 @@ const DeviceManager = memo<DeviceManagerProps>(({ onConnect, scope, visibility }
errorVariant={'block'}
isEmpty={devices.length === 0}
isLoading={isLoading}
- loading={<ListSkeleton withHeader={!isWorkspace} />}
+ loading={<ListSkeleton bordered={isWorkspace} />}
onRetry={() => mutate()}
>
<Flexbox horizontal align={'flex-start'} gap={16}>
- <Flexbox className={styles.listCol} flex={1}>
- {/* Workspace scope has no list header β€” its connect + refresh actions
- live in the page's tab row (beside the visibility tabs). */}
- {!isWorkspace && (
- <Flexbox
- horizontal
- align={'center'}
- className={styles.listHeader}
- justify={'space-between'}
- >
- <Text fontSize={12} type={'secondary'} weight={500}>
- {t('devices.selection.total', { count: devices.length })}
- </Text>
- <Flexbox horizontal align={'center'} gap={8}>
- <Button
- icon={<Icon icon={MonitorUpIcon} />}
- size={'small'}
- onClick={() => onConnect()}
- >
- {t('devices.connectWizard.button')}
- </Button>
- <ActionIcon
- icon={RefreshCwIcon}
- loading={isValidating}
- size={'small'}
- title={t('devices.actions.refresh')}
- onClick={() => mutate()}
- />
- </Flexbox>
- </Flexbox>
- )}
- <Flexbox className={styles.listScroll} gap={2} padding={4}>
+ <Flexbox className={isWorkspace ? styles.listCol : styles.plainCol} flex={1}>
+ <Flexbox className={styles.listScroll} gap={2} padding={isWorkspace ? 4 : 0}>
{devices.map((device) => (
<DeviceItem
device={device}
diff --git a/src/features/Settings/devices/index.tsx b/src/features/Settings/devices/index.tsx
index 5d49471ccbf..a11353c17cc 100644
--- a/src/features/Settings/devices/index.tsx
+++ b/src/features/Settings/devices/index.tsx
@@ -1,32 +1,66 @@
'use client';
+import { Flexbox, Form, Icon } from '@lobehub/ui';
+import { ActionIcon, Button, Text } from '@lobehub/ui/base-ui';
+import { MonitorUpIcon, RefreshCwIcon } from 'lucide-react';
import { memo, useState } from 'react';
import { useTranslation } from 'react-i18next';
-import { DeviceConnectModal, DeviceManager } from '@/features/DeviceManager';
-import SettingHeader from '@/features/Settings/features/SettingHeader';
+import { FORM_STYLE } from '@/const/layoutTokens';
+import { DeviceConnectModal, DeviceManager, useDeviceList } from '@/features/DeviceManager';
-interface PageProps {
- showSettingHeader?: boolean;
-}
-
-const Page = memo<PageProps>(({ showSettingHeader = true }) => {
+const Page = memo(() => {
const { t } = useTranslation('setting');
const [open, setOpen] = useState(false);
const [initialTab, setInitialTab] = useState<'cli' | 'desktop'>();
+ // Shares DeviceManager's SWR entry, so the header actions drive the list it
+ // renders β€” the same wiring the workspace devices page uses.
+ const { data, isValidating, mutate } = useDeviceList();
const handleConnect = (tab?: 'cli' | 'desktop') => {
setInitialTab(tab);
setOpen(true);
};
+ const devices = (data ?? []).filter((device) => device.scope === 'personal');
+
return (
<>
- {/* "Connect device" moved into the device list header (next to Refresh) β€”
- keep the page header to the title only. */}
- {showSettingHeader && <SettingHeader title={t('devices.title')} />}
-
- <DeviceManager scope={'personal'} onConnect={handleConnect} />
+ <Form
+ collapsible={false}
+ itemsType={'group'}
+ variant={'filled'}
+ items={[
+ {
+ children: <DeviceManager scope={'personal'} onConnect={handleConnect} />,
+ extra: (
+ <Flexbox horizontal align={'center'} gap={8}>
+ {devices.length > 0 && (
+ <Text fontSize={12} type={'secondary'} weight={500}>
+ {t('devices.selection.total', { count: devices.length })}
+ </Text>
+ )}
+ <Button
+ icon={<Icon icon={MonitorUpIcon} />}
+ size={'small'}
+ onClick={() => handleConnect()}
+ >
+ {t('devices.connectWizard.button')}
+ </Button>
+ <ActionIcon
+ icon={RefreshCwIcon}
+ loading={isValidating}
+ size={'small'}
+ title={t('devices.actions.refresh')}
+ onClick={() => mutate()}
+ />
+ </Flexbox>
+ ),
+ title: t('devices.title'),
+ },
+ ]}
+ {...FORM_STYLE}
+ />
<DeviceConnectModal
initialTab={initialTab}