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.

Long-chat gate: settle pointer targets before a trusted hover or click (#17274)

Daniel Hanc2eedcb2b1eb
diff --git a/tests/studio/_area_matrix.py b/tests/studio/_area_matrix.py
index 22c5508cd17..eab067e2b42 100644
--- a/tests/studio/_area_matrix.py
+++ b/tests/studio/_area_matrix.py
@@ -689,7 +689,30 @@ FIND = """(spec) => {
el = a ? [...a.querySelectorAll(spec.slice(5))].filter(vis).pop() : null; }
else el = [...document.querySelectorAll(spec)].filter(vis).pop();
if (!el) return false;
- el.setAttribute('data-gate-target', ''); el.scrollIntoView({block: 'nearest'}); return true;
+ // Instant: the thread viewport is scroll-smooth, so a plain scrollIntoView animates and returns while the
+ // target is still moving; a trusted pointer action then lands wherever the target has got to.
+ el.setAttribute('data-gate-target', ''); el.scrollIntoView({block: 'nearest', behavior: 'instant'});
+ return true;
+}"""
+# The target must hold still and be hit at its centre: the floating composer can cover a row scrolled in from
+# below. Only an occluded target is re-centred, so a clear one adds no scroll to the measured window.
+STEADY = """async () => {
+ const el = document.querySelector('[data-gate-target]');
+ if (!el) return false;
+ const frame = () => new Promise((r) => requestAnimationFrame(() => r()));
+ const still = async () => {
+ let last = '', same = 0;
+ for (let i = 0; i < 120 && same < 3; i++) {
+ await frame();
+ const r = el.getBoundingClientRect();
+ const k = `${Math.round(r.x)},${Math.round(r.y)},${Math.round(r.width)},${Math.round(r.height)}`;
+ same = k === last ? same + 1 : 0; last = k;
+ }
+ };
+ const hit = () => { const r = el.getBoundingClientRect(); const t = document.elementFromPoint(r.x + r.width / 2, r.y + r.height / 2); return !!t && (t === el || el.contains(t)); };
+ await still();
+ if (!hit()) { el.scrollIntoView({block: 'center', behavior: 'instant'}); await still(); }
+ return hit();
}"""
CLICK = """(right) => {
const el = document.querySelector('[data-gate-target]'); const r = el.getBoundingClientRect();
@@ -840,6 +863,9 @@ class Page:
return not problems
if not page.evaluate(FIND, arg):
return False
+ if kind in ("hover", "pclick") and not page.evaluate(STEADY):
+ self.last_error = "target never held still and clear of overlays under its centre"
+ return False
if kind == "hover":
page.locator("[data-gate-target]").first.hover(timeout = 3_000, force = True)
self.hovered = True