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.
Python agentaichatgptdeepseekfine-tuninggemmaimage-generationllamallmllmsopenaipythonqwenreinforcement-learningself-hostedstable-diffusiontext-to-speechttsuiunsloth
Studio: keep chat settings changed in another window (#16589)
Nilay942b173692f9
diff --git a/studio/frontend/src/features/chat/stores/chat-preferences-store.ts b/studio/frontend/src/features/chat/stores/chat-preferences-store.tsindex ed83bf12f09..645d3057133 100644--- a/studio/frontend/src/features/chat/stores/chat-preferences-store.ts+++ b/studio/frontend/src/features/chat/stores/chat-preferences-store.ts@@ -3,6 +3,7 @@import { create } from "zustand";import { persist } from "zustand/middleware";+import { syncAcrossWindows } from "../../../lib/sync-across-windows.ts";import {type ComposerSendShortcut,type ComposerFollowUpBehavior,@@ -181,3 +182,5 @@ export const useChatPreferencesStore = create<ChatPreferencesState>()(},),);++syncAcrossWindows(useChatPreferencesStore);diff --git a/studio/frontend/tests/chat-preferences-sync-across-windows.test.ts b/studio/frontend/tests/chat-preferences-sync-across-windows.test.tsnew file mode 100644index 00000000000..aca1d43985b--- /dev/null+++ b/studio/frontend/tests/chat-preferences-sync-across-windows.test.ts@@ -0,0 +1,68 @@+// SPDX-License-Identifier: AGPL-3.0-only+// Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0++import assert from "node:assert/strict";+import { test } from "node:test";++const key = "unsloth_chat_preferences";+const data = new Map<string, string>();+const listeners: ((event: { key: string | null }) => void)[] = [];+const localStorage = {+ getItem: (name: string) => data.get(name) ?? null,+ setItem: (name: string, value: string) => void data.set(name, value),+ removeItem: (name: string) => void data.delete(name),+};+Object.assign(globalThis, {+ localStorage,+ window: {+ localStorage,+ addEventListener: (type: string, listener: (event: { key: string | null }) => void) => {+ if (type === "storage") listeners.push(listener);+ },+ },+});++const { useChatPreferencesStore } = await import(+ "../src/features/chat/stores/chat-preferences-store.ts"+);++function stored(): Record<string, unknown> {+ return JSON.parse(data.get(key) ?? "{}").state ?? {};+}++function otherWindowWrites(change: Record<string, unknown> | null) {+ if (change === null) data.delete(key);+ else {+ const saved = JSON.parse(data.get(key) ?? "{}");+ data.set(key, JSON.stringify({ ...saved, state: { ...saved.state, ...change } }));+ }+ for (const listener of listeners) listener({ key });+}++test("chat settings chosen in another window survive a change in this one", () => {+ useChatPreferencesStore.getState().setShowReplyTimes(true);+ otherWindowWrites({+ sendShortcut: "mod-enter",+ notifyWhenReplyFinishes: true,+ confirmDeleteChats: false,+ });+ useChatPreferencesStore.getState().setFilesPanelCollapsed(true);+ assert.equal(stored().sendShortcut, "mod-enter");+ assert.equal(stored().notifyWhenReplyFinishes, true);+ assert.equal(stored().confirmDeleteChats, false);+ assert.equal(stored().filesPanelCollapsed, true);+ assert.equal(stored().showReplyTimes, true);+ assert.equal(useChatPreferencesStore.getState().sendShortcut, "mod-enter");+});++test("a setting from another window is still checked before use", () => {+ otherWindowWrites({ followUpBehavior: "steer", pastedTextMinChars: 123 });+ assert.equal(useChatPreferencesStore.getState().followUpBehavior, "steer");+ assert.equal(useChatPreferencesStore.getState().pastedTextMinChars, 4000);+});++test("chat settings reset in another window reset here too", () => {+ otherWindowWrites(null);+ assert.equal(useChatPreferencesStore.getState().sendShortcut, "enter");+ assert.equal(useChatPreferencesStore.getState().filesPanelCollapsed, false);+});diff --git a/studio/frontend/tests/reply-finished-notification.test.ts b/studio/frontend/tests/reply-finished-notification.test.tsindex 3a5b801dd07..e3357174b8e 100644--- a/studio/frontend/tests/reply-finished-notification.test.ts+++ b/studio/frontend/tests/reply-finished-notification.test.ts@@ -85,6 +85,7 @@ async function load(env: Env) {location: { protocol: tauri ? "tauri:" : "http:" },localStorage: storage,focus() {},+ addEventListener() {},};if (tauri) {windowStub.__TAURI_INTERNALS__ = {};