diff --git a/studio/frontend/src/features/chat/chat-settings-sheet.tsx b/studio/frontend/src/features/chat/chat-settings-sheet.tsx index 45c9d17888..081e3efc26 100644 --- a/studio/frontend/src/features/chat/chat-settings-sheet.tsx +++ b/studio/frontend/src/features/chat/chat-settings-sheet.tsx @@ -28,6 +28,8 @@ import { PencilEdit01Icon, Settings02Icon, SlidersHorizontalIcon, + UserSettings01Icon, + Wrench01Icon, } from "@hugeicons/core-free-icons"; import { HugeiconsIcon } from "@hugeicons/react"; import { AnimatePresence, motion } from "motion/react"; @@ -164,6 +166,39 @@ function ParamSlider({ ); } +const COLLAPSIBLE_STATE_KEY = "unsloth_chat_collapsible_state"; + +function loadCollapsibleState(): Record { + if (!canUseStorage()) return {}; + try { + const raw = localStorage.getItem(COLLAPSIBLE_STATE_KEY); + if (!raw) return {}; + const parsed = JSON.parse(raw); + if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed)) { + return {}; + } + return Object.fromEntries( + Object.entries(parsed).filter( + (entry): entry is [string, boolean] => typeof entry[1] === "boolean", + ), + ); + } catch (error) { + console.warn("Failed to load collapsible state from localStorage:", error); + return {}; + } +} + +function saveCollapsibleOpen(label: string, open: boolean) { + if (!canUseStorage()) return; + try { + const state = loadCollapsibleState(); + state[label] = open; + localStorage.setItem(COLLAPSIBLE_STATE_KEY, JSON.stringify(state)); + } catch { + // ignore + } +} + function CollapsibleSection({ icon, label, @@ -175,13 +210,20 @@ function CollapsibleSection({ children?: ReactNode; defaultOpen?: boolean; }) { - const [open, setOpen] = useState(defaultOpen); + const [open, setOpen] = useState(() => { + const saved = loadCollapsibleState(); + return Object.hasOwn(saved, label) ? saved[label] : defaultOpen; + }); return (
+ +
+ {isGguf && ( + <> +
+
+
Context Length
+
+ Reported by the loaded GGUF model. +
+
+ +
+
+
+
KV Cache Dtype
+
+ Quantize KV cache to reduce VRAM. Reload to apply. +
+
+ +
+ + )} + {!isGguf && ( +
+
+
Trust remote code
+
+ Allow models with custom code (e.g. Nemotron). Only enable for repos you trust. +
+
+ +
+ )} +
+
+ - + +
+ + + +
+
+ +
@@ -519,49 +632,6 @@ export function ChatSettingsPanel({ onCheckedChange={onAutoTitleChange} />
-
-
-
Trust remote code
-
- Allow models with custom code (e.g. Nemotron). Only enable for repos you trust. -
-
- -
- {isGguf && ( -
-
-
KV Cache Dtype
-
- Quantize KV cache to reduce VRAM. Reload to apply. -
-
- -
- )} - - -