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: one tooltip design everywhere, matching chat's text colours in light and dark (#14172)
Michael Han8bb21cca9a94
diff --git a/studio/frontend/src/app/provider.tsx b/studio/frontend/src/app/provider.tsxindex 2bceaa3f2fd..c7011bd7fb4 100644--- a/studio/frontend/src/app/provider.tsx+++ b/studio/frontend/src/app/provider.tsx@@ -15,6 +15,7 @@ import {shouldUseNativeMacWindowTitlebar,} from "@/components/tauri/window-titlebar";import { Toaster } from "@/components/ui/sonner";+import { TitleTooltipLayer } from "@/components/ui/title-tooltip";import { TooltipProvider } from "@/components/ui/tooltip";import { WebUpdateBanner } from "@/components/web/update-banner";import { fetchDeviceType } from "@/config/env";@@ -1181,6 +1182,7 @@ export function AppProvider({ children }: AppProviderProps) {return (<MotionConfig reducedMotion={REDUCED_MOTION_MAP[reduceMotion]}><TooltipProvider>+ <TitleTooltipLayer /><AppearanceCustomizationEffect /><LowDeviceScaleEffect /><DeepLinkHandler onOpenUrls={receiveSharedRunConfigUrls} />diff --git a/studio/frontend/src/components/assistant-ui/sources.tsx b/studio/frontend/src/components/assistant-ui/sources.tsxindex 330a7962c59..2a776b9bd21 100644--- a/studio/frontend/src/components/assistant-ui/sources.tsx+++ b/studio/frontend/src/components/assistant-ui/sources.tsx@@ -153,7 +153,7 @@ const SourceBadge: FC<{ source: SourceData; allowRemoteIcons?: boolean }> = ({<HoverCardContentside="top"align="start"- className="!bg-black !text-white !w-72 !p-3 !rounded-2xl !shadow-md !ring-0 !duration-0"+ className="!bg-(--tooltip-bg) !text-(--tooltip-fg) !w-72 !p-3 !rounded-2xl !shadow-(--tooltip-shadow) !ring-0 !duration-0"style={{ animation: "none" }}><div className="flex gap-2.5">@@ -167,9 +167,9 @@ const SourceBadge: FC<{ source: SourceData; allowRemoteIcons?: boolean }> = ({<p className="text-sm font-semibold leading-tight truncate">{source.title || domain}</p>- <p className="text-xs text-white/60 truncate">{domain}</p>+ <p className="text-xs text-(--tooltip-muted) truncate">{domain}</p>{source.description && (- <p className="text-xs text-white/70 leading-relaxed line-clamp-3">+ <p className="text-xs text-(--tooltip-muted) leading-relaxed line-clamp-3">{source.description}</p>)}diff --git a/studio/frontend/src/components/ui/chart.tsx b/studio/frontend/src/components/ui/chart.tsxindex 425d1ad2dd7..a4d0ab450b8 100644--- a/studio/frontend/src/components/ui/chart.tsx+++ b/studio/frontend/src/components/ui/chart.tsx@@ -4,6 +4,7 @@import * as React from "react";import * as RechartsPrimitive from "recharts";+import { roundIfSingleLine } from "@/lib/tooltip-pill";import { cn } from "@/lib/utils";// Format: { THEME_NAME: CSS_SELECTOR }@@ -246,8 +247,9 @@ function ChartTooltipContent({return (<div+ ref={roundIfSingleLine}className={cn(- "border-border/50 corner-squircle bg-background gap-1.5 rounded-lg border px-2.5 py-1.5 text-xs shadow-xl grid min-w-[calc(8rem*var(--ui-space-scale,1))] items-start",+ "tooltip-compact gap-1.5 px-2.5 py-1.5 text-xs grid min-w-[calc(8rem*var(--ui-space-scale,1))] items-start",className,)}>diff --git a/studio/frontend/src/components/ui/title-tooltip.tsx b/studio/frontend/src/components/ui/title-tooltip.tsxnew file mode 100644index 00000000000..e0b88e48ecf--- /dev/null+++ b/studio/frontend/src/components/ui/title-tooltip.tsx@@ -0,0 +1,183 @@+// 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 { useEffect, useRef, useState } from "react";+import { createPortal } from "react-dom";++import {+ type TitleStandIn,+ placeTitleTooltip,+ resolveTitleTarget,+ titleStandIn,+} from "@/lib/title-tooltip-placement";+import { roundIfSingleLine } from "@/lib/tooltip-pill";+import { Z_LAYER } from "@/lib/z-layers";++const SHOW_DELAY_MS = 120;+// An empty title is one this layer holds.+const TITLED = '[title]:not([title=""])';++type Shown = { text: string; anchor: DOMRect };++/** Disabled buttons are `pointer-events: none`, so the hit lands on their parent. */+function pointIn(el: Element, x: number, y: number): boolean {+ const r = el.getBoundingClientRect();+ return x >= r.left && x <= r.right && y >= r.top && y <= r.bottom;+}++function disabledUnder(hit: Element | null, x: number, y: number): HTMLElement | null {+ if (!hit) return null;+ for (const el of hit.querySelectorAll<HTMLElement>(`${TITLED}:disabled, ${TITLED}[aria-disabled='true']`)) {+ if (pointIn(el, x, y)) return el;+ }+ return null;+}++/** A collapsed composer pill already shows its own label tooltip from CSS. */+function hasOwnHoverLabel(el: Element): boolean {+ if (!el.hasAttribute("data-pill-label")) return false;+ const after = getComputedStyle(el, "::after").content;+ return Boolean(after) && after !== "none" && after !== "normal";+}++/** Draws native `title` tooltips in the tooltip design: the hovered title is held empty, which stops+ * the OS one, and restored on leave. */+export function TitleTooltipLayer() {+ const [shown, setShown] = useState<Shown | null>(null);+ const [pos, setPos] = useState<{ left: number; top: number } | null>(null);+ const tipRef = useRef<HTMLDivElement | null>(null);++ useEffect(() => {+ let current: HTMLElement | null = null;+ let lifted: string | null = null;+ let standIn: TitleStandIn = null;+ let owned = false;+ let timer: number | undefined;++ const lift = (el: HTMLElement) => {+ lifted = el.getAttribute("title") ?? "";+ // Emptied, not removed: with no title the native tooltip would fall back to a titled ancestor's.+ el.setAttribute("title", "");+ if (standIn) el.setAttribute(standIn, lifted);+ };+ // React may rewrite a hovered title (re-lift it) or clear it (drop the tooltip, restore nothing).+ const retitled = new MutationObserver((records) => {+ const el = current;+ if (!el) return;+ const title = el.getAttribute("title");+ if (title) {+ lift(el);+ if (owned) setShown({ text: lifted ?? "", anchor: el.getBoundingClientRect() });+ return;+ }+ // Our own lift writes "" over the old text; React clearing it removes it, or writes "" over "".+ const cleared = title === null || records.some((r) => r.oldValue === "");+ if (!cleared) return;+ if (standIn) el.removeAttribute(standIn);+ lifted = null;+ standIn = null;+ window.clearTimeout(timer);+ setShown(null);+ setPos(null);+ });++ const release = () => {+ window.clearTimeout(timer);+ retitled.disconnect();+ if (current && lifted !== null && current.getAttribute("title") === "") {+ current.setAttribute("title", lifted);+ }+ if (current && standIn) current.removeAttribute(standIn);+ current = null;+ lifted = null;+ standIn = null;+ owned = false;+ setShown(null);+ setPos(null);+ };++ const track = (x: number, y: number) => {+ const hit = document.elementFromPoint(x, y);+ const found = hit?.closest<HTMLElement>(TITLED) ?? disabledUnder(hit, x, y);+ const el = resolveTitleTarget(+ current,+ found,+ current !== null && (current.contains(hit) || pointIn(current, x, y)),+ );+ if (el === current) return;+ release();+ if (!el || el.closest("svg") || !el.getAttribute("title")?.trim()) return;+ current = el;+ // The title may be the control's only name (an icon button): keep it for assistive tech.+ standIn = titleStandIn({+ labelled: el.hasAttribute("aria-label") || el.hasAttribute("aria-labelledby"),+ named: Boolean(el.textContent?.trim()) || Boolean(el.getAttribute("alt")?.trim()),+ described: el.hasAttribute("aria-describedby") || el.hasAttribute("aria-description"),+ });+ if (standIn && el.hasAttribute(standIn)) standIn = null;+ lift(el);+ retitled.observe(el, { attributes: true, attributeFilter: ["title"], attributeOldValue: true });+ if (el.closest('[data-slot="tooltip-trigger"]') || hasOwnHoverLabel(el)) return;+ timer = window.setTimeout(() => {+ if (current !== el || !el.isConnected || lifted === null) return;+ owned = true;+ setShown({ text: lifted, anchor: el.getBoundingClientRect() });+ }, SHOW_DELAY_MS);+ };++ const onMove = (event: PointerEvent) => {+ if (event.pointerType === "touch") return;+ track(event.clientX, event.clientY);+ };+ const onLeaveWindow = (event: PointerEvent) => {+ if (!event.relatedTarget) release();+ };+ document.addEventListener("pointermove", onMove, { capture: true, passive: true });+ document.addEventListener("pointerout", onLeaveWindow, true);+ document.addEventListener("pointerdown", release, true);+ document.addEventListener("keydown", release, true);+ window.addEventListener("scroll", release, true);+ window.addEventListener("blur", release);+ return () => {+ release();+ document.removeEventListener("pointermove", onMove, true);+ document.removeEventListener("pointerout", onLeaveWindow, true);+ document.removeEventListener("pointerdown", release, true);+ document.removeEventListener("keydown", release, true);+ window.removeEventListener("scroll", release, true);+ window.removeEventListener("blur", release);+ };+ }, []);++ useEffect(() => {+ const tip = tipRef.current;+ if (!shown || !tip) return;+ roundIfSingleLine(tip);+ setPos(+ placeTitleTooltip(+ shown.anchor,+ { width: tip.offsetWidth, height: tip.offsetHeight },+ { width: window.innerWidth, height: window.innerHeight },+ ),+ );+ }, [shown]);++ if (!shown) return null;+ return createPortal(+ <div+ ref={tipRef}+ role="tooltip"+ data-title-tooltip=""+ className="tooltip-compact pointer-events-none fixed line-clamp-[12] w-fit max-w-xs break-words whitespace-pre-line"+ style={{+ left: pos?.left ?? 0,+ top: pos?.top ?? 0,+ visibility: pos ? "visible" : "hidden",+ zIndex: Z_LAYER.TOOLTIP,+ }}+ >+ {shown.text}+ </div>,+ document.body,+ );+}diff --git a/studio/frontend/src/components/ui/tooltip.tsx b/studio/frontend/src/components/ui/tooltip.tsxindex 3baaaee9010..a9a73e47a78 100644--- a/studio/frontend/src/components/ui/tooltip.tsx+++ b/studio/frontend/src/components/ui/tooltip.tsx@@ -19,6 +19,7 @@ import {} from "@/components/ui/tooltip-modal-layer";import { resolveTooltipOpen } from "@/components/ui/tooltip-open-state";import { isTouchClick } from "@/components/ui/touch-click";+import { roundIfSingleLine } from "@/lib/tooltip-pill";import { cn } from "@/lib/utils";type ToggleFn = () => void;@@ -281,14 +282,7 @@ function TooltipContent({const contentRef = useCallback((el: React.ComponentRef<typeof TooltipPrimitive.Content> | null) => {assignRef(ref, el);- if (!el || variant !== "default") return;- const cs = getComputedStyle(el);- const lineHeight = Number.parseFloat(cs.lineHeight) || 16;- const innerHeight =- el.clientHeight -- Number.parseFloat(cs.paddingTop) -- Number.parseFloat(cs.paddingBottom);- el.classList.toggle("rounded-full!", innerHeight < lineHeight * 1.5);+ if (variant === "default") roundIfSingleLine(el);},[ref, variant],);diff --git a/studio/frontend/src/features/hub/catalog/model-inspector.tsx b/studio/frontend/src/features/hub/catalog/model-inspector.tsxindex 5c680da6b61..40748714208 100644--- a/studio/frontend/src/features/hub/catalog/model-inspector.tsx+++ b/studio/frontend/src/features/hub/catalog/model-inspector.tsx@@ -337,11 +337,11 @@ function ModelStatusChips({>This model may not be supported yet.{unslothSupport.reason && (- <span className="mt-1 block text-ui-10p5 font-normal text-white/75">+ <span className="mt-1 block text-ui-10p5 font-normal text-(--tooltip-muted)">{unslothSupport.reason}</span>)}- <span className="mt-1 block text-ui-10p5 font-normal text-white/75">+ <span className="mt-1 block text-ui-10p5 font-normal text-(--tooltip-muted)">Still downloadable to your Hugging Face cache.</span></TooltipContent>@@ -363,7 +363,7 @@ function ModelStatusChips({it from the chat model picker and choose vLLM as the Inferenceengine in its run settings.{unslothSupport.reason && (- <span className="mt-1 block text-ui-10p5 font-normal text-white/75">+ <span className="mt-1 block text-ui-10p5 font-normal text-(--tooltip-muted)">{unslothSupport.reason}</span>)}@@ -384,7 +384,7 @@ function ModelStatusChips({>This device has no supported GPU or usable MLX, so only GGUF modelscan run here.- <span className="mt-1 block text-ui-10p5 font-normal text-white/75">+ <span className="mt-1 block text-ui-10p5 font-normal text-(--tooltip-muted)">Still downloadable to your Hugging Face cache.</span></TooltipContent>@@ -403,7 +403,7 @@ function ModelStatusChips({className="tooltip-compact max-w-xs">Estimated 4-bit memory load is around {vramInfo.est} GB.- <span className="mt-1 block text-ui-10p5 font-normal text-white/75">+ <span className="mt-1 block text-ui-10p5 font-normal text-(--tooltip-muted)">{vramDetail}</span></TooltipContent>@@ -571,7 +571,7 @@ export const ModelInspector = memo(function ModelInspector({model.downloadsAllTime != null ? (<>Downloads (30 days)- <span className="mt-1 block text-ui-10p5 font-normal text-white/75">+ <span className="mt-1 block text-ui-10p5 font-normal text-(--tooltip-muted)">{formatCompact(model.downloadsAllTime)} all time</span></>diff --git a/studio/frontend/src/features/hub/catalog/models-catalog-rows.tsx b/studio/frontend/src/features/hub/catalog/models-catalog-rows.tsxindex 02ebae6ad64..d8d0d168867 100644--- a/studio/frontend/src/features/hub/catalog/models-catalog-rows.tsx+++ b/studio/frontend/src/features/hub/catalog/models-catalog-rows.tsx@@ -191,11 +191,10 @@ function CachedSizeChipLive({><span className="min-w-0 truncate">{row.label}</span><span className="ml-auto">- {/* Brightened for the dark tooltip: muted grey reads poorly there. */}<StatChipicon={PackageIcon}value={formatBytes(row.size_bytes)}- className="text-ui-11 text-white/70"+ className="text-ui-11 text-(--tooltip-muted)"/></span></li>@@ -430,11 +429,11 @@ export function buildRowStatusTooltip({This {resourceLabel} may not be supported yet.</span>{unsupportedReason && (- <span className="mt-0.5 block text-white/75">+ <span className="mt-0.5 block text-(--tooltip-muted)">{unsupportedReason}</span>)}- <span className="mt-0.5 block text-white/75">+ <span className="mt-0.5 block text-(--tooltip-muted)">Still downloadable to your Hugging Face cache.</span></TooltipLegendRow>,diff --git a/studio/frontend/src/features/profile/components/stats/token-activity-card.tsx b/studio/frontend/src/features/profile/components/stats/token-activity-card.tsxindex dfa76e8c7ef..09a6ba50a26 100644--- a/studio/frontend/src/features/profile/components/stats/token-activity-card.tsx+++ b/studio/frontend/src/features/profile/components/stats/token-activity-card.tsx@@ -31,6 +31,7 @@ import {windowBaseline,} from "../../utils/stats-format";import { StatsCard } from "./stat-primitives";+import { roundIfSingleLine } from "@/lib/tooltip-pill";const DAYS_PER_WEEK = 7;const CELL_SIZE = 11;@@ -321,7 +322,7 @@ function WeekChart({return null;}return (- <div className="rounded-md border border-border/50 bg-background px-2 py-1 text-xs shadow-md">+ <div ref={roundIfSingleLine} className="tooltip-compact">{t("settings.profile.stats.weekTooltip", {date: dateFormatter.format(parseDayKey(point.week)),tokens: formatProfileCount(point.tokens, "token", locale),diff --git a/studio/frontend/src/index.css b/studio/frontend/src/index.cssindex f4b85a479fe..ed5e5db4a07 100644--- a/studio/frontend/src/index.css+++ b/studio/frontend/src/index.css@@ -226,6 +226,14 @@:root {/* Every popup surface: a faint lift off the dimmed page. */--popup-shadow: 0 12px 32px -12px rgb(0 0 0 / 0.16), 0 2px 6px -2px rgb(0 0 0 / 0.06);+ /* Theme-following tooltips (#13997): borderless shadow in light, flat black in dark. */+ --tooltip-bg: var(--popover);+ --tooltip-fg: var(--foreground);+ /* Chat's thinking and tool text (--color-trace-foreground). */+ --tooltip-muted: color-mix(in oklab, var(--muted-foreground), var(--background) var(--trace-fade, 0%));+ --tooltip-divider: rgb(0 0 0 / 0.08);+ --tooltip-shadow: 0 4px 14px -4px rgb(0 0 0 / 0.18), 0 1px 3px rgb(0 0 0 / 0.06);+ --tooltip-shadow-rich: 0 8px 28px -6px rgb(0 0 0 / 0.2), 0 1px 3px rgb(0 0 0 / 0.06);/* Animation timing */--duration-micro: 100ms;--duration-fast: 150ms;@@ -451,6 +459,12 @@.dark {/* A faint shadow needs more alpha to read on a dark page. */--popup-shadow: 0 16px 40px -12px rgb(0 0 0 / 0.7);+ --tooltip-bg: #000000;+ /* One shade above chat's dark trace grey. */+ --tooltip-muted: var(--muted-foreground);+ --tooltip-divider: rgb(255 255 255 / 0.12);+ --tooltip-shadow: none;+ --tooltip-shadow-rich: none;/* Dark surfaces shared by ALL palettes: #181818 page, elevated #272727sidebar/cards, #3a3a3a hover, #fcfcfc ink. Palette dark blocks overrideonly accent tokens so dark mode stays consistent across themes. */@@ -2824,7 +2838,10 @@ html[data-chat-font] .aui-root {}.tooltip-compact {- @apply rounded-[11px] border-transparent bg-black px-2.5 py-1.5 text-ui-11 font-medium leading-snug text-white shadow-md;+ @apply rounded-[11px] border-transparent bg-(--tooltip-bg) px-2.5 py-1.5 text-ui-11 font-medium leading-snug text-(--tooltip-fg) shadow-(--tooltip-shadow);+ }+ .tooltip-compact .text-muted-foreground {+ color: var(--tooltip-muted) !important;}/* Queue hints must not block menu actions. */@@ -2839,24 +2856,20 @@ html[data-chat-font] .aui-root {}/* Rich tooltip — used for the context-usage and token-counter- popups (multi-row metric breakdowns). Same black surface as the+ popups (multi-row metric breakdowns). Same surface as thecompact tooltips so chat-area popovers feel like one family.Corner radius matches the user-profile dropdown in the leftsidebar (14px) so panel-level menu surfaces share a singleroundness. Uses the heading font with tracking for the structured- content. Same in both themes. */+ content. */.tooltip-rich {- @apply rounded-[16px] border-transparent bg-black px-4 py-3 font-heading tracking-wide text-white shadow-[0_8px_28px_-6px_rgba(0,0,0,0.32)];+ @apply rounded-[16px] border-transparent bg-(--tooltip-bg) px-4 py-3 font-heading tracking-wide text-(--tooltip-fg) shadow-(--tooltip-shadow-rich);}- /* Row-label color override — the popups reuse the existing prose- `text-muted-foreground` class. Fixed light gray on the black- surface keeps the label clearly legible while staying distinct- from the values (full white). */.tooltip-rich .text-muted-foreground {- color: #b1b1b1 !important;+ color: var(--tooltip-muted) !important;}.tooltip-rich .border-border\/40 {- border-color: rgb(255 255 255 / 0.12) !important;+ border-color: var(--tooltip-divider) !important;}.app-user-menu [data-slot="dropdown-menu-item"],@@ -3291,7 +3304,7 @@ html[data-chat-font] .aui-root {&[data-pill-label]:hover::after {content: attr(data-pill-label);/* Always one nowrap line, so always a full pill. */- @apply pointer-events-none absolute bottom-[calc(100%+6px)] left-1/2 z-50 -translate-x-1/2 rounded-full bg-black px-2.5 py-1.5 text-ui-11 font-medium leading-snug whitespace-nowrap text-white shadow-md;+ @apply pointer-events-none absolute bottom-[calc(100%+6px)] left-1/2 z-50 -translate-x-1/2 rounded-full bg-(--tooltip-bg) px-2.5 py-1.5 text-ui-11 font-medium leading-snug whitespace-nowrap text-(--tooltip-fg) shadow-(--tooltip-shadow);}/* Caret pills (permissions, RAG, MCP) open a menu on click instead of@@ -3830,7 +3843,7 @@ html[data-chat-font] .aui-root {.unsloth-thinking-pill[data-pill-label]:not([data-state="open"]):hover::after {content: attr(data-pill-label);- @apply pointer-events-none absolute bottom-[calc(100%+6px)] left-1/2 z-50 -translate-x-1/2 rounded-full bg-black px-2.5 py-1.5 text-ui-11 font-medium leading-snug whitespace-nowrap text-white shadow-md;+ @apply pointer-events-none absolute bottom-[calc(100%+6px)] left-1/2 z-50 -translate-x-1/2 rounded-full bg-(--tooltip-bg) px-2.5 py-1.5 text-ui-11 font-medium leading-snug whitespace-nowrap text-(--tooltip-fg) shadow-(--tooltip-shadow);}}diff --git a/studio/frontend/src/lib/title-tooltip-placement.ts b/studio/frontend/src/lib/title-tooltip-placement.tsnew file mode 100644index 00000000000..25fd62cbdf0--- /dev/null+++ b/studio/frontend/src/lib/title-tooltip-placement.ts@@ -0,0 +1,41 @@+// SPDX-License-Identifier: AGPL-3.0-only+// Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0++const GAP = 6;+const EDGE = 8;++/** Centred below `anchor`, flipped above near the bottom edge, clamped to the viewport. */+export function placeTitleTooltip(+ anchor: Pick<DOMRect, "left" | "top" | "bottom" | "width">,+ size: { width: number; height: number },+ viewport: { width: number; height: number },+): { left: number; top: number } {+ const below = anchor.bottom + GAP;+ const top =+ below + size.height + EDGE > viewport.height ? anchor.top - GAP - size.height : below;+ const centred = anchor.left + anchor.width / 2 - size.width / 2;+ const left = Math.min(Math.max(EDGE, centred), viewport.width - EDGE - size.width);+ return { left, top: Math.max(EDGE, top) };+}++/** `current`'s title is held empty, so `found` skips past it: keep `current` while still over it. */+export function resolveTitleTarget<T extends { contains(other: T | null): boolean }>(+ current: T | null,+ found: T | null,+ stillOverCurrent: boolean,+): T | null {+ if (!current || !stillOverCurrent) return found;+ return found && found !== current && current.contains(found) ? found : current;+}++export type TitleStandIn = "aria-label" | "aria-description" | null;++/** A lifted title is an unnamed control's name, else its description unless it already has one. */+export function titleStandIn({+ labelled,+ named,+ described,+}: { labelled: boolean; named: boolean; described: boolean }): TitleStandIn {+ if (!labelled && !named) return "aria-label";+ return described ? null : "aria-description";+}diff --git a/studio/frontend/src/lib/tooltip-pill.ts b/studio/frontend/src/lib/tooltip-pill.tsnew file mode 100644index 00000000000..5bf237ee20f--- /dev/null+++ b/studio/frontend/src/lib/tooltip-pill.ts@@ -0,0 +1,12 @@+// SPDX-License-Identifier: AGPL-3.0-only+// Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0++/** One line: a full pill. Wrapped: the squarer corners, so it does not read as a capsule. */+export function roundIfSingleLine(el: HTMLElement | null): void {+ if (!el) return;+ const cs = getComputedStyle(el);+ const lineHeight = Number.parseFloat(cs.lineHeight) || 16;+ const inner =+ el.clientHeight - Number.parseFloat(cs.paddingTop) - Number.parseFloat(cs.paddingBottom);+ el.classList.toggle("rounded-full!", inner < lineHeight * 1.5);+}diff --git a/studio/frontend/tests/title-tooltip-placement.test.ts b/studio/frontend/tests/title-tooltip-placement.test.tsnew file mode 100644index 00000000000..93b90f7307f--- /dev/null+++ b/studio/frontend/tests/title-tooltip-placement.test.ts@@ -0,0 +1,55 @@+// 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";++import { placeTitleTooltip, resolveTitleTarget, titleStandIn } from "../src/lib/title-tooltip-placement.ts";++const viewport = { width: 1000, height: 800 };+const size = { width: 100, height: 30 };++test("a title tooltip sits centred below its element", () => {+ assert.deepEqual(placeTitleTooltip({ left: 400, top: 100, bottom: 120, width: 40 }, size, viewport), { left: 370, top: 126 });+});++test("near the bottom edge it flips above", () => {+ assert.deepEqual(placeTitleTooltip({ left: 400, top: 760, bottom: 780, width: 40 }, size, viewport), { left: 370, top: 724 });+});++test("it stays inside the left and right edges", () => {+ assert.equal(placeTitleTooltip({ left: 0, top: 100, bottom: 120, width: 20 }, size, viewport).left, 8);+ assert.equal(placeTitleTooltip({ left: 980, top: 100, bottom: 120, width: 20 }, size, viewport).left, 892);+});++type Node = { name: string; kids: Node[]; contains(other: Node | null): boolean };+function node(name: string, kids: Node[] = []): Node {+ const n: Node = {+ name,+ kids,+ contains: (other) => other === n || kids.some((k) => k.contains(other)),+ };+ return n;+}++// Codex review on #14172: the lifted title made every second move release the tooltip.+test("a control keeps its title tooltip while the pointer moves over it", () => {+ const inner = node("inner");+ const button = node("button", [inner]);+ const panel = node("panel", [button]);+ // The lifted button is skipped, so the hit resolves to a titled ancestor, or to nothing.+ assert.equal(resolveTitleTarget(button, panel, true), button);+ assert.equal(resolveTitleTarget(button, null, true), button);+ assert.equal(resolveTitleTarget(button, inner, true), inner, "a titled child inside it still wins");+ assert.equal(resolveTitleTarget(button, panel, false), panel, "leaving it moves on");+ assert.equal(resolveTitleTarget(null, panel, false), panel);+});++// Codex review on #14172: lifting the title must not strip an icon button's only name.+test("a lifted title keeps its meaning for assistive tech", () => {+ const s = (labelled: boolean, named: boolean, described = false) => titleStandIn({ labelled, named, described });+ assert.equal(s(false, false), "aria-label", "icon-only: the title was its name");+ assert.equal(s(false, true), "aria-description", "named by text: the title was its description");+ assert.equal(s(true, false), "aria-description", "named by aria-label: the title is still its description");+ assert.equal(s(true, true, true), null, "an existing description outranks the title");+});diff --git a/studio/frontend/tests/tooltip-theme.test.ts b/studio/frontend/tests/tooltip-theme.test.tsnew file mode 100644index 00000000000..2f406b276e7--- /dev/null+++ b/studio/frontend/tests/tooltip-theme.test.ts@@ -0,0 +1,72 @@+// 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";++import { readSrc } from "./helpers/kit.ts";++const css = readSrc("index.css");++function rule(selector: string): string {+ const start = css.indexOf(`${selector} {`);+ assert.ok(start >= 0, `${selector} is gone`);+ return css.slice(start, css.indexOf("}", start));+}++// #13997: tooltips were black in both themes, with theme grey text on them.+test("tooltip surfaces follow the theme instead of a fixed black", () => {+ for (const selector of [".tooltip-compact", ".tooltip-rich"]) {+ const body = rule(selector);+ assert.match(body, /bg-\(--tooltip-bg\)/, selector);+ assert.match(body, /text-\(--tooltip-fg\)/, selector);+ assert.doesNotMatch(body, /bg-black|text-white/, selector);+ }+ for (const pseudo of css.matchAll(/content: attr\(data-pill-label\);\s*@apply ([^;]+);/g)) {+ assert.match(pseudo[1], /bg-\(--tooltip-bg\)/, "a pill label tooltip is black again");+ }+ assert.doesNotMatch(css, /#b1b1b1/, "a tooltip label colour assumes a black surface");+});++test("light tooltips are the popover surface with a shadow, dark ones flat black", () => {+ const root = css.slice(css.indexOf(":root {"), css.indexOf("}", css.indexOf(":root {")));+ const dark = css.slice(css.indexOf(".dark {"), css.indexOf("}", css.indexOf(".dark {")));+ assert.match(root, /--tooltip-bg: var\(--popover\);/);+ assert.match(root, /--tooltip-shadow: /);+ assert.match(dark, /--tooltip-bg: #000000;/);+ assert.match(dark, /--tooltip-muted: var\(--muted-foreground\);/);+ assert.match(dark, /--tooltip-shadow: none;/);+ assert.match(dark, /--tooltip-shadow-rich: none;/);+});++test("tooltip contents use the tooltip tokens, not white-on-black tints", () => {+ for (const file of [+ "components/assistant-ui/sources.tsx",+ "features/hub/catalog/model-inspector.tsx",+ "features/hub/catalog/models-catalog-rows.tsx",+ ]) {+ assert.doesNotMatch(readSrc(file), /bg-black|text-white\/\d+/, file);+ }+});++test("tooltip secondary text is chat's thinking and tool text colour", () => {+ const root = css.slice(css.indexOf(":root {"), css.indexOf("}", css.indexOf(":root {")));+ const trace = /--color-trace-foreground: (color-mix\([^;]+\));/.exec(css)?.[1];+ assert.ok(trace, "--color-trace-foreground is gone");+ assert.ok(root.includes(`--tooltip-muted: ${trace};`), "tooltip secondary text drifted from chat's trace text");+ assert.match(root, /--tooltip-fg: var\(--foreground\);/);+});++test("chart tooltips and native titles use the tooltip surface", () => {+ assert.match(readSrc("components/ui/chart.tsx"), /"tooltip-compact /);+ assert.match(readSrc("features/profile/components/stats/token-activity-card.tsx"), /className="tooltip-compact"/);+ assert.match(readSrc("app/provider.tsx"), /<TitleTooltipLayer \/>/);+ assert.match(readSrc("components/ui/title-tooltip.tsx"), /className="tooltip-compact /);+});++test("every tooltip surface outside TooltipContent rounds to a pill on one line", () => {+ assert.match(readSrc("components/ui/tooltip.tsx"), /roundIfSingleLine\(el\)/);+ assert.match(readSrc("components/ui/title-tooltip.tsx"), /roundIfSingleLine\(tip\)/);+ assert.match(readSrc("components/ui/chart.tsx"), /ref=\{roundIfSingleLine\}/);+ assert.match(readSrc("features/profile/components/stats/token-activity-card.tsx"), /ref=\{roundIfSingleLine\}/);+});