From 9d3ad3ba12e8a80a6ebc21e9eea8e612500896ba Mon Sep 17 00:00:00 2001 From: Daniel Han Date: Fri, 22 May 2026 07:06:49 -0700 Subject: [PATCH] Studio: also persist external checkpoint when picker calls setParams (#5700) The first pass only wired the localStorage mirror into `setCheckpoint`, but the main chat-page picker actually selects an external model by calling `setParams({ ...store.params, checkpoint: value })`. That path never hit `setCheckpoint`, so the persisted slot stayed empty and a refresh fell back to whatever `/api/inference/status.active_model` returned -- the previously loaded local model (Qwen3.5 etc) or null ("Select model") when nothing was loaded locally. Mirror the persistence in `setParams` whenever the checkpoint changes so every entry point converges on the same behavior. `setCheckpoint` still does it directly so the load path (compare, GGUF auto-load, gemma fallback in chat-adapter) keeps working. --- .../src/features/chat/stores/chat-runtime-store.ts | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/studio/frontend/src/features/chat/stores/chat-runtime-store.ts b/studio/frontend/src/features/chat/stores/chat-runtime-store.ts index 287dd1fa8b..1f7442ccd2 100644 --- a/studio/frontend/src/features/chat/stores/chat-runtime-store.ts +++ b/studio/frontend/src/features/chat/stores/chat-runtime-store.ts @@ -627,6 +627,17 @@ export const useChatRuntimeStore = create((set, get) => ({ if (state.settingsHydrated && hasKeys(changedParams)) { saveSettingsPatch({ inferenceParams: changedParams }); } + // chat-page picks an external model by mutating `params.checkpoint` + // through this setter (not through `setCheckpoint`), so the + // localStorage mirror needs to be refreshed here too. Otherwise + // the persisted slot stays empty and a refresh falls back to + // whatever the backend's `/api/inference/status.active_model` + // returns -- usually the previously loaded local model. + if (params.checkpoint !== state.params.checkpoint) { + saveLastExternalCheckpoint( + isExternalModelId(params.checkpoint) ? params.checkpoint : null, + ); + } return { params }; }), setCustomPresets: (customPresets) =>