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: read personalization only once a first sign-in has changed its password (#12071)
Daniel Handef1b947c926
diff --git a/studio/frontend/src/app/routes/__root.tsx b/studio/frontend/src/app/routes/__root.tsxindex b938364f02b..561f1419307 100644--- a/studio/frontend/src/app/routes/__root.tsx+++ b/studio/frontend/src/app/routes/__root.tsx@@ -13,6 +13,7 @@ import {AUTH_SESSION_CLEARED_EVENT,AUTH_SESSION_STORED_EVENT,hasAuthToken,+ hasSettledAuthSession,useIsAccountOwner,} from "@/features/auth";import {@@ -167,8 +168,12 @@ const AudioPage = lazy(() =>import("@/features/audio").then((m) => ({ default: m.AudioPage })),);+// Enabled once the session is settled, not once a token exists. The first read runs once per session, so a read+// refused mid password change would leave personalization unhydrated, and every save paused, until a reload. The+// pathname subscription re-reads the gate on the navigation that ends the change.function PersonalizationSyncMount() {- usePersonalizationSync(hasAuthToken());+ useRouterState({ select: (s) => s.location.pathname });+ usePersonalizationSync(hasSettledAuthSession());return null;}diff --git a/studio/frontend/src/features/auth/index.ts b/studio/frontend/src/features/auth/index.tsindex 75735616b5c..8e95afd9e4e 100644--- a/studio/frontend/src/features/auth/index.ts+++ b/studio/frontend/src/features/auth/index.ts@@ -16,6 +16,7 @@ export {getPostAuthRoute,hasAuthToken,hasRefreshToken,+ hasSettledAuthSession,mustChangePassword,setMustChangePassword,storeAuthTokens,diff --git a/studio/frontend/src/features/auth/session.ts b/studio/frontend/src/features/auth/session.tsindex 34c96c61a5e..98afc78cb23 100644--- a/studio/frontend/src/features/auth/session.ts+++ b/studio/frontend/src/features/auth/session.ts@@ -125,3 +125,12 @@ export function getPostAuthRoute(): PostAuthRoute {if (mustChangePassword()) return "/change-password";return "/chat";}++/**+ * Whether this session may read its account's settings yet. Until a required password change lands,+ * the backend refuses every other route with a 403, and the bootstrap sign-in on /change-password+ * stores its tokens a step before that change.+ */+export function hasSettledAuthSession(): boolean {+ return hasAuthToken() && getPostAuthRoute() === "/chat";+}diff --git a/studio/frontend/tests/account-session-routing.test.ts b/studio/frontend/tests/account-session-routing.test.tsindex 9e5289ac02c..4d6f5bc8ecc 100644--- a/studio/frontend/tests/account-session-routing.test.ts+++ b/studio/frontend/tests/account-session-routing.test.ts@@ -47,3 +47,48 @@ for (const [desktop, loginMode, change, expected] of [assert.equal(listening, 1);});}++// Account settings are read once per session, and a session still owing a password change is+// refused them with a 403. The bootstrap sign-in on /change-password stores its tokens before the+// change, so "has a token" is not "may read settings": a read in that gap leaves personalization+// unhydrated for the whole session. The gate agrees with the route the session is sent to.+for (const [desktop, loginMode, token, change, expected] of [+ [false, "single", false, false, false],+ [false, "single", true, true, false],+ [false, "multi", true, true, false],+ [false, "single", true, false, true],+ [true, "multi", true, true, false],+ [true, "single", true, true, true],+ [true, "single", false, false, false],+] as const) {+ test(`${desktop ? "desktop" : "browser"} ${loginMode} session with token=${token} change=${change} is settled=${expected}`, (t) => {+ const previousWindow = globalThis.window;+ const previousStorage = globalThis.localStorage;+ const storage = {+ getItem: (key: string) => {+ if (key === "unsloth_auth_token") return token ? "a.b.c" : null;+ if (key === "unsloth_auth_must_change_password") return change ? "1" : null;+ return null;+ },+ } as unknown as Storage;+ globalThis.localStorage = storage;+ globalThis.window = {+ localStorage: storage,+ addEventListener() {},+ } as unknown as Window & typeof globalThis;+ t.after(() => {+ globalThis.window = previousWindow;+ globalThis.localStorage = previousStorage;+ });+ const session = loadWithStubs<typeof Session>(+ new URL("../src/features/auth/session.ts", import.meta.url),+ {+ "@/lib/api-base": { isTauri: desktop },+ "@/lib/account-transition": { installAccountTransitionListener: () => {} },+ "./login-client": { getLoginMode: () => loginMode },+ "./session-events": {},+ },+ );+ assert.equal(session.hasSettledAuthSession(), expected);+ });+}