Skip to content

Local UI to run and train LLMs and diffusion models. Supports GGUF, MLX, Qwen3.8, DeepSeek-V4.1, MiniMax-H3, Gemma 4, FLUX and more.

Studio: recover saved context when switching back to a snapshot path (#10447)

Chaitanya Laxman3a172fbf8468
diff --git a/studio/frontend/src/features/chat/chat-page.tsx b/studio/frontend/src/features/chat/chat-page.tsx
index f8284711745..1483c5a6947 100644
--- a/studio/frontend/src/features/chat/chat-page.tsx
+++ b/studio/frontend/src/features/chat/chat-page.tsx
@@ -16,7 +16,7 @@ import {
isServedByMlx,
loadedContextFields,
modelConfigHandoffForDestination,
- resolveInitialConfig,
+ resolveResidentInitialConfig,
SidebarModelConfig,
useActiveModelConfig,
useModelConfigHandoffStore,
@@ -2433,7 +2433,10 @@ export function ChatPage({
source?: string;
}) => {
if (selection.source === "external") return null;
- const resolved = resolveInitialConfig(selection.id, selection.ggufVariant);
+ const resolved = resolveResidentInitialConfig(
+ selection.id,
+ selection.ggufVariant,
+ );
return resolved.remembered ? resolved.config : null;
},
[],
diff --git a/studio/frontend/tests/chat-remembers-its-model.test.ts b/studio/frontend/tests/chat-remembers-its-model.test.ts
index 5c5ddb0f645..b51d79d3cc3 100644
--- a/studio/frontend/tests/chat-remembers-its-model.test.ts
+++ b/studio/frontend/tests/chat-remembers-its-model.test.ts
@@ -26,8 +26,12 @@ const {
const { chatLocalModelOptions } = await import(
"../src/features/chat/local-model-options.ts"
);
-const { DEFAULT_PER_MODEL_CONFIG, resolveInitialConfig, savePerModelConfig } =
- await import("../src/features/model-picker/model-config/per-model-config.ts");
+const {
+ DEFAULT_PER_MODEL_CONFIG,
+ resolveInitialConfig,
+ resolveResidentInitialConfig,
+ savePerModelConfig,
+} = await import("../src/features/model-picker/model-config/per-model-config.ts");
const { shouldPersistResolvedQueuedModel } = await import(
"../src/features/chat/utils/queued-chat-run-settings.ts"
);
@@ -649,15 +653,43 @@ test("the switch back leaves the remembered config to stageOrLoad", () => {
);
assert.match(
remembered,
- /resolveInitialConfig\(selection\.id, selection\.ggufVariant\)/,
+ /resolveResidentInitialConfig\(\s*selection\.id,\s*selection\.ggufVariant,?\s*\)/,
);
assert.equal(
- resolveInitialConfig(selection.id, selection.ggufVariant).config
+ resolveResidentInitialConfig(selection.id, selection.ggufVariant).config
.customContextLength,
32768,
);
});
+test("switch back recovers a repo-keyed context through a snapshot path", () => {
+ store.clear();
+ const snapshotPath =
+ "/home/u/.cache/huggingface/hub/models--unsloth--Repo-GGUF/snapshots/2f1c9ab";
+ const repoId = "unsloth/Repo-GGUF";
+ assert.ok(
+ savePerModelConfig(repoId, "Q4_K_M", {
+ ...DEFAULT_PER_MODEL_CONFIG,
+ customContextLength: 32768,
+ }),
+ );
+ assert.equal(resolveInitialConfig(snapshotPath, "Q4_K_M").remembered, false);
+ assert.equal(
+ resolveResidentInitialConfig(snapshotPath, "Q4_K_M").config
+ .customContextLength,
+ 32768,
+ );
+ const remembered = slice(
+ page,
+ "const rememberedConfigFor = useCallback",
+ "const isExternalModel",
+ );
+ assert.match(
+ remembered,
+ /resolveResidentInitialConfig\(\s*selection\.id,\s*selection\.ggufVariant,?\s*\)/,
+ );
+});
+
test("switching back to a fine-tuned row mirrors the picker's own metadata", () => {
// Same fields the fine-tuned list's selectionMeta sets, so the two doors agree.
const adapters = [