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: spell the owner's sidebar name Unsloth, not unsloth (#11275)
Michael Hanb5cb7bb5f09e
diff --git a/studio/frontend/src/features/auth/account-session.ts b/studio/frontend/src/features/auth/account-session.tsindex b1ec732cee3..59931d53985 100644--- a/studio/frontend/src/features/auth/account-session.ts+++ b/studio/frontend/src/features/auth/account-session.ts@@ -15,6 +15,10 @@ import {} from "./session";/** Display policy only; the server validates the token and enforces owner access. */+// The owner's login id, reserved rather than chosen: validate_account_username+// rejects it, so no managed account can take it and the owner cannot rename off it.+export const OWNER_USERNAME = "unsloth";+export function sessionAccount(token: string | null,): { username: string; isOwner: boolean } | null {@@ -28,7 +32,7 @@ export function sessionAccount(username: payload.sub,isOwner: payload.role? payload.role === "owner"- : payload.sub === "unsloth",+ : payload.sub === OWNER_USERNAME,};} catch {return null;diff --git a/studio/frontend/src/features/auth/index.ts b/studio/frontend/src/features/auth/index.tsindex 2e03d1c8ca3..75735616b5c 100644--- a/studio/frontend/src/features/auth/index.ts+++ b/studio/frontend/src/features/auth/index.ts@@ -25,4 +25,4 @@ export {getTauriAuthFailure,tauriAutoAuth,} from "./tauri-auto-auth";-export { sessionAccount, useIsAccountOwner, useLoginMode } from "./account-session";+export { OWNER_USERNAME, sessionAccount, useIsAccountOwner, useLoginMode } from "./account-session";diff --git a/studio/frontend/src/features/profile/components/profile-personalization-panel.tsx b/studio/frontend/src/features/profile/components/profile-personalization-panel.tsxindex 2f4ac8db4d2..012d7bd6251 100644--- a/studio/frontend/src/features/profile/components/profile-personalization-panel.tsx+++ b/studio/frontend/src/features/profile/components/profile-personalization-panel.tsx@@ -23,6 +23,7 @@ import {import { HugeiconsIcon } from "@hugeicons/react";import { useEffect, useRef, useState } from "react";import { SLOTH_AVATARS } from "../sloth-avatars";+import { loginDisplayName } from "../hooks/use-effective-profile";import { decodeJwtSubject } from "../utils/jwt-subject";import { resizeImageFileToDataUrl } from "../utils/resize-image-file";import {@@ -88,7 +89,9 @@ export function ProfilePersonalizationPanel() {const lastNicknameRef = useRef(nickname);const sessionSub = decodeJwtSubject(getAuthToken()) ?? "";- const previewName = draftName.trim() || sessionSub || "Unsloth";+ // Fallback only: the draft being typed still wins over this.+ const loginName = loginDisplayName(sessionSub);+ const previewName = draftName.trim() || loginName || "Unsloth";useEffect(() => {const previous = lastDisplayNameRef.current;@@ -385,7 +388,7 @@ export function ProfilePersonalizationPanel() {}}}autoComplete="off"- placeholder={sessionSub || "Unsloth"}+ placeholder={loginName || "Unsloth"}className="h-9 w-full rounded-full text-sm"/></div>diff --git a/studio/frontend/src/features/profile/hooks/use-effective-profile.ts b/studio/frontend/src/features/profile/hooks/use-effective-profile.tsindex eacf38a06d2..b0db34da3bc 100644--- a/studio/frontend/src/features/profile/hooks/use-effective-profile.ts+++ b/studio/frontend/src/features/profile/hooks/use-effective-profile.ts@@ -1,10 +1,17 @@// 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 { getAuthToken } from "@/features/auth";+import { getAuthToken, OWNER_USERNAME } from "@/features/auth";import { decodeJwtSubject } from "../utils/jwt-subject";import { useUserProfileStore } from "../stores/user-profile-store";+// The owner's id is the reserved literal "unsloth", so a verbatim subject spells+// the brand lower case. Only that id maps; a chosen username stays as chosen.+// Shared, not copied: every surface falling back to the login id must agree.+export function loginDisplayName(sessionSub: string | null): string {+ return sessionSub === OWNER_USERNAME ? "Unsloth" : (sessionSub ?? "");+}+export function useEffectiveProfile() {const displayName = useUserProfileStore((s) => s.displayName);const nickname = useUserProfileStore((s) => s.nickname);@@ -12,11 +19,12 @@ export function useEffectiveProfile() {const sessionSub = decodeJwtSubject(getAuthToken());const dn = displayName.trim();+ const login = loginDisplayName(sessionSub);// Name to address the user by: nickname, else first name, else login id.- const addressName = nickname.trim() || dn.split(/\s+/)[0] || sessionSub || "";+ const addressName = nickname.trim() || dn.split(/\s+/)[0] || login;return {sessionSub,- displayTitle: dn || sessionSub || "Unsloth",+ displayTitle: dn || login || "Unsloth",addressName,avatarDataUrl,};diff --git a/studio/frontend/tests/effective-profile.test.ts b/studio/frontend/tests/effective-profile.test.tsindex f09e399e91c..fe60423671f 100644--- a/studio/frontend/tests/effective-profile.test.ts+++ b/studio/frontend/tests/effective-profile.test.ts@@ -22,7 +22,7 @@ test("account identity supplies the sidebar name and avatar unless a display namimport.meta.url,),{- "@/features/auth": { getAuthToken: () => token },+ "@/features/auth": { getAuthToken: () => token, OWNER_USERNAME: "unsloth" },"../utils/jwt-subject": { decodeJwtSubject },"../stores/user-profile-store": {useUserProfileStore: (select: (state: typeof profile) => unknown) =>@@ -31,10 +31,19 @@ test("account identity supplies the sidebar name and avatar unless a display nam},);- for (const username of ["unsloth", "alice", "bob"]) {+ // A managed account shows the username its owner chose, verbatim. The owner's own+ // id is the reserved literal "unsloth", which is the product name in lower case, so+ // that ONE id displays as "Unsloth" rather than spelling the brand wrongly on every+ // default install. sessionSub keeps the real subject either way.+ for (const [username, shown] of [+ ["unsloth", "Unsloth"],+ ["alice", "alice"],+ ["bob", "bob"],+ ]) {token = `test.${Buffer.from(JSON.stringify({ sub: username })).toString("base64url")}.test`;const effective = renderProfile();- assert.equal(effective.displayTitle, username);+ assert.equal(effective.displayTitle, shown);+ assert.equal(effective.addressName, shown);assert.equal(effective.sessionSub, username);assert.equal(initialsFromName(effective.displayTitle),diff --git a/studio/frontend/tests/profile-login-name-spelling.test.ts b/studio/frontend/tests/profile-login-name-spelling.test.tsnew file mode 100644index 00000000000..78d6c538ad4--- /dev/null+++ b/studio/frontend/tests/profile-login-name-spelling.test.ts@@ -0,0 +1,134 @@+// 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 { readFileSync } from "node:fs";+import test from "node:test";+import { fileURLToPath } from "node:url";++import ts from "typescript";++import { loadWithStubs } from "./helpers/module-stubs.ts";+import { openingTag } from "./helpers/tsx-ast.ts";++// Both modules come from the shipped source with only their edges cut, so the+// constant under test is the one the app ships rather than one spelled here.+const { OWNER_USERNAME } = loadWithStubs<{ OWNER_USERNAME: string }>(+ new URL("../src/features/auth/account-session.ts", import.meta.url),+ {+ react: { useEffect: () => {}, useSyncExternalStore: () => undefined },+ "./login-client": {+ ensureLoginMode: () => {},+ getFullAccessAllowed: () => true,+ getLoginMode: () => "single",+ subscribeLoginMode: () => () => {},+ },+ "./session": {+ AUTH_SESSION_CLEARED_EVENT: "cleared",+ AUTH_SESSION_STORED_EVENT: "stored",+ getAuthToken: () => null,+ },+ },+);++const { loginDisplayName } = loadWithStubs<{+ loginDisplayName: (sub: string | null) => string;+}>(new URL("../src/features/profile/hooks/use-effective-profile.ts", import.meta.url), {+ "@/features/auth": { getAuthToken: () => null, OWNER_USERNAME },+ "../utils/jwt-subject": { decodeJwtSubject: () => null },+ "../stores/user-profile-store": { useUserProfileStore: () => "" },+});++test("the reserved owner id is the only subject whose spelling is mapped", () => {+ // Read from the shipped export, not a copy: a test pinned to its own literal+ // cannot notice the constant it is about drifting.+ assert.equal(loginDisplayName(OWNER_USERNAME), "Unsloth");+ for (const chosen of ["alice", "bob", "unsloth2", "Unsloth", "UNSLOTH", " unsloth "]) {+ assert.equal(loginDisplayName(chosen), chosen);+ }+ assert.equal(loginDisplayName(null), "");+ assert.equal(loginDisplayName(""), "");+});++const panelSource = readFileSync(+ fileURLToPath(+ new URL(+ "../src/features/profile/components/profile-personalization-panel.tsx",+ import.meta.url,+ ),+ ),+ "utf8",+);++test("the personalization panel spells its login fallback the way the sidebar does", () => {+ const file = ts.createSourceFile(+ "profile-personalization-panel.tsx",+ panelSource,+ ts.ScriptTarget.ES2022,+ true,+ ts.ScriptKind.TSX,+ );++ // Both fallbacks route through the shared mapper rather than the raw subject.+ const previewName = findInitializer(file, "previewName");+ assert.ok(previewName, "previewName is no longer declared; update this test");+ assert.match(previewName, /loginName/);+ assert.doesNotMatch(+ previewName,+ /sessionSub/,+ "the preview avatar fell back to the raw subject, so it spells the brand lower case",+ );++ const placeholders = jsxAttributeTexts(file, "placeholder");+ assert.ok(placeholders.length > 0, "no placeholder attribute found; update this test");+ for (const placeholder of placeholders) {+ assert.doesNotMatch(+ placeholder,+ /sessionSub/,+ "the display-name placeholder shows the raw subject, so it spells the brand lower case",+ );+ }++ // The draft the user is typing still outranks any fallback.+ assert.match(previewName, /draftName\.trim\(\)\s*\|\|/);+});++/** The initializer text of `const <name> = ...`, or null when it is gone. */+function findInitializer(file: ts.SourceFile, name: string): string | null {+ let found: string | null = null;+ const visit = (node: ts.Node): void => {+ if (+ ts.isVariableDeclaration(node) &&+ ts.isIdentifier(node.name) &&+ node.name.text === name &&+ node.initializer+ ) {+ found = node.initializer.getText(file);+ }+ ts.forEachChild(node, visit);+ };+ visit(file);+ return found;+}++/** Every `<x <name>={...}>` expression in the file, as source text. */+function jsxAttributeTexts(file: ts.SourceFile, name: string): string[] {+ const texts: string[] = [];+ const visit = (node: ts.Node): void => {+ const tag = openingTag(node);+ if (tag) {+ for (const attribute of tag.attributes.properties) {+ if (+ ts.isJsxAttribute(attribute) &&+ attribute.name.getText(file) === name &&+ attribute.initializer+ ) {+ texts.push(attribute.initializer.getText(file));+ }+ }+ }+ ts.forEachChild(node, visit);+ };+ visit(file);+ return texts;+}