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): unify save-state feedback and close settings-tab UX gaps (#16846)

Arvin Xu3c46efaffb4b
diff --git a/locales/en-US/setting.json b/locales/en-US/setting.json
index 54821120e4c..8c0205b40e1 100644
--- a/locales/en-US/setting.json
+++ b/locales/en-US/setting.json
@@ -335,6 +335,7 @@
"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.remove.confirmMany": "Remove {{count}} devices?",
"devices.remove.confirmManyDesc": "This disconnects the selected devices from your account. They are not signed out, and each can re-register on next connect.",
+ "devices.remove.currentSessionWarning": "This includes the device you're using right now — removing it disconnects your current session.",
"devices.selection.selected": "{{count}} selected",
"devices.selection.total": "{{count}} devices",
"devices.status.offline": "Offline",
@@ -456,6 +457,7 @@
"memory.effort.title": "Aggressiveness",
"memory.enabled.desc": "Allow LobeHub to extract preferences and info from conversations and use them later. You can view, edit, or clear memory anytime.",
"memory.enabled.title": "Enable Memory",
+ "memory.manageEntry": "Manage memories",
"memory.title": "Memory Settings",
"message.success": "Update successful",
"myAgents.actions.cancel": "Cancel",
diff --git a/locales/zh-CN/setting.json b/locales/zh-CN/setting.json
index b28e61e0346..b2b223f031e 100644
--- a/locales/zh-CN/setting.json
+++ b/locales/zh-CN/setting.json
@@ -335,6 +335,7 @@
"devices.remove.confirmDesc": "这会断开设备与你账户的关联,但不会让设备登出,下次连接时它可重新注册。",
"devices.remove.confirmMany": "移除这 {{count}} 台设备?",
"devices.remove.confirmManyDesc": "这会断开所选设备与你账户的关联,它们不会被登出,下次连接时均可重新注册。",
+ "devices.remove.currentSessionWarning": "其中包含你当前正在使用的设备,移除后会断开当前会话。",
"devices.selection.selected": "已选 {{count}} 项",
"devices.selection.total": "{{count}} 台设备",
"devices.status.offline": "离线",
@@ -456,6 +457,7 @@
"memory.effort.title": "积极性",
"memory.enabled.desc": "允许 LobeHub 从对话中提取偏好和信息,并在之后使用。您可以随时查看、编辑或清除记忆内容。",
"memory.enabled.title": "启用记忆功能",
+ "memory.manageEntry": "管理记忆",
"memory.title": "记忆设置",
"message.success": "更新成功",
"myAgents.actions.cancel": "取消",
diff --git a/packages/locales/src/default/setting.ts b/packages/locales/src/default/setting.ts
index 2445fabbf3f..69a05bd377b 100644
--- a/packages/locales/src/default/setting.ts
+++ b/packages/locales/src/default/setting.ts
@@ -408,6 +408,8 @@ export default {
'devices.remove.confirmMany': 'Remove {{count}} devices?',
'devices.remove.confirmManyDesc':
'This disconnects the selected devices from your account. They are not signed out, and each can re-register on next connect.',
+ 'devices.remove.currentSessionWarning':
+ "This includes the device you're using right now — removing it disconnects your current session.",
'devices.selection.selected': '{{count}} selected',
'devices.selection.total': '{{count}} devices',
'devices.status.offline': 'Offline',
@@ -530,6 +532,7 @@ export default {
'memory.enabled.desc':
'Allow LobeHub to extract preferences and info from conversations and use them later. You can view, edit, or clear memory anytime.',
'memory.enabled.title': 'Enable Memory',
+ 'memory.manageEntry': 'Manage memories',
'memory.title': 'Memory Settings',
'message.success': 'Update successful',
'notification.enabled': 'Enabled',
diff --git a/src/features/DeviceManager/DeviceItem.tsx b/src/features/DeviceManager/DeviceItem.tsx
index 30bf415f3f6..f7ed86f83c6 100644
--- a/src/features/DeviceManager/DeviceItem.tsx
+++ b/src/features/DeviceManager/DeviceItem.tsx
@@ -30,6 +30,7 @@ const styles = createStaticStyles(({ css }) => ({
// row at one line.
cwd: css`
overflow: hidden;
+
font-family: ${cssVar.fontFamilyCode};
font-size: ${cssVar.fontSizeSM};
text-overflow: ellipsis;
@@ -193,7 +194,9 @@ const DeviceItem = memo<DeviceItemProps>(
const handleRemove = () =>
confirmModal({
- content: t('devices.remove.confirmDesc'),
+ content: isCurrent
+ ? `${t('devices.remove.confirmDesc')}\n\n${t('devices.remove.currentSessionWarning')}`
+ : t('devices.remove.confirmDesc'),
okButtonProps: { danger: true },
okText: t('devices.actions.remove'),
onOk: async () => {
@@ -207,15 +210,15 @@ const DeviceItem = memo<DeviceItemProps>(
horizontal
align={'center'}
aria-pressed={selected}
+ gap={12}
+ role={'button'}
+ tabIndex={0}
className={cx(
styles.row,
selected && styles.rowActive,
onCheckChange && styles.selectable,
pinSelect && styles.selectOn,
)}
- gap={12}
- role={'button'}
- tabIndex={0}
onClick={onSelect}
onKeyDown={(e) => {
// Mirror native button keyboard semantics for the div-as-button row.
diff --git a/src/features/DeviceManager/DeviceManager.tsx b/src/features/DeviceManager/DeviceManager.tsx
index 55e486e4376..d0ab0d61974 100644
--- a/src/features/DeviceManager/DeviceManager.tsx
+++ b/src/features/DeviceManager/DeviceManager.tsx
@@ -396,8 +396,13 @@ const DeviceManager = memo<DeviceManagerProps>(({ onConnect, scope }) => {
const handleBulkRemove = () => {
const ids = editableDevices.filter((d) => checkedIds.has(d.deviceId)).map((d) => d.deviceId);
if (ids.length === 0) return;
+ // Revoking the machine the user is on right now disconnects this very session
+ // — call it out so a bulk sweep can't silently cut the ground from under them.
+ const includesCurrent = ids.some((id) => isCurrent(id));
confirmModal({
- content: t('devices.remove.confirmManyDesc', { count: ids.length }),
+ content: includesCurrent
+ ? `${t('devices.remove.confirmManyDesc', { count: ids.length })}\n\n${t('devices.remove.currentSessionWarning')}`
+ : t('devices.remove.confirmManyDesc', { count: ids.length }),
okButtonProps: { danger: true },
okText: t('devices.actions.removeSelected', { count: ids.length }),
onOk: async () => {
diff --git a/src/features/ServiceModel/ModelAssignmentsForm.tsx b/src/features/ServiceModel/ModelAssignmentsForm.tsx
index 64452db0e33..005b631fda2 100644
--- a/src/features/ServiceModel/ModelAssignmentsForm.tsx
+++ b/src/features/ServiceModel/ModelAssignmentsForm.tsx
@@ -1,18 +1,19 @@
'use client';
import type { FormGroupItemType, FormItemProps } from '@lobehub/ui';
-import { Flexbox, Form, Icon, InputNumber, Skeleton, Tooltip } from '@lobehub/ui';
+import { Flexbox, Form, InputNumber, Skeleton, Tooltip } from '@lobehub/ui';
import { Switch } from '@lobehub/ui/base-ui';
import { ConfigProvider } from 'antd';
import isEqual from 'fast-deep-equal';
-import { Loader2Icon } from 'lucide-react';
import { memo, useEffect, useState } from 'react';
import { useTranslation } from 'react-i18next';
import AsyncError from '@/components/AsyncError';
+import AutoSaveHint from '@/components/Editor/AutoSaveHint';
import { FORM_STYLE } from '@/const/layoutTokens';
import ModelSelect from '@/features/ModelSelect';
import { usePermission } from '@/hooks/usePermission';
+import { useSaveState } from '@/hooks/useSaveState';
import { useUserStore } from '@/store/user';
import { settingsSelectors } from '@/store/user/selectors';
import type { SystemAgentItem, UserServiceModelConfigKey } from '@/types/user/settings';
@@ -24,6 +25,8 @@ interface SystemAgentModelItem {
type LoadingKey = 'defaultAgent' | UserServiceModelConfigKey;
+type SavingGroup = 'assignments' | 'memory' | 'optional';
+
const SYSTEM_AGENT_MODEL_ITEMS: SystemAgentModelItem[] = [
{ key: 'topic' },
{ key: 'generationTopic' },
@@ -65,11 +68,21 @@ const ModelAssignmentsForm = memo(() => {
s.refreshUserState,
]);
const [loadingKey, setLoadingKey] = useState<LoadingKey>();
+ // Track which group last saved so its AutoSaveHint (and only its) reflects the
+ // shared save-state — the write-side counterpart to the read-side AsyncError above.
+ const [savingGroup, setSavingGroup] = useState<SavingGroup>();
+ const { status: saveStatus, lastSavedAt, save, retry } = useSaveState();
useEffect(() => {
if (loadingKey === 'defaultAgent') setLoadingKey(undefined);
}, [defaultAgent.config.model, defaultAgent.config.provider, loadingKey]);
+ const groupOfKey = (key: UserServiceModelConfigKey): SavingGroup => {
+ if (MEMORY_MODEL_ITEMS.some((item) => item.key === key)) return 'memory';
+ if (OPTIONAL_FEATURE_ITEMS.some((item) => item.key === key)) return 'optional';
+ return 'assignments';
+ };
+
if (!isUserStateInit) {
// A failed user-state init must show error + Retry, not a permanent skeleton
if (isUserStateInitError)
@@ -92,9 +105,10 @@ const ModelAssignmentsForm = memo(() => {
}) => {
if (!canManageServiceModel) return;
+ setSavingGroup('assignments');
setLoadingKey('defaultAgent');
try {
- await updateDefaultAgent({ config: { model, provider } });
+ await save(() => updateDefaultAgent({ config: { model, provider } }));
} finally {
setLoadingKey(undefined);
}
@@ -106,9 +120,10 @@ const ModelAssignmentsForm = memo(() => {
) => {
if (!canManageServiceModel) return;
+ setSavingGroup(groupOfKey(key));
setLoadingKey(key);
try {
- await updateSystemAgent(key, value);
+ await save(() => updateSystemAgent(key, value));
} finally {
setLoadingKey(undefined);
}
@@ -243,34 +258,26 @@ const ModelAssignmentsForm = memo(() => {
} satisfies FormItemProps;
});
- const isOptionalFeatureLoading =
- loadingKey === 'followUpAction' ||
- loadingKey === 'inputCompletion' ||
- loadingKey === 'promptRewrite';
- const isMemoryModelLoading = MEMORY_MODEL_ITEMS.some(({ key }) => loadingKey === key);
- const isModelAssignmentLoading = loadingKey && !isOptionalFeatureLoading && !isMemoryModelLoading;
+ const renderSaveHint = (group: SavingGroup) =>
+ savingGroup === group && (
+ <AutoSaveHint lastUpdatedTime={lastSavedAt} saveStatus={saveStatus} onRetry={retry} />
+ );
const modelAssignments: FormGroupItemType = {
children: [defaultAgentItem, ...systemModelItems],
- extra: isModelAssignmentLoading && (
- <Icon spin icon={Loader2Icon} size={16} style={{ opacity: 0.5 }} />
- ),
+ extra: renderSaveHint('assignments'),
title: t('serviceModel.modelAssignments.title'),
};
const optionalFeatures: FormGroupItemType = {
children: optionalFeatureItems,
- extra: isOptionalFeatureLoading && (
- <Icon spin icon={Loader2Icon} size={16} style={{ opacity: 0.5 }} />
- ),
+ extra: renderSaveHint('optional'),
title: t('serviceModel.optionalFeatures.title'),
};
const memoryModels: FormGroupItemType = {
children: memoryModelItems,
- extra: isMemoryModelLoading && (
- <Icon spin icon={Loader2Icon} size={16} style={{ opacity: 0.5 }} />
- ),
+ extra: renderSaveHint('memory'),
title: t('serviceModel.memoryModels.title'),
};
diff --git a/src/routes/(main)/settings/about/features/Version.tsx b/src/routes/(main)/settings/about/features/Version.tsx
index 89f0f281b59..3cd229f7a4c 100644
--- a/src/routes/(main)/settings/about/features/Version.tsx
+++ b/src/routes/(main)/settings/about/features/Version.tsx
@@ -15,6 +15,7 @@ import { CURRENT_VERSION } from '@/const/version';
import { useNewVersion } from '@/features/User/UserPanel/useNewVersion';
import { autoUpdateService } from '@/services/electron/autoUpdate';
import { useGlobalStore } from '@/store/global';
+import { featureFlagsSelectors, useServerConfigStore } from '@/store/serverConfig';
import { APP_VERSION } from './appVersion';
@@ -26,15 +27,27 @@ const styles = createStaticStyles(({ css, cssVar }) => ({
const Version = memo<{ mobile?: boolean }>(({ mobile }) => {
const hasNewVersion = useNewVersion();
- const [latestVersion, serverVersion, useCheckServerVersion] = useGlobalStore((s) => [
- s.latestVersion,
- s.serverVersion,
- s.useCheckServerVersion,
- ]);
+ const [latestVersion, serverVersion, useCheckServerVersion, useCheckLatestVersion] =
+ useGlobalStore((s) => [
+ s.latestVersion,
+ s.serverVersion,
+ s.useCheckServerVersion,
+ s.useCheckLatestVersion,
+ ]);
const { t } = useTranslation(['common', 'setting']);
useCheckServerVersion();
+ // Read the shared latest-version check state (deduped by key, no extra fetch)
+ // so a failed update check can surface a retry instead of silently rendering
+ // nothing — which is indistinguishable from "up to date".
+ const { enableCheckUpdates } = useServerConfigStore(featureFlagsSelectors);
+ const {
+ error: updateCheckError,
+ isValidating: isCheckingUpdate,
+ mutate: recheckUpdate,
+ } = useCheckLatestVersion(enableCheckUpdates);
+
const showServerVersion = serverVersion && serverVersion !== CURRENT_VERSION;
const isDesktop = useMemo(() => !!getElectronIpc(), []);
@@ -66,6 +79,14 @@ const Version = memo<{ mobile?: boolean }>(({ mobile }) => {
</a>
);
}
+ // A failed update check must not read as "up to date" — offer a retry.
+ if (updateCheckError) {
+ return (
+ <Button block={mobile} loading={isCheckingUpdate} onClick={() => recheckUpdate()}>
+ {t('checkForUpdates')}
+ </Button>
+ );
+ }
return null;
}
diff --git a/src/routes/(main)/settings/chat-appearance/features/ChatAppearance/index.tsx b/src/routes/(main)/settings/chat-appearance/features/ChatAppearance/index.tsx
index bd965f38cc6..5f61d5116a0 100644
--- a/src/routes/(main)/settings/chat-appearance/features/ChatAppearance/index.tsx
+++ b/src/routes/(main)/settings/chat-appearance/features/ChatAppearance/index.tsx
@@ -4,17 +4,17 @@ import {
Flexbox,
FormGroup,
highlighterThemes,
- Icon,
mermaidThemes,
Skeleton,
SliderWithInput,
} from '@lobehub/ui';
import { Select, Switch, Tabs } from '@lobehub/ui/base-ui';
import isEqual from 'fast-deep-equal';
-import { Loader2Icon } from 'lucide-react';
import { memo, useState } from 'react';
import { useTranslation } from 'react-i18next';
+import AutoSaveHint from '@/components/Editor/AutoSaveHint';
+import { useSaveState } from '@/hooks/useSaveState';
import { useUserStore } from '@/store/user';
import { settingsSelectors } from '@/store/user/selectors';
@@ -28,16 +28,22 @@ const ChatAppearance = memo(() => {
const { t } = useTranslation('setting');
const { general } = useUserStore(settingsSelectors.currentSettings, isEqual);
const [setSettings, isUserStateInit] = useUserStore((s) => [s.setSettings, s.isUserStateInit]);
- const [loadingStates, setLoadingStates] = useState<Record<string, boolean>>({});
+ const { status: saveStatus, lastSavedAt, save, retry } = useSaveState();
+ const [savingKey, setSavingKey] = useState<string>();
if (!isUserStateInit) return <Skeleton active paragraph={{ rows: 5 }} title={false} />;
- const handleChange = async (key: string, value: any) => {
- setLoadingStates((prev) => ({ ...prev, [key]: true }));
- await setSettings({ general: { [key]: value } });
- setLoadingStates((prev) => ({ ...prev, [key]: false }));
+ const handleChange = (key: string, value: any) => {
+ setSavingKey(key);
+ save(() => setSettings({ general: { [key]: value } }));
};
+ // Show the shared save-state hint only on the control the user last touched.
+ const renderSaveHint = (key: string) =>
+ savingKey === key && (
+ <AutoSaveHint lastUpdatedTime={lastSavedAt} saveStatus={saveStatus} onRetry={retry} />
+ );
+
return (
<>
<FormGroup
@@ -48,9 +54,7 @@ const ChatAppearance = memo(() => {
variant={'filled'}
extra={
<Flexbox horizontal align={'center'} gap={8}>
- {loadingStates.transitionMode && (
- <Icon spin icon={Loader2Icon} size={16} style={{ opacity: 0.5 }} />
- )}
+ {renderSaveHint('transitionMode')}
<Tabs
activeKey={general.transitionMode}
items={[
@@ -83,9 +87,7 @@ const ChatAppearance = memo(() => {
variant={'filled'}
extra={
<Flexbox horizontal align={'center'} gap={8}>
- {loadingStates.enableAutoScrollOnStreaming && (
- <Icon spin icon={Loader2Icon} size={16} style={{ opacity: 0.5 }} />
- )}
+ {renderSaveHint('enableAutoScrollOnStreaming')}
<Switch
checked={general.enableAutoScrollOnStreaming ?? true}
onChange={(checked) => handleChange('enableAutoScrollOnStreaming', checked)}
@@ -104,9 +106,7 @@ const ChatAppearance = memo(() => {
variant={'filled'}
extra={
<Flexbox horizontal align={'center'} gap={8}>
- {loadingStates.enableMessageLinkIcon && (
- <Icon spin icon={Loader2Icon} size={16} style={{ opacity: 0.5 }} />
- )}
+ {renderSaveHint('enableMessageLinkIcon')}
<Switch
checked={general.enableMessageLinkIcon ?? true}
onChange={(checked) => handleChange('enableMessageLinkIcon', checked)}
@@ -125,9 +125,7 @@ const ChatAppearance = memo(() => {
variant={'filled'}
extra={
<Flexbox horizontal align={'center'} gap={8}>
- {loadingStates.fontSize && (
- <Icon spin icon={Loader2Icon} size={16} style={{ opacity: 0.5 }} />
- )}
+ {renderSaveHint('fontSize')}
<SliderWithInput
max={18}
min={12}
@@ -174,9 +172,7 @@ const ChatAppearance = memo(() => {
variant={'filled'}
extra={
<Flexbox horizontal align={'center'} gap={8}>
- {loadingStates.highlighterTheme && (
- <Icon spin icon={Loader2Icon} size={16} style={{ opacity: 0.5 }} />
- )}
+ {renderSaveHint('highlighterTheme')}
<Select
value={general.highlighterTheme}
options={highlighterThemes.map((item) => ({
@@ -200,9 +196,7 @@ const ChatAppearance = memo(() => {
variant={'filled'}
extra={
<Flexbox horizontal align={'center'} gap={8}>
- {loadingStates.mermaidTheme && (
- <Icon spin icon={Loader2Icon} size={16} style={{ opacity: 0.5 }} />
- )}
+ {renderSaveHint('mermaidTheme')}
<Select
value={general.mermaidTheme}
options={mermaidThemes.map((item) => ({
diff --git a/src/routes/(main)/settings/common/features/Appearance/index.tsx b/src/routes/(main)/settings/common/features/Appearance/index.tsx
index dfb99028619..2c8d31de4de 100644
--- a/src/routes/(main)/settings/common/features/Appearance/index.tsx
+++ b/src/routes/(main)/settings/common/features/Appearance/index.tsx
@@ -1,13 +1,14 @@
'use client';
import { type FormGroupItemType } from '@lobehub/ui';
-import { Form, Icon, Skeleton } from '@lobehub/ui';
+import { Form, Skeleton } from '@lobehub/ui';
import isEqual from 'fast-deep-equal';
-import { Loader2Icon } from 'lucide-react';
-import { memo, useState } from 'react';
+import { memo } from 'react';
import { useTranslation } from 'react-i18next';
+import AutoSaveHint from '@/components/Editor/AutoSaveHint';
import { FORM_STYLE } from '@/const/layoutTokens';
+import { useSaveState } from '@/hooks/useSaveState';
import { useUserStore } from '@/store/user';
import { settingsSelectors } from '@/store/user/slices/settings/selectors';
@@ -18,7 +19,7 @@ const Appearance = memo(() => {
const { t } = useTranslation('setting');
const { general } = useUserStore(settingsSelectors.currentSettings, isEqual);
const [setSettings, isUserStateInit] = useUserStore((s) => [s.setSettings, s.isUserStateInit]);
- const [loading, setLoading] = useState(false);
+ const { status: saveStatus, lastSavedAt, save, retry } = useSaveState();
if (!isUserStateInit) return <Skeleton active paragraph={{ rows: 5 }} title={false} />;
@@ -44,7 +45,7 @@ const Appearance = memo(() => {
name: 'neutralColor',
},
],
- extra: loading && <Icon spin icon={Loader2Icon} size={16} style={{ opacity: 0.5 }} />,
+ extra: <AutoSaveHint lastUpdatedTime={lastSavedAt} saveStatus={saveStatus} onRetry={retry} />,
title: t('settingAppearance.title'),
};
@@ -55,11 +56,7 @@ const Appearance = memo(() => {
items={[theme]}
itemsType={'group'}
variant={'filled'}
- onValuesChange={async (value) => {
- setLoading(true);
- await setSettings({ general: value });
- setLoading(false);
- }}
+ onValuesChange={(value) => save(() => setSettings({ general: value }))}
{...FORM_STYLE}
/>
);
diff --git a/src/routes/(main)/settings/common/features/Common/Common.tsx b/src/routes/(main)/settings/common/features/Common/Common.tsx
index e8b9ab1ec57..65f9fb8b3cd 100644
--- a/src/routes/(main)/settings/common/features/Common/Common.tsx
+++ b/src/routes/(main)/settings/common/features/Common/Common.tsx
@@ -4,14 +4,16 @@ import { type FormGroupItemType } from '@lobehub/ui';
import { Flexbox, Form, Icon, ImageSelect, Skeleton } from '@lobehub/ui';
import { Select, Tabs } from '@lobehub/ui/base-ui';
import isEqual from 'fast-deep-equal';
-import { Ban, Gauge, Loader2Icon, Monitor, Moon, Mouse, Sun, Waves } from 'lucide-react';
+import { Ban, Gauge, Monitor, Moon, Mouse, Sun, Waves } from 'lucide-react';
import { useTheme as useNextThemesTheme } from 'next-themes';
-import { memo, useState } from 'react';
+import { memo } from 'react';
import { useTranslation } from 'react-i18next';
+import AutoSaveHint from '@/components/Editor/AutoSaveHint';
import { FORM_STYLE } from '@/const/layoutTokens';
import { imageUrl } from '@/const/url';
import { isDesktop } from '@/const/version';
+import { useSaveState } from '@/hooks/useSaveState';
import { localeOptions } from '@/locales/resources';
import { useGlobalStore } from '@/store/global';
import { systemStatusSelectors } from '@/store/global/selectors';
@@ -27,7 +29,7 @@ const Common = memo(() => {
const language = useGlobalStore(systemStatusSelectors.language);
const [setSettings, isUserStateInit] = useUserStore((s) => [s.setSettings, s.isUserStateInit]);
const [switchLocale, isStatusInit] = useGlobalStore((s) => [s.switchLocale, s.isStatusInit]);
- const [loading, setLoading] = useState(false);
+ const { status: saveStatus, lastSavedAt, save, retry } = useSaveState();
// Use the theme value from next-themes, default to 'system'
const currentTheme = theme || 'system';
@@ -156,7 +158,7 @@ const Common = memo(() => {
width: '50%',
}}
onChange={(value) => {
- setSettings({ general: { responseLanguage: value ?? '' } });
+ save(() => setSettings({ general: { responseLanguage: value ?? '' } }));
}}
/>
</Flexbox>
@@ -165,7 +167,7 @@ const Common = memo(() => {
label: t('settingCommon.responseLanguage.title'),
},
],
- extra: loading && <Icon spin icon={Loader2Icon} size={16} style={{ opacity: 0.5 }} />,
+ extra: <AutoSaveHint lastUpdatedTime={lastSavedAt} saveStatus={saveStatus} onRetry={retry} />,
title: t('settingCommon.title'),
};
@@ -176,11 +178,7 @@ const Common = memo(() => {
items={[themeFormGroup]}
itemsType={'group'}
variant={'filled'}
- onValuesChange={async (v) => {
- setLoading(true);
- await setSettings({ general: v });
- setLoading(false);
- }}
+ onValuesChange={(v) => save(() => setSettings({ general: v }))}
{...FORM_STYLE}
/>
);
diff --git a/src/routes/(main)/settings/hotkey/features/Conversation.tsx b/src/routes/(main)/settings/hotkey/features/Conversation.tsx
index 08ec2242aec..0dd7c402f02 100644
--- a/src/routes/(main)/settings/hotkey/features/Conversation.tsx
+++ b/src/routes/(main)/settings/hotkey/features/Conversation.tsx
@@ -2,14 +2,15 @@
import { HotkeyGroupEnum } from '@lobechat/const/hotkeys';
import { type FormGroupItemType } from '@lobehub/ui';
-import { Form, HotkeyInput, Icon, Skeleton } from '@lobehub/ui';
+import { Form, HotkeyInput, Skeleton } from '@lobehub/ui';
import isEqual from 'fast-deep-equal';
-import { Loader2Icon } from 'lucide-react';
-import { memo, useState } from 'react';
+import { memo } from 'react';
import { useTranslation } from 'react-i18next';
+import AutoSaveHint from '@/components/Editor/AutoSaveHint';
import { HOTKEYS_REGISTRATION } from '@/const/hotkeys';
import { FORM_STYLE } from '@/const/layoutTokens';
+import { useSaveState } from '@/hooks/useSaveState';
import hotkeyMeta from '@/locales/default/hotkey';
import { useUserStore } from '@/store/user';
import { settingsSelectors } from '@/store/user/selectors';
@@ -21,21 +22,15 @@ const HotkeySetting = memo(() => {
const { hotkey } = useUserStore(settingsSelectors.currentSettings, isEqual);
const [setSettings, isUserStateInit] = useUserStore((s) => [s.setSettings, s.isUserStateInit]);
- const [loading, setLoading] = useState(false);
+ const { status: saveStatus, lastSavedAt, save, retry } = useSaveState();
if (!isUserStateInit) return <Skeleton active paragraph={{ rows: 5 }} title={false} />;
- const clearHotkeyBinding = async (id: HotkeyItem['id']) => {
+ const clearHotkeyBinding = (id: HotkeyItem['id']) => {
if (!hotkey[id]) return;
- setLoading(true);
form.setFieldValue(id, '');
-
- try {
- await setSettings({ hotkey: { [id]: '' } });
- } finally {
- setLoading(false);
- }
+ save(() => setSettings({ hotkey: { [id]: '' } }));
};
const mapHotkeyItem = (item: HotkeyItem) => {
@@ -68,7 +63,7 @@ const HotkeySetting = memo(() => {
children: HOTKEYS_REGISTRATION.filter(
(item) => item.group === HotkeyGroupEnum.Conversation,
).map((item) => mapHotkeyItem(item)),
- extra: loading && <Icon spin icon={Loader2Icon} size={16} style={{ opacity: 0.5 }} />,
+ extra: <AutoSaveHint lastUpdatedTime={lastSavedAt} saveStatus={saveStatus} onRetry={retry} />,
title: t('hotkey.group.conversation'),
};
@@ -80,14 +75,7 @@ const HotkeySetting = memo(() => {
items={[conversation]}
itemsType={'group'}
variant={'filled'}
- onValuesChange={async (values) => {
- setLoading(true);
- try {
- await setSettings({ hotkey: values });
- } finally {
- setLoading(false);
- }
- }}
+ onValuesChange={(values) => save(() => setSettings({ hotkey: values }))}
{...FORM_STYLE}
/>
);
diff --git a/src/routes/(main)/settings/hotkey/features/Essential.tsx b/src/routes/(main)/settings/hotkey/features/Essential.tsx
index b1bcafaa2f2..6e5ba1a1020 100644
--- a/src/routes/(main)/settings/hotkey/features/Essential.tsx
+++ b/src/routes/(main)/settings/hotkey/features/Essential.tsx
@@ -2,14 +2,15 @@
import { HotkeyGroupEnum } from '@lobechat/const/hotkeys';
import { type FormGroupItemType } from '@lobehub/ui';
-import { Form, HotkeyInput, Icon, Skeleton } from '@lobehub/ui';
+import { Form, HotkeyInput, Skeleton } from '@lobehub/ui';
import isEqual from 'fast-deep-equal';
-import { Loader2Icon } from 'lucide-react';
-import { memo, useState } from 'react';
+import { memo } from 'react';
import { useTranslation } from 'react-i18next';
+import AutoSaveHint from '@/components/Editor/AutoSaveHint';
import { HOTKEYS_REGISTRATION } from '@/const/hotkeys';
import { FORM_STYLE } from '@/const/layoutTokens';
+import { useSaveState } from '@/hooks/useSaveState';
import hotkeyMeta from '@/locales/default/hotkey';
import { useUserStore } from '@/store/user';
import { settingsSelectors } from '@/store/user/selectors';
@@ -21,21 +22,15 @@ const HotkeySetting = memo(() => {
const { hotkey } = useUserStore(settingsSelectors.currentSettings, isEqual);
const [setSettings, isUserStateInit] = useUserStore((s) => [s.setSettings, s.isUserStateInit]);
- const [loading, setLoading] = useState(false);
+ const { status: saveStatus, lastSavedAt, save, retry } = useSaveState();
if (!isUserStateInit) return <Skeleton active paragraph={{ rows: 5 }} title={false} />;
- const clearHotkeyBinding = async (id: HotkeyItem['id']) => {
+ const clearHotkeyBinding = (id: HotkeyItem['id']) => {
if (!hotkey[id]) return;
- setLoading(true);
form.setFieldValue(id, '');
-
- try {
- await setSettings({ hotkey: { [id]: '' } });
- } finally {
- setLoading(false);
- }
+ save(() => setSettings({ hotkey: { [id]: '' } }));
};
const mapHotkeyItem = (item: HotkeyItem) => {
@@ -68,7 +63,7 @@ const HotkeySetting = memo(() => {
children: HOTKEYS_REGISTRATION.filter((item) => item.group === HotkeyGroupEnum.Essential).map(
(item) => mapHotkeyItem(item),
),
- extra: loading && <Icon spin icon={Loader2Icon} size={16} style={{ opacity: 0.5 }} />,
+ extra: <AutoSaveHint lastUpdatedTime={lastSavedAt} saveStatus={saveStatus} onRetry={retry} />,
title: t('hotkey.group.essential'),
};
@@ -80,14 +75,7 @@ const HotkeySetting = memo(() => {
items={[essential]}
itemsType={'group'}
variant={'filled'}
- onValuesChange={async (values) => {
- setLoading(true);
- try {
- await setSettings({ hotkey: values });
- } finally {
- setLoading(false);
- }
- }}
+ onValuesChange={(values) => save(() => setSettings({ hotkey: values }))}
{...FORM_STYLE}
/>
);
diff --git a/src/routes/(main)/settings/memory/features/Memory.tsx b/src/routes/(main)/settings/memory/features/Memory.tsx
index 54b489a21d9..27e6f52a396 100644
--- a/src/routes/(main)/settings/memory/features/Memory.tsx
+++ b/src/routes/(main)/settings/memory/features/Memory.tsx
@@ -2,16 +2,17 @@
import { type UserMemoryEffort } from '@lobechat/types';
import { type FormGroupItemType } from '@lobehub/ui';
-import { Form, Icon, Skeleton, Tooltip } from '@lobehub/ui';
+import { Form, Skeleton, Tooltip } from '@lobehub/ui';
import { Switch } from 'antd';
import isEqual from 'fast-deep-equal';
-import { Loader2Icon } from 'lucide-react';
-import { memo, useState } from 'react';
+import { memo } from 'react';
import { useTranslation } from 'react-i18next';
+import AutoSaveHint from '@/components/Editor/AutoSaveHint';
import { FORM_STYLE } from '@/const/layoutTokens';
import LevelSlider from '@/features/ModelSwitchPanel/components/ControlsForm/LevelSlider';
import { usePermission } from '@/hooks/usePermission';
+import { useSaveState } from '@/hooks/useSaveState';
import { useUserStore } from '@/store/user';
import { settingsSelectors } from '@/store/user/selectors';
@@ -23,7 +24,7 @@ const MemorySetting = memo(() => {
const [form] = Form.useForm();
const { memory } = useUserStore(settingsSelectors.currentSettings, isEqual);
const [setSettings, isUserStateInit] = useUserStore((s) => [s.setSettings, s.isUserStateInit]);
- const [loading, setLoading] = useState(false);
+ const { status: saveStatus, lastSavedAt, save, retry } = useSaveState();
if (!isUserStateInit) return <Skeleton active paragraph={{ rows: 3 }} title={false} />;
@@ -56,12 +57,10 @@ const MemorySetting = memo(() => {
1: t('memory.effort.level.medium'),
2: t('memory.effort.level.high'),
}}
- onChange={async (value) => {
+ onChange={(value) => {
if (!canManageMemory) return;
- setLoading(true);
- await setSettings({ memory: { effort: value } });
- setLoading(false);
+ save(() => setSettings({ memory: { effort: value } }));
}}
/>
</Tooltip>
@@ -72,7 +71,7 @@ const MemorySetting = memo(() => {
minWidth: undefined,
},
],
- extra: loading && <Icon spin icon={Loader2Icon} size={16} style={{ opacity: 0.5 }} />,
+ extra: <AutoSaveHint lastUpdatedTime={lastSavedAt} saveStatus={saveStatus} onRetry={retry} />,
title: t('memory.title'),
};
@@ -84,12 +83,10 @@ const MemorySetting = memo(() => {
items={[memorySettings]}
itemsType={'group'}
variant={'filled'}
- onValuesChange={async (values) => {
+ onValuesChange={(values) => {
if (!canManageMemory) return;
- setLoading(true);
- await setSettings({ memory: values });
- setLoading(false);
+ save(() => setSettings({ memory: values }));
}}
{...FORM_STYLE}
/>
diff --git a/src/routes/(main)/settings/memory/index.tsx b/src/routes/(main)/settings/memory/index.tsx
index f70bc85989a..44f1088cc6c 100644
--- a/src/routes/(main)/settings/memory/index.tsx
+++ b/src/routes/(main)/settings/memory/index.tsx
@@ -1,14 +1,42 @@
+'use client';
+
+import { isDesktop } from '@lobechat/const';
+import { Icon } from '@lobehub/ui';
+import { Button } from '@lobehub/ui/base-ui';
+import { BrainCircuit } from 'lucide-react';
import { useTranslation } from 'react-i18next';
+import { useWorkspaceAwareNavigate } from '@/features/Workspace/useWorkspaceAwareNavigate';
import SettingHeader from '@/routes/(main)/settings/features/SettingHeader';
import Memory from './features/Memory';
const Page = () => {
const { t } = useTranslation('setting');
+ const navigate = useWorkspaceAwareNavigate();
return (
<>
- <SettingHeader title={t('tab.memory')} />
+ <SettingHeader
+ title={t('tab.memory')}
+ // Config and management live on separate surfaces — give this settings
+ // page the entry to actually view / edit / clear memory that its copy
+ // promises, instead of dead-ending at a toggle + slider.
+ // Desktop-only: the `/memory` manager route is registered in the desktop
+ // router, not the mobile one (mobile renders this same tab via its
+ // generic settings route but has no `/memory`). Linking on mobile would
+ // hit an unmatched route / blank page.
+ extra={
+ isDesktop ? (
+ <Button
+ icon={<Icon icon={BrainCircuit} />}
+ size={'small'}
+ onClick={() => navigate('/memory', { escape: true })}
+ >
+ {t('memory.manageEntry')}
+ </Button>
+ ) : undefined
+ }
+ />
<Memory />
</>
);
diff --git a/src/routes/(main)/settings/profile/features/AvatarRow.tsx b/src/routes/(main)/settings/profile/features/AvatarRow.tsx
index c869ffb1d16..5f0da4fbdd5 100644
--- a/src/routes/(main)/settings/profile/features/AvatarRow.tsx
+++ b/src/routes/(main)/settings/profile/features/AvatarRow.tsx
@@ -1,10 +1,9 @@
'use client';
-import { LoadingOutlined } from '@ant-design/icons';
import { Icon } from '@lobehub/ui';
-import { Spin, Upload } from 'antd';
+import { Upload } from 'antd';
import { createStaticStyles, cssVar } from 'antd-style';
-import { PencilIcon } from 'lucide-react';
+import { Loader2Icon, PencilIcon } from 'lucide-react';
import { useMemo, useState } from 'react';
import { useTranslation } from 'react-i18next';
@@ -87,14 +86,20 @@ const AvatarRow = () => {
const avatarContent = canUpload ? (
<Upload beforeUpload={handleUploadAvatar} itemRender={() => void 0} maxCount={1}>
- <Spin indicator={<LoadingOutlined spin />} spinning={uploading}>
- <div className={styles.wrapper}>
- <UserAvatar size={40} />
- <div className={`${styles.overlay} avatar-edit-overlay`}>
- <Icon color={cssVar.colorTextLightSolid} icon={PencilIcon} size={16} />
- </div>
+ <div className={styles.wrapper}>
+ <UserAvatar size={40} />
+ <div
+ className={`${styles.overlay} avatar-edit-overlay`}
+ style={uploading ? { opacity: 1 } : undefined}
+ >
+ <Icon
+ color={cssVar.colorTextLightSolid}
+ icon={uploading ? Loader2Icon : PencilIcon}
+ size={16}
+ spin={uploading}
+ />
</div>
- </Spin>
+ </div>
</Upload>
) : (
<UserAvatar size={40} />
diff --git a/src/routes/(main)/settings/profile/features/FullNameRow.tsx b/src/routes/(main)/settings/profile/features/FullNameRow.tsx
index 2b80023acf3..f7676ad4f8d 100644
--- a/src/routes/(main)/settings/profile/features/FullNameRow.tsx
+++ b/src/routes/(main)/settings/profile/features/FullNameRow.tsx
@@ -1,8 +1,8 @@
'use client';
-import { LoadingOutlined } from '@ant-design/icons';
-import { Flexbox, Input } from '@lobehub/ui';
-import { type InputRef, Spin } from 'antd';
+import { Flexbox, Icon, Input } from '@lobehub/ui';
+import { type InputRef } from 'antd';
+import { Loader2Icon } from 'lucide-react';
import { useCallback, useRef, useState } from 'react';
import { useTranslation } from 'react-i18next';
@@ -40,7 +40,7 @@ const FullNameRow = () => {
return (
<ProfileRow label={t('profile.fullName')}>
<Flexbox horizontal align="center" gap={8}>
- {saving && <Spin indicator={<LoadingOutlined spin />} size="small" />}
+ {saving && <Icon spin icon={Loader2Icon} size={16} style={{ opacity: 0.5 }} />}
<Input
defaultValue={fullName || ''}
disabled={saving}
diff --git a/src/routes/(main)/settings/profile/features/UsernameRow.tsx b/src/routes/(main)/settings/profile/features/UsernameRow.tsx
index 9eba4cbc19e..8f7d9fa5a90 100644
--- a/src/routes/(main)/settings/profile/features/UsernameRow.tsx
+++ b/src/routes/(main)/settings/profile/features/UsernameRow.tsx
@@ -1,8 +1,8 @@
'use client';
-import { LoadingOutlined } from '@ant-design/icons';
-import { Button, Flexbox, Input, Text } from '@lobehub/ui';
-import { type InputRef, Spin } from 'antd';
+import { Button, Flexbox, Icon, Input, Text } from '@lobehub/ui';
+import { type InputRef } from 'antd';
+import { Loader2Icon } from 'lucide-react';
import { type ChangeEvent } from 'react';
import { useCallback, useRef, useState } from 'react';
import { useTranslation } from 'react-i18next';
@@ -92,7 +92,7 @@ const UsernameRow = () => {
return (
<ProfileRow label={t('profile.username')}>
<Flexbox horizontal align="center" gap={8}>
- {saving && <Spin indicator={<LoadingOutlined spin />} size="small" />}
+ {saving && <Icon spin icon={Loader2Icon} size={16} style={{ opacity: 0.5 }} />}
{error && (
<Text style={{ fontSize: 12, whiteSpace: 'nowrap' }} type="danger">
{error}
diff --git a/src/routes/(main)/settings/profile/index.tsx b/src/routes/(main)/settings/profile/index.tsx
index 49fba2c905a..c34f35abeee 100644
--- a/src/routes/(main)/settings/profile/index.tsx
+++ b/src/routes/(main)/settings/profile/index.tsx
@@ -53,8 +53,11 @@ const ProfileSetting = () => {
// Fetch Composio servers
useFetchUserComposioConnections(enableComposio);
- const isLoading =
- !isUserLoaded || (isLogin && !isLoadedAuthProviders) || (enableComposio && !isServersInit);
+ // Only the core profile rows (avatar / name / username / email) gate on the
+ // user record itself. Auth-providers (SSO) and Composio are independent, slower
+ // sub-sections that render their own rows when ready — folding them into one
+ // composite gate let a single slow/failed dependency skeleton the whole tab.
+ const isLoading = !isUserLoaded;
useEffect(() => {
if (isLogin) {
@@ -106,7 +109,7 @@ const ProfileSetting = () => {
</>
)}
- {isLogin && !isDesktop && (
+ {isLogin && !isDesktop && isLoadedAuthProviders && (
<>
<Divider style={{ margin: 0 }} />
<ProfileRow label={t('profile.sso.providers')}>
@@ -115,7 +118,7 @@ const ProfileSetting = () => {
</>
)}
- {enableComposio && connectedServers.length > 0 && (
+ {enableComposio && isServersInit && connectedServers.length > 0 && (
<>
<Divider style={{ margin: 0 }} />
<ProfileRow label={t('profile.authorizations.title')}>
diff --git a/src/routes/(main)/settings/proxy/features/ProxyForm.tsx b/src/routes/(main)/settings/proxy/features/ProxyForm.tsx
index a94c32332ac..83e1ceff3c8 100644
--- a/src/routes/(main)/settings/proxy/features/ProxyForm.tsx
+++ b/src/routes/(main)/settings/proxy/features/ProxyForm.tsx
@@ -154,16 +154,25 @@ const ProxyForm = () => {
);
const handleSave = useCallback(async () => {
+ let values: NetworkProxySettings;
+ try {
+ values = await form.validateFields();
+ } catch {
+ // Validation error — fields surface their own inline messages.
+ return;
+ }
+
try {
setIsSaving(true);
- const values = await form.validateFields();
await setProxySettings(values);
- } catch {
- // validation error
+ toast.success(t('proxy.saveSuccess'));
+ } catch (error) {
+ const message = error instanceof Error ? error.message : String(error);
+ toast.error(t('proxy.saveFailed', { error: message }));
} finally {
setIsSaving(false);
}
- }, [form, setProxySettings]);
+ }, [form, setProxySettings, t]);
const handleReset = useCallback(() => {
if (proxySettings) form.setFieldsValue(proxySettings);