Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions src/components/settings/SettingsEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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");

Expand Down Expand Up @@ -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
Expand Down
11 changes: 11 additions & 0 deletions src/components/settings/__tests__/SettingsEditor.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -96,6 +101,12 @@ vi.mock("@/utils/restrictedSettings", () => ({
getSettingRestrictionReason: () => null,
}));

vi.mock("@/utils/safeStorage", () => ({
safeGetItem: () => null,
safeSetItem: () => {},
safeRemoveItem: () => {},
}));

vi.mock("@/utils/lazyStyles", () => ({
loadStylesheet: () => {},
}));
Expand Down
Loading