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 settings search in sidebar (#17103)

YuTengjingc39bc38a72ba
diff --git a/locales/en-US/setting.json b/locales/en-US/setting.json
index 5af04ae79a8..1a156855936 100644
--- a/locales/en-US/setting.json
+++ b/locales/en-US/setting.json
@@ -880,6 +880,32 @@
"settingTTS.voice.desc": "Select a voice for the current agent, different TTS services support different voices",
"settingTTS.voice.preview": "Voice Preview",
"settingTTS.voice.title": "Text-to-Speech Voice",
+ "settingsSearch.empty": "No settings found for \"{{keyword}}\"",
+ "settingsSearch.placeholder": "Search settings...",
+ "settingsSearch.tabKeywords.about": "about, version, changelog, feedback, help",
+ "settingsSearch.tabKeywords.advanced": "advanced, developer, labs, experiment, beta",
+ "settingsSearch.tabKeywords.apikey": "api key, apikey, token, secret",
+ "settingsSearch.tabKeywords.appearance": "appearance, theme, dark mode, light mode, font, language, color",
+ "settingsSearch.tabKeywords.billing": "billing, payment, invoice, card, transaction",
+ "settingsSearch.tabKeywords.connector": "connectors, integrations, mcp",
+ "settingsSearch.tabKeywords.credits": "credits, balance, top up, recharge, buy credits",
+ "settingsSearch.tabKeywords.creds": "credentials, secrets, oauth",
+ "settingsSearch.tabKeywords.devices": "devices, sessions, logged in devices",
+ "settingsSearch.tabKeywords.hotkey": "hotkey, shortcut, keyboard",
+ "settingsSearch.tabKeywords.memory": "memory, memories, personalization",
+ "settingsSearch.tabKeywords.messenger": "messenger, chat platform, bot",
+ "settingsSearch.tabKeywords.notification": "notification, email, push, alerts",
+ "settingsSearch.tabKeywords.plans": "subscription, plan, upgrade, pricing, membership",
+ "settingsSearch.tabKeywords.profile": "profile, account, avatar, username, password, email, sign out, logout",
+ "settingsSearch.tabKeywords.provider": "provider, model, llm, api key, apikey, byok, bring your own key, endpoint",
+ "settingsSearch.tabKeywords.proxy": "proxy, network, connection",
+ "settingsSearch.tabKeywords.referral": "referral, invite, rewards, bonus",
+ "settingsSearch.tabKeywords.serviceModel": "service model, model assignment, topic naming, translation, tts, voice, speech, image, image generation, embedding, prompt rewrite, suggestion",
+ "settingsSearch.tabKeywords.skill": "skills, plugins, tools",
+ "settingsSearch.tabKeywords.stats": "analytics, statistics, stats",
+ "settingsSearch.tabKeywords.storage": "storage, files, import, export, backup, reset, clear data, account deletion, delete account",
+ "settingsSearch.tabKeywords.systemTools": "system tools, built-in tools",
+ "settingsSearch.tabKeywords.usage": "usage, consumption, quota, spend, statistics",
"skillGroup.builtinSkills": "Built-in Skills",
"skillGroup.builtinTools": "Built-in Tools",
"skillGroup.communityConnectors": "OAuth Connectors",
diff --git a/locales/zh-CN/setting.json b/locales/zh-CN/setting.json
index c8ccbc6592a..664b2cae398 100644
--- a/locales/zh-CN/setting.json
+++ b/locales/zh-CN/setting.json
@@ -880,6 +880,32 @@
"settingTTS.voice.desc": "为当前助理挑选一个声音,不同 TTS 服务支持的声源不同",
"settingTTS.voice.preview": "试听声源",
"settingTTS.voice.title": "语音合成声源",
+ "settingsSearch.empty": "未找到与“{{keyword}}”相关的设置",
+ "settingsSearch.placeholder": "搜索设置...",
+ "settingsSearch.tabKeywords.about": "关于,版本,更新日志,反馈,帮助",
+ "settingsSearch.tabKeywords.advanced": "高级,开发者,实验室,实验功能",
+ "settingsSearch.tabKeywords.apikey": "密钥,令牌,API Key,apikey",
+ "settingsSearch.tabKeywords.appearance": "外观,主题,深色模式,浅色模式,字体,语言,颜色",
+ "settingsSearch.tabKeywords.billing": "账单,支付,付款,发票,交易记录,银行卡",
+ "settingsSearch.tabKeywords.connector": "连接器,集成,MCP",
+ "settingsSearch.tabKeywords.credits": "积分,余额,充值,购买积分",
+ "settingsSearch.tabKeywords.creds": "凭证,密钥,授权",
+ "settingsSearch.tabKeywords.devices": "设备,会话,登录设备",
+ "settingsSearch.tabKeywords.hotkey": "快捷键,键盘,热键",
+ "settingsSearch.tabKeywords.memory": "记忆,个性化",
+ "settingsSearch.tabKeywords.messenger": "聊天平台,机器人,消息",
+ "settingsSearch.tabKeywords.notification": "通知,推送,邮件提醒",
+ "settingsSearch.tabKeywords.plans": "订阅,套餐,升级,价格,会员",
+ "settingsSearch.tabKeywords.profile": "个人资料,账号,头像,用户名,密码,邮箱,退出登录",
+ "settingsSearch.tabKeywords.provider": "服务商,模型,大模型,密钥,接入点,apikey,byok",
+ "settingsSearch.tabKeywords.proxy": "代理,网络,连接",
+ "settingsSearch.tabKeywords.referral": "推荐,邀请,奖励,返利",
+ "settingsSearch.tabKeywords.serviceModel": "服务模型,模型分配,话题命名,翻译,语音,语音合成,图片,图片生成,向量化,提示词改写,输入建议,跟进建议",
+ "settingsSearch.tabKeywords.skill": "技能,插件,工具",
+ "settingsSearch.tabKeywords.stats": "数据统计,统计,分析",
+ "settingsSearch.tabKeywords.storage": "存储,文件,导入,导出,备份,重置,清除数据,注销,删除账号",
+ "settingsSearch.tabKeywords.systemTools": "系统工具,内置工具",
+ "settingsSearch.tabKeywords.usage": "用量,消耗,配额,花费,统计",
"skillGroup.builtinSkills": "内置技能",
"skillGroup.builtinTools": "内置工具",
"skillGroup.communityConnectors": "OAuth 连接器",
diff --git a/package.json b/package.json
index c444e199eb9..f37284f8b41 100644
--- a/package.json
+++ b/package.json
@@ -401,6 +401,7 @@
"pdfjs-dist": "5.4.530",
"pdfkit": "^0.17.2",
"pg": "^8.22.0",
+ "pinyin-pro": "^3.28.1",
"plaiceholder": "^3.0.0",
"polished": "^4.3.1",
"posthog-js": "~1.278.0",
diff --git a/packages/locales/src/default/setting.ts b/packages/locales/src/default/setting.ts
index 41b425918c9..868b5f6d5ee 100644
--- a/packages/locales/src/default/setting.ts
+++ b/packages/locales/src/default/setting.ts
@@ -915,6 +915,37 @@ export default {
'Always on for Lobe AI while Self-Iteration is available.',
'settingSelfIteration.enabled.title': 'Enable Self-Iteration',
'settingSelfIteration.title': 'Self-Iteration',
+ 'settingsSearch.empty': 'No settings found for "{{keyword}}"',
+ 'settingsSearch.placeholder': 'Search settings...',
+ 'settingsSearch.tabKeywords.about': 'about, version, changelog, feedback, help',
+ 'settingsSearch.tabKeywords.advanced': 'advanced, developer, labs, experiment, beta',
+ 'settingsSearch.tabKeywords.apikey': 'api key, apikey, token, secret',
+ 'settingsSearch.tabKeywords.appearance':
+ 'appearance, theme, dark mode, light mode, font, language, color',
+ 'settingsSearch.tabKeywords.billing': 'billing, payment, invoice, card, transaction',
+ 'settingsSearch.tabKeywords.connector': 'connectors, integrations, mcp',
+ 'settingsSearch.tabKeywords.credits': 'credits, balance, top up, recharge, buy credits',
+ 'settingsSearch.tabKeywords.creds': 'credentials, secrets, oauth',
+ 'settingsSearch.tabKeywords.devices': 'devices, sessions, logged in devices',
+ 'settingsSearch.tabKeywords.hotkey': 'hotkey, shortcut, keyboard',
+ 'settingsSearch.tabKeywords.memory': 'memory, memories, personalization',
+ 'settingsSearch.tabKeywords.messenger': 'messenger, chat platform, bot',
+ 'settingsSearch.tabKeywords.notification': 'notification, email, push, alerts',
+ 'settingsSearch.tabKeywords.plans': 'subscription, plan, upgrade, pricing, membership',
+ 'settingsSearch.tabKeywords.profile':
+ 'profile, account, avatar, username, password, email, sign out, logout',
+ 'settingsSearch.tabKeywords.provider':
+ 'provider, model, llm, api key, apikey, byok, bring your own key, endpoint',
+ 'settingsSearch.tabKeywords.proxy': 'proxy, network, connection',
+ 'settingsSearch.tabKeywords.referral': 'referral, invite, rewards, bonus',
+ 'settingsSearch.tabKeywords.serviceModel':
+ 'service model, model assignment, topic naming, translation, tts, voice, speech, image, image generation, embedding, prompt rewrite, suggestion',
+ 'settingsSearch.tabKeywords.skill': 'skills, plugins, tools',
+ 'settingsSearch.tabKeywords.stats': 'analytics, statistics, stats',
+ 'settingsSearch.tabKeywords.storage':
+ 'storage, files, import, export, backup, reset, clear data, account deletion, delete account',
+ 'settingsSearch.tabKeywords.systemTools': 'system tools, built-in tools',
+ 'settingsSearch.tabKeywords.usage': 'usage, consumption, quota, spend, statistics',
'settingSystem.oauth.info.desc': 'Logged in',
'settingSystem.oauth.info.title': 'Account Information',
'settingSystem.oauth.signin.action': 'Sign In',
diff --git a/src/features/ServiceModel/ModelAssignmentsForm.tsx b/src/features/ServiceModel/ModelAssignmentsForm.tsx
index 946e8ef9be2..94712a5079b 100644
--- a/src/features/ServiceModel/ModelAssignmentsForm.tsx
+++ b/src/features/ServiceModel/ModelAssignmentsForm.tsx
@@ -12,6 +12,7 @@ import AsyncError from '@/components/AsyncError';
import AutoSaveHint from '@/components/Editor/AutoSaveHint';
import { FORM_STYLE } from '@/const/layoutTokens';
import ModelSelect from '@/features/ModelSelect';
+import { SettingsSearchAnchor } from '@/features/SettingsSearch/anchor';
import { usePermission } from '@/hooks/usePermission';
import { useSaveState } from '@/hooks/useSaveState';
import { useUserStore } from '@/store/user';
@@ -270,19 +271,31 @@ const ModelAssignmentsForm = memo(() => {
const modelAssignments: FormGroupItemType = {
children: [defaultAgentItem, ...systemModelItems],
extra: renderSaveHint('assignments'),
- title: t('serviceModel.modelAssignments.title'),
+ title: (
+ <SettingsSearchAnchor id={'service-model-assignments'}>
+ {t('serviceModel.modelAssignments.title')}
+ </SettingsSearchAnchor>
+ ),
};
const optionalFeatures: FormGroupItemType = {
children: optionalFeatureItems,
extra: renderSaveHint('optional'),
- title: t('serviceModel.optionalFeatures.title'),
+ title: (
+ <SettingsSearchAnchor id={'service-model-optional-features'}>
+ {t('serviceModel.optionalFeatures.title')}
+ </SettingsSearchAnchor>
+ ),
};
const memoryModels: FormGroupItemType = {
children: memoryModelItems,
extra: renderSaveHint('memory'),
- title: t('serviceModel.memoryModels.title'),
+ title: (
+ <SettingsSearchAnchor id={'service-model-memory'}>
+ {t('serviceModel.memoryModels.title')}
+ </SettingsSearchAnchor>
+ ),
};
return (
diff --git a/src/features/SettingsSearch/SearchResults.tsx b/src/features/SettingsSearch/SearchResults.tsx
new file mode 100644
index 00000000000..0575cc2562b
--- /dev/null
+++ b/src/features/SettingsSearch/SearchResults.tsx
@@ -0,0 +1,97 @@
+'use client';
+
+import { Flexbox, Icon, Text } from '@lobehub/ui';
+import { createStaticStyles, cssVar } from 'antd-style';
+import { Loader2Icon } from 'lucide-react';
+import { memo } from 'react';
+import { useTranslation } from 'react-i18next';
+
+import NavItem from '@/features/NavPanel/components/NavItem';
+import { useWorkspaceAwareNavigate } from '@/features/Workspace/useWorkspaceAwareNavigate';
+import { isModifierClick } from '@/utils/navigation';
+
+import { useSettingsSearchAnalytics } from './analytics';
+import type { SettingsSearchResult } from './useSettingsSearch';
+
+const styles = createStaticStyles(({ css }) => ({
+ match: css`
+ color: ${cssVar.colorPrimary};
+ `,
+}));
+
+const HighlightMatch = memo<{ query: string; text: string }>(({ text, query }) => {
+ const index = text.toLowerCase().indexOf(query.toLowerCase());
+ if (index < 0) return text;
+
+ return (
+ <>
+ {text.slice(0, index)}
+ <span className={styles.match}>{text.slice(index, index + query.length)}</span>
+ {text.slice(index + query.length)}
+ </>
+ );
+});
+
+HighlightMatch.displayName = 'HighlightMatch';
+
+interface SearchResultsProps {
+ isIndexing: boolean;
+ query: string;
+ results: SettingsSearchResult[];
+}
+
+/**
+ * Mounted only while the query is non-empty — the analytics hook relies on
+ * this lifecycle: unmount (input cleared / left settings) ends the search
+ * session and may emit the abandoned event.
+ */
+const SearchResults = memo<SearchResultsProps>(({ isIndexing, query, results }) => {
+ const { t } = useTranslation('setting');
+ const navigate = useWorkspaceAwareNavigate();
+ const { trackResultClick } = useSettingsSearchAnalytics(query, results, isIndexing);
+ const keyword = query.trim();
+
+ if (results.length === 0)
+ return (
+ <Flexbox align={'center'} paddingBlock={24} paddingInline={8}>
+ {isIndexing ? (
+ // A zero-result answer is not authoritative while the pinyin dict is
+ // still loading — show a spinner instead of a false empty state.
+ <Icon spin color={cssVar.colorTextSecondary} icon={Loader2Icon} />
+ ) : (
+ <Text fontSize={12} type={'secondary'}>
+ {t('settingsSearch.empty', { keyword })}
+ </Text>
+ )}
+ </Flexbox>
+ );
+
+ return (
+ <Flexbox gap={1} paddingBlock={4}>
+ {results.map((result, index) => (
+ <NavItem
+ href={result.url}
+ icon={result.icon}
+ key={result.key}
+ title={<HighlightMatch query={keyword} text={result.label} />}
+ description={
+ <Text ellipsis fontSize={12} type={'secondary'}>
+ {result.breadcrumb}
+ </Text>
+ }
+ onClick={(e) => {
+ trackResultClick(result, index + 1);
+ // Modifier clicks (cmd/ctrl) open a new tab via the href; don't also
+ // navigate the current tab.
+ if (isModifierClick(e)) return;
+ navigate(result.url);
+ }}
+ />
+ ))}
+ </Flexbox>
+ );
+});
+
+SearchResults.displayName = 'SearchResults';
+
+export default SearchResults;
diff --git a/src/features/SettingsSearch/SearchSection.tsx b/src/features/SettingsSearch/SearchSection.tsx
new file mode 100644
index 00000000000..48abb816353
--- /dev/null
+++ b/src/features/SettingsSearch/SearchSection.tsx
@@ -0,0 +1,46 @@
+'use client';
+
+import { Flexbox, SearchBar } from '@lobehub/ui';
+import { memo, type PropsWithChildren, useState } from 'react';
+import { useTranslation } from 'react-i18next';
+
+import SearchResults from './SearchResults';
+import { useSettingsSearch } from './useSettingsSearch';
+
+/**
+ * Self-contained settings-search unit: owns the query state, renders the
+ * search bar, and swaps `children` (the category list) for live results while
+ * a query is present. Living here (not in the route layout) also means the
+ * search index — and the lazy pinyin dict — starts warming up as soon as the
+ * sidebar mounts, well before the first keystroke.
+ */
+const SearchSection = memo<PropsWithChildren>(({ children }) => {
+ const { t } = useTranslation('setting');
+ const [query, setQuery] = useState('');
+ const { isIndexing, results } = useSettingsSearch(query);
+
+ const showResults = !!query.trim();
+
+ return (
+ <>
+ <Flexbox paddingInline={4}>
+ <SearchBar
+ allowClear
+ placeholder={t('settingsSearch.placeholder')}
+ value={query}
+ variant={'filled'}
+ onInputChange={setQuery}
+ />
+ </Flexbox>
+ {showResults ? (
+ <SearchResults isIndexing={isIndexing} query={query} results={results} />
+ ) : (
+ children
+ )}
+ </>
+ );
+});
+
+SearchSection.displayName = 'SettingsSearchSection';
+
+export default SearchSection;
diff --git a/src/features/SettingsSearch/analytics.test.ts b/src/features/SettingsSearch/analytics.test.ts
new file mode 100644
index 00000000000..f67b7d83215
--- /dev/null
+++ b/src/features/SettingsSearch/analytics.test.ts
@@ -0,0 +1,189 @@
+import { renderHook } from '@testing-library/react';
+import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
+
+import { trackProductUsageEvent } from '@/libs/analytics/productUsageEvent';
+
+import { useSettingsSearchAnalytics } from './analytics';
+import type { SettingsSearchResult } from './useSettingsSearch';
+
+vi.mock('@/libs/analytics/productUsageEvent', () => ({
+ trackProductUsageEvent: vi.fn(),
+}));
+
+const trackMock = vi.mocked(trackProductUsageEvent);
+
+const makeResult = (key: string): SettingsSearchResult => ({
+ breadcrumb: 'General › Appearance',
+ key,
+ label: 'Theme',
+ tab: 'appearance' as SettingsSearchResult['tab'],
+ url: '/settings/appearance',
+});
+
+const eventsByName = (name: string) =>
+ trackMock.mock.calls.map(([event]) => event).filter((event) => event.name === name);
+
+describe('useSettingsSearchAnalytics', () => {
+ beforeEach(() => {
+ vi.useFakeTimers();
+ // Clear in beforeEach, not afterEach: testing-library's auto-cleanup unmounts
+ // hooks AFTER our afterEach, and that unmount can emit an abandoned event
+ // which would otherwise leak into the next test's assertions.
+ vi.clearAllMocks();
+ });
+
+ afterEach(() => {
+ vi.useRealTimers();
+ });
+
+ it('reports a settled query once, skipping intermediate keystrokes', () => {
+ const results = [makeResult('tab-general-appearance')];
+ const { rerender } = renderHook(({ query }) => useSettingsSearchAnalytics(query, results), {
+ initialProps: { query: '图' },
+ });
+
+ // Keystroke before the settle timeout should not be reported
+ vi.advanceTimersByTime(300);
+ rerender({ query: '图片' });
+ vi.advanceTimersByTime(1000);
+
+ const queryEvents = eventsByName('settings_search_query');
+ expect(queryEvents).toHaveLength(1);
+ expect(queryEvents[0].properties).toMatchObject({
+ query: '图片',
+ result_count: 1,
+ sequence: 1,
+ });
+
+ // Re-render with the same query must not report a duplicate
+ rerender({ query: '图片' });
+ vi.advanceTimersByTime(1000);
+ expect(eventsByName('settings_search_query')).toHaveLength(1);
+ });
+
+ it('reports result clicks with type and 1-based position', () => {
+ const results = [makeResult('tab-general-appearance'), makeResult('item-appearance-theme')];
+ const { result } = renderHook(() => useSettingsSearchAnalytics('theme', results));
+
+ result.current.trackResultClick(results[1], 2);
+
+ const clickEvents = eventsByName('settings_search_result_clicked');
+ expect(clickEvents).toHaveLength(1);
+ expect(clickEvents[0].properties).toMatchObject({
+ position: 2,
+ query: 'theme',
+ result_key: 'item-appearance-theme',
+ result_type: 'item',
+ });
+ });
+
+ it('reports abandonment on unmount without a click, but not after a click', () => {
+ const results: SettingsSearchResult[] = [];
+ const { unmount } = renderHook(() => useSettingsSearchAnalytics('nonexistent', results));
+ vi.advanceTimersByTime(1000);
+ unmount();
+
+ const abandonedEvents = eventsByName('settings_search_abandoned');
+ expect(abandonedEvents).toHaveLength(1);
+ expect(abandonedEvents[0].properties).toMatchObject({
+ had_results: false,
+ last_query: 'nonexistent',
+ query_count: 1,
+ });
+
+ trackMock.mockClear();
+ const clicked = [makeResult('provider-openai')];
+ const { result, unmount: unmountClicked } = renderHook(() =>
+ useSettingsSearchAnalytics('openai', clicked),
+ );
+ vi.advanceTimersByTime(1000);
+ result.current.trackResultClick(clicked[0], 1);
+ unmountClicked();
+
+ expect(eventsByName('settings_search_abandoned')).toHaveLength(0);
+ });
+
+ it('redacts token-like queries but keeps real length metadata', () => {
+ const secret = 'sk-proj-Abc123XyzSecretValue';
+ const results = [makeResult('tab-system-apikey')];
+ const { result } = renderHook(() => useSettingsSearchAnalytics(secret, results));
+ vi.advanceTimersByTime(1000);
+
+ const queryEvents = eventsByName('settings_search_query');
+ expect(queryEvents).toHaveLength(1);
+ expect(queryEvents[0].properties).toMatchObject({
+ query: '[redacted]',
+ query_length: secret.length,
+ });
+
+ result.current.trackResultClick(results[0], 1);
+ const clickEvents = eventsByName('settings_search_result_clicked');
+ expect(clickEvents[0].properties!.query).toBe('[redacted]');
+ });
+
+ it('redacts punctuated secrets like JWTs and base64 tokens', () => {
+ const jwt = 'eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiIxIn0.sflKxwRJSMeKKF2QT4fwpM';
+ renderHook(() => useSettingsSearchAnalytics(jwt, []));
+ vi.advanceTimersByTime(1000);
+
+ const queryEvents = eventsByName('settings_search_query');
+ expect(queryEvents).toHaveLength(1);
+ expect(queryEvents[0].properties).toMatchObject({
+ query: '[redacted]',
+ query_length: jwt.length,
+ });
+ });
+
+ it('redacts secrets embedded in surrounding text', () => {
+ renderHook(() =>
+ useSettingsSearchAnalytics('{"apiKey": "sk-proj-abc123def456"}', [makeResult('tab-a-b')]),
+ );
+ vi.advanceTimersByTime(1000);
+
+ expect(eventsByName('settings_search_query')[0].properties!.query).toBe('[redacted]');
+ });
+
+ it('does not redact hyphenated words containing a prefix substring', () => {
+ renderHook(() => useSettingsSearchAnalytics('risk-control settings', [makeResult('tab-a-b')]));
+ vi.advanceTimersByTime(1000);
+
+ expect(eventsByName('settings_search_query')[0].properties!.query).toBe(
+ 'risk-control settings',
+ );
+ });
+
+ it('does not redact ordinary short queries', () => {
+ renderHook(() => useSettingsSearchAnalytics('dark mode', [makeResult('tab-a-b')]));
+ vi.advanceTimersByTime(1000);
+
+ expect(eventsByName('settings_search_query')[0].properties!.query).toBe('dark mode');
+ });
+
+ it('holds the settle timer while the index is loading and reports the final count', () => {
+ const { rerender } = renderHook(
+ ({ isIndexing, results }: { isIndexing: boolean; results: SettingsSearchResult[] }) =>
+ useSettingsSearchAnalytics('zhuti', results, isIndexing),
+ { initialProps: { isIndexing: true, results: [] as SettingsSearchResult[] } },
+ );
+
+ // Transient zero-result state during pinyin dict load must not be reported
+ vi.advanceTimersByTime(2000);
+ expect(eventsByName('settings_search_query')).toHaveLength(0);
+
+ rerender({ isIndexing: false, results: [makeResult('tab-general-appearance')] });
+ vi.advanceTimersByTime(1000);
+
+ const queryEvents = eventsByName('settings_search_query');
+ expect(queryEvents).toHaveLength(1);
+ expect(queryEvents[0].properties).toMatchObject({ query: 'zhuti', result_count: 1 });
+ });
+
+ it('does not report abandonment when no query ever settled', () => {
+ const { unmount } = renderHook(() => useSettingsSearchAnalytics('a', []));
+ // Unmount before the settle timeout — e.g. user cleared input immediately
+ vi.advanceTimersByTime(300);
+ unmount();
+
+ expect(eventsByName('settings_search_abandoned')).toHaveLength(0);
+ });
+});
diff --git a/src/features/SettingsSearch/analytics.ts b/src/features/SettingsSearch/analytics.ts
new file mode 100644
index 00000000000..833c1b00e25
--- /dev/null
+++ b/src/features/SettingsSearch/analytics.ts
@@ -0,0 +1,179 @@
+import { uuid } from '@lobechat/utils';
+import { useEffect, useMemo, useRef } from 'react';
+
+import { trackProductUsageEvent } from '@/libs/analytics/productUsageEvent';
+
+import type { SettingsSearchResult } from './useSettingsSearch';
+
+export const SETTINGS_SEARCH_EVENTS = {
+ ABANDONED: 'settings_search_abandoned',
+ QUERY: 'settings_search_query',
+ RESULT_CLICKED: 'settings_search_result_clicked',
+} as const;
+
+export const SETTINGS_SEARCH_SPM = {
+ ABANDONED: 'settings.search.abandoned',
+ QUERY: 'settings.search.query',
+ RESULT_CLICKED: 'settings.search.result_clicked',
+} as const;
+
+/**
+ * A query only counts once the user pauses typing — keystroke-level tracking
+ * would record every prefix ("图", "图片") as a separate keyword.
+ */
+const QUERY_SETTLE_MS = 1000;
+
+/** Cap recorded query length: enough for analysis, avoids logging pasted blobs */
+const MAX_QUERY_LENGTH = 100;
+
+/**
+ * Secret-looking input must never reach analytics: telemetry is default-on and
+ * users may paste an API key into the search box by accident. Real settings
+ * queries are short human words, so redact anything that looks like a
+ * credential — a known key prefix at any token boundary (covers pastes with
+ * surrounding text like `apiKey=sk-...` or JSON snippets), or a long unbroken
+ * ASCII token (including base64/JWT punctuation `+ / = .`). This is
+ * defense-in-depth for the accidental-paste scenario, not an exhaustive secret
+ * scanner — blocklist completeness is a non-goal; users can also disable
+ * telemetry entirely.
+ */
+const TOKEN_LIKE_QUERY = /(?:^|[^\w-])(?:sk-|pk-|ghp_|gho_|xox|akia|bearer\s)|^[\w+/=.-]{16,}$/i;
+
+const REDACTED_QUERY = '[redacted]';
+
+const sanitizeQuery = (query: string) => {
+ const normalized = query.trim().toLowerCase().slice(0, MAX_QUERY_LENGTH);
+ return TOKEN_LIKE_QUERY.test(normalized) ? REDACTED_QUERY : normalized;
+};
+
+type SettingsSearchResultType = 'connector' | 'item' | 'provider' | 'tab';
+
+/** Result keys are prefixed by their index source: `tab-*` / `item-*` / `provider-*` / `connector-*` */
+const getResultType = (resultKey: string): SettingsSearchResultType => {
+ if (resultKey.startsWith('item-')) return 'item';
+ if (resultKey.startsWith('provider-')) return 'provider';
+ if (resultKey.startsWith('connector-')) return 'connector';
+ return 'tab';
+};
+
+interface SearchSession {
+ clicked: boolean;
+ id: string;
+ lastQuery: string;
+ lastResultCount: number;
+ /** Number of settled (reported) queries in this session */
+ queryCount: number;
+}
+
+/**
+ * Tracks one search session: mounts with the first non-empty query and ends on
+ * unmount (input cleared or user left settings). Emits:
+ *
+ * - `settings_search_query` — each settled query with its result count. Zero-result
+ * queries reveal missing keywords/synonyms in the search index.
+ * - `settings_search_result_clicked` — which result was picked, its type and rank.
+ * Click-through rate and clicked position are the primary satisfaction proxies.
+ * - `settings_search_abandoned` — session ended without any click. Combined with
+ * `had_results` this separates "nothing matched" from "results were irrelevant".
+ */
+export const useSettingsSearchAnalytics = (
+ query: string,
+ results: SettingsSearchResult[],
+ /**
+ * While the search index is still loading (pinyin dict), result counts are
+ * not authoritative — hold the settle timer so a transient zero-result state
+ * is never reported as a missing-keyword signal.
+ */
+ isIndexing = false,
+) => {
+ const sessionRef = useRef<SearchSession>({
+ clicked: false,
+ // Not crypto.randomUUID: it is secure-context-only, and this initializer
+ // runs on every render — self-hosted plain-http deployments would crash.
+ id: uuid(),
+ lastQuery: '',
+ lastResultCount: 0,
+ queryCount: 0,
+ });
+
+ const sanitizedQuery = sanitizeQuery(query);
+ // Real length of what the user typed (capped), even when the content is redacted
+ const queryLength = Math.min(query.trim().length, MAX_QUERY_LENGTH);
+ const resultCount = results.length;
+
+ useEffect(() => {
+ if (!sanitizedQuery || isIndexing) return;
+
+ const timer = setTimeout(() => {
+ const session = sessionRef.current;
+ // Skip repeats (e.g. re-render with the same settled query)
+ if (sanitizedQuery === session.lastQuery) return;
+
+ session.queryCount += 1;
+ session.lastQuery = sanitizedQuery;
+ session.lastResultCount = resultCount;
+
+ trackProductUsageEvent({
+ name: SETTINGS_SEARCH_EVENTS.QUERY,
+ properties: {
+ query: sanitizedQuery,
+ query_length: queryLength,
+ result_count: resultCount,
+ sequence: session.queryCount,
+ session_id: session.id,
+ spm: SETTINGS_SEARCH_SPM.QUERY,
+ },
+ });
+ }, QUERY_SETTLE_MS);
+
+ return () => clearTimeout(timer);
+ }, [sanitizedQuery, queryLength, resultCount, isIndexing]);
+
+ // Session end = component unmount. Report abandonment only when at least one
+ // query settled and nothing was ever clicked.
+ useEffect(
+ () => () => {
+ const session = sessionRef.current;
+ if (session.clicked || session.queryCount === 0) return;
+
+ trackProductUsageEvent({
+ name: SETTINGS_SEARCH_EVENTS.ABANDONED,
+ properties: {
+ had_results: session.lastResultCount > 0,
+ last_query: session.lastQuery,
+ last_result_count: session.lastResultCount,
+ query_count: session.queryCount,
+ session_id: session.id,
+ spm: SETTINGS_SEARCH_SPM.ABANDONED,
+ },
+ });
+ },
+ [],
+ );
+
+ return useMemo(
+ () => ({
+ trackResultClick: (result: SettingsSearchResult, position: number) => {
+ const session = sessionRef.current;
+ session.clicked = true;
+
+ trackProductUsageEvent({
+ name: SETTINGS_SEARCH_EVENTS.RESULT_CLICKED,
+ properties: {
+ // The click may land before the settle timer, so report the live
+ // query, not the last settled one.
+ position,
+ query: sanitizeQuery(query),
+ query_count: session.queryCount,
+ result_count: resultCount,
+ result_key: result.key,
+ result_type: getResultType(result.key),
+ session_id: session.id,
+ spm: SETTINGS_SEARCH_SPM.RESULT_CLICKED,
+ },
+ });
+ },
+ }),
+ [query, resultCount],
+ );
+};
diff --git a/src/features/SettingsSearch/anchor.tsx b/src/features/SettingsSearch/anchor.tsx
new file mode 100644
index 00000000000..de85bb87414
--- /dev/null
+++ b/src/features/SettingsSearch/anchor.tsx
@@ -0,0 +1,111 @@
+'use client';
+
+import { createStaticStyles, cssVar } from 'antd-style';
+import { memo, type PropsWithChildren, useEffect } from 'react';
+import { useLocation } from 'react-router';
+
+export const SETTINGS_ANCHOR_ATTR = 'data-settings-anchor';
+/**
+ * Marks the row container to flash-highlight for anchors inside non-antd rows
+ * (e.g. profile ProfileRow) — the highlight lookup falls back to this attribute
+ * when no `.ant-form-item` ancestor exists.
+ */
+export const SETTINGS_ANCHOR_ROW_ATTR = 'data-settings-anchor-row';
+
+const HIGHLIGHT_DURATION = 2400;
+const POLL_INTERVAL = 100;
+// Settings tabs are lazy-loaded, so the anchor node may not exist right after
+// navigation — poll for a few seconds before giving up (fall back to a plain
+// tab switch, which is still a correct result).
+const POLL_TIMEOUT = 3000;
+
+const styles = createStaticStyles(({ css }) => ({
+ anchor: css`
+ scroll-margin-block-start: 80px;
+ `,
+ highlight: css`
+ border-radius: ${cssVar.borderRadius};
+ animation: settings-search-highlight 1.2s ease-in-out 2;
+
+ @keyframes settings-search-highlight {
+ 0%,
+ 100% {
+ background: transparent;
+ }
+
+ 50% {
+ /* One step above colorPrimaryBg — plain Bg is barely visible in dark mode */
+ background: ${cssVar.colorPrimaryBgHover};
+ }
+ }
+
+ @media (prefers-reduced-motion: reduce) {
+ /* Keep the locate cue, drop the flashing: a steady highlight that the
+ removal timer clears */
+ background: ${cssVar.colorPrimaryBgHover};
+ animation: none;
+ }
+ `,
+}));
+
+/**
+ * Marks a settings section / item as a search target. Wrap the group title or
+ * item label so `scrollToSettingsAnchor` can locate and highlight it. The `id`
+ * must match a `SETTINGS_SEARCH_ITEMS` entry's `anchor`.
+ */
+export const SettingsSearchAnchor = memo<PropsWithChildren<{ id: string }>>(({ id, children }) => (
+ <span className={styles.anchor} {...{ [SETTINGS_ANCHOR_ATTR]: id }}>
+ {children}
+ </span>
+));
+
+SettingsSearchAnchor.displayName = 'SettingsSearchAnchor';
+
+/**
+ * Scroll the anchor into view and flash-highlight its enclosing form row (or
+ * group header). Safe to call before the target tab finishes rendering.
+ * Returns a cancel function that stops the poll (the highlight timer is left
+ * to finish — removing a CSS class on a detached node is harmless).
+ */
+export const scrollToSettingsAnchor = (anchor: string) => {
+ const startAt = Date.now();
+ let timer: ReturnType<typeof setTimeout> | undefined;
+
+ const tryScroll = () => {
+ const el = document.querySelector(`[${SETTINGS_ANCHOR_ATTR}="${CSS.escape(anchor)}"]`);
+
+ if (!el) {
+ if (Date.now() - startAt < POLL_TIMEOUT) timer = setTimeout(tryScroll, POLL_INTERVAL);
+ return;
+ }
+
+ const reduceMotion = window.matchMedia('(prefers-reduced-motion: reduce)').matches;
+ el.scrollIntoView({ behavior: reduceMotion ? 'auto' : 'smooth', block: 'center' });
+
+ // Highlight the whole form row / group header instead of the bare label
+ // text so the flash is visible at a glance.
+ const target =
+ el.closest(`.ant-form-item, .ant-collapse-header, [${SETTINGS_ANCHOR_ROW_ATTR}]`) ?? el;
+ target.classList.add(styles.highlight);
+ setTimeout(() => target.classList.remove(styles.highlight), HIGHLIGHT_DURATION);
+ };
+
+ tryScroll();
+
+ return () => clearTimeout(timer);
+};
+
+/**
+ * Settings-search deep link: scroll to the `#anchor` item once the active tab
+ * renders. Keyed on location.key so re-clicking the same result re-triggers;
+ * navigating away cancels the in-flight poll.
+ */
+export const useSettingsAnchorScroll = () => {
+ const location = useLocation();
+
+ useEffect(() => {
+ const anchor = location.hash.replace(/^#/, '');
+ if (anchor) return scrollToSettingsAnchor(anchor);
+ // eslint-disable-next-line react-hooks/exhaustive-deps
+ }, [location.key]);
+};
diff --git a/src/features/SettingsSearch/index.ts b/src/features/SettingsSearch/index.ts
new file mode 100644
index 00000000000..e05eba3572a
--- /dev/null
+++ b/src/features/SettingsSearch/index.ts
@@ -0,0 +1,3 @@
+export { SettingsSearchAnchor, useSettingsAnchorScroll } from './anchor';
+export { default as SearchSection } from './SearchSection';
+export { getTabUrl, type SettingsSearchResult, useSettingsSearch } from './useSettingsSearch';
diff --git a/src/features/SettingsSearch/items.ts b/src/features/SettingsSearch/items.ts
new file mode 100644
index 00000000000..4b903901fe7
--- /dev/null
+++ b/src/features/SettingsSearch/items.ts
@@ -0,0 +1,589 @@
+import { SettingsTabs } from '@/store/global/initialState';
+
+export interface SettingsSearchContext {
+ disableEmailPassword: boolean;
+ enableBusinessFeatures: boolean;
+ enableComposio: boolean;
+ enableGatewayMode: boolean;
+ enableSTT: boolean;
+ /** Whether the signed-in user has an email on their profile */
+ hasEmail: boolean;
+ hideDocs: boolean;
+ isDesktop: boolean;
+ isLogin: boolean;
+ showAiImage: boolean;
+}
+
+export interface SettingsSearchItem {
+ /**
+ * Unique anchor id, also used as the URL hash fragment. The target page must
+ * wrap the matching label with `<SettingsSearchAnchor id={anchor}>`.
+ */
+ anchor: string;
+ /** i18n key of the item description, in the same namespace as `labelKey` */
+ descKey?: string;
+ /** Extra untranslated match keywords (English) */
+ keywords?: string[];
+ /** i18n key of the item label */
+ labelKey: string;
+ /** i18n namespace of `labelKey` / `descKey`, defaults to `setting` */
+ ns?: 'auth' | 'electron' | 'labs' | 'setting' | 'spend' | 'subscription';
+ tab: SettingsTabs;
+ /**
+ * Extra visibility gate mirroring the target item's own render condition
+ * (tab visibility is already handled via useCategory). Defaults to visible.
+ */
+ visible?: (ctx: SettingsSearchContext) => boolean;
+}
+
+/**
+ * Canonical English keywords per tab, indexed in every locale. The localized
+ * strings from TAB_SEARCH_KEYWORDS_KEYS are translations that usually replace
+ * the English terms (zh-CN: `用量,消耗,配额…`), which made English queries like
+ * `usage` or `skill` miss on non-English UIs. English is the lingua franca for
+ * technical terms — it must always stay searchable; localized keywords enrich
+ * on top of this floor.
+ */
+export const TAB_SEARCH_EN_KEYWORDS: Partial<Record<SettingsTabs, string[]>> = {
+ [SettingsTabs.About]: ['about', 'version', 'changelog', 'feedback', 'help'],
+ [SettingsTabs.Advanced]: ['advanced', 'developer', 'labs', 'experiment', 'beta'],
+ [SettingsTabs.APIKey]: ['api key', 'apikey', 'token', 'secret'],
+ [SettingsTabs.Appearance]: [
+ 'appearance',
+ 'theme',
+ 'dark mode',
+ 'light mode',
+ 'font',
+ 'language',
+ 'color',
+ ],
+ [SettingsTabs.Billing]: ['billing', 'payment', 'invoice', 'card', 'transaction'],
+ [SettingsTabs.Connector]: ['connectors', 'integrations', 'mcp', 'oauth'],
+ [SettingsTabs.Credits]: ['credits', 'balance', 'top up', 'recharge', 'buy credits'],
+ [SettingsTabs.Creds]: ['credentials', 'secrets', 'oauth'],
+ [SettingsTabs.Devices]: ['devices', 'sessions', 'logged in devices'],
+ [SettingsTabs.Hotkey]: ['hotkey', 'shortcut', 'keyboard'],
+ [SettingsTabs.Memory]: ['memory', 'memories', 'personalization'],
+ [SettingsTabs.Messenger]: ['messenger', 'chat platform', 'bot'],
+ [SettingsTabs.Notification]: ['notification', 'email', 'push', 'alerts'],
+ [SettingsTabs.Plans]: ['subscription', 'plan', 'upgrade', 'pricing', 'membership'],
+ [SettingsTabs.Profile]: [
+ 'profile',
+ 'account',
+ 'avatar',
+ 'username',
+ 'password',
+ 'email',
+ 'sign out',
+ 'logout',
+ ],
+ [SettingsTabs.Provider]: [
+ 'provider',
+ 'model',
+ 'llm',
+ 'api key',
+ 'apikey',
+ 'byok',
+ 'bring your own key',
+ 'endpoint',
+ ],
+ [SettingsTabs.Proxy]: ['proxy', 'network', 'connection'],
+ [SettingsTabs.Referral]: ['referral', 'invite', 'rewards', 'bonus'],
+ [SettingsTabs.ServiceModel]: [
+ 'service model',
+ 'model assignment',
+ 'topic naming',
+ 'translation',
+ 'tts',
+ 'voice',
+ 'speech',
+ 'image',
+ 'image generation',
+ 'embedding',
+ 'prompt rewrite',
+ 'suggestion',
+ ],
+ [SettingsTabs.Skill]: ['skill', 'skills', 'plugins', 'tools'],
+ [SettingsTabs.Stats]: ['analytics', 'statistics', 'stats'],
+ [SettingsTabs.Storage]: [
+ 'storage',
+ 'files',
+ 'import',
+ 'export',
+ 'backup',
+ 'reset',
+ 'clear data',
+ 'account deletion',
+ 'delete account',
+ ],
+ [SettingsTabs.SystemTools]: ['system tools', 'built-in tools'],
+ [SettingsTabs.Usage]: ['usage', 'consumption', 'quota', 'spend', 'statistics'],
+};
+
+/**
+ * Localized synonym keywords for tab-level entries (i18n keys in the `setting`
+ * namespace, comma-separated values). Tab labels alone miss common synonyms —
+ * e.g. searching "充值" (top up) should hit the Credits tab whose label is just
+ * "积分", and "文件" (files) should hit Storage ("数据存储"). Each locale
+ * carries its own synonym set, layered on top of TAB_SEARCH_EN_KEYWORDS.
+ */
+export const TAB_SEARCH_KEYWORDS_KEYS: Partial<Record<SettingsTabs, string>> = {
+ [SettingsTabs.About]: 'settingsSearch.tabKeywords.about',
+ [SettingsTabs.Advanced]: 'settingsSearch.tabKeywords.advanced',
+ [SettingsTabs.APIKey]: 'settingsSearch.tabKeywords.apikey',
+ [SettingsTabs.Appearance]: 'settingsSearch.tabKeywords.appearance',
+ [SettingsTabs.Billing]: 'settingsSearch.tabKeywords.billing',
+ [SettingsTabs.Connector]: 'settingsSearch.tabKeywords.connector',
+ [SettingsTabs.Credits]: 'settingsSearch.tabKeywords.credits',
+ [SettingsTabs.Creds]: 'settingsSearch.tabKeywords.creds',
+ [SettingsTabs.Devices]: 'settingsSearch.tabKeywords.devices',
+ [SettingsTabs.Hotkey]: 'settingsSearch.tabKeywords.hotkey',
+ [SettingsTabs.Memory]: 'settingsSearch.tabKeywords.memory',
+ [SettingsTabs.Messenger]: 'settingsSearch.tabKeywords.messenger',
+ [SettingsTabs.Notification]: 'settingsSearch.tabKeywords.notification',
+ [SettingsTabs.Plans]: 'settingsSearch.tabKeywords.plans',
+ [SettingsTabs.Profile]: 'settingsSearch.tabKeywords.profile',
+ [SettingsTabs.Provider]: 'settingsSearch.tabKeywords.provider',
+ [SettingsTabs.Proxy]: 'settingsSearch.tabKeywords.proxy',
+ [SettingsTabs.Referral]: 'settingsSearch.tabKeywords.referral',
+ [SettingsTabs.ServiceModel]: 'settingsSearch.tabKeywords.serviceModel',
+ [SettingsTabs.Skill]: 'settingsSearch.tabKeywords.skill',
+ [SettingsTabs.Stats]: 'settingsSearch.tabKeywords.stats',
+ [SettingsTabs.Storage]: 'settingsSearch.tabKeywords.storage',
+ [SettingsTabs.SystemTools]: 'settingsSearch.tabKeywords.systemTools',
+ [SettingsTabs.Usage]: 'settingsSearch.tabKeywords.usage',
+};
+
+/**
+ * Hand-curated searchable settings entries below the tab level. Tab-level
+ * entries are derived from `useCategory` at runtime and need no registration
+ * here. Keep this list in sync when moving or removing the referenced items —
+ * an entry whose tab is hidden for the current user is filtered out
+ * automatically, but a stale anchor silently degrades to a plain tab switch.
+ */
+export const SETTINGS_SEARCH_ITEMS: SettingsSearchItem[] = [
+ // Profile
+ {
+ anchor: 'profile-avatar',
+ keywords: ['avatar', 'photo', 'profile picture'],
+ labelKey: 'profile.avatar',
+ ns: 'auth',
+ tab: SettingsTabs.Profile,
+ },
+ {
+ anchor: 'profile-full-name',
+ keywords: ['full name', 'fullname', 'display name', 'nickname'],
+ labelKey: 'profile.fullName',
+ ns: 'auth',
+ tab: SettingsTabs.Profile,
+ },
+ {
+ anchor: 'profile-username',
+ keywords: ['username', 'handle', 'user name'],
+ labelKey: 'profile.username',
+ ns: 'auth',
+ tab: SettingsTabs.Profile,
+ },
+ {
+ anchor: 'profile-interests',
+ keywords: ['interests', 'topics', 'personalization'],
+ labelKey: 'profile.interests',
+ ns: 'auth',
+ tab: SettingsTabs.Profile,
+ },
+ {
+ anchor: 'profile-password',
+ keywords: ['password', 'change password', 'set password', 'reset password'],
+ labelKey: 'profile.password',
+ ns: 'auth',
+ tab: SettingsTabs.Profile,
+ visible: (ctx) => ctx.isLogin && !ctx.isDesktop && !ctx.disableEmailPassword,
+ },
+ {
+ anchor: 'profile-email',
+ keywords: ['email', 'email address', 'update email', 'change email'],
+ labelKey: 'profile.email',
+ ns: 'auth',
+ tab: SettingsTabs.Profile,
+ visible: (ctx) => ctx.isLogin && ctx.hasEmail,
+ },
+ {
+ anchor: 'profile-connected-accounts',
+ keywords: [
+ 'connected accounts',
+ 'linked accounts',
+ 'sso',
+ 'oauth',
+ 'github',
+ 'google',
+ 'apple',
+ ],
+ labelKey: 'profile.sso.providers',
+ ns: 'auth',
+ tab: SettingsTabs.Profile,
+ visible: (ctx) => ctx.isLogin && !ctx.isDesktop,
+ },
+ {
+ anchor: 'profile-authorizations',
+ keywords: ['authorizations', 'manage authorizations', 'composio', 'revoke access'],
+ labelKey: 'profile.authorizations.title',
+ ns: 'auth',
+ tab: SettingsTabs.Profile,
+ // The row additionally requires at least one connected Composio server —
+ // async user data intentionally not mirrored; a miss degrades to a plain
+ // tab switch.
+ visible: (ctx) => ctx.enableComposio,
+ },
+ // Appearance
+ {
+ anchor: 'appearance-theme-mode',
+ keywords: ['theme', 'dark', 'light', 'mode'],
+ labelKey: 'settingCommon.themeMode.title',
+ tab: SettingsTabs.Appearance,
+ },
+ {
+ anchor: 'appearance-language',
+ keywords: ['language', 'locale', 'i18n'],
+ labelKey: 'settingCommon.lang.title',
+ tab: SettingsTabs.Appearance,
+ },
+ {
+ anchor: 'appearance-animation',
+ descKey: 'settingAppearance.animationMode.desc',
+ keywords: ['animation', 'motion', 'transition'],
+ labelKey: 'settingAppearance.animationMode.title',
+ tab: SettingsTabs.Appearance,
+ },
+ {
+ anchor: 'appearance-context-menu',
+ descKey: 'settingAppearance.contextMenuMode.desc',
+ keywords: ['context menu', 'right click'],
+ labelKey: 'settingAppearance.contextMenuMode.title',
+ tab: SettingsTabs.Appearance,
+ },
+ {
+ anchor: 'appearance-response-language',
+ descKey: 'settingCommon.responseLanguage.desc',
+ keywords: ['response language', 'reply'],
+ labelKey: 'settingCommon.responseLanguage.title',
+ tab: SettingsTabs.Appearance,
+ },
+ {
+ anchor: 'appearance-primary-color',
+ keywords: ['color', 'accent'],
+ labelKey: 'settingAppearance.primaryColor.title',
+ tab: SettingsTabs.Appearance,
+ },
+ {
+ anchor: 'appearance-neutral-color',
+ keywords: ['color', 'gray', 'grey'],
+ labelKey: 'settingAppearance.neutralColor.title',
+ tab: SettingsTabs.Appearance,
+ },
+ {
+ anchor: 'appearance-font-size',
+ descKey: 'settingChatAppearance.fontSize.desc',
+ keywords: ['font', 'size', 'text'],
+ labelKey: 'settingChatAppearance.fontSize.title',
+ tab: SettingsTabs.Appearance,
+ },
+ {
+ anchor: 'appearance-app-tray',
+ keywords: ['tray', 'menu bar', 'menubar'],
+ labelKey: 'settingAppearance.appTray.title',
+ tab: SettingsTabs.Appearance,
+ visible: (ctx) => ctx.isDesktop,
+ },
+ // Advanced
+ {
+ anchor: 'advanced-dev-mode',
+ descKey: 'settingCommon.devMode.desc',
+ keywords: ['developer', 'debug', 'dev mode'],
+ labelKey: 'settingCommon.devMode.title',
+ tab: SettingsTabs.Advanced,
+ },
+ {
+ anchor: 'advanced-gateway-mode',
+ descKey: 'tab.advanced.gatewayMode.desc',
+ keywords: ['gateway', 'agent runtime'],
+ labelKey: 'tab.advanced.gatewayMode.title',
+ tab: SettingsTabs.Advanced,
+ visible: (ctx) => ctx.enableGatewayMode,
+ },
+ {
+ anchor: 'advanced-update-channel',
+ descKey: 'tab.advanced.updateChannel.desc',
+ keywords: ['update', 'version', 'canary', 'stable'],
+ labelKey: 'tab.advanced.updateChannel.title',
+ tab: SettingsTabs.Advanced,
+ visible: (ctx) => ctx.isDesktop,
+ },
+ {
+ anchor: 'advanced-labs',
+ keywords: ['labs', 'experiment', 'beta', 'preview'],
+ labelKey: 'title',
+ ns: 'labs',
+ tab: SettingsTabs.Advanced,
+ },
+ // Service Model
+ {
+ anchor: 'service-model-assignments',
+ keywords: ['model assignment', 'topic naming', 'translation', 'default model'],
+ labelKey: 'serviceModel.modelAssignments.title',
+ tab: SettingsTabs.ServiceModel,
+ },
+ {
+ anchor: 'service-model-memory',
+ keywords: ['memory', 'embedding', 'vector'],
+ labelKey: 'serviceModel.memoryModels.title',
+ tab: SettingsTabs.ServiceModel,
+ },
+ {
+ anchor: 'service-model-optional-features',
+ keywords: ['follow up', 'input completion', 'prompt rewrite', 'suggestion'],
+ labelKey: 'serviceModel.optionalFeatures.title',
+ tab: SettingsTabs.ServiceModel,
+ },
+ {
+ anchor: 'service-model-tts',
+ keywords: ['tts', 'voice', 'speech', 'text to speech'],
+ labelKey: 'settingTTS.openai.ttsModel',
+ tab: SettingsTabs.ServiceModel,
+ visible: (ctx) => ctx.enableSTT,
+ },
+ {
+ anchor: 'service-model-image',
+ descKey: 'settingImage.defaultCount.desc',
+ keywords: ['image', 'image generation', 'ai image'],
+ labelKey: 'settingImage.defaultCount.title',
+ tab: SettingsTabs.ServiceModel,
+ visible: (ctx) => ctx.showAiImage,
+ },
+ // Storage
+ {
+ anchor: 'storage-export',
+ keywords: ['export', 'backup'],
+ labelKey: 'storage.actions.export.title',
+ tab: SettingsTabs.Storage,
+ visible: (ctx) => ctx.enableBusinessFeatures,
+ },
+ {
+ anchor: 'storage-import',
+ keywords: ['import', 'restore'],
+ labelKey: 'storage.actions.import.title',
+ tab: SettingsTabs.Storage,
+ },
+ {
+ anchor: 'storage-reset',
+ keywords: ['reset', 'clear', 'delete', 'danger'],
+ labelKey: 'danger.reset.title',
+ tab: SettingsTabs.Storage,
+ },
+ {
+ anchor: 'storage-telemetry',
+ keywords: ['telemetry', 'analytics', 'privacy', 'tracking'],
+ labelKey: 'analytics.telemetry.title',
+ tab: SettingsTabs.Storage,
+ visible: (ctx) => ctx.hideDocs,
+ },
+ {
+ anchor: 'storage-account-deletion',
+ descKey: 'accountDeletion.desc',
+ keywords: ['delete account', 'deactivate', 'close account'],
+ labelKey: 'accountDeletion.title',
+ tab: SettingsTabs.Storage,
+ // Rendered by the business AccountDeletion slot; the OSS default slot
+ // renders nothing, so this gate matches the actual render condition only
+ // for implementations that provide the slot (e.g. cloud).
+ visible: (ctx) => ctx.enableBusinessFeatures,
+ },
+ // Proxy (the tab itself is desktop-only and filtered via useCategory)
+ {
+ anchor: 'proxy-enable',
+ descKey: 'proxy.enableDesc',
+ keywords: ['proxy', 'network'],
+ labelKey: 'proxy.enable',
+ ns: 'electron',
+ tab: SettingsTabs.Proxy,
+ },
+ {
+ anchor: 'proxy-auth',
+ descKey: 'proxy.authDesc',
+ keywords: ['authentication', 'username', 'password'],
+ labelKey: 'proxy.auth',
+ ns: 'electron',
+ tab: SettingsTabs.Proxy,
+ },
+ {
+ anchor: 'proxy-test',
+ descKey: 'proxy.testDescription',
+ keywords: ['test', 'connection', 'check'],
+ labelKey: 'proxy.testUrl',
+ ns: 'electron',
+ tab: SettingsTabs.Proxy,
+ },
+ // Hotkey
+ {
+ anchor: 'hotkey-essential',
+ keywords: ['shortcut', 'keyboard', 'hotkey'],
+ labelKey: 'hotkey.group.essential',
+ tab: SettingsTabs.Hotkey,
+ },
+ {
+ anchor: 'hotkey-conversation',
+ keywords: ['shortcut', 'keyboard', 'chat'],
+ labelKey: 'hotkey.group.conversation',
+ tab: SettingsTabs.Hotkey,
+ },
+ {
+ anchor: 'hotkey-desktop',
+ keywords: ['shortcut', 'keyboard', 'global'],
+ labelKey: 'hotkey.group.desktop',
+ tab: SettingsTabs.Hotkey,
+ visible: (ctx) => ctx.isDesktop,
+ },
+ // Business pages below are rendered by business slots (cloud implementation);
+ // their tabs only appear when the business build provides them, so tab
+ // visibility via useCategory is the effective gate — no per-item gate needed.
+ // Billing
+ {
+ anchor: 'billing-summary',
+ keywords: ['payment method', 'next payment', 'card'],
+ labelKey: 'summary.title',
+ ns: 'subscription',
+ tab: SettingsTabs.Billing,
+ },
+ {
+ anchor: 'billing-current-plan',
+ keywords: ['plan', 'subscription', 'cancel'],
+ labelKey: 'currentPlan.title',
+ ns: 'subscription',
+ tab: SettingsTabs.Billing,
+ },
+ {
+ anchor: 'billing-history',
+ keywords: ['invoice', 'receipt', 'payment history'],
+ labelKey: 'billing.history',
+ ns: 'subscription',
+ tab: SettingsTabs.Billing,
+ },
+ // Credits
+ {
+ anchor: 'credits-balance',
+ keywords: ['balance', 'credits'],
+ labelKey: 'balance.title',
+ ns: 'subscription',
+ tab: SettingsTabs.Credits,
+ },
+ {
+ anchor: 'credits-top-up',
+ keywords: ['top up', 'topup', 'buy credits', 'recharge'],
+ labelKey: 'credits.topUp.title',
+ ns: 'subscription',
+ tab: SettingsTabs.Credits,
+ },
+ {
+ anchor: 'credits-cost-estimate-hint',
+ descKey: 'credits.costEstimateHint.desc',
+ keywords: ['cost estimate'],
+ labelKey: 'credits.costEstimateHint.title',
+ ns: 'subscription',
+ tab: SettingsTabs.Credits,
+ },
+ {
+ anchor: 'credits-auto-top-up',
+ descKey: 'credits.autoTopUp.desc',
+ keywords: ['auto top up', 'automatic recharge'],
+ labelKey: 'credits.autoTopUp.title',
+ ns: 'subscription',
+ tab: SettingsTabs.Credits,
+ },
+ {
+ anchor: 'credits-packages',
+ keywords: ['package', 'budget'],
+ labelKey: 'credits.packages.title',
+ ns: 'subscription',
+ tab: SettingsTabs.Credits,
+ },
+ // Plans
+ {
+ anchor: 'plans-model-pricing',
+ keywords: ['model pricing', 'price'],
+ labelKey: 'modelPricing.title',
+ ns: 'subscription',
+ tab: SettingsTabs.Plans,
+ },
+ {
+ anchor: 'plans-qa',
+ keywords: ['faq', 'question'],
+ labelKey: 'qa.title',
+ ns: 'subscription',
+ tab: SettingsTabs.Plans,
+ },
+ // Referral
+ {
+ anchor: 'referral-invite-link',
+ keywords: ['invite link', 'share'],
+ labelKey: 'referral.inviteLink.title',
+ ns: 'subscription',
+ tab: SettingsTabs.Referral,
+ },
+ {
+ anchor: 'referral-invite-code',
+ keywords: ['invite code', 'referral code'],
+ labelKey: 'referral.inviteCode.title',
+ ns: 'subscription',
+ tab: SettingsTabs.Referral,
+ },
+ {
+ anchor: 'referral-stats',
+ keywords: ['rewards', 'invites'],
+ labelKey: 'referral.stats.title',
+ ns: 'subscription',
+ tab: SettingsTabs.Referral,
+ },
+ {
+ anchor: 'referral-table',
+ keywords: ['referral history'],
+ labelKey: 'referral.table.title',
+ ns: 'subscription',
+ tab: SettingsTabs.Referral,
+ },
+ {
+ anchor: 'referral-rules',
+ descKey: 'referral.rules.description',
+ keywords: ['rules'],
+ labelKey: 'referral.rules.title',
+ ns: 'subscription',
+ tab: SettingsTabs.Referral,
+ },
+ // Usage
+ {
+ anchor: 'usage-spend',
+ descKey: 'table.desc',
+ keywords: ['spend', 'cost'],
+ labelKey: 'table.title',
+ ns: 'spend',
+ tab: SettingsTabs.Usage,
+ },
+ {
+ anchor: 'usage-overview',
+ keywords: ['usage', 'quota'],
+ labelKey: 'usage.title',
+ ns: 'subscription',
+ tab: SettingsTabs.Usage,
+ },
+ // Notification
+ {
+ anchor: 'notification-email',
+ keywords: ['email'],
+ labelKey: 'notification.email.title',
+ tab: SettingsTabs.Notification,
+ },
+ {
+ anchor: 'notification-push',
+ keywords: ['push'],
+ labelKey: 'notification.push.title',
+ tab: SettingsTabs.Notification,
+ },
+];
diff --git a/src/features/SettingsSearch/matcher.test.ts b/src/features/SettingsSearch/matcher.test.ts
new file mode 100644
index 00000000000..e18d82d8127
--- /dev/null
+++ b/src/features/SettingsSearch/matcher.test.ts
@@ -0,0 +1,46 @@
+import { describe, expect, it } from 'vitest';
+
+import { createSettingsSearchFuse, MAX_SEARCH_RESULTS } from './matcher';
+
+const entries = [
+ { haystack: ['appearance', 'theme', '主题', 'zhuti', 'zt'], key: 'tab-appearance' },
+ { haystack: ['theme mode', 'dark mode', 'light'], key: 'item-theme-mode' },
+ { haystack: ['充值', 'chongzhi', 'cz', 'top up', 'recharge'], key: 'item-top-up' },
+ // Polyphone drift: the pinyin dict renders 重置 as `zhongzhi`
+ { haystack: ['重置', 'zhongzhi', 'zz', 'reset'], key: 'item-reset' },
+ {
+ haystack: ['storage', 'clear all session messages and reset the database'],
+ key: 'tab-storage',
+ },
+];
+
+const search = (query: string) =>
+ createSettingsSearchFuse(entries)
+ .search(query, { limit: MAX_SEARCH_RESULTS })
+ .map((result) => result.item.key);
+
+describe('createSettingsSearchFuse', () => {
+ it('matches exact substrings', () => {
+ expect(search('theme')).toContain('tab-appearance');
+ expect(search('主题')).toContain('tab-appearance');
+ });
+
+ it('tolerates small typos', () => {
+ expect(search('apearance')).toContain('tab-appearance');
+ expect(search('thme')).toContain('tab-appearance');
+ });
+
+ it('ranks the exact match above fuzzy matches', () => {
+ // `chongzhi` is exact for 充值 and edit-distance 1 from 重置's `zhongzhi` —
+ // the fuzzy hit compensates the polyphone drift but must rank below.
+ expect(search('chongzhi')).toEqual(['item-top-up', 'item-reset']);
+ });
+
+ it('matches deep inside long description texts', () => {
+ expect(search('reset the database')).toContain('tab-storage');
+ });
+
+ it('returns nothing for unrelated queries', () => {
+ expect(search('banana')).toEqual([]);
+ });
+});
diff --git a/src/features/SettingsSearch/matcher.ts b/src/features/SettingsSearch/matcher.ts
new file mode 100644
index 00000000000..6d8990b04db
--- /dev/null
+++ b/src/features/SettingsSearch/matcher.ts
@@ -0,0 +1,28 @@
+import Fuse from 'fuse.js';
+
+export interface SearchableEntry {
+ /** Lowercased searchable texts (label / desc / keywords / pinyin variants) */
+ haystack: string[];
+}
+
+/**
+ * Fuzzy matches crowd a small sidebar panel fast, so cap how many we show —
+ * anything below the top 20 is noise for a settings query.
+ */
+export const MAX_SEARCH_RESULTS = 20;
+
+/**
+ * Fuzzy matcher over the settings index. Compared to the ChatInput Fuse usages
+ * (threshold 0.3–0.4 over short command labels), the settings haystack includes
+ * longer description texts, so `ignoreLocation` keeps matches deep inside a
+ * description from being scored away; threshold 0.35 tolerates a typo or two
+ * without flooding the panel with unrelated entries. Results are score-sorted,
+ * and Fuse keeps insertion order on ties — the index lists tab entries first,
+ * so tabs still rank above item-level matches when equally relevant.
+ */
+export const createSettingsSearchFuse = <T extends SearchableEntry>(entries: T[]) =>
+ new Fuse(entries, {
+ ignoreLocation: true,
+ keys: ['haystack'],
+ threshold: 0.35,
+ });
diff --git a/src/features/SettingsSearch/pinyin.test.ts b/src/features/SettingsSearch/pinyin.test.ts
new file mode 100644
index 00000000000..a17e1ed106f
--- /dev/null
+++ b/src/features/SettingsSearch/pinyin.test.ts
@@ -0,0 +1,34 @@
+import { describe, expect, it } from 'vitest';
+
+import { containsHan, loadPinyinTexts } from './pinyin';
+
+describe('containsHan', () => {
+ it('detects Han characters', () => {
+ expect(containsHan('主题')).toBe(true);
+ expect(containsHan('OpenAI 密钥')).toBe(true);
+ expect(containsHan('dark mode')).toBe(false);
+ });
+});
+
+describe('loadPinyinTexts', () => {
+ it('produces full pinyin and initials for Han text', async () => {
+ const pinyinTexts = await loadPinyinTexts();
+ expect(pinyinTexts!('主题')).toEqual(['zhuti', 'zt']);
+ expect(pinyinTexts!('快捷键')).toEqual(['kuaijiejian', 'kjj']);
+ });
+
+ it('strips non-Han characters from mixed text', async () => {
+ const pinyinTexts = await loadPinyinTexts();
+ expect(pinyinTexts!('openai 密钥')).toEqual(['miyao', 'my']);
+ });
+
+ it('skips single-letter initials that would match everything', async () => {
+ const pinyinTexts = await loadPinyinTexts();
+ expect(pinyinTexts!('图')).toEqual(['tu']);
+ });
+
+ it('returns empty for non-Han text', async () => {
+ const pinyinTexts = await loadPinyinTexts();
+ expect(pinyinTexts!('dark mode')).toEqual([]);
+ });
+});
diff --git a/src/features/SettingsSearch/pinyin.ts b/src/features/SettingsSearch/pinyin.ts
new file mode 100644
index 00000000000..dc29fc80cc4
--- /dev/null
+++ b/src/features/SettingsSearch/pinyin.ts
@@ -0,0 +1,38 @@
+/** Whether the text contains Han characters that pinyin search applies to */
+export const containsHan = (text: string) => /\p{Script=Han}/u.test(text);
+
+/** Returns lowercase pinyin variants (full spelling + initials) for Han text */
+export type PinyinTexts = (text: string) => string[];
+
+let loader: Promise<PinyinTexts | null> | undefined;
+
+/**
+ * Lazily load pinyin-pro so users can hit Chinese labels with pinyin queries
+ * (e.g. `zhuti` / `zt` → 主题). The package is mostly dictionary weight, so it
+ * is dynamically imported only when the built index actually contains Han text
+ * (see useSettingsSearch) — non-CJK locales never pay for it. pinyin-pro over
+ * lighter char-table converters for its per-word polyphone segmentation
+ * (充值 → chongzhi, where a char table can only guess per character). The
+ * default dict still drifts on some words (重置 → zhongzhi, not chongzhi);
+ * that residue is compensated by Fuse fuzzy matching — see matcher.test.ts —
+ * so don't tighten the Fuse threshold without re-checking polyphone queries.
+ * Resolves null if the chunk fails to load; search then works without pinyin.
+ */
+export const loadPinyinTexts = (): Promise<PinyinTexts | null> => {
+ loader ??= import('pinyin-pro').then(
+ ({ pinyin }) =>
+ (text: string) => {
+ if (!containsHan(text)) return [];
+
+ const syllables = pinyin(text, { nonZh: 'removed', toneType: 'none', type: 'array' });
+ if (syllables.length === 0) return [];
+
+ const full = syllables.join('');
+ const initials = syllables.map((syllable) => syllable[0]).join('');
+ // A single-letter initials text would fuzzy-match nearly any query
+ return initials.length > 1 ? [full, initials] : [full];
+ },
+ () => null,
+ );
+ return loader;
+};
diff --git a/src/features/SettingsSearch/useSettingsSearch.ts b/src/features/SettingsSearch/useSettingsSearch.ts
new file mode 100644
index 00000000000..ec94b3e2533
--- /dev/null
+++ b/src/features/SettingsSearch/useSettingsSearch.ts
@@ -0,0 +1,273 @@
+import { isDesktop, LOBEHUB_SKILL_PROVIDERS } from '@lobechat/const';
+import type { IconProps } from '@lobehub/ui';
+import { DEFAULT_MODEL_PROVIDER_LIST } from 'model-bank/modelProviders';
+import { useEffect, useMemo, useState } from 'react';
+import { useTranslation } from 'react-i18next';
+
+import { useCategory } from '@/routes/(main)/settings/hooks/useCategory';
+import { SettingsTabs } from '@/store/global/initialState';
+import {
+ featureFlagsSelectors,
+ serverConfigSelectors,
+ useServerConfigStore,
+} from '@/store/serverConfig';
+import { useUserStore } from '@/store/user';
+import { authSelectors, userProfileSelectors } from '@/store/user/selectors';
+
+import {
+ SETTINGS_SEARCH_ITEMS,
+ type SettingsSearchContext,
+ TAB_SEARCH_EN_KEYWORDS,
+ TAB_SEARCH_KEYWORDS_KEYS,
+} from './items';
+import { createSettingsSearchFuse, MAX_SEARCH_RESULTS } from './matcher';
+import { containsHan, loadPinyinTexts, type PinyinTexts } from './pinyin';
+
+export interface SettingsSearchResult {
+ /** Present on item-level results; used as the URL hash for scroll targeting */
+ anchor?: string;
+ /** Where the result lives, e.g. `General › Appearance` */
+ breadcrumb: string;
+ icon?: IconProps['icon'];
+ key: string;
+ label: string;
+ tab: SettingsTabs;
+ url: string;
+}
+
+interface IndexedEntry extends SettingsSearchResult {
+ /** Lowercased searchable texts (label / desc / keywords / …) */
+ haystack: string[];
+ /**
+ * Label/keyword texts that get pinyin variants appended once the dict loads.
+ * Descriptions are excluded — their pinyin strings are long and only add
+ * fuzzy-match noise.
+ */
+ pinyinBase: string[];
+}
+
+export const getTabUrl = (tab: SettingsTabs) =>
+ tab === SettingsTabs.Provider ? '/settings/provider/all' : `/settings/${tab}`;
+
+/** Split a localized comma-separated keyword string (supports CJK commas) */
+const splitKeywords = (text: string) =>
+ text
+ .split(/[,、]/)
+ .map((keyword) => keyword.trim().toLowerCase())
+ .filter(Boolean);
+
+/**
+ * Search visible settings by the current-locale label text plus registered
+ * keywords, fuzzy-matched via Fuse and pinyin-augmented for Han labels. Tab
+ * entries derive from `useCategory` (inheriting its feature-flag / platform
+ * gating and `href` overrides); item-level entries come from
+ * `SETTINGS_SEARCH_ITEMS` and are dropped when their tab is not visible.
+ */
+export const useSettingsSearch = (
+ query: string,
+): {
+ /**
+ * True while the pinyin dict chunk is still loading for a Han-text index —
+ * a zero-result answer is not authoritative yet (pinyin queries like `zhuti`
+ * can only match after the dict arrives). Settles to false on load success,
+ * failure (graceful non-pinyin degradation), or when no Han text is indexed.
+ */
+ isIndexing: boolean;
+ results: SettingsSearchResult[];
+} => {
+ const { t } = useTranslation(['setting', 'labs', 'electron', 'subscription', 'spend', 'auth']);
+ const categoryGroups = useCategory();
+ const { enableSTT, hideDocs, showAiImage } = useServerConfigStore(featureFlagsSelectors);
+ const enableBusinessFeatures = useServerConfigStore(serverConfigSelectors.enableBusinessFeatures);
+ const enableGatewayMode = useServerConfigStore(serverConfigSelectors.enableGatewayMode);
+ const enableComposio = useServerConfigStore(serverConfigSelectors.enableComposio);
+ const disableEmailPassword = useServerConfigStore(serverConfigSelectors.disableEmailPassword);
+ const isLogin = useUserStore(authSelectors.isLogin);
+ const hasEmail = useUserStore((s) => !!userProfileSelectors.userProfile(s)?.email);
+ const [pinyin, setPinyin] = useState<{ settled: boolean; texts: PinyinTexts | null }>({
+ settled: false,
+ texts: null,
+ });
+
+ // The translated index only depends on locale / visibility inputs — build it
+ // once, not on every keystroke.
+ const baseIndex = useMemo(() => {
+ const ctx: SettingsSearchContext = {
+ disableEmailPassword: !!disableEmailPassword,
+ enableBusinessFeatures: !!enableBusinessFeatures,
+ enableComposio: !!enableComposio,
+ enableGatewayMode: !!enableGatewayMode,
+ enableSTT: !!enableSTT,
+ hasEmail,
+ hideDocs: !!hideDocs,
+ isDesktop,
+ isLogin: !!isLogin,
+ showAiImage: !!showAiImage,
+ };
+
+ // Tab-level entries first so they rank above item-level matches.
+ const entries: IndexedEntry[] = [];
+ const visibleTabs = new Map<
+ SettingsTabs,
+ { groupTitle: string; icon?: IconProps['icon']; label: string; url: string }
+ >();
+
+ for (const group of categoryGroups) {
+ for (const item of group.items) {
+ // The same tab may appear in multiple groups (e.g. APIKey in Agent and
+ // System when dev mode is on); index only the first occurrence,
+ // matching the sidebar's top-to-bottom order — otherwise one query
+ // shows duplicate results pointing at the same page.
+ if (visibleTabs.has(item.key)) continue;
+
+ const url = item.href ?? getTabUrl(item.key);
+ visibleTabs.set(item.key, {
+ groupTitle: group.title,
+ icon: item.icon,
+ label: item.label,
+ url,
+ });
+
+ const keywordsKey = TAB_SEARCH_KEYWORDS_KEYS[item.key];
+ // English floor + localized enrichment (deduped: on en-US they overlap)
+ const texts = Array.from(
+ new Set([
+ item.label.toLowerCase(),
+ ...(TAB_SEARCH_EN_KEYWORDS[item.key] ?? []),
+ ...(keywordsKey ? splitKeywords(t(keywordsKey as never) as string) : []),
+ ]),
+ );
+
+ entries.push({
+ breadcrumb: group.title,
+ haystack: texts,
+ icon: item.icon,
+ key: `tab-${group.key}-${item.key}`,
+ label: item.label,
+ pinyinBase: texts,
+ tab: item.key,
+ url,
+ });
+ }
+ }
+
+ for (const def of SETTINGS_SEARCH_ITEMS) {
+ const tabInfo = visibleTabs.get(def.tab);
+ if (!tabInfo) continue;
+ if (def.visible && !def.visible(ctx)) continue;
+
+ const ns = def.ns ?? 'setting';
+ const label = t(def.labelKey as never, { ns }) as string;
+ const desc = def.descKey ? (t(def.descKey as never, { ns }) as string) : undefined;
+ const keywordTexts = (def.keywords ?? []).map((text) => text.toLowerCase());
+
+ entries.push({
+ anchor: def.anchor,
+ breadcrumb: `${tabInfo.groupTitle} › ${tabInfo.label}`,
+ haystack: [label.toLowerCase(), ...(desc ? [desc.toLowerCase()] : []), ...keywordTexts],
+ icon: tabInfo.icon,
+ key: `item-${def.anchor}`,
+ label,
+ pinyinBase: [label.toLowerCase(), ...keywordTexts],
+ tab: def.tab,
+ url: `${tabInfo.url}#${def.anchor}`,
+ });
+ }
+
+ // Builtin OAuth connectors (Notion, GitHub, …): searching a connector name
+ // should land on the connector page. The page has no per-connector deep
+ // link, so these navigate to the tab itself. Availability ultimately
+ // depends on the Market API, but this static catalog is what the page
+ // renders from.
+ const connectorTab = visibleTabs.get(SettingsTabs.Connector);
+ if (connectorTab)
+ for (const connector of LOBEHUB_SKILL_PROVIDERS) {
+ entries.push({
+ breadcrumb: `${connectorTab.groupTitle} › ${connectorTab.label}`,
+ haystack: [connector.label.toLowerCase(), connector.id.toLowerCase()],
+ icon: connectorTab.icon,
+ key: `connector-${connector.id}`,
+ label: connector.label,
+ pinyinBase: [],
+ tab: SettingsTabs.Connector,
+ url: connectorTab.url,
+ });
+ }
+
+ // Model providers rank last: builtin names/ids (e.g. "OpenAI") link straight
+ // to the provider detail page. Custom providers need an async store fetch and
+ // are intentionally not indexed.
+ const providerTab = visibleTabs.get(SettingsTabs.Provider);
+ if (providerTab)
+ for (const provider of DEFAULT_MODEL_PROVIDER_LIST) {
+ entries.push({
+ breadcrumb: `${providerTab.groupTitle} › ${providerTab.label}`,
+ haystack: [provider.name.toLowerCase(), provider.id.toLowerCase()],
+ icon: providerTab.icon,
+ key: `provider-${provider.id}`,
+ label: provider.name,
+ pinyinBase: [],
+ tab: SettingsTabs.Provider,
+ url: `/settings/provider/${provider.id}`,
+ });
+ }
+
+ return entries;
+ }, [
+ categoryGroups,
+ t,
+ disableEmailPassword,
+ enableBusinessFeatures,
+ enableComposio,
+ enableGatewayMode,
+ enableSTT,
+ hasEmail,
+ hideDocs,
+ isLogin,
+ showAiImage,
+ ]);
+
+ // Load the pinyin dict only when the index actually contains Han text, so
+ // non-CJK locales never download it.
+ const needsPinyin = useMemo(
+ () => baseIndex.some((entry) => entry.pinyinBase.some((text) => containsHan(text))),
+ [baseIndex],
+ );
+
+ useEffect(() => {
+ if (!needsPinyin || pinyin.settled) return;
+
+ let active = true;
+ // Settle even on load failure (texts stays null) so isIndexing can't stick.
+ loadPinyinTexts().then((fn) => {
+ if (active) setPinyin({ settled: true, texts: fn });
+ });
+ return () => {
+ active = false;
+ };
+ }, [needsPinyin, pinyin.settled]);
+
+ const fuse = useMemo(() => {
+ const pinyinTexts = pinyin.texts;
+ const index = pinyinTexts
+ ? baseIndex.map((entry) =>
+ entry.pinyinBase.some((text) => containsHan(text))
+ ? { ...entry, haystack: [...entry.haystack, ...entry.pinyinBase.flatMap(pinyinTexts)] }
+ : entry,
+ )
+ : baseIndex;
+
+ return createSettingsSearchFuse(index);
+ }, [baseIndex, pinyin.texts]);
+
+ const results = useMemo(() => {
+ const q = query.trim();
+ if (!q) return [];
+
+ return fuse
+ .search(q, { limit: MAX_SEARCH_RESULTS })
+ .map(({ item: { haystack: _h, pinyinBase: _p, ...result } }) => result);
+ }, [query, fuse]);
+
+ return { isIndexing: needsPinyin && !pinyin.settled, results };
+};
diff --git a/src/routes/(main)/settings/_layout/Body/index.tsx b/src/routes/(main)/settings/_layout/Body/index.tsx
index 899974016d1..615426d7d05 100644
--- a/src/routes/(main)/settings/_layout/Body/index.tsx
+++ b/src/routes/(main)/settings/_layout/Body/index.tsx
@@ -5,6 +5,7 @@ import { memo, useMemo } from 'react';
import { Link, useLocation } from 'react-router';
import NavItem from '@/features/NavPanel/components/NavItem';
+import { getTabUrl, SearchSection } from '@/features/SettingsSearch';
import { useWorkspaceAwareNavigate } from '@/features/Workspace/useWorkspaceAwareNavigate';
import { SettingsTabs } from '@/store/global/initialState';
import { isModifierClick } from '@/utils/navigation';
@@ -26,54 +27,56 @@ const Body = memo(() => {
return SettingsTabs.Profile;
}, [location.pathname]);
- const getTabUrl = (tab: SettingsTabs) => {
- return tab === SettingsTabs.Provider ? '/settings/provider/all' : `/settings/${tab}`;
- };
-
return (
- <Flexbox paddingInline={4}>
- <Accordion
- gap={8}
- defaultExpandedKeys={[
- SettingsGroupKey.General,
- SettingsGroupKey.Subscription,
- SettingsGroupKey.Agent,
- SettingsGroupKey.System,
- ]}
- >
- {categoryGroups.map((group) => (
- <AccordionItem
- itemKey={group.key}
- key={group.key}
- paddingBlock={4}
- paddingInline={'8px 4px'}
- title={
- <Text ellipsis fontSize={12} type={'secondary'} weight={500}>
- {group.title}
- </Text>
- }
- >
- <Flexbox gap={1} paddingBlock={1}>
- {group.items.map((item) => {
- const url = item.href ?? getTabUrl(item.key);
- return (
- <Link
- key={item.key}
- to={url}
- onClick={(e) => {
- if (isModifierClick(e)) return;
- e.preventDefault();
- navigate(url);
- }}
- >
- <NavItem active={activeTab === item.key} icon={item.icon} title={item.label} />
- </Link>
- );
- })}
- </Flexbox>
- </AccordionItem>
- ))}
- </Accordion>
+ <Flexbox gap={4} paddingInline={4}>
+ <SearchSection>
+ <Accordion
+ gap={8}
+ defaultExpandedKeys={[
+ SettingsGroupKey.General,
+ SettingsGroupKey.Subscription,
+ SettingsGroupKey.Agent,
+ SettingsGroupKey.System,
+ ]}
+ >
+ {categoryGroups.map((group) => (
+ <AccordionItem
+ itemKey={group.key}
+ key={group.key}
+ paddingBlock={4}
+ paddingInline={'8px 4px'}
+ title={
+ <Text ellipsis fontSize={12} type={'secondary'} weight={500}>
+ {group.title}
+ </Text>
+ }
+ >
+ <Flexbox gap={1} paddingBlock={1}>
+ {group.items.map((item) => {
+ const url = item.href ?? getTabUrl(item.key);
+ return (
+ <Link
+ key={item.key}
+ to={url}
+ onClick={(e) => {
+ if (isModifierClick(e)) return;
+ e.preventDefault();
+ navigate(url);
+ }}
+ >
+ <NavItem
+ active={activeTab === item.key}
+ icon={item.icon}
+ title={item.label}
+ />
+ </Link>
+ );
+ })}
+ </Flexbox>
+ </AccordionItem>
+ ))}
+ </Accordion>
+ </SearchSection>
</Flexbox>
);
});
diff --git a/src/routes/(main)/settings/advanced/index.tsx b/src/routes/(main)/settings/advanced/index.tsx
index bfa06b0fc30..694bb75798b 100644
--- a/src/routes/(main)/settings/advanced/index.tsx
+++ b/src/routes/(main)/settings/advanced/index.tsx
@@ -12,6 +12,7 @@ import { useTranslation } from 'react-i18next';
import AsyncError from '@/components/AsyncError';
import { FORM_STYLE } from '@/const/layoutTokens';
+import { SettingsSearchAnchor } from '@/features/SettingsSearch/anchor';
import SettingHeader from '@/routes/(main)/settings/features/SettingHeader';
import { autoUpdateService } from '@/services/electron/autoUpdate';
import { serverConfigSelectors, useServerConfigStore } from '@/store/serverConfig';
@@ -118,7 +119,11 @@ const Page = memo(() => {
{
children: <Switch />,
desc: t('settingCommon.devMode.desc'),
- label: t('settingCommon.devMode.title'),
+ label: (
+ <SettingsSearchAnchor id={'advanced-dev-mode'}>
+ {t('settingCommon.devMode.title')}
+ </SettingsSearchAnchor>
+ ),
minWidth: undefined,
name: 'isDevMode',
valuePropName: 'checked',
@@ -134,7 +139,11 @@ const Page = memo(() => {
),
className: styles.labItem,
desc: t('tab.advanced.gatewayMode.desc'),
- label: t('tab.advanced.gatewayMode.title'),
+ label: (
+ <SettingsSearchAnchor id={'advanced-gateway-mode'}>
+ {t('tab.advanced.gatewayMode.title')}
+ </SettingsSearchAnchor>
+ ),
minWidth: undefined,
} satisfies FormItemProps,
]
@@ -156,7 +165,11 @@ const Page = memo(() => {
<Select options={channelOptions} value={channel} onChange={handleChannelChange} />
),
desc: t('tab.advanced.updateChannel.desc'),
- label: t('tab.advanced.updateChannel.title'),
+ label: (
+ <SettingsSearchAnchor id={'advanced-update-channel'}>
+ {t('tab.advanced.updateChannel.title')}
+ </SettingsSearchAnchor>
+ ),
},
],
title: t('tab.advanced.appUpdates.title'),
@@ -297,7 +310,7 @@ const Page = memo(() => {
const labsGroup: FormGroupItemType = {
children: labItems,
- title: tLabs('title'),
+ title: <SettingsSearchAnchor id={'advanced-labs'}>{tLabs('title')}</SettingsSearchAnchor>,
};
const items = isDesktop
diff --git a/src/routes/(main)/settings/appearance/features/Desktop.tsx b/src/routes/(main)/settings/appearance/features/Desktop.tsx
index 410e8261d5b..dc204bdd623 100644
--- a/src/routes/(main)/settings/appearance/features/Desktop.tsx
+++ b/src/routes/(main)/settings/appearance/features/Desktop.tsx
@@ -8,6 +8,7 @@ import { memo, useState } from 'react';
import { useTranslation } from 'react-i18next';
import { FORM_STYLE } from '@/const/layoutTokens';
+import { SettingsSearchAnchor } from '@/features/SettingsSearch/anchor';
import { useElectronStore } from '@/store/electron';
const Desktop = memo(() => {
@@ -41,7 +42,11 @@ const Desktop = memo(() => {
/>
),
desc: t('settingAppearance.appTray.desc'),
- label: t('settingAppearance.appTray.title'),
+ label: (
+ <SettingsSearchAnchor id={'appearance-app-tray'}>
+ {t('settingAppearance.appTray.title')}
+ </SettingsSearchAnchor>
+ ),
minWidth: undefined,
},
],
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 5f61d5116a0..bf7860ff844 100644
--- a/src/routes/(main)/settings/chat-appearance/features/ChatAppearance/index.tsx
+++ b/src/routes/(main)/settings/chat-appearance/features/ChatAppearance/index.tsx
@@ -14,6 +14,7 @@ import { memo, useState } from 'react';
import { useTranslation } from 'react-i18next';
import AutoSaveHint from '@/components/Editor/AutoSaveHint';
+import { SettingsSearchAnchor } from '@/features/SettingsSearch/anchor';
import { useSaveState } from '@/hooks/useSaveState';
import { useUserStore } from '@/store/user';
import { settingsSelectors } from '@/store/user/selectors';
@@ -121,7 +122,6 @@ const ChatAppearance = memo(() => {
collapsible={false}
desc={t('settingChatAppearance.fontSize.desc')}
gap={16}
- title={t('settingChatAppearance.fontSize.title')}
variant={'filled'}
extra={
<Flexbox horizontal align={'center'} gap={8}>
@@ -161,6 +161,11 @@ const ChatAppearance = memo(() => {
/>
</Flexbox>
}
+ title={
+ <SettingsSearchAnchor id={'appearance-font-size'}>
+ {t('settingChatAppearance.fontSize.title')}
+ </SettingsSearchAnchor>
+ }
>
<ChatPreview fontSize={general.fontSize} />
</FormGroup>
diff --git a/src/routes/(main)/settings/common/features/Appearance/index.tsx b/src/routes/(main)/settings/common/features/Appearance/index.tsx
index 2c8d31de4de..fefd12d75c2 100644
--- a/src/routes/(main)/settings/common/features/Appearance/index.tsx
+++ b/src/routes/(main)/settings/common/features/Appearance/index.tsx
@@ -8,6 +8,7 @@ import { useTranslation } from 'react-i18next';
import AutoSaveHint from '@/components/Editor/AutoSaveHint';
import { FORM_STYLE } from '@/const/layoutTokens';
+import { SettingsSearchAnchor } from '@/features/SettingsSearch/anchor';
import { useSaveState } from '@/hooks/useSaveState';
import { useUserStore } from '@/store/user';
import { settingsSelectors } from '@/store/user/slices/settings/selectors';
@@ -33,14 +34,22 @@ const Appearance = memo(() => {
{
children: <ThemeSwatchesPrimary />,
desc: t('settingAppearance.primaryColor.desc'),
- label: t('settingAppearance.primaryColor.title'),
+ label: (
+ <SettingsSearchAnchor id={'appearance-primary-color'}>
+ {t('settingAppearance.primaryColor.title')}
+ </SettingsSearchAnchor>
+ ),
minWidth: undefined,
name: 'primaryColor',
},
{
children: <ThemeSwatchesNeutral />,
desc: t('settingAppearance.neutralColor.desc'),
- label: t('settingAppearance.neutralColor.title'),
+ label: (
+ <SettingsSearchAnchor id={'appearance-neutral-color'}>
+ {t('settingAppearance.neutralColor.title')}
+ </SettingsSearchAnchor>
+ ),
minWidth: undefined,
name: 'neutralColor',
},
diff --git a/src/routes/(main)/settings/common/features/Common/Common.tsx b/src/routes/(main)/settings/common/features/Common/Common.tsx
index 65f9fb8b3cd..200abb95df6 100644
--- a/src/routes/(main)/settings/common/features/Common/Common.tsx
+++ b/src/routes/(main)/settings/common/features/Common/Common.tsx
@@ -13,6 +13,7 @@ import AutoSaveHint from '@/components/Editor/AutoSaveHint';
import { FORM_STYLE } from '@/const/layoutTokens';
import { imageUrl } from '@/const/url';
import { isDesktop } from '@/const/version';
+import { SettingsSearchAnchor } from '@/features/SettingsSearch/anchor';
import { useSaveState } from '@/hooks/useSaveState';
import { localeOptions } from '@/locales/resources';
import { useGlobalStore } from '@/store/global';
@@ -73,7 +74,11 @@ const Common = memo(() => {
onChange={(value) => setTheme(value === 'auto' ? 'system' : value)}
/>
),
- label: t('settingCommon.themeMode.title'),
+ label: (
+ <SettingsSearchAnchor id={'appearance-theme-mode'}>
+ {t('settingCommon.themeMode.title')}
+ </SettingsSearchAnchor>
+ ),
minWidth: undefined,
},
{
@@ -92,7 +97,11 @@ const Common = memo(() => {
/>
</Flexbox>
),
- label: t('settingCommon.lang.title'),
+ label: (
+ <SettingsSearchAnchor id={'appearance-language'}>
+ {t('settingCommon.lang.title')}
+ </SettingsSearchAnchor>
+ ),
},
{
children: (
@@ -117,7 +126,11 @@ const Common = memo(() => {
/>
),
desc: t('settingAppearance.animationMode.desc'),
- label: t('settingAppearance.animationMode.title'),
+ label: (
+ <SettingsSearchAnchor id={'appearance-animation'}>
+ {t('settingAppearance.animationMode.title')}
+ </SettingsSearchAnchor>
+ ),
minWidth: undefined,
name: 'animationMode',
valuePropName: 'activeKey',
@@ -140,7 +153,11 @@ const Common = memo(() => {
/>
),
desc: t('settingAppearance.contextMenuMode.desc'),
- label: t('settingAppearance.contextMenuMode.title'),
+ label: (
+ <SettingsSearchAnchor id={'appearance-context-menu'}>
+ {t('settingAppearance.contextMenuMode.title')}
+ </SettingsSearchAnchor>
+ ),
minWidth: undefined,
name: 'contextMenuMode',
valuePropName: 'activeKey',
@@ -164,7 +181,11 @@ const Common = memo(() => {
</Flexbox>
),
desc: t('settingCommon.responseLanguage.desc'),
- label: t('settingCommon.responseLanguage.title'),
+ label: (
+ <SettingsSearchAnchor id={'appearance-response-language'}>
+ {t('settingCommon.responseLanguage.title')}
+ </SettingsSearchAnchor>
+ ),
},
],
extra: <AutoSaveHint lastUpdatedTime={lastSavedAt} saveStatus={saveStatus} onRetry={retry} />,
diff --git a/src/routes/(main)/settings/features/SettingsContent.tsx b/src/routes/(main)/settings/features/SettingsContent.tsx
index f9ba83d9fd2..18c32d9ed43 100644
--- a/src/routes/(main)/settings/features/SettingsContent.tsx
+++ b/src/routes/(main)/settings/features/SettingsContent.tsx
@@ -4,6 +4,7 @@ import { Fragment, useEffect } from 'react';
import NavHeader from '@/features/NavHeader';
import SettingContainer from '@/features/Setting/SettingContainer';
+import { useSettingsAnchorScroll } from '@/features/SettingsSearch/anchor';
import { useWorkspaceAwareNavigate } from '@/features/Workspace/useWorkspaceAwareNavigate';
import { SettingsTabs } from '@/store/global/initialState';
import { serverConfigSelectors, useServerConfigStore } from '@/store/serverConfig';
@@ -27,6 +28,8 @@ const SettingsContent = ({ mobile, activeTab }: SettingsContentProps) => {
const enableBusinessFeatures = useServerConfigStore(serverConfigSelectors.enableBusinessFeatures);
const navigate = useWorkspaceAwareNavigate();
+ useSettingsAnchorScroll();
+
useEffect(() => {
if (activeTab && REDIRECT_MAP[activeTab]) {
// Personal-only redirect: legacy URL aliases (common, agent, tts, image,
diff --git a/src/routes/(main)/settings/hotkey/features/Conversation.tsx b/src/routes/(main)/settings/hotkey/features/Conversation.tsx
index 0dd7c402f02..24986386895 100644
--- a/src/routes/(main)/settings/hotkey/features/Conversation.tsx
+++ b/src/routes/(main)/settings/hotkey/features/Conversation.tsx
@@ -10,6 +10,7 @@ import { useTranslation } from 'react-i18next';
import AutoSaveHint from '@/components/Editor/AutoSaveHint';
import { HOTKEYS_REGISTRATION } from '@/const/hotkeys';
import { FORM_STYLE } from '@/const/layoutTokens';
+import { SettingsSearchAnchor } from '@/features/SettingsSearch/anchor';
import { useSaveState } from '@/hooks/useSaveState';
import hotkeyMeta from '@/locales/default/hotkey';
import { useUserStore } from '@/store/user';
@@ -64,7 +65,11 @@ const HotkeySetting = memo(() => {
(item) => item.group === HotkeyGroupEnum.Conversation,
).map((item) => mapHotkeyItem(item)),
extra: <AutoSaveHint lastUpdatedTime={lastSavedAt} saveStatus={saveStatus} onRetry={retry} />,
- title: t('hotkey.group.conversation'),
+ title: (
+ <SettingsSearchAnchor id={'hotkey-conversation'}>
+ {t('hotkey.group.conversation')}
+ </SettingsSearchAnchor>
+ ),
};
return (
diff --git a/src/routes/(main)/settings/hotkey/features/Desktop.tsx b/src/routes/(main)/settings/hotkey/features/Desktop.tsx
index b592321f370..fe7cbb00c51 100644
--- a/src/routes/(main)/settings/hotkey/features/Desktop.tsx
+++ b/src/routes/(main)/settings/hotkey/features/Desktop.tsx
@@ -10,6 +10,7 @@ import { useTranslation } from 'react-i18next';
import { DESKTOP_HOTKEYS_REGISTRATION } from '@/const/desktopGlobalShortcuts';
import { FORM_STYLE } from '@/const/layoutTokens';
+import { SettingsSearchAnchor } from '@/features/SettingsSearch/anchor';
import hotkeyMeta from '@/locales/default/hotkey';
import { useElectronStore } from '@/store/electron';
import { desktopHotkeysSelectors } from '@/store/electron/selectors';
@@ -74,7 +75,9 @@ const HotkeySetting = memo(() => {
const desktop: FormGroupItemType = {
children: DESKTOP_HOTKEYS_REGISTRATION.map((item) => mapHotkeyItem(item)),
extra: loading && <Icon spin icon={Loader2Icon} size={16} style={{ opacity: 0.5 }} />,
- title: t('hotkey.group.desktop'),
+ title: (
+ <SettingsSearchAnchor id={'hotkey-desktop'}>{t('hotkey.group.desktop')}</SettingsSearchAnchor>
+ ),
};
return (
diff --git a/src/routes/(main)/settings/hotkey/features/Essential.tsx b/src/routes/(main)/settings/hotkey/features/Essential.tsx
index 6e5ba1a1020..ac4f9c5aa0b 100644
--- a/src/routes/(main)/settings/hotkey/features/Essential.tsx
+++ b/src/routes/(main)/settings/hotkey/features/Essential.tsx
@@ -10,6 +10,7 @@ import { useTranslation } from 'react-i18next';
import AutoSaveHint from '@/components/Editor/AutoSaveHint';
import { HOTKEYS_REGISTRATION } from '@/const/hotkeys';
import { FORM_STYLE } from '@/const/layoutTokens';
+import { SettingsSearchAnchor } from '@/features/SettingsSearch/anchor';
import { useSaveState } from '@/hooks/useSaveState';
import hotkeyMeta from '@/locales/default/hotkey';
import { useUserStore } from '@/store/user';
@@ -64,7 +65,11 @@ const HotkeySetting = memo(() => {
(item) => mapHotkeyItem(item),
),
extra: <AutoSaveHint lastUpdatedTime={lastSavedAt} saveStatus={saveStatus} onRetry={retry} />,
- title: t('hotkey.group.essential'),
+ title: (
+ <SettingsSearchAnchor id={'hotkey-essential'}>
+ {t('hotkey.group.essential')}
+ </SettingsSearchAnchor>
+ ),
};
return (
diff --git a/src/routes/(main)/settings/image/features/Image.tsx b/src/routes/(main)/settings/image/features/Image.tsx
index 9abc3aae3e2..00e39eaf83d 100644
--- a/src/routes/(main)/settings/image/features/Image.tsx
+++ b/src/routes/(main)/settings/image/features/Image.tsx
@@ -10,6 +10,7 @@ import { useTranslation } from 'react-i18next';
import { FormSliderWithInput } from '@/components/FormInput';
import { FORM_STYLE } from '@/const/layoutTokens';
import { MAX_DEFAULT_IMAGE_NUM, MIN_DEFAULT_IMAGE_NUM } from '@/const/settings';
+import { SettingsSearchAnchor } from '@/features/SettingsSearch/anchor';
import { usePermission } from '@/hooks/usePermission';
import { useUserStore } from '@/store/user';
import { settingsSelectors } from '@/store/user/slices/settings/selectors';
@@ -49,7 +50,11 @@ const ImageSettings = memo(() => {
extra: isUpdating ? (
<Icon spin icon={Loader2Icon} size={16} style={{ opacity: 0.6 }} />
) : undefined,
- title: t('settingImage.defaultCount.title'),
+ title: (
+ <SettingsSearchAnchor id={'service-model-image'}>
+ {t('settingImage.defaultCount.title')}
+ </SettingsSearchAnchor>
+ ),
},
];
diff --git a/src/routes/(main)/settings/profile/features/AvatarRow.tsx b/src/routes/(main)/settings/profile/features/AvatarRow.tsx
index 5f0da4fbdd5..a95e7c6da9f 100644
--- a/src/routes/(main)/settings/profile/features/AvatarRow.tsx
+++ b/src/routes/(main)/settings/profile/features/AvatarRow.tsx
@@ -105,7 +105,9 @@ const AvatarRow = () => {
<UserAvatar size={40} />
);
- return <ProfileRow action={avatarContent} label={t('profile.avatar')} />;
+ return (
+ <ProfileRow action={avatarContent} anchor={'profile-avatar'} label={t('profile.avatar')} />
+ );
};
export default AvatarRow;
diff --git a/src/routes/(main)/settings/profile/features/EmailRow.tsx b/src/routes/(main)/settings/profile/features/EmailRow.tsx
index db20730af6a..f98757fe4ae 100644
--- a/src/routes/(main)/settings/profile/features/EmailRow.tsx
+++ b/src/routes/(main)/settings/profile/features/EmailRow.tsx
@@ -116,6 +116,7 @@ const EmailRow = () => {
return (
<ProfileRow
+ anchor={'profile-email'}
label={t('profile.email')}
action={
!isEditing && (
diff --git a/src/routes/(main)/settings/profile/features/FullNameRow.tsx b/src/routes/(main)/settings/profile/features/FullNameRow.tsx
index f7676ad4f8d..879eca8629e 100644
--- a/src/routes/(main)/settings/profile/features/FullNameRow.tsx
+++ b/src/routes/(main)/settings/profile/features/FullNameRow.tsx
@@ -38,7 +38,7 @@ const FullNameRow = () => {
}, [fullName, updateFullName]);
return (
- <ProfileRow label={t('profile.fullName')}>
+ <ProfileRow anchor={'profile-full-name'} label={t('profile.fullName')}>
<Flexbox horizontal align="center" gap={8}>
{saving && <Icon spin icon={Loader2Icon} size={16} style={{ opacity: 0.5 }} />}
<Input
diff --git a/src/routes/(main)/settings/profile/features/InterestsRow.tsx b/src/routes/(main)/settings/profile/features/InterestsRow.tsx
index 1c540f37199..200e81afc59 100644
--- a/src/routes/(main)/settings/profile/features/InterestsRow.tsx
+++ b/src/routes/(main)/settings/profile/features/InterestsRow.tsx
@@ -79,7 +79,7 @@ const InterestsRow = () => {
}, [customInput, normalizedInterests, saveInterests]);
return (
- <ProfileRow label={t('profile.interests')}>
+ <ProfileRow anchor={'profile-interests'} label={t('profile.interests')}>
<Flexbox gap={12}>
<Flexbox horizontal align="center" gap={8} wrap="wrap">
{areas.map((item) => {
diff --git a/src/routes/(main)/settings/profile/features/PasswordRow.tsx b/src/routes/(main)/settings/profile/features/PasswordRow.tsx
index a5f35e2e452..c2e584965d4 100644
--- a/src/routes/(main)/settings/profile/features/PasswordRow.tsx
+++ b/src/routes/(main)/settings/profile/features/PasswordRow.tsx
@@ -41,6 +41,7 @@ const PasswordRow = () => {
return (
<ProfileRow
+ anchor={'profile-password'}
label={t('profile.password')}
action={
<Button loading={sending} size="small" onClick={handleChangePassword}>
diff --git a/src/routes/(main)/settings/profile/features/ProfileRow.tsx b/src/routes/(main)/settings/profile/features/ProfileRow.tsx
index 23105c52a7b..0b0a26fa57a 100644
--- a/src/routes/(main)/settings/profile/features/ProfileRow.tsx
+++ b/src/routes/(main)/settings/profile/features/ProfileRow.tsx
@@ -4,8 +4,12 @@ import { Text } from '@lobehub/ui';
import { createStaticStyles } from 'antd-style';
import { type ReactNode } from 'react';
+import { SETTINGS_ANCHOR_ROW_ATTR, SettingsSearchAnchor } from '@/features/SettingsSearch/anchor';
+
interface ProfileRowProps {
action?: ReactNode;
+ /** Settings-search anchor id; when set, the row becomes a scroll/highlight target */
+ anchor?: string;
children?: ReactNode;
label?: string;
labelSlot?: ReactNode;
@@ -50,10 +54,14 @@ const styles = createStaticStyles(({ css, responsive }) => ({
`,
}));
-const ProfileRow = ({ label, labelSlot, children, action }: ProfileRowProps) => {
+const ProfileRow = ({ anchor, label, labelSlot, children, action }: ProfileRowProps) => {
+ const labelNode = labelSlot ?? (label && <Text strong>{label}</Text>);
+
return (
- <div className={styles.row}>
- <div className={styles.label}>{labelSlot ?? (label && <Text strong>{label}</Text>)}</div>
+ <div className={styles.row} {...(anchor ? { [SETTINGS_ANCHOR_ROW_ATTR]: '' } : undefined)}>
+ <div className={styles.label}>
+ {anchor ? <SettingsSearchAnchor id={anchor}>{labelNode}</SettingsSearchAnchor> : labelNode}
+ </div>
<div className={styles.body}>
{children}
{action && <div className={styles.action}>{action}</div>}
diff --git a/src/routes/(main)/settings/profile/features/UsernameRow.tsx b/src/routes/(main)/settings/profile/features/UsernameRow.tsx
index 7c414937e1c..80aa266d7a2 100644
--- a/src/routes/(main)/settings/profile/features/UsernameRow.tsx
+++ b/src/routes/(main)/settings/profile/features/UsernameRow.tsx
@@ -91,7 +91,7 @@ const UsernameRow = () => {
}, [username]);
return (
- <ProfileRow label={t('profile.username')}>
+ <ProfileRow anchor={'profile-username'} label={t('profile.username')}>
<Flexbox horizontal align="center" gap={8}>
{saving && <Icon spin icon={Loader2Icon} size={16} style={{ opacity: 0.5 }} />}
{error && (
diff --git a/src/routes/(main)/settings/profile/index.tsx b/src/routes/(main)/settings/profile/index.tsx
index c34f35abeee..53995c1206b 100644
--- a/src/routes/(main)/settings/profile/index.tsx
+++ b/src/routes/(main)/settings/profile/index.tsx
@@ -112,7 +112,7 @@ const ProfileSetting = () => {
{isLogin && !isDesktop && isLoadedAuthProviders && (
<>
<Divider style={{ margin: 0 }} />
- <ProfileRow label={t('profile.sso.providers')}>
+ <ProfileRow anchor={'profile-connected-accounts'} label={t('profile.sso.providers')}>
<SSOProvidersList />
</ProfileRow>
</>
@@ -121,7 +121,10 @@ const ProfileSetting = () => {
{enableComposio && isServersInit && connectedServers.length > 0 && (
<>
<Divider style={{ margin: 0 }} />
- <ProfileRow label={t('profile.authorizations.title')}>
+ <ProfileRow
+ anchor={'profile-authorizations'}
+ label={t('profile.authorizations.title')}
+ >
<ComposioAuthorizationList servers={connectedServers} />
</ProfileRow>
</>
diff --git a/src/routes/(main)/settings/proxy/features/ProxyForm.tsx b/src/routes/(main)/settings/proxy/features/ProxyForm.tsx
index 373b81270ba..3a59acb548d 100644
--- a/src/routes/(main)/settings/proxy/features/ProxyForm.tsx
+++ b/src/routes/(main)/settings/proxy/features/ProxyForm.tsx
@@ -9,6 +9,7 @@ import { useCallback, useEffect, useRef, useState } from 'react';
import { useTranslation } from 'react-i18next';
import { FORM_STYLE } from '@/const/layoutTokens';
+import { SettingsSearchAnchor } from '@/features/SettingsSearch/anchor';
import { desktopSettingsService } from '@/services/electron/settings';
import { useElectronStore } from '@/store/electron';
@@ -212,7 +213,7 @@ const ProxyForm = () => {
{
children: <Switch />,
desc: t('proxy.enableDesc'),
- label: t('proxy.enable'),
+ label: <SettingsSearchAnchor id={'proxy-enable'}>{t('proxy.enable')}</SettingsSearchAnchor>,
layout: 'horizontal',
minWidth: undefined,
name: 'enableProxy',
@@ -260,7 +261,7 @@ const ProxyForm = () => {
{
children: <Switch disabled={!isEnableProxy} />,
desc: t('proxy.authDesc'),
- label: t('proxy.auth'),
+ label: <SettingsSearchAnchor id={'proxy-auth'}>{t('proxy.auth')}</SettingsSearchAnchor>,
layout: 'horizontal',
minWidth: undefined,
name: 'proxyRequireAuth',
@@ -308,7 +309,7 @@ const ProxyForm = () => {
</Space.Compact>
),
desc: t('proxy.testDescription'),
- label: t('proxy.testUrl'),
+ label: <SettingsSearchAnchor id={'proxy-test'}>{t('proxy.testUrl')}</SettingsSearchAnchor>,
minWidth: undefined,
},
],
diff --git a/src/routes/(main)/settings/storage/features/Advanced.tsx b/src/routes/(main)/settings/storage/features/Advanced.tsx
index f8114e27684..39c58df6c52 100644
--- a/src/routes/(main)/settings/storage/features/Advanced.tsx
+++ b/src/routes/(main)/settings/storage/features/Advanced.tsx
@@ -13,6 +13,7 @@ import AccountDeletion from '@/business/client/features/AccountDeletion';
import { useTransferAgentsFormItem } from '@/business/client/hooks/useTransferAgentsFormItem';
import { FORM_STYLE } from '@/const/layoutTokens';
import DataImporter from '@/features/DataImporter';
+import { SettingsSearchAnchor } from '@/features/SettingsSearch/anchor';
import { configService } from '@/services/config';
import { useServerConfigStore } from '@/store/serverConfig';
import { featureFlagsSelectors, serverConfigSelectors } from '@/store/serverConfig/selectors';
@@ -55,7 +56,11 @@ const AdvancedActions = () => {
{t('storage.actions.export.button')}
</Button>
),
- label: t('storage.actions.export.title'),
+ label: (
+ <SettingsSearchAnchor id={'storage-export'}>
+ {t('storage.actions.export.title')}
+ </SettingsSearchAnchor>
+ ),
layout: 'horizontal',
minWidth: undefined,
} as const;
@@ -71,7 +76,11 @@ const AdvancedActions = () => {
</Button>
</DataImporter>
),
- label: t('storage.actions.import.title'),
+ label: (
+ <SettingsSearchAnchor id={'storage-import'}>
+ {t('storage.actions.import.title')}
+ </SettingsSearchAnchor>
+ ),
layout: 'horizontal',
minWidth: undefined,
},
@@ -83,7 +92,11 @@ const AdvancedActions = () => {
</Button>
),
desc: t('danger.reset.desc'),
- label: t('danger.reset.title'),
+ label: (
+ <SettingsSearchAnchor id={'storage-reset'}>
+ {t('danger.reset.title')}
+ </SettingsSearchAnchor>
+ ),
layout: 'horizontal',
minWidth: undefined,
},
@@ -103,7 +116,11 @@ const AdvancedActions = () => {
/>
),
desc: t('analytics.telemetry.desc', { appName: BRANDING_NAME }),
- label: t('analytics.telemetry.title'),
+ label: (
+ <SettingsSearchAnchor id={'storage-telemetry'}>
+ {t('analytics.telemetry.title')}
+ </SettingsSearchAnchor>
+ ),
minWidth: undefined,
valuePropName: 'checked',
},
diff --git a/src/routes/(main)/settings/tts/features/OpenAI.tsx b/src/routes/(main)/settings/tts/features/OpenAI.tsx
index c48ba8a362b..49f0bc9b168 100644
--- a/src/routes/(main)/settings/tts/features/OpenAI.tsx
+++ b/src/routes/(main)/settings/tts/features/OpenAI.tsx
@@ -9,6 +9,7 @@ import { memo, useState } from 'react';
import { useTranslation } from 'react-i18next';
import { FORM_STYLE } from '@/const/layoutTokens';
+import { SettingsSearchAnchor } from '@/features/SettingsSearch/anchor';
import { usePermission } from '@/hooks/usePermission';
import { useUserStore } from '@/store/user';
import { settingsSelectors } from '@/store/user/selectors';
@@ -37,7 +38,11 @@ const OpenAI = memo(() => {
/>
</Tooltip>
),
- label: t('settingTTS.openai.ttsModel'),
+ label: (
+ <SettingsSearchAnchor id={'service-model-tts'}>
+ {t('settingTTS.openai.ttsModel')}
+ </SettingsSearchAnchor>
+ ),
name: ['openAI', 'ttsModel'],
},
],