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: let the custom accent recolor the brand variable too (#7604)
Michael Han009a005099b1
diff --git a/studio/frontend/src/components/ui/radio-group.tsx b/studio/frontend/src/components/ui/radio-group.tsxindex 62225adc6e7..a1aea7232fa 100644--- a/studio/frontend/src/components/ui/radio-group.tsx+++ b/studio/frontend/src/components/ui/radio-group.tsx@@ -36,7 +36,9 @@ function RadioGroupItem({><RadioGroupPrimitive.Indicatordata-slot="radio-group-indicator"- className="group-aria-invalid/radio-group-item:text-destructive flex size-4 items-center justify-center text-white"+ // The dot sits on data-checked:bg-primary, which a custom accent can+ // set to any color, so it has to track that background's foreground.+ className="group-aria-invalid/radio-group-item:text-destructive flex size-4 items-center justify-center text-primary-foreground"><HugeiconsIconicon={CircleIcon}diff --git a/studio/frontend/src/components/ui/resizable.tsx b/studio/frontend/src/components/ui/resizable.tsxindex 60df343b15e..ed1e8a880f8 100644--- a/studio/frontend/src/components/ui/resizable.tsx+++ b/studio/frontend/src/components/ui/resizable.tsx@@ -39,13 +39,13 @@ function ResizableHandle({<ResizablePrimitive.Separatordata-slot="resizable-handle"className={cn(- "group bg-border/80 relative z-10 flex w-px cursor-col-resize items-center justify-center transition-[background-color,box-shadow] duration-150 ease-out after:absolute after:inset-y-0 after:left-1/2 after:w-2 after:-translate-x-1/2 hover:bg-primary/80 hover:shadow-[0_0_16px_rgba(23,184,139,0.55)] active:bg-primary/90 active:shadow-[0_0_18px_rgba(23,184,139,0.7)] focus-visible:bg-primary/80 focus-visible:ring-1 focus-visible:ring-ring focus-visible:outline-hidden data-[panel-group-direction=vertical]:h-px data-[panel-group-direction=vertical]:w-full data-[panel-group-direction=vertical]:cursor-row-resize data-[panel-group-direction=vertical]:after:left-0 data-[panel-group-direction=vertical]:after:h-2 data-[panel-group-direction=vertical]:after:w-full data-[panel-group-direction=vertical]:after:translate-x-0 data-[panel-group-direction=vertical]:after:-translate-y-1/2 [&[data-panel-group-direction=vertical]>div]:rotate-90",+ "group bg-border/80 relative z-10 flex w-px cursor-col-resize items-center justify-center transition-[background-color,box-shadow] duration-150 ease-out after:absolute after:inset-y-0 after:left-1/2 after:w-2 after:-translate-x-1/2 hover:bg-primary/80 hover:shadow-[0_0_16px_color-mix(in_srgb,var(--primary)_55%,transparent)] active:bg-primary/90 active:shadow-[0_0_18px_color-mix(in_srgb,var(--primary)_70%,transparent)] focus-visible:bg-primary/80 focus-visible:ring-1 focus-visible:ring-ring focus-visible:outline-hidden data-[panel-group-direction=vertical]:h-px data-[panel-group-direction=vertical]:w-full data-[panel-group-direction=vertical]:cursor-row-resize data-[panel-group-direction=vertical]:after:left-0 data-[panel-group-direction=vertical]:after:h-2 data-[panel-group-direction=vertical]:after:w-full data-[panel-group-direction=vertical]:after:translate-x-0 data-[panel-group-direction=vertical]:after:-translate-y-1/2 [&[data-panel-group-direction=vertical]>div]:rotate-90",className,)}{...props}>{withHandle && (- <div className="z-10 flex h-6 w-1 shrink-0 rounded-lg bg-border transition-[background-color,box-shadow,transform] duration-150 ease-out group-hover:scale-y-110 group-hover:bg-primary/80 group-hover:shadow-[0_0_12px_rgba(23,184,139,0.65)] group-active:bg-primary" />+ <div className="z-10 flex h-6 w-1 shrink-0 rounded-lg bg-border transition-[background-color,box-shadow,transform] duration-150 ease-out group-hover:scale-y-110 group-hover:bg-primary/80 group-hover:shadow-[0_0_12px_color-mix(in_srgb,var(--primary)_65%,transparent)] group-active:bg-primary" />)}</ResizablePrimitive.Separator>);diff --git a/studio/frontend/src/features/hub/hub.css b/studio/frontend/src/features/hub/hub.cssindex 8dc6dac6171..9329c9382f1 100644--- a/studio/frontend/src/features/hub/hub.css+++ b/studio/frontend/src/features/hub/hub.css@@ -19,6 +19,11 @@--status-warning: #eab308;--status-danger: #ef4444;--status-success: #11b686;+ /* Fixed ink for text on --status-success. It cannot borrow+ --primary-foreground: a custom accent recolors that, while the success+ background stays put, so the pair would drift out of contrast. This is+ the ink Classic and Minimal dark already render there, at 7.46:1. */+ --status-success-foreground: #0d0d0d;}.dark {@@ -29,6 +34,7 @@--status-warning: #fbbf24;--status-danger: #ef4444;--status-success: #11b686;+ --status-success-foreground: #0d0d0d;}@theme inline {@@ -39,6 +45,7 @@--color-status-warning: var(--status-warning);--color-status-danger: var(--status-danger);--color-status-success: var(--status-success);+ --color-status-success-foreground: var(--status-success-foreground);}@layer base {@@ -585,15 +592,17 @@}/* On-device rows reuse the result-row card but carry selection/active state:- a neutral tint for the inspected row and a success tint with a primary edge- for the model currently loaded. Discover rows never set these attributes. */+ a neutral tint for the inspected row and a success tint with a matching+ success edge for the model currently loaded. Discover rows never set these+ attributes. */.hub-page .hub-result-row[data-selected="true"] {background-color: color-mix(in srgb, var(--foreground) 5%, var(--card));}.hub-page .hub-result-row[data-active="true"] {background-color: color-mix(in srgb, var(--status-success) 7%, var(--card));- box-shadow: 0 2px 8px -2px rgba(0, 0, 0, 0.16), inset 2px 0 0 0 var(--primary);+ box-shadow: 0 2px 8px -2px rgba(0, 0, 0, 0.16),+ inset 2px 0 0 0 var(--status-success);}html.dark .hub-page .hub-result-row[data-selected="true"] {@@ -603,7 +612,7 @@html.dark .hub-page .hub-result-row[data-active="true"] {background-color: color-mix(in srgb, var(--status-success) 14%, var(--background));- box-shadow: inset 2px 0 0 0 var(--primary);+ box-shadow: inset 2px 0 0 0 var(--status-success);}/* Recent-searches suggestion panel. The surface comes from@@ -731,7 +740,7 @@both loaded and selected still reads as loaded. */html:not(.dark) .hub-page .catalog-row[data-active="true"] {background-color: color-mix(in srgb, var(--status-success) 7%, transparent);- box-shadow: inset 2px 0 0 0 var(--primary);+ box-shadow: inset 2px 0 0 0 var(--status-success);}html.dark .hub-page .catalog-row {@@ -751,7 +760,7 @@html.dark .hub-page .catalog-row[data-active="true"] {background-color: color-mix(in srgb, var(--status-success) 12%, transparent);- box-shadow: inset 2px 0 0 0 var(--primary);+ box-shadow: inset 2px 0 0 0 var(--status-success);}}@@ -840,7 +849,7 @@border-radius: 9999px;padding-inline: 0;background-color: var(--status-success);- color: var(--primary-foreground);+ color: var(--status-success-foreground);font-size: calc(0.65625rem * var(--ui-font-scale, 1));font-weight: 600;line-height: 1;@@ -1168,11 +1177,11 @@font-weight: 600;line-height: calc(1.125rem * var(--ui-font-scale, 1));letter-spacing: -0.025em;- color: var(--primary-foreground);+ color: var(--status-success-foreground);transition: background-color 150ms, transform 150ms;box-shadow: inset 0 1px 0- color-mix(in srgb, var(--primary-foreground) 18%, transparent), 0 1px 2px- color-mix(in srgb, var(--status-success) 22%, transparent);+ color-mix(in srgb, var(--status-success-foreground) 18%, transparent),+ 0 1px 2px color-mix(in srgb, var(--status-success) 22%, transparent);}.hub-run-action-btn:hover:not(:disabled) {diff --git a/studio/frontend/src/features/settings/stores/appearance-custom-store.ts b/studio/frontend/src/features/settings/stores/appearance-custom-store.tsindex 0e449092e53..3430434d621 100644--- a/studio/frontend/src/features/settings/stores/appearance-custom-store.ts+++ b/studio/frontend/src/features/settings/stores/appearance-custom-store.ts@@ -2,7 +2,11 @@// Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0import { create } from "zustand";-import { createJSONStorage, persist, type StateStorage } from "zustand/middleware";+import {+ type StateStorage,+ createJSONStorage,+ persist,+} from "zustand/middleware";import type { ResolvedTheme } from "./theme-store";// Best-effort persistence: localStorage can be blocked (private browsing) and@@ -200,7 +204,9 @@ function sanitizeImportedFonts(value: unknown): ImportedFont[] {const source = (entry ?? {}) as Partial<ImportedFont>;// Cap to the backend name length so an over-long name can't fail the PUT.const rawName = sanitizeFont(source.name);- const name = rawName ? rawName.slice(0, MAX_IMPORTED_FONT_NAME_LENGTH) : null;+ const name = rawName+ ? rawName.slice(0, MAX_IMPORTED_FONT_NAME_LENGTH)+ : null;if (!name || seen.has(name)) continue;const dataUrl = source.dataUrl;if (@@ -389,15 +395,160 @@ function hexLuminance(hex: string): number {return 0.2126 * channel(1) + 0.7152 * channel(3) + 0.0722 * channel(5);}+const FOREGROUND_DARK = "#111417";+const FOREGROUND_LIGHT = "#ffffff";+const FOREGROUND_DARK_FALLBACK = "#000000";+const FOREGROUND_CONTRAST_FLOOR = 4.5;+const ACCENT_TEXT_FLOOR = 2.5;+const ACCENT_TEXT_WASH_OPACITY = 0.2;+// Cover the full 8-bit channel range so a narrow valid contrast band is not+// skipped when the custom and elevated surfaces sit far apart.+const MIX_STEPS = 255;++/** WCAG contrast ratio between two relative luminances. */+function contrastRatio(a: number, b: number): number {+ const [high, low] = a >= b ? [a, b] : [b, a];+ return (high + 0.05) / (low + 0.05);+}++function mixColors(hex: string, target: string, amount: number): string {+ const channel = (index: number) => {+ const value = Number.parseInt(hex.slice(index, index + 2), 16);+ const targetValue = Number.parseInt(target.slice(index, index + 2), 16);+ return Math.round(value + (targetValue - value) * amount)+ .toString(16)+ .padStart(2, "0");+ };+ return `#${channel(1)}${channel(3)}${channel(5)}`;+}++/**+ * Whichever foreground actually contrasts more. A fixed luminance threshold+ * put white on mid-tone accents: #22c55e scored 2.28:1 on white against+ * 8.11:1 on the dark ink. The crossover for this pair is near 0.19, but+ * comparing the ratios needs no constant at all.+ */function readableForeground(hex: string): string {- return hexLuminance(hex) > 0.45 ? "#111417" : "#ffffff";+ const accent = hexLuminance(hex);+ const darkContrast = contrastRatio(accent, hexLuminance(FOREGROUND_DARK));+ const lightContrast = contrastRatio(accent, hexLuminance(FOREGROUND_LIGHT));+ const preferred =+ darkContrast >= lightContrast ? FOREGROUND_DARK : FOREGROUND_LIGHT;+ if (Math.max(darkContrast, lightContrast) >= FOREGROUND_CONTRAST_FLOOR) {+ return preferred;+ }+ // The preferred inks have a narrow crossover where both fall below AA.+ // True black closes it without changing the established dark ink elsewhere.+ return FOREGROUND_DARK_FALLBACK;+}++/** Palette surfaces that custom colors do not replace. */+const PALETTE_SURFACES: Record<+ ResolvedTheme,+ { background: string; elevated: string }+> = {+ light: { background: "#ffffff", elevated: "#ffffff" },+ dark: { background: "#181818", elevated: "#212121" },+};++function minimumAccentTextContrast(+ accent: string,+ backgrounds: readonly string[],+): number {+ const accentLuminance = hexLuminance(accent);+ const against = (background: string) => {+ const wash = mixColors(background, accent, ACCENT_TEXT_WASH_OPACITY);+ return Math.min(+ contrastRatio(accentLuminance, hexLuminance(background)),+ contrastRatio(accentLuminance, hexLuminance(wash)),+ );+ };+ return Math.min(...backgrounds.map(against));+}++function minimumPlainTextContrast(+ accent: string,+ backgrounds: readonly string[],+): number {+ const accentLuminance = hexLuminance(accent);+ return Math.min(+ ...backgrounds.map((background) =>+ contrastRatio(accentLuminance, hexLuminance(background)),+ ),+ );+}++function findAccentCorrection(+ accent: string,+ backgrounds: readonly string[],+ score: (hex: string, surfaces: readonly string[]) => number,+): string | null {+ const clears = (hex: string) => score(hex, backgrounds) >= ACCENT_TEXT_FLOOR;+ if (clears(accent)) {+ return accent;+ }++ const targets = [FOREGROUND_DARK_FALLBACK, FOREGROUND_LIGHT].sort(+ (a, b) => score(b, backgrounds) - score(a, backgrounds),+ );+ for (let step = 1; step <= MIX_STEPS; step += 1) {+ for (const target of targets) {+ const candidate = mixColors(accent, target, step / MIX_STEPS);+ if (clears(candidate)) {+ return candidate;+ }+ }+ }+ return null;+}++/**+ * The accent is not only a fill: text-primary and text-control-accent paint it+ * straight onto page and elevated surfaces, including primary washes up to+ * 20%. A pale pick in light mode, or a near-black one in dark, then disappears.+ * Hold custom accents to the same 2.5:1 bar across both plain and tinted uses.+ *+ * Find the smallest correction in either direction. Endpoint order is based+ * on actual worst-case contrast, so a mid-gray background cannot send a+ * failing accent toward white when black is the readable endpoint. Arbitrary+ * custom and elevated surfaces can make the stronger wash constraint+ * impossible; in that case the plain-surface floor remains mandatory.+ */+function legibleAccent(accent: string, backgrounds: readonly string[]): string {+ const washSafe = findAccentCorrection(+ accent,+ backgrounds,+ minimumAccentTextContrast,+ );+ if (washSafe) {+ return washSafe;+ }++ const plainSafe = findAccentCorrection(+ accent,+ backgrounds,+ minimumPlainTextContrast,+ );+ if (plainSafe) {+ return plainSafe;+ }++ const targets = [FOREGROUND_DARK_FALLBACK, FOREGROUND_LIGHT].sort(+ (a, b) =>+ minimumPlainTextContrast(b, backgrounds) -+ minimumPlainTextContrast(a, backgrounds),+ );+ return targets[0] ?? FOREGROUND_DARK_FALLBACK;}/*** FontFaces registered for imported fonts, keyed by family name. The dataUrl is* tracked too so a re-import under the same name (new bytes) replaces the face.*/-const registeredFontFaces = new Map<string, { face: FontFace; dataUrl: string }>();+const registeredFontFaces = new Map<+ string,+ { face: FontFace; dataUrl: string }+>();function syncImportedFonts(fonts: ImportedFont[]): void {if (typeof document === "undefined" || !("fonts" in document)) return;@@ -436,12 +587,20 @@ function syncImportedFonts(fonts: ImportedFont[]): void {}/**- * The custom "Accent" recolors the accent family (toggles, badges, chart-1).- * Focus/selection rings and button colors (--primary) are deliberately left- * alone: highlight borders stay neutral and Classic's buttons stay neutral.+ * The custom "Accent" recolors the whole accent family: toggles and badges+ * (--control-accent), charts (--chart-1), and the brand color behind primary+ * buttons, active pills and meter labels (--primary). Only set while the user+ * has picked an accent, so every palette keeps its own colors by default.+ *+ * Focus rings are unaffected: --ring is its own neutral in every palette.+ * --verified stays pinned to the brand green on purpose, since it signals+ * status rather than theme.*/-const ACCENT_VARS = ["--control-accent", "--chart-1"] as const;-const ACCENT_FG_VARS = ["--control-accent-foreground"] as const;+const ACCENT_VARS = ["--control-accent", "--chart-1", "--primary"] as const;+const ACCENT_FG_VARS = [+ "--control-accent-foreground",+ "--primary-foreground",+] as const;/*** Push the customization onto <html> as inline CSS variables, attributes, and@@ -463,10 +622,18 @@ export function applyCustomizationToDocument(};const colors = c.colors[resolved];-- for (const name of ACCENT_VARS) setVar(name, colors.accent);+ const paletteSurfaces = PALETTE_SURFACES[resolved];++ const accent = colors.accent+ ? legibleAccent(colors.accent, [+ colors.background ?? paletteSurfaces.background,+ paletteSurfaces.elevated,+ ])+ : null;+ for (const name of ACCENT_VARS) setVar(name, accent);for (const name of ACCENT_FG_VARS) {- setVar(name, colors.accent ? readableForeground(colors.accent) : null);+ // Keyed off the corrected accent, since that is the color labels sit on.+ setVar(name, accent ? readableForeground(accent) : null);}setVar("--background", colors.background);setVar("--foreground", colors.foreground);@@ -515,7 +682,10 @@ export function applyCustomizationToDocument(// scale reaches text through the --text-* / --text-ui-* / --leading-*// tokens in index.css.if (c.uiFontSize !== null && c.uiFontSize !== UI_FONT_SIZE_RANGE.default) {- setVar("--ui-font-scale", String(c.uiFontSize / UI_FONT_SIZE_RANGE.default));+ setVar(+ "--ui-font-scale",+ String(c.uiFontSize / UI_FONT_SIZE_RANGE.default),+ );el.setAttribute("data-ui-font-size", String(c.uiFontSize));} else {setVar("--ui-font-scale", null);@@ -563,7 +733,8 @@ export function applyCustomizationToDocument(* (canvas-confetti, view transitions) that CSS/MotionConfig cannot reach.*/export function prefersReducedMotion(): boolean {- const setting = useAppearanceCustomStore.getState().customization.reduceMotion;+ const setting =+ useAppearanceCustomStore.getState().customization.reduceMotion;if (setting === "on") return true;if (setting === "off") return false;return (diff --git a/studio/frontend/tests/appearance-accent-vars.test.ts b/studio/frontend/tests/appearance-accent-vars.test.tsnew file mode 100644index 00000000000..b8b77b00987--- /dev/null+++ b/studio/frontend/tests/appearance-accent-vars.test.ts@@ -0,0 +1,281 @@+// 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";++/** Minimal <html> stand-in: the applier only needs style, attributes, classes. */+function stubDocument() {+ const vars = new Map<string, string>();+ const attributes = new Set<string>();+ const classes = new Set<string>();+ const element = {+ style: {+ setProperty: (name: string, value: string) => vars.set(name, value),+ removeProperty: (name: string) => vars.delete(name),+ },+ setAttribute: (name: string) => attributes.add(name),+ removeAttribute: (name: string) => attributes.delete(name),+ toggleAttribute: (name: string, on: boolean) =>+ on ? attributes.add(name) : attributes.delete(name),+ classList: {+ toggle: (name: string, on: boolean) =>+ on ? classes.add(name) : classes.delete(name),+ },+ };+ // No "fonts" key, so syncImportedFonts bails before touching FontFace.+ (globalThis as { document?: unknown }).document = {+ documentElement: element,+ };+ return vars;+}++const vars = stubDocument();++const { applyCustomizationToDocument, DEFAULT_CUSTOMIZATION } = await import(+ "../src/features/settings/stores/appearance-custom-store.ts"+);++const withAccent = (accent: string | null) => ({+ ...DEFAULT_CUSTOMIZATION,+ colors: {+ light: { ...DEFAULT_CUSTOMIZATION.colors.light, accent },+ dark: { ...DEFAULT_CUSTOMIZATION.colors.dark, accent },+ },+});++test("a custom accent recolors the brand variable, not just the control one", () => {+ applyCustomizationToDocument(withAccent("#7c3aed"), "light");++ // --primary drives primary buttons, active composer pills and the meter+ // percentages; leaving it out is what stranded them on the palette green.+ assert.equal(vars.get("--primary"), "#7c3aed");+ assert.equal(vars.get("--control-accent"), "#7c3aed");+ assert.equal(vars.get("--chart-1"), "#7c3aed");+});++test("both foregrounds follow the accent so button labels stay readable", () => {+ applyCustomizationToDocument(withAccent("#7c3aed"), "light");+ const onDark = vars.get("--primary-foreground");+ assert.equal(vars.get("--control-accent-foreground"), onDark);++ applyCustomizationToDocument(withAccent("#fde68a"), "light");+ assert.notEqual(vars.get("--primary-foreground"), onDark);+});++/** WCAG relative luminance, independent of the implementation under test. */+function luminance(hex: string): number {+ const channel = (index: number) => {+ const value = Number.parseInt(hex.slice(index, index + 2), 16) / 255;+ return value <= 0.03928 ? value / 12.92 : ((value + 0.055) / 1.055) ** 2.4;+ };+ return 0.2126 * channel(1) + 0.7152 * channel(3) + 0.0722 * channel(5);+}++function ratio(a: string, b: string): number {+ const [high, low] = [luminance(a), luminance(b)].sort((x, y) => y - x);+ return ((high ?? 0) + 0.05) / ((low ?? 0) + 0.05);+}++function mix(foreground: string, background: string, opacity: number): string {+ const channel = (index: number) => {+ const front = Number.parseInt(foreground.slice(index, index + 2), 16);+ const back = Number.parseInt(background.slice(index, index + 2), 16);+ return Math.round(front * opacity + back * (1 - opacity))+ .toString(16)+ .padStart(2, "0");+ };+ return `#${channel(1)}${channel(3)}${channel(5)}`;+}++test("the foreground is the higher-contrast of the two, not a luminance guess", () => {+ // Mid-tone accents are the ones a fixed 0.45 cutoff got wrong.+ for (const accent of [+ "#22c55e",+ "#17b88b",+ "#339cff",+ "#f59e0b",+ "#4ade80",+ "#7c3aed",+ "#e11d48",+ "#0d0d0d",+ "#fde68a",+ "#ececec",+ ]) {+ applyCustomizationToDocument(withAccent(accent), "light");+ const renderedAccent = vars.get("--primary") ?? "";+ const chosen = vars.get("--primary-foreground") ?? "";+ assert.ok(+ ratio(renderedAccent, chosen) >=+ Math.max(+ ratio(renderedAccent, "#111417"),+ ratio(renderedAccent, "#ffffff"),+ ),+ `${renderedAccent}: ${chosen} is not the highest-contrast foreground`,+ );+ }+});++test("accent labels always clear WCAG AA, including the ink crossover", () => {+ for (const accent of ["#22c55e", "#7a7a7a"]) {+ applyCustomizationToDocument(withAccent(accent), "light");+ const renderedAccent = vars.get("--primary") ?? "";+ const chosen = vars.get("--primary-foreground") ?? "";+ assert.ok(+ ratio(renderedAccent, chosen) >= 4.5,+ `${renderedAccent} on ${chosen} is only ${ratio(renderedAccent, chosen).toFixed(2)}:1`,+ );+ }+ assert.equal(vars.get("--primary-foreground"), "#000000");+});++test("no accent leaves every palette variable alone", () => {+ applyCustomizationToDocument(withAccent("#7c3aed"), "light");+ applyCustomizationToDocument(withAccent(null), "light");++ for (const name of [+ "--primary",+ "--primary-foreground",+ "--control-accent",+ "--control-accent-foreground",+ "--chart-1",+ ]) {+ assert.equal(vars.has(name), false, `${name} should be removed`);+ }+});++test("focus rings are never touched, so highlight borders stay neutral", () => {+ applyCustomizationToDocument(withAccent("#7c3aed"), "light");+ assert.equal(vars.has("--ring"), false);+ // Status green is a signal, not a theme color.+ assert.equal(vars.has("--verified"), false);+});++test("custom accents already safe on their strongest wash stay untouched", () => {+ for (const [accent, mode] of [+ ["#17b88b", "dark"],+ ["#4dabff", "dark"],+ ["#171717", "light"],+ ["#ededed", "dark"],+ ] as const) {+ applyCustomizationToDocument(withAccent(accent), mode);+ assert.equal(vars.get("--primary"), accent, `${accent} in ${mode}`);+ }+});++test("an accent too pale to read as text is pulled into range", () => {+ const background = "#ffffff";+ assert.ok(ratio("#fde68a", background) < 2.5);++ applyCustomizationToDocument(withAccent("#fde68a"), "light");+ const corrected = vars.get("--primary") ?? "";++ assert.notEqual(corrected, "#fde68a");+ assert.ok(+ ratio(corrected, background) >= 2.5,+ `${corrected} is only ${ratio(corrected, background).toFixed(2)}:1`,+ );+ const wash = mix(corrected, background, 0.2);+ assert.ok(+ ratio(corrected, wash) >= 2.5,+ `${corrected} is only ${ratio(corrected, wash).toFixed(2)}:1 on ${wash}`,+ );+ // Darkened, not discarded: still a yellow, red channel still leads.+ const [r, g, b] = [1, 3, 5].map((i) =>+ Number.parseInt(corrected.slice(i, i + 2), 16),+ ) as [number, number, number];+ assert.ok(r > b && g > b, `${corrected} lost its hue`);+});++test("a near-black accent is lifted in dark mode instead", () => {+ applyCustomizationToDocument(withAccent("#101010"), "dark");+ const corrected = vars.get("--primary") ?? "";+ assert.notEqual(corrected, "#101010");+ assert.ok(ratio(corrected, "#181818") >= 2.5);+ // Lightened, so it reads against the dark page.+ assert.ok(+ Number.parseInt(corrected.slice(1, 3), 16) > 0x10,+ `${corrected} was not lightened`,+ );+});++test("the label follows the corrected accent, not the raw pick", () => {+ applyCustomizationToDocument(withAccent("#fde68a"), "light");+ const corrected = vars.get("--primary") ?? "";+ const chosen = vars.get("--primary-foreground") ?? "";+ const other = chosen === "#ffffff" ? "#111417" : "#ffffff";+ assert.ok(ratio(corrected, chosen) >= ratio(corrected, other));+});++test("a custom background does not hide the unchanged elevated surfaces", () => {+ const onDark = {+ ...DEFAULT_CUSTOMIZATION,+ colors: {+ light: { accent: "#fde68a", background: "#101014", foreground: null },+ dark: { ...DEFAULT_CUSTOMIZATION.colors.dark, accent: null },+ },+ };+ applyCustomizationToDocument(onDark, "light");+ const corrected = vars.get("--primary") ?? "";+ assert.notEqual(corrected, "#fde68a");+ assert.ok(ratio(corrected, "#101014") >= 2.5);+ assert.ok(ratio(corrected, "#ffffff") >= 2.5);+});++test("the correction endpoint follows contrast rather than a luminance guess", () => {+ const midGray = {+ ...DEFAULT_CUSTOMIZATION,+ colors: {+ light: { accent: "#aaaaaa", background: "#aaaaaa", foreground: null },+ dark: { ...DEFAULT_CUSTOMIZATION.colors.dark, accent: null },+ },+ };+ applyCustomizationToDocument(midGray, "light");+ const corrected = vars.get("--primary") ?? "";+ assert.notEqual(corrected, "#ffffff");+ assert.ok(ratio(corrected, "#aaaaaa") >= 2.5);+ assert.ok(ratio(corrected, "#ffffff") >= 2.5);+});++test("a narrow valid band between custom and elevated surfaces is not skipped", () => {+ const splitSurfaces = {+ ...DEFAULT_CUSTOMIZATION,+ colors: {+ light: { ...DEFAULT_CUSTOMIZATION.colors.light, accent: null },+ dark: { accent: "#44d088", background: "#4bba47", foreground: null },+ },+ };+ applyCustomizationToDocument(splitSurfaces, "dark");+ const corrected = vars.get("--primary") ?? "";+ assert.ok(ratio(corrected, "#4bba47") >= 2.5);+ assert.ok(ratio(corrected, "#212121") >= 2.5);+});++test("loaded-model stripes stay on the semantic success color", () => {+ const hubCss = readFileSync(+ new URL("../src/features/hub/hub.css", import.meta.url),+ "utf8",+ );+ const activeBlocks = [+ ...hubCss.matchAll(/\[data-active="true"\]\s*\{([^}]+)\}/g),+ ];+ assert.equal(activeBlocks.length, 4);+ for (const [, declarations = ""] of activeBlocks) {+ assert.match(declarations, /box-shadow:[^;]+var\(--status-success\)/);+ assert.doesNotMatch(declarations, /var\(--primary\)/);+ }+});++test("resize-handle glows follow the primary token", () => {+ const source = readFileSync(+ new URL("../src/components/ui/resizable.tsx", import.meta.url),+ "utf8",+ );+ assert.doesNotMatch(source, /rgba\(23,\s*184,\s*139/);+ assert.equal(+ source.match(/color-mix\(in_srgb,var\(--primary\)_[0-9]+%,transparent\)/g)+ ?.length,+ 3,+ );+});