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: key group hover / focus-within / active on the group class (WebKit long-chat menus and dialogs) (#17323)
Daniel Han433317fc208d
diff --git a/studio/frontend/src/components/ui/input.tsx b/studio/frontend/src/components/ui/input.tsxindex df5e9ca0284..ad105f06c88 100644--- a/studio/frontend/src/components/ui/input.tsx+++ b/studio/frontend/src/components/ui/input.tsx@@ -122,7 +122,7 @@ function Input({ className, type, ...props }: React.ComponentProps<"input">) {{field}<spanaria-hidden="true"- className="absolute top-1/2 right-2.5 flex h-[calc(21px*var(--ui-space-scale,1))] w-4 -translate-y-1/2 flex-col overflow-hidden rounded-[5px] bg-[rgb(0_0_0_/_calc(0.07*var(--contrast-wash-gain,1)))] opacity-0 transition-opacity group-hover/number:opacity-100 group-focus-within/number:opacity-100 group-has-[input:disabled]/number:pointer-events-none group-has-[input:disabled]/number:opacity-0 dark:bg-[rgb(255_255_255_/_calc(0.12*var(--contrast-wash-gain,1)))]"+ className="absolute top-1/2 right-2.5 flex h-[calc(21px*var(--ui-space-scale,1))] w-4 -translate-y-1/2 flex-col overflow-hidden rounded-[5px] bg-[rgb(0_0_0_/_calc(0.07*var(--contrast-wash-gain,1)))] opacity-0 transition-opacity group-hover/number:opacity-100 group-focus-within/number:opacity-100 group-has-[input:disabled]/number:pointer-events-none group-has-[input:disabled]/number:opacity-0! dark:bg-[rgb(255_255_255_/_calc(0.12*var(--contrast-wash-gain,1)))]"><StepperButton direction={1} /><StepperButton direction={-1} />diff --git a/studio/frontend/tests/group-state-keys.test.ts b/studio/frontend/tests/group-state-keys.test.tsnew file mode 100644index 00000000000..fe9ddfa36bf--- /dev/null+++ b/studio/frontend/tests/group-state-keys.test.ts@@ -0,0 +1,48 @@+// 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 { groupStateKeys, keyedGroupStates } from "../vite-plugin-group-state.ts";++test("group hover, focus-within and active descendants are keyed on the group class", () => {+ assert.equal(+ keyedGroupStates(".group-hover\\:opacity-100:is(:where(.group):hover *){opacity:1}"),+ ".group-hover\\:opacity-100:is(.group:hover *){opacity:1}",+ );+ assert.equal(+ keyedGroupStates(".a:is(:where(.group\\/assistant-message):focus-within *),.b:is(:where(.group\\/row):active *)"),+ ".a:is(.group\\/assistant-message:focus-within *),.b:is(.group\\/row:active *)",+ );+});++test("other :where() forms are left alone", () => {+ for (const css of [+ ".peer-hover\\:x:is(:where(.peer):hover~*){}",+ ".x:is(:where(.group):focus-visible *){}",+ ".x:is(:where(.group):has(input:disabled) *){}",+ ":where(.a > *):where(:not(:last-child)){}",+ ".x:where(.dark, .dark *){}",+ ]) {+ assert.equal(keyedGroupStates(css), css);+ }+});++test("idempotent", () => {+ const once = keyedGroupStates(".x:is(:where(.group\\/n):hover *)");+ assert.equal(keyedGroupStates(once), once);+});++test("the plugin runs on CSS after Tailwind in the shipped config", () => {+ const hook = groupStateKeys().transform as { handler: (code: string) => { code: string } | null };+ assert.equal(hook.handler(".x{}"), null);+ assert.equal(hook.handler(".x:is(:where(.group):hover *){}")?.code, ".x:is(.group:hover *){}");+ const vite = readFileSync(new URL("../vite.config.ts", import.meta.url), "utf8");+ assert.match(vite, /tailwindcss\(\), childSelectorOrder\(\), hasAnchorOrder\(\), viewportMediaGate\(\), groupStateKeys\(\),/);+});++test("a disabled number field keeps its stepper hidden against the group hover / focus-within reveal", () => {+ const input = readFileSync(new URL("../src/components/ui/input.tsx", import.meta.url), "utf8");+ assert.match(input, /group-has-\[input:disabled\]\/number:opacity-0!/);+});diff --git a/studio/frontend/tests/has-subject-after.test.ts b/studio/frontend/tests/has-subject-after.test.tsindex 77a7b4f801a..00e97159c41 100644--- a/studio/frontend/tests/has-subject-after.test.ts+++ b/studio/frontend/tests/has-subject-after.test.ts@@ -59,7 +59,7 @@ const ALLOWED_TAILWIND = new Set<string>(["group-has-[[data-orientation=horizontal]]/field:text-balance","group-has-[[data-slot=command-shortcut]]/command-item:hidden","group-has-[input:disabled]/number:pointer-events-none",- "group-has-[input:disabled]/number:opacity-0",+ "group-has-[input:disabled]/number:opacity-0!","group-has-[>input]/input-group:pt-3","group-has-[>input]/input-group:pb-3","group-has-[>svg]/alert:col-start-2",diff --git a/studio/frontend/vite-plugin-group-state.ts b/studio/frontend/vite-plugin-group-state.tsnew file mode 100644index 00000000000..949565bd287--- /dev/null+++ b/studio/frontend/vite-plugin-group-state.ts@@ -0,0 +1,30 @@+// 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 type { Plugin } from "vite";++/**+ * Tailwind v4 writes `group-hover:x` as `.x:is(:where(.group):hover *)`. WebKit cannot key that invalidation+ * on `.group` inside `:where()`, so when :hover, :focus-within or :active flips on any element (each ancestor+ * of the pointer or focus, up to <html>) it re-styles that element's whole subtree: about 150 ms per focus+ * move into a menu or dialog on a 150-turn chat. `.group:hover *` is keyed on the class. The selector matches+ * the same elements; specificity goes up by one class, as in Tailwind v3, for all three states alike.+ */+const GROUP_STATE = /:where\((\.(?:[\w-]|\\.)+)\):(hover|focus-within|active)(?=\s*\*)/g;++export function keyedGroupStates(css: string): string {+ return css.replace(GROUP_STATE, "$1:$2");+}++export function groupStateKeys(): Plugin {+ return {+ name: "group-state-keys",+ transform: {+ filter: { id: /\.css(?:$|\?)/, code: ":where(" },+ handler(code) {+ const next = keyedGroupStates(code);+ return next === code ? null : { code: next, map: null };+ },+ },+ };+}diff --git a/studio/frontend/vite.config.ts b/studio/frontend/vite.config.tsindex 6dc94968372..adb5b6ef0bd 100644--- a/studio/frontend/vite.config.ts+++ b/studio/frontend/vite.config.ts@@ -7,6 +7,7 @@ import react from "@vitejs/plugin-react";import { type Plugin, defineConfig } from "vite";import { chatPagePreload } from "./vite-plugin-chat-preload";import { childSelectorOrder } from "./vite-plugin-child-selectors";+import { groupStateKeys } from "./vite-plugin-group-state";import { hasAnchorOrder } from "./vite-plugin-has-anchor";import { katexWoff2Only } from "./vite-plugin-katex-woff2";import { preloadNonceInHead } from "./vite-plugin-preload-nonce";@@ -61,7 +62,7 @@ export default defineConfig({cacheDir: process.env.VITE_TEST_CACHE_DIR || "node_modules/.vite",// Reasoning's highlighter loads only the grammar it needs in its module worker.worker: { format: "es" },- plugins: [react(), tailwindcss(), childSelectorOrder(), hasAnchorOrder(), viewportMediaGate(), { ...assistantUiTapStandIn(), apply: "build", enforce: "pre" }, smokeModuleDelay(), previewRuntime(), chatPagePreload(), katexWoff2Only(), preloadNonceInHead()],+ plugins: [react(), tailwindcss(), childSelectorOrder(), hasAnchorOrder(), viewportMediaGate(), groupStateKeys(), { ...assistantUiTapStandIn(), apply: "build", enforce: "pre" }, smokeModuleDelay(), previewRuntime(), chatPagePreload(), katexWoff2Only(), preloadNonceInHead()],// prevent ancestor PostCSS configs from leaking into installs; Tailwind uses its Vite plugin.css: {postcss: {diff --git a/tests/studio/has_subject_allowlist.txt b/tests/studio/has_subject_allowlist.txtindex f0ac07d1303..681a76a26dc 100644--- a/tests/studio/has_subject_allowlist.txt+++ b/tests/studio/has_subject_allowlist.txt@@ -46,7 +46,7 @@:where(.group\/input-group):has(> input) .group-has-\[\>input\]\/input-group\:pt-3:where(.group\/input-group):has([data-slot="combobox-clear"]) .group-has-data-\[slot\=combobox-clear\]\/input-group\:hidden:where(.group\/menu-item):has([data-sidebar="menu-action"]) .group-has-data-\[sidebar\=menu-action\]\/menu-item\:pr-8-:where(.group\/number):has(:is(input:disabled)) .group-has-\[input\:disabled\]\/number\:opacity-0+:where(.group\/number):has(:is(input:disabled)) .group-has-\[input\:disabled\]\/number\:opacity-0\!:where(.group\/number):has(:is(input:disabled)) .group-has-\[input\:disabled\]\/number\:pointer-events-none[data-sonner-toast][data-styled="true"]:has([data-button]) [data-button][data-sonner-toast][data-styled="true"]:has([data-button]) [data-content]