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 profile and appearance changes made in another window (#16580)
Nilayf5adb3664256
diff --git a/studio/frontend/src/features/profile/stores/user-profile-store.ts b/studio/frontend/src/features/profile/stores/user-profile-store.tsindex f20859cd115..6944f98ad47 100644--- a/studio/frontend/src/features/profile/stores/user-profile-store.ts+++ b/studio/frontend/src/features/profile/stores/user-profile-store.ts@@ -62,3 +62,14 @@ export const useUserProfileStore = create<UserProfileState>()({ name: "unsloth_user_profile" },),);++if (typeof window !== "undefined") {+ window.addEventListener("storage", (event) => {+ if (+ event.key === useUserProfileStore.persist.getOptions().name &&+ event.newValue !== null+ ) {+ void useUserProfileStore.persist.rehydrate();+ }+ });+}diff --git a/studio/frontend/src/features/settings/stores/appearance-custom-store.ts b/studio/frontend/src/features/settings/stores/appearance-custom-store.tsindex a1582c2fba2..2e7a119eed7 100644--- a/studio/frontend/src/features/settings/stores/appearance-custom-store.ts+++ b/studio/frontend/src/features/settings/stores/appearance-custom-store.ts@@ -627,6 +627,17 @@ export const useAppearanceCustomStore = create<AppearanceCustomState>()(),);+if (typeof window !== "undefined") {+ window.addEventListener("storage", (event) => {+ if (+ event.key === useAppearanceCustomStore.persist.getOptions().name &&+ event.newValue !== null+ ) {+ void useAppearanceCustomStore.persist.rehydrate();+ }+ });+}+/* ------------------------------ DOM applier ------------------------------ */// Platform default from index.css: Inter, or the system font on macOS.const DEFAULT_SANS_STACK = "var(--font-sans-default)";diff --git a/studio/frontend/tests/profile-sync-across-windows.test.ts b/studio/frontend/tests/profile-sync-across-windows.test.tsnew file mode 100644index 00000000000..1dcd4914766--- /dev/null+++ b/studio/frontend/tests/profile-sync-across-windows.test.ts@@ -0,0 +1,95 @@+// 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_user_profile";+const APPEARANCE_KEY = "unsloth_appearance_customization";+const data = new Map<string, string>();+type StorageEvent = { key: string | null; newValue: string | null };+const listeners: ((event: StorageEvent) => void)[] = [];+const localStorage = {+ getItem: (key: string) => data.get(key) ?? null,+ setItem: (key: string, value: string) => void data.set(key, value),+ removeItem: (key: string) => void data.delete(key),+};+Object.assign(globalThis, {+ localStorage,+ window: {+ localStorage,+ addEventListener: (+ type: string,+ listener: (event: StorageEvent) => void,+ ) => {+ if (type === "storage") listeners.push(listener);+ },+ },+});++const { useUserProfileStore } = await import(+ "../src/features/profile/stores/user-profile-store.ts"+);+const { useAppearanceCustomStore } = await import(+ "../src/features/settings/stores/appearance-custom-store.ts"+);++function otherWindowWrites(change: Record<string, unknown>, key = KEY) {+ const saved = JSON.parse(data.get(key) ?? "{}");+ const newValue = JSON.stringify({+ ...saved,+ state: { ...saved.state, ...change },+ });+ data.set(key, newValue);+ for (const listener of listeners) listener({ key, newValue });+}++test("a name set in another window is not overwritten by an edit in this one", async () => {+ useUserProfileStore.getState().setDisplayName("Old");+ otherWindowWrites({ displayName: "Alice", greetingText: "Hi Alice" });+ await Promise.resolve();+ assert.equal(useUserProfileStore.getState().displayName, "Alice");+ assert.equal(useUserProfileStore.getState().greetingText, "Hi Alice");+ useUserProfileStore.getState().setNickname("Al");+ const stored = JSON.parse(data.get(KEY) ?? "{}").state;+ assert.equal(stored.displayName, "Alice");+ assert.equal(stored.greetingText, "Hi Alice");+ assert.equal(stored.nickname, "Al");+});++test("an appearance change made in another window is not overwritten by an edit in this one", async () => {+ const store = useAppearanceCustomStore;+ store.getState().patch({ uiFont: "Old Font" });+ const saved = JSON.parse(data.get(APPEARANCE_KEY) ?? "{}").state;+ otherWindowWrites(+ {+ customization: {+ ...saved.customization,+ uiFont: "Other Font",+ colors: {+ ...saved.customization.colors,+ light: { ...saved.customization.colors.light, accent: "#ff0000" },+ },+ },+ },+ APPEARANCE_KEY,+ );+ await Promise.resolve();+ assert.equal(store.getState().customization.uiFont, "Other Font");+ assert.equal(store.getState().customization.colors.light.accent, "#ff0000");+ store.getState().patch({ headingFont: "Heading" });+ const stored = JSON.parse(data.get(APPEARANCE_KEY) ?? "{}").state;+ assert.equal(stored.customization.uiFont, "Other Font");+ assert.equal(stored.customization.colors.light.accent, "#ff0000");+ assert.equal(stored.customization.headingFont, "Heading");+});++test("another window resetting local preferences keeps this window's appearance", async () => {+ const store = useAppearanceCustomStore;+ store.getState().patch({ uiFont: "Kept Font" });+ data.delete(APPEARANCE_KEY);+ for (const listener of listeners)+ listener({ key: APPEARANCE_KEY, newValue: null });+ await Promise.resolve();+ assert.equal(store.getState().customization.uiFont, "Kept Font");+});diff --git a/studio/frontend/tests/skipped-content-remeasure.test.ts b/studio/frontend/tests/skipped-content-remeasure.test.tsindex ce74fab3826..9eb3c77bda2 100644--- a/studio/frontend/tests/skipped-content-remeasure.test.ts+++ b/studio/frontend/tests/skipped-content-remeasure.test.ts@@ -11,6 +11,7 @@ const attributes = new Set<string>();const scope = globalThis as { window?: unknown; document?: unknown };scope.window = {location: { protocol: "https:" },+ addEventListener: () => undefined,localStorage: {getItem: () => null,setItem: () => undefined,