diff --git a/src/components/settings/SettingsEditor.tsx b/src/components/settings/SettingsEditor.tsx index af2b8b6..f5d5204 100644 --- a/src/components/settings/SettingsEditor.tsx +++ b/src/components/settings/SettingsEditor.tsx @@ -34,6 +34,7 @@ import { useWorkspaceTrust } from "@/context/WorkspaceTrustContext"; import { isSettingRestricted, getSettingRestrictionReason } from "@/utils/restrictedSettings"; import { tokens } from "@/design-system/tokens"; import { Button, IconButton, Input, Text, Badge, Toggle } from "@/components/ui"; +import { safeGetItem, safeSetItem } from "@/utils/safeStorage"; import { loadStylesheet } from "@/utils/lazyStyles"; loadStylesheet("settings"); @@ -105,8 +106,17 @@ interface FilterSuggestion { description: string; } -// Module-level signal to persist TOC section across re-renders / focus changes -const [persistedActiveSection, setPersistedActiveSection] = createSignal("editor"); +// Module-level signal to persist TOC section across re-renders / focus changes. +// Back the signal with sessionStorage so the value survives lazy-chunk re-evaluation +// and component unmount/remount cycles (e.g. switching editor tabs). +const SETTINGS_TOC_STORAGE_KEY = "settings_active_toc_section"; +const [persistedActiveSection, _setPersistedRaw] = createSignal( + safeGetItem(SETTINGS_TOC_STORAGE_KEY) || "editor" +); +const setPersistedActiveSection = (id: string) => { + _setPersistedRaw(id); + safeSetItem(SETTINGS_TOC_STORAGE_KEY, id); +}; // ============================================================================= // SETTINGS REGISTRY diff --git a/src/components/settings/__tests__/SettingsEditor.test.tsx b/src/components/settings/__tests__/SettingsEditor.test.tsx index 2d83994..e0e475b 100644 --- a/src/components/settings/__tests__/SettingsEditor.test.tsx +++ b/src/components/settings/__tests__/SettingsEditor.test.tsx @@ -15,6 +15,11 @@ vi.mock("@/context/SettingsContext", () => { linkedEditing: false, stickyScrollEnabled: false, foldingEnabled: true, showFoldingControls: "mouseover", guidesIndentation: true, guidesBracketPairs: true, verticalTabs: false, + inlayHints: { + enabled: true, fontSize: 0, fontFamily: "", showTypes: true, + showParameterNames: true, showReturnTypes: true, maxLength: 25, padding: false, + }, + semanticHighlighting: { enabled: true, strings: true, comments: true }, }, theme: { theme: "dark", iconTheme: "seti", accentColor: "#007acc", uiFontFamily: "Inter", @@ -96,6 +101,12 @@ vi.mock("@/utils/restrictedSettings", () => ({ getSettingRestrictionReason: () => null, })); +vi.mock("@/utils/safeStorage", () => ({ + safeGetItem: () => null, + safeSetItem: () => {}, + safeRemoveItem: () => {}, +})); + vi.mock("@/utils/lazyStyles", () => ({ loadStylesheet: () => {}, }));