Skip to content

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.

Studio: title tooltips stop walking the whole thread on every pointer move (#17304)

Daniel Hanb0e84bf0f8aa
diff --git a/studio/frontend/src/components/ui/title-tooltip.tsx b/studio/frontend/src/components/ui/title-tooltip.tsx
index e0b88e48ecf..5f49bd32bb2 100644
--- a/studio/frontend/src/components/ui/title-tooltip.tsx
+++ b/studio/frontend/src/components/ui/title-tooltip.tsx
@@ -25,10 +25,27 @@ function pointIn(el: Element, x: number, y: number): boolean {
return x >= r.left && x <= r.right && y >= r.top && y <= r.bottom;
}
+const DISABLED_TITLED = `${TITLED}:disabled, ${TITLED}[aria-disabled='true']`;
+
+/** Runs on every pointermove. With the pointer over the chat column's margins the hit is the thread
+ * viewport, so a subtree query would walk every message (~2.5 ms per move at 200 turns). A hit above
+ * the message rows means the point is in none of them (a row under it would have been the hit), so
+ * their subtrees are skipped. */
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;
+ if (!hit.querySelector("[data-role]")) {
+ for (const el of hit.querySelectorAll<HTMLElement>(DISABLED_TITLED)) {
+ if (pointIn(el, x, y)) return el;
+ }
+ return null;
+ }
+ const walker = document.createTreeWalker(hit, NodeFilter.SHOW_ELEMENT, {
+ acceptNode: (node) =>
+ (node as Element).hasAttribute("data-role") ? NodeFilter.FILTER_REJECT : NodeFilter.FILTER_ACCEPT,
+ });
+ for (let node = walker.nextNode(); node; node = walker.nextNode()) {
+ const el = node as HTMLElement;
+ if (el.hasAttribute("title") && el.matches(DISABLED_TITLED) && pointIn(el, x, y)) return el;
}
return null;
}
diff --git a/studio/frontend/tests/title-tooltip-thread-rows.test.ts b/studio/frontend/tests/title-tooltip-thread-rows.test.ts
new file mode 100644
index 00000000000..f4bd8d61c05
--- /dev/null
+++ b/studio/frontend/tests/title-tooltip-thread-rows.test.ts
@@ -0,0 +1,19 @@
+// 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";
+
+const read = (path: string) => readFileSync(new URL(`../src/${path}`, import.meta.url), "utf8");
+
+test("the disabled-control lookup on pointermove skips message rows instead of walking the thread", () => {
+ const src = read("components/ui/title-tooltip.tsx");
+ const fn = src.slice(src.indexOf("function disabledUnder"), src.indexOf("\n}\n", src.indexOf("function disabledUnder")));
+ assert.match(fn, /hasAttribute\("data-role"\) \? NodeFilter\.FILTER_REJECT/);
+ assert.match(fn, /if \(!hit\.querySelector\("\[data-role\]"\)\)/);
+ // The skip relies on message rows (and only them) carrying data-role.
+ const thread = read("components/assistant-ui/thread.tsx");
+ assert.match(thread, /data-role="assistant"/);
+ assert.match(thread, /data-role="user"/);
+});