🤯 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.
TypeScript agentagent-collaborationagent-harnessloop-engineeringmcppersonal-assistantproactive-agentskillssuper-agenttask-management
✨ feat(desktop): font fallback stacks and title-bar-safe floating popups (#19332)
Inneib796bb7e1510
diff --git a/locales/en-US/setting.json b/locales/en-US/setting.jsonindex 9062ab9d7a5..9d620434f08 100644--- a/locales/en-US/setting.json+++ b/locales/en-US/setting.json@@ -921,6 +921,13 @@"settingAppearance.contextMenuMode.disabled": "Disabled","settingAppearance.contextMenuMode.title": "Right-Click Menu Mode","settingAppearance.desktop.title": "Desktop",+ "settingAppearance.font.fallback.add": "Add fallback font",+ "settingAppearance.font.fallback.desc": "When the interface font is missing a glyph, these fonts are tried in order. A common pairing is a Latin font first and a CJK font second.",+ "settingAppearance.font.fallback.limit": "Up to {{count}} fallback fonts",+ "settingAppearance.font.fallback.needPrimary": "Choose an interface font first.",+ "settingAppearance.font.fallback.placeholder": "Choose a fallback font",+ "settingAppearance.font.fallback.remove": "Remove fallback font",+ "settingAppearance.font.fallback.title": "Fallback Fonts","settingAppearance.font.fontFamily.default": "System Default","settingAppearance.font.fontFamily.desc": "Choose a font installed on this device for the whole interface. System Default follows the built-in font stack of your current language.","settingAppearance.font.fontFamily.loadError": "System fonts could not be loaded. System Default remains available.",@@ -931,6 +938,9 @@"settingAppearance.font.monospace.loadError": "System fonts could not be loaded. System Default remains available.","settingAppearance.font.monospace.title": "Monospace Font","settingAppearance.font.monospace.unavailable": "{{font}} (Unavailable on this device)",+ "settingAppearance.font.monospaceFallback.desc": "Tried in order after the monospace font, for code blocks and the built-in terminal.",+ "settingAppearance.font.monospaceFallback.needPrimary": "Choose a monospace font first.",+ "settingAppearance.font.monospaceFallback.title": "Monospace Fallback Fonts","settingAppearance.font.title": "Font","settingAppearance.neutralColor.desc": "Custom grayscale with different color tendencies","settingAppearance.neutralColor.title": "Neutral Color",diff --git a/locales/zh-CN/setting.json b/locales/zh-CN/setting.jsonindex b9749c8d759..db650ecfe6e 100644--- a/locales/zh-CN/setting.json+++ b/locales/zh-CN/setting.json@@ -921,6 +921,13 @@"settingAppearance.contextMenuMode.disabled": "不使用","settingAppearance.contextMenuMode.title": "右键菜单方案","settingAppearance.desktop.title": "桌面",+ "settingAppearance.font.fallback.add": "添加回退字体",+ "settingAppearance.font.fallback.desc": "界面字体缺少某些字形时,按此顺序逐个尝试。常见搭配:西文字体在前,中文字体在后。",+ "settingAppearance.font.fallback.limit": "最多 {{count}} 个回退字体",+ "settingAppearance.font.fallback.needPrimary": "请先选择界面字体。",+ "settingAppearance.font.fallback.placeholder": "选择回退字体",+ "settingAppearance.font.fallback.remove": "移除回退字体",+ "settingAppearance.font.fallback.title": "回退字体","settingAppearance.font.fontFamily.default": "跟随系统","settingAppearance.font.fontFamily.desc": "为整个界面选择本机已安装的字体。选择「跟随系统」将使用当前语言对应的内置字体方案。","settingAppearance.font.fontFamily.loadError": "无法加载系统字体,仍可选择「跟随系统」。",@@ -931,6 +938,9 @@"settingAppearance.font.monospace.loadError": "无法加载系统字体,仍可选择「跟随系统」。","settingAppearance.font.monospace.title": "等宽字体","settingAppearance.font.monospace.unavailable": "{{font}}(本机未安装)",+ "settingAppearance.font.monospaceFallback.desc": "用于代码块与内置终端,在等宽字体之后按顺序尝试。",+ "settingAppearance.font.monospaceFallback.needPrimary": "请先选择等宽字体。",+ "settingAppearance.font.monospaceFallback.title": "等宽回退字体","settingAppearance.font.title": "字体","settingAppearance.neutralColor.desc": "不同色彩倾向的灰阶自定义","settingAppearance.neutralColor.title": "中性色",diff --git a/package.json b/package.jsonindex 3c5030dcdc2..5b5290ef00e 100644--- a/package.json+++ b/package.json@@ -314,7 +314,7 @@"@lobehub/icons": "^5.18.0","@lobehub/market-sdk": "0.41.0","@lobehub/tts": "^5.1.2",- "@lobehub/ui": "^5.38.0",+ "@lobehub/ui": "^5.40.3","@modelcontextprotocol/sdk": "^1.30.0","@neondatabase/serverless": "^1.1.0","@next/third-parties": "^16.3.0",diff --git a/packages/locales/src/default/setting.ts b/packages/locales/src/default/setting.tsindex a8990b74b33..42cfe5d6f07 100644--- a/packages/locales/src/default/setting.ts+++ b/packages/locales/src/default/setting.ts@@ -1068,6 +1068,14 @@ export default {'System fonts could not be loaded. System Default remains available.','settingAppearance.font.fontFamily.title': 'Interface Font','settingAppearance.font.fontFamily.unavailable': '{{font}} (Unavailable on this device)',+ 'settingAppearance.font.fallback.add': 'Add fallback font',+ 'settingAppearance.font.fallback.desc':+ 'When the interface font is missing a glyph, these fonts are tried in order. A common pairing is a Latin font first and a CJK font second.',+ 'settingAppearance.font.fallback.limit': 'Up to {{count}} fallback fonts',+ 'settingAppearance.font.fallback.needPrimary': 'Choose an interface font first.',+ 'settingAppearance.font.fallback.placeholder': 'Choose a fallback font',+ 'settingAppearance.font.fallback.remove': 'Remove fallback font',+ 'settingAppearance.font.fallback.title': 'Fallback Fonts','settingAppearance.font.monospace.default': 'System Default','settingAppearance.font.monospace.desc':'Used by code blocks and the built-in terminal. Choose a monospaced font installed on this device.',@@ -1075,6 +1083,10 @@ export default {'System fonts could not be loaded. System Default remains available.','settingAppearance.font.monospace.title': 'Monospace Font','settingAppearance.font.monospace.unavailable': '{{font}} (Unavailable on this device)',+ 'settingAppearance.font.monospaceFallback.desc':+ 'Tried in order after the monospace font, for code blocks and the built-in terminal.',+ 'settingAppearance.font.monospaceFallback.needPrimary': 'Choose a monospace font first.',+ 'settingAppearance.font.monospaceFallback.title': 'Monospace Fallback Fonts','settingAppearance.font.title': 'Font','settingAppearance.neutralColor.desc': 'Custom grayscale with different color tendencies','settingAppearance.neutralColor.title': 'Neutral Color',diff --git a/src/features/Settings/appearance/features/Font/FallbackFontList.tsx b/src/features/Settings/appearance/features/Font/FallbackFontList.tsxnew file mode 100644index 00000000000..56e27cf7b57--- /dev/null+++ b/src/features/Settings/appearance/features/Font/FallbackFontList.tsx@@ -0,0 +1,98 @@+'use client';++import { Flexbox, SortableList } from '@lobehub/ui';+import { ActionIcon, Button, Select, type SelectOption, Text } from '@lobehub/ui/base-ui';+import { PlusIcon, XIcon } from 'lucide-react';+import { useState } from 'react';+import { useTranslation } from 'react-i18next';++import { MAX_FALLBACK_FONTS } from './fontStack';+import { useFontFallbackStack } from './useFontFallbackStack';++const width = { width: 320 };++interface FallbackFontListProps {+ ariaLabel: string;+ loading?: boolean;+ needPrimaryHint: string;+ onChange: (stack: string[]) => void;+ options: SelectOption[];+ stack: string[];+}++const FallbackFontList = ({+ ariaLabel,+ loading,+ needPrimaryHint,+ onChange,+ options,+ stack,+}: FallbackFontListProps) => {+ const { t } = useTranslation('setting');+ const [adding, setAdding] = useState(false);+ const { add, atLimit, candidates, fallbacks, labelOf, primary, remove, reorder } =+ useFontFallbackStack({ onChange, options, stack });++ if (!primary) return <Text type={'secondary'}>{needPrimaryHint}</Text>;++ return (+ <Flexbox gap={6} style={width}>+ <SortableList+ gap={6}+ items={fallbacks.map((value) => ({ id: value }))}+ renderItem={(item) => (+ <SortableList.Item+ horizontal+ align={'center'}+ gap={4}+ id={item.id}+ justify={'space-between'}+ variant={'filled'}+ >+ <Text ellipsis style={{ flex: 1, fontFamily: item.id }}>+ {labelOf(item.id)}+ </Text>+ <ActionIcon+ aria-label={t('settingAppearance.font.fallback.remove')}+ icon={XIcon}+ size={'small'}+ title={t('settingAppearance.font.fallback.remove')}+ onClick={() => remove(item.id)}+ />+ <SortableList.DragHandle />+ </SortableList.Item>+ )}+ onChange={(next) => reorder(next.map((item) => item.id))}+ />+ {adding ? (+ <Select+ autoFocus+ defaultOpen+ showSearch+ aria-label={ariaLabel}+ loading={loading}+ options={candidates}+ placeholder={t('settingAppearance.font.fallback.placeholder')}+ onChange={(value: string) => add(value)}+ onOpenChange={(open) => {+ if (!open) setAdding(false);+ }}+ />+ ) : (+ <Button+ block+ disabled={atLimit}+ icon={PlusIcon}+ type={'dashed'}+ onClick={() => setAdding(true)}+ >+ {atLimit+ ? t('settingAppearance.font.fallback.limit', { count: MAX_FALLBACK_FONTS })+ : t('settingAppearance.font.fallback.add')}+ </Button>+ )}+ </Flexbox>+ );+};++export default FallbackFontList;diff --git a/src/features/Settings/appearance/features/Font/fontStack.test.ts b/src/features/Settings/appearance/features/Font/fontStack.test.tsnew file mode 100644index 00000000000..72fd0176532--- /dev/null+++ b/src/features/Settings/appearance/features/Font/fontStack.test.ts@@ -0,0 +1,33 @@+import { describe, expect, it } from 'vitest';++import { joinFontStack, parseFontStack } from './fontStack';++describe('parseFontStack', () => {+ it('returns an empty stack for empty or whitespace input', () => {+ expect(parseFontStack(undefined)).toEqual([]);+ expect(parseFontStack(' ')).toEqual([]);+ });++ it('splits on commas and keeps quoted names intact', () => {+ expect(parseFontStack('Inter, "LXGW WenKai" , Menlo')).toEqual([+ 'Inter',+ '"LXGW WenKai"',+ 'Menlo',+ ]);+ });++ it('drops empty segments and duplicates', () => {+ expect(parseFontStack('Inter,,Inter, Georgia')).toEqual(['Inter', 'Georgia']);+ });+});++describe('joinFontStack', () => {+ it('round-trips with parseFontStack', () => {+ const stack = ['Inter', '"LXGW WenKai"'];+ expect(parseFontStack(joinFontStack(stack))).toEqual(stack);+ });++ it('returns an empty string for an empty stack', () => {+ expect(joinFontStack([])).toBe('');+ });+});diff --git a/src/features/Settings/appearance/features/Font/fontStack.ts b/src/features/Settings/appearance/features/Font/fontStack.tsnew file mode 100644index 00000000000..b3a705a5259--- /dev/null+++ b/src/features/Settings/appearance/features/Font/fontStack.ts@@ -0,0 +1,16 @@+export const MAX_FALLBACK_FONTS = 3;++export const parseFontStack = (value?: string): string[] => {+ if (!value) return [];+ const seen = new Set<string>();+ const stack: string[] = [];+ for (const raw of value.split(',')) {+ const font = raw.trim();+ if (!font || seen.has(font)) continue;+ seen.add(font);+ stack.push(font);+ }+ return stack;+};++export const joinFontStack = (stack: string[]): string => stack.join(', ');diff --git a/src/features/Settings/appearance/features/Font/index.tsx b/src/features/Settings/appearance/features/Font/index.tsxindex b18f473d4b9..969700af4f5 100644--- a/src/features/Settings/appearance/features/Font/index.tsx+++ b/src/features/Settings/appearance/features/Font/index.tsx@@ -4,7 +4,7 @@ import { isDesktop } from '@lobechat/const';import type { FormGroupItemType } from '@lobehub/ui';import { Flexbox, Form } from '@lobehub/ui';import { Select, Skeleton } from '@lobehub/ui/base-ui';-import { memo } from 'react';+import { memo, useMemo } from 'react';import { useTranslation } from 'react-i18next';import AutoSaveHint from '@/components/Editor/AutoSaveHint';@@ -15,7 +15,9 @@ import { useUserStore } from '@/store/user';import { preferenceSelectors, userGeneralSettingsSelectors } from '@/store/user/selectors';import { APPLICATION_DEFAULT_FONT, useSystemFontOptions } from '../useSystemFontOptions';+import FallbackFontList from './FallbackFontList';import { FontSizeControl } from './FontSize';+import { joinFontStack, parseFontStack } from './fontStack';const wrapperCol = {style: {@@ -38,20 +40,28 @@ const FontSettings = memo(() => {const isUserStateInit = useUserStore((s) => s.isUserStateInit);const { status: saveStatus, lastSavedAt, save, retry } = useSaveState();+ const interfaceStack = useMemo(() => parseFontStack(fontFamily), [fontFamily]);+ const monospaceStack = useMemo(() => parseFontStack(monospaceFontFamily), [monospaceFontFamily]);+const interfaceFonts = useSystemFontOptions({defaultLabel: t('settingAppearance.font.fontFamily.default'),enabled: isDesktop,unavailableLabel: (font) => t('settingAppearance.font.fontFamily.unavailable', { font }),- value: fontFamily,+ values: interfaceStack,});const monospaceFonts = useSystemFontOptions({defaultLabel: t('settingAppearance.font.monospace.default'),enabled: isDesktop,monospaceOnly: true,unavailableLabel: (font) => t('settingAppearance.font.monospace.unavailable', { font }),- value: monospaceFontFamily,+ values: monospaceStack,});+ const saveInterfaceStack = (stack: string[]) =>+ save(() => updatePreference({ fontFamily: joinFontStack(stack) }));+ const saveMonospaceStack = (stack: string[]) =>+ save(() => updatePreference({ terminalFontFamily: joinFontStack(stack) }));+if (!isUserStateInit) {const loadingFont: FormGroupItemType = {children: [@@ -122,12 +132,10 @@ const FontSettings = memo(() => {loading={interfaceFonts.isLoading}options={interfaceFonts.options}style={{ width: 320 }}- value={fontFamily || APPLICATION_DEFAULT_FONT}+ value={interfaceStack[0] || APPLICATION_DEFAULT_FONT}onChange={(value: string) =>- save(() =>- updatePreference({- fontFamily: value === APPLICATION_DEFAULT_FONT ? '' : value,- }),+ saveInterfaceStack(+ value === APPLICATION_DEFAULT_FONT ? [] : [value, ...interfaceStack.slice(1)],)}/>@@ -142,6 +150,25 @@ const FontSettings = memo(() => {),minWidth: undefined,},+ {+ children: (+ <FallbackFontList+ ariaLabel={t('settingAppearance.font.fallback.title')}+ loading={interfaceFonts.isLoading}+ needPrimaryHint={t('settingAppearance.font.fallback.needPrimary')}+ options={interfaceFonts.options}+ stack={interfaceStack}+ onChange={saveInterfaceStack}+ />+ ),+ desc: t('settingAppearance.font.fallback.desc'),+ label: (+ <SettingsSearchAnchor id={'appearance-font-fallback'}>+ {t('settingAppearance.font.fallback.title')}+ </SettingsSearchAnchor>+ ),+ minWidth: undefined,+ },{children: (<Select@@ -150,12 +177,10 @@ const FontSettings = memo(() => {loading={monospaceFonts.isLoading}options={monospaceFonts.options}style={{ width: 320 }}- value={monospaceFontFamily || APPLICATION_DEFAULT_FONT}+ value={monospaceStack[0] || APPLICATION_DEFAULT_FONT}onChange={(value: string) =>- save(() =>- updatePreference({- terminalFontFamily: value === APPLICATION_DEFAULT_FONT ? '' : value,- }),+ saveMonospaceStack(+ value === APPLICATION_DEFAULT_FONT ? [] : [value, ...monospaceStack.slice(1)],)}/>@@ -170,6 +195,25 @@ const FontSettings = memo(() => {),minWidth: undefined,},+ {+ children: (+ <FallbackFontList+ ariaLabel={t('settingAppearance.font.monospaceFallback.title')}+ loading={monospaceFonts.isLoading}+ needPrimaryHint={t('settingAppearance.font.monospaceFallback.needPrimary')}+ options={monospaceFonts.options}+ stack={monospaceStack}+ onChange={saveMonospaceStack}+ />+ ),+ desc: t('settingAppearance.font.monospaceFallback.desc'),+ label: (+ <SettingsSearchAnchor id={'appearance-monospace-font-fallback'}>+ {t('settingAppearance.font.monospaceFallback.title')}+ </SettingsSearchAnchor>+ ),+ minWidth: undefined,+ },]: []),{diff --git a/src/features/Settings/appearance/features/Font/useFontFallbackStack.test.ts b/src/features/Settings/appearance/features/Font/useFontFallbackStack.test.tsnew file mode 100644index 00000000000..eb5f783b078--- /dev/null+++ b/src/features/Settings/appearance/features/Font/useFontFallbackStack.test.ts@@ -0,0 +1,71 @@+import { renderHook } from '@testing-library/react';+import { describe, expect, it, vi } from 'vitest';++import { APPLICATION_DEFAULT_FONT } from '../useSystemFontOptions';+import { useFontFallbackStack } from './useFontFallbackStack';++const options = [+ { label: 'System Default', value: APPLICATION_DEFAULT_FONT },+ { label: 'Inter', value: 'Inter' },+ { label: 'LXGW WenKai', value: '"LXGW WenKai"' },+ { label: 'Georgia', value: 'Georgia' },+ { label: 'Menlo', value: 'Menlo' },+];++const setup = (stack: string[]) => {+ const onChange = vi.fn();+ const { result } = renderHook(() => useFontFallbackStack({ onChange, options, stack }));+ return { onChange, result };+};++describe('useFontFallbackStack', () => {+ it('splits the stack into primary and fallbacks', () => {+ const { result } = setup(['Inter', 'Georgia']);++ expect(result.current.primary).toBe('Inter');+ expect(result.current.fallbacks).toEqual(['Georgia']);+ expect(result.current.atLimit).toBe(false);+ });++ it('has no primary for an empty stack', () => {+ const { result } = setup([]);++ expect(result.current.primary).toBeUndefined();+ expect(result.current.fallbacks).toEqual([]);+ });++ it('hides the default entry and disables fonts already in the stack', () => {+ const { result } = setup(['Inter', 'Georgia']);++ expect(result.current.candidates.map((o) => o.value)).not.toContain(APPLICATION_DEFAULT_FONT);+ expect(result.current.candidates.find((o) => o.value === 'Georgia')?.disabled).toBe(true);+ expect(result.current.candidates.find((o) => o.value === 'Inter')?.disabled).toBe(true);+ expect(result.current.candidates.find((o) => o.value === 'Menlo')?.disabled).toBeUndefined();+ });++ it('labels a font from its option and falls back to the raw value', () => {+ const { result } = setup(['Inter']);++ expect(result.current.labelOf('"LXGW WenKai"')).toBe('LXGW WenKai');+ expect(result.current.labelOf('"Lost Serif"')).toBe('"Lost Serif"');+ });++ it('appends, removes and reorders without touching the primary', () => {+ const { onChange, result } = setup(['Inter', 'Georgia', 'Menlo']);++ result.current.add('"LXGW WenKai"');+ expect(onChange).toHaveBeenLastCalledWith(['Inter', 'Georgia', 'Menlo', '"LXGW WenKai"']);++ result.current.remove('Georgia');+ expect(onChange).toHaveBeenLastCalledWith(['Inter', 'Menlo']);++ result.current.reorder(['Menlo', 'Georgia']);+ expect(onChange).toHaveBeenLastCalledWith(['Inter', 'Menlo', 'Georgia']);+ });++ it('reports the limit once three fallbacks exist', () => {+ const { result } = setup(['Inter', 'Georgia', 'Menlo', '"LXGW WenKai"']);++ expect(result.current.atLimit).toBe(true);+ });+});diff --git a/src/features/Settings/appearance/features/Font/useFontFallbackStack.ts b/src/features/Settings/appearance/features/Font/useFontFallbackStack.tsnew file mode 100644index 00000000000..1cb7de5d096--- /dev/null+++ b/src/features/Settings/appearance/features/Font/useFontFallbackStack.ts@@ -0,0 +1,37 @@+import type { SelectOption } from '@lobehub/ui/base-ui';+import { useMemo } from 'react';++import { APPLICATION_DEFAULT_FONT } from '../useSystemFontOptions';+import { MAX_FALLBACK_FONTS } from './fontStack';++interface UseFontFallbackStackParams {+ onChange: (stack: string[]) => void;+ options: SelectOption[];+ stack: string[];+}++export const useFontFallbackStack = ({ onChange, options, stack }: UseFontFallbackStackParams) => {+ const [primary, ...fallbacks] = stack;++ const candidates = useMemo(+ () =>+ options+ .filter((option) => option.value !== APPLICATION_DEFAULT_FONT)+ .map((option) => (stack.includes(option.value) ? { ...option, disabled: true } : option)),+ [options, stack],+ );++ const labelOf = (value: string) =>+ options.find((option) => option.value === value)?.label ?? value;++ return {+ add: (value: string) => onChange([...stack, value]),+ atLimit: fallbacks.length >= MAX_FALLBACK_FONTS,+ candidates,+ fallbacks,+ labelOf,+ primary,+ remove: (value: string) => onChange(stack.filter((font) => font !== value)),+ reorder: (next: string[]) => onChange([primary, ...next]),+ };+};diff --git a/src/features/Settings/appearance/features/useSystemFontOptions.test.ts b/src/features/Settings/appearance/features/useSystemFontOptions.test.tsindex 9c4d131819e..669269c4e9d 100644--- a/src/features/Settings/appearance/features/useSystemFontOptions.test.ts+++ b/src/features/Settings/appearance/features/useSystemFontOptions.test.ts@@ -54,15 +54,18 @@ describe('useSystemFontOptions', () => {expect(electronSystemService.getSystemFonts).not.toHaveBeenCalled();});- it('keeps a selected font that is not installed on this device', async () => {- const { result } = renderHook(() => useSystemFontOptions({ ...params, value: 'Gone Sans' }));+ it('keeps every selected font that is not installed on this device', async () => {+ const { result } = renderHook(() =>+ useSystemFontOptions({ ...params, values: ['Gone Sans', 'Georgia', 'Lost Serif'] }),+ );await waitFor(() => expect(result.current.isLoading).toBe(false));- expect(result.current.options[1]).toEqual({- label: 'Gone Sans (unavailable)',- value: 'Gone Sans',- });+ expect(result.current.options.slice(1, 3)).toEqual([+ { label: 'Gone Sans (unavailable)', value: 'Gone Sans' },+ { label: 'Lost Serif (unavailable)', value: 'Lost Serif' },+ ]);+ expect(result.current.options.filter((o) => o.value === 'Georgia')).toHaveLength(1);});it('reports a load failure while still offering the default entry', async () => {diff --git a/src/features/Settings/appearance/features/useSystemFontOptions.ts b/src/features/Settings/appearance/features/useSystemFontOptions.tsindex d9c15bcced5..4af2d11441a 100644--- a/src/features/Settings/appearance/features/useSystemFontOptions.ts+++ b/src/features/Settings/appearance/features/useSystemFontOptions.ts@@ -10,7 +10,7 @@ interface UseSystemFontOptionsParams {enabled?: boolean;monospaceOnly?: boolean;unavailableLabel: (font: string) => string;- value?: string;+ values?: string[];}export const useSystemFontOptions = ({@@ -18,7 +18,7 @@ export const useSystemFontOptions = ({enabled = true,monospaceOnly,unavailableLabel,- value,+ values,}: UseSystemFontOptionsParams) => {const [systemFonts, setSystemFonts] = useState<SystemFont[]>([]);const [isLoading, setIsLoading] = useState(enabled);@@ -60,14 +60,12 @@ export const useSystemFontOptions = ({}, [enabled, monospaceOnly]);const options = useMemo(() => {- const fontOptions = [...systemFonts];+ const missing = (values ?? [])+ .filter((value) => !systemFonts.some((font) => font.value === value))+ .map((value) => ({ label: unavailableLabel(value), value }));- if (value && !systemFonts.some((font) => font.value === value)) {- fontOptions.unshift({ label: unavailableLabel(value), value });- }-- return [{ label: defaultLabel, value: APPLICATION_DEFAULT_FONT }, ...fontOptions];- }, [systemFonts, value, defaultLabel, unavailableLabel]);+ return [{ label: defaultLabel, value: APPLICATION_DEFAULT_FONT }, ...missing, ...systemFonts];+ }, [systemFonts, values, defaultLabel, unavailableLabel]);return { hasLoadError, isLoading, options };};diff --git a/src/features/SettingsSearch/items.ts b/src/features/SettingsSearch/items.tsindex 62362c50eb3..4132c51a0b0 100644--- a/src/features/SettingsSearch/items.ts+++ b/src/features/SettingsSearch/items.ts@@ -340,6 +340,14 @@ export const SETTINGS_SEARCH_ITEMS: SettingsSearchItem[] = [tab: SettingsTabs.Appearance,visible: (ctx) => ctx.isDesktop,},+ {+ anchor: 'appearance-font-fallback',+ descKey: 'settingAppearance.font.fallback.desc',+ keywords: ['fallback font', 'font stack', 'cjk font', 'chinese font', 'font family'],+ labelKey: 'settingAppearance.font.fallback.title',+ tab: SettingsTabs.Appearance,+ visible: (ctx) => ctx.isDesktop,+ },{anchor: 'appearance-monospace-font',descKey: 'settingAppearance.font.monospace.desc',@@ -348,6 +356,14 @@ export const SETTINGS_SEARCH_ITEMS: SettingsSearchItem[] = [tab: SettingsTabs.Appearance,visible: (ctx) => ctx.isDesktop,},+ {+ anchor: 'appearance-monospace-font-fallback',+ descKey: 'settingAppearance.font.monospaceFallback.desc',+ keywords: ['fallback font', 'monospace', 'code font', 'terminal font'],+ labelKey: 'settingAppearance.font.monospaceFallback.title',+ tab: SettingsTabs.Appearance,+ visible: (ctx) => ctx.isDesktop,+ },{anchor: 'appearance-font-size',descKey: 'settingChatAppearance.fontSize.desc',diff --git a/src/spa/entry.desktop.tsx b/src/spa/entry.desktop.tsxindex f0fe3d0e9ca..a1cbbc927a5 100644--- a/src/spa/entry.desktop.tsx+++ b/src/spa/entry.desktop.tsx@@ -13,6 +13,7 @@ import BootShell from './BootShell';import { isMainLayoutLocation } from './BootShell/routeScope';import { startAppInitialization } from './initialize/bootstrap';import { applyDesktopBootstrapIdentity } from './initialize/desktopIdentity';+import { reserveTitleBarForFloatingLayers } from './initialize/floatingLayers';import { desktopRoutes } from './router/desktopRouter.config';import { createSPARoot } from './runtime';@@ -26,6 +27,7 @@ registerLocalDatabaseAdapter(createElectronLocalDatabaseAdapter());// `isIdentityResolved` to pick the cache partition, and on desktop preload is// the only source that knows it without waiting for `getUserState()`.applyDesktopBootstrapIdentity();+reserveTitleBarForFloatingLayers();bootTiming.mark('bundle-eval');startAppInitialization();diff --git a/src/spa/entry.popup.tsx b/src/spa/entry.popup.tsxindex 762501ff4b0..a4fce990941 100644--- a/src/spa/entry.popup.tsx+++ b/src/spa/entry.popup.tsx@@ -9,11 +9,13 @@ import { createElectronLocalDatabaseAdapter } from '@/libs/localDatabase/electroimport { createAppRouter } from '@/utils/router';import { startAppInitialization } from './initialize/bootstrap';+import { reserveTitleBarForFloatingLayers } from './initialize/floatingLayers';import { popupRoutes } from './router/popupRouter.config';import { createSPARoot } from './runtime';registerLocalDatabaseAdapter(createElectronLocalDatabaseAdapter());bootTiming.mark('bundle-eval');+reserveTitleBarForFloatingLayers();startAppInitialization();const router = createAppRouter(popupRoutes);diff --git a/src/spa/initialize/floatingLayers.test.ts b/src/spa/initialize/floatingLayers.test.tsnew file mode 100644index 00000000000..365ac845984--- /dev/null+++ b/src/spa/initialize/floatingLayers.test.ts@@ -0,0 +1,15 @@+import { TITLE_BAR_HEIGHT } from '@lobechat/desktop-bridge';+import { getFloatingCollisionPadding, setFloatingCollisionPadding } from '@lobehub/ui/base-ui';+import { afterEach, describe, expect, it } from 'vitest';++import { reserveTitleBarForFloatingLayers } from './floatingLayers';++afterEach(() => setFloatingCollisionPadding(undefined));++describe('reserveTitleBarForFloatingLayers', () => {+ it('keeps every base-ui floating layer below the desktop title bar', () => {+ reserveTitleBarForFloatingLayers();++ expect(getFloatingCollisionPadding()).toMatchObject({ top: TITLE_BAR_HEIGHT });+ });+});diff --git a/src/spa/initialize/floatingLayers.ts b/src/spa/initialize/floatingLayers.tsnew file mode 100644index 00000000000..6ca714f90fe--- /dev/null+++ b/src/spa/initialize/floatingLayers.ts@@ -0,0 +1,6 @@+import { TITLE_BAR_HEIGHT } from '@lobechat/desktop-bridge';+import { setFloatingCollisionPadding } from '@lobehub/ui/base-ui';++export const reserveTitleBarForFloatingLayers = () => {+ setFloatingCollisionPadding({ top: TITLE_BAR_HEIGHT });+};