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 turn bookmarks made in another window (#16578)
Nilaycba13757ab79
diff --git a/studio/frontend/src/features/chat/stores/bookmarked-turns-store.ts b/studio/frontend/src/features/chat/stores/bookmarked-turns-store.tsindex e621c0eb408..8f0f437e87c 100644--- a/studio/frontend/src/features/chat/stores/bookmarked-turns-store.ts+++ b/studio/frontend/src/features/chat/stores/bookmarked-turns-store.ts@@ -79,3 +79,13 @@ export const useBookmarkedTurnsStore = create<BookmarkedTurnsState>()(},),);++if (typeof window !== "undefined") {+ window.addEventListener("storage", (event) => {+ // A null key is localStorage.clear().+ const key = useBookmarkedTurnsStore.persist.getOptions().name;+ if (event.key === key || event.key === null) {+ void useBookmarkedTurnsStore.persist.rehydrate();+ }+ });+}diff --git a/studio/frontend/tests/bookmarked-turns-across-windows.test.ts b/studio/frontend/tests/bookmarked-turns-across-windows.test.tsnew file mode 100644index 00000000000..27c67d610e6--- /dev/null+++ b/studio/frontend/tests/bookmarked-turns-across-windows.test.ts@@ -0,0 +1,47 @@+// 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_bookmarked_turns";+const data = new Map<string, string>();+const listeners: ((event: { key: string | null }) => 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: { key: string | null }) => void) => {+ if (type === "storage") listeners.push(listener);+ },+ },+});++const { useBookmarkedTurnsStore } = await import(+ "../src/features/chat/stores/bookmarked-turns-store.ts"+);++function otherWindowWrites(bookmarkedByThread: Record<string, string[]>) {+ data.set(KEY, JSON.stringify({ state: { bookmarkedByThread }, version: 0 }));+ for (const listener of listeners) listener({ key: KEY });+}++test("a bookmark made in another window survives a bookmark made in this one", () => {+ otherWindowWrites({ "chat-a": ["m1"] });+ useBookmarkedTurnsStore.getState().toggleBookmarkedTurn("chat-b", "m2");+ assert.deepEqual(JSON.parse(data.get(KEY) ?? "{}").state.bookmarkedByThread, {+ "chat-a": ["m1"],+ "chat-b": ["m2"],+ });+});++test("clearing storage in another window drops this window's bookmarks", () => {+ data.clear();+ for (const listener of listeners) listener({ key: null });+ assert.deepEqual(useBookmarkedTurnsStore.getState().bookmarkedByThread, {});+});