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
tests: click the inline Delete button #13615 put back on the action bar (#13634)
Daniel Han03022a4ed13a
diff --git a/tests/studio/playwright_heavy_thread.py b/tests/studio/playwright_heavy_thread.pyindex aefd4024711..ce726190d5b 100644--- a/tests/studio/playwright_heavy_thread.py+++ b/tests/studio/playwright_heavy_thread.py@@ -600,45 +600,14 @@ async (timeoutMs) => {}"""-# Delete is the last item of the reply's More menu (#12735 took it off the action bar). The menu is-# opened and the item found BEFORE the clock starts, so the window still holds only what selecting-# Delete costs: Radix closing the menu, and the message leaving the thread. Opening the menu is the-# `menu` action's number already. The trigger opens on `pointerdown`, as MENU_JS explains; an item-# selects on `click`.+# Delete is a button on the reply's action bar again since #13615 (#12735 had moved it into the More+# menu). The button is found before the clock starts, so the window holds only what Delete costs: the+# message leaving the thread.DELETE_JS = """async (timeoutMs) => {const api = window.__heavyThread;- const trigger = api.actionButton("More");- if (!trigger) return null;- const content = () => document.querySelector(".aui-action-bar-more-content");- // The portal mounting is a change to body's children, so the lookup runs on that mutation and- // not once per frame while the menu is still on its way.- let menu = content();- const watcher = new MutationObserver(() => { menu = content(); });- watcher.observe(document.body, { childList: true, subtree: false });- const pointer = {- bubbles: true, cancelable: true, composed: true,- button: 0, pointerId: 1, pointerType: "mouse", isPrimary: true,- };- trigger.dispatchEvent(new PointerEvent("pointerdown", { ...pointer, buttons: 1 }));- trigger.dispatchEvent(new PointerEvent("pointerup", { ...pointer, buttons: 0 }));- const opening = performance.now();- while (!menu && performance.now() - opening < timeoutMs) await window.__nextPaint();- watcher.disconnect();- const item = menu- ? Array.from(menu.querySelectorAll(".aui-action-bar-more-item")).find(- (candidate) => (candidate.textContent ?? "").trim() === "Delete",- )- : null;- if (!item) {- // A menu this action opened and could not use would sit over the next action.- if (menu) {- document.dispatchEvent(- new KeyboardEvent("keydown", { key: "Escape", bubbles: true, cancelable: true }),- );- }- return null;- }+ const button = api.actionButton("Delete");+ if (!button) return null;// The last assistant message. That is the cheapest delete on the React side -- one subtree// unmounts -- so this column under-measures reconciliation, though the export/rebuild/import// half is O(messages) wherever the target sits.@@ -646,7 +615,7 @@ async (timeoutMs) => {const before = api.messageCount();window.__hv.begin();const started = performance.now();- item.click();+ button.click();let ms = null;// isConnected on the captured node is O(1). Re-counting [data-role] every frame would put an// O(messages) query inside the window being timed, growing like the signal.diff --git a/tests/studio/playwright_thread_weight.py b/tests/studio/playwright_thread_weight.pyindex 0ee9d914b14..67e1dcdaf32 100644--- a/tests/studio/playwright_thread_weight.py+++ b/tests/studio/playwright_thread_weight.py@@ -304,47 +304,21 @@ async (timeoutMs) => {}"""-# Delete is the last item of the reply's More menu (#12735 took it off the action bar). The menu is-# opened and the item found before the clock starts, so the number is still what selecting Delete-# costs. The trigger opens on `pointerdown`; an item selects on `click`.+# Delete is a button on the reply's action bar again since #13615 (#12735 had moved it into the More+# menu). The button is found before the clock starts, so the window holds only what Delete costs: the+# message leaving the thread.DELETE_JS = """async (timeoutMs) => {const api = window.__threadWeight;- const trigger = api.actionButton("More");- if (!trigger) return null;- const content = () => document.querySelector(".aui-action-bar-more-content");- let menu = content();- const watcher = new MutationObserver(() => { menu = content(); });- watcher.observe(document.body, { childList: true, subtree: false });- const pointer = {- bubbles: true, cancelable: true, composed: true,- button: 0, pointerId: 1, pointerType: "mouse", isPrimary: true,- };- trigger.dispatchEvent(new PointerEvent("pointerdown", { ...pointer, buttons: 1 }));- trigger.dispatchEvent(new PointerEvent("pointerup", { ...pointer, buttons: 0 }));- const opening = performance.now();- while (!menu && performance.now() - opening < timeoutMs) await window.__nextPaint();- watcher.disconnect();- const item = menu- ? Array.from(menu.querySelectorAll(".aui-action-bar-more-item")).find(- (candidate) => (candidate.textContent ?? "").trim() === "Delete",- )- : null;- if (!item) {- if (menu) {- document.dispatchEvent(- new KeyboardEvent("keydown", { key: "Escape", bubbles: true, cancelable: true }),- );- }- return null;- }+ const button = api.actionButton("Delete");+ if (!button) return null;// The last assistant message. That is the cheapest delete on the React side -- one subtree// unmounts -- so this column under-measures reconciliation, though the export/rebuild/import// half is O(messages) wherever the target sits.const target = api.lastAssistantMessage();const before = api.messageCount();const started = performance.now();- item.click();+ button.click();// isConnected on the captured node is O(1). Re-counting [data-role] every frame would put an// O(messages) query inside the window being timed, growing like the signal.while (performance.now() - started < timeoutMs) {diff --git a/tests/studio/studiobench/scene/actions.py b/tests/studio/studiobench/scene/actions.pyindex 289330ab943..04813225614 100644--- a/tests/studio/studiobench/scene/actions.py+++ b/tests/studio/studiobench/scene/actions.py@@ -709,8 +709,8 @@ OWN_TURN_TEXT = "one more"#: Remove the throwaway turn: assistant first, then the user turn, because deleting the user#: message can take the reply with it and leave the count ambiguous. Reports rather than asserts.-#: The cleanup reaches Delete through the reply's More menu (#12735), so it first waits for that-#: menu to mount. A paint or two in practice; the bound matters only when the menu is slow or never+#: The cleanup waits for the reply's Delete button (on the action bar since #13615) to mount after+#: the hover. A paint or two in practice; the bound matters only when the bar is slow or never#: comes. `stop_generation` passes what is left of its slot after the settle, clamped to these, so a#: slow menu cannot carry the turn into the next action's window. The floor is a few paints, so a#: slot already spent still tries once rather than leaving the turn in the thread.@@ -730,15 +730,9 @@ async (opts) => {const target = D.lastAssistantMessage();if (!target) return false;target.dispatchEvent(new PointerEvent("pointerover", { bubbles: true, pointerType: "mouse" }));- // Delete is the More menu's last item since #12735; see DELETE_JS.- const trigger = D.actionButton("More");- if (!trigger) return false;- const button = (await D.openMenuAndFind(trigger, "Delete", opts.menuWaitMs)).item;- if (!button) {- document.dispatchEvent(new KeyboardEvent("keydown",- { key: "Escape", bubbles: true, cancelable: true }));- return false;- }+ // Delete is a button on the reply's action bar since #13615; see DELETE_JS.+ const button = (await D.waitForActionButton("Delete", opts.menuWaitMs)).el;+ if (!button) return false;const started = performance.now();button.click();while (performance.now() - started < timeoutMs) {@@ -2382,10 +2376,10 @@ async (opts) => {// action still reported NOT RUN on the first sample rather than waiting for the running message// to stop running. Same wait, same bound and same reporting as `message_menu`.//- // Delete is the last item of the reply's More menu since #12735, not a button on the bar, so- // the wait is for the More trigger and the menu is opened BEFORE the clock starts: what this- // action times is the delete, and `message_menu` already times the menu.- const found = await D.waitForActionButton("More", opts.waitForButtonMs);+ // Delete is a button on the reply's action bar since #13615 (#12735 had moved it into the More+ // menu), so the wait is for that button, found BEFORE the clock starts: what this action times is+ // the delete.+ const found = await D.waitForActionButton("Delete", opts.waitForButtonMs);const waitedMs = found.waitedMs;if (!found.el) {return {@@ -2393,28 +2387,15 @@ async (opts) => {waitedMs,running: found.running,reason:- "no More button after waiting " + waitedMs + "ms" ++ "no Delete button after waiting " + waitedMs + "ms" +(found.running ? ": the thread was still generating, which unmounts the action bar" : ""),};}- const menu = await D.openMenuAndFind(found.el, "Delete", opts.waitForButtonMs);- const button = menu.item;- if (!button) {- document.dispatchEvent(new KeyboardEvent("keydown",- { key: "Escape", bubbles: true, cancelable: true }));- return {- ran: false,- waitedMs,- reason:- "no Delete item in the More menu (opened=" + menu.opened + ", items=" + menu.items +- ", after " + menu.openMs + "ms)",- };- }+ const button = found.el;const target = D.lastAssistantMessage();const before = D.threadTotal();const mountedBefore = D.messageCount();const started = performance.now();- // A Radix menu item selects on click, unlike its trigger.button.click();let ms = null;// isConnected on the captured node is O(1). Re-counting [data-role] every frame would put an@@ -2434,7 +2415,7 @@ async (opts) => {// alongside rather than replacing it: on a windowed mount `messageCount()` is the size of the// window and a recycled node would read as a delete. `waitedMs` is how long the bar was waited// for, which the row reports so a slot that opened too early is visible.- return { ran: true, waitedMs, menuOpenMs: menu.openMs,+ return { ran: true, waitedMs,ms: ms === null ? null : Math.round(ms * 10) / 10,before, after: D.threadTotal(),mountedBefore, mountedAfter: D.messageCount() };@@ -2467,7 +2448,6 @@ def delete_message(ctx: ActionContext) -> ActionResult:"mounted_before": raw.get("mountedBefore"),"mounted_after": raw.get("mountedAfter"),"action_bar_wait_ms": raw.get("waitedMs"),- "menu_open_ms": raw.get("menuOpenMs"),},timings = {"delete_ms": raw["ms"]},reason = None if ok else f"the message count went {raw['before']} -> {raw['after']}",diff --git a/tests/studio/studiobench/scene/selftest/test_studiobench_delete_through_more_menu.py b/tests/studio/studiobench/scene/selftest/test_studiobench_delete_on_the_action_bar.pysimilarity index 68%rename from tests/studio/studiobench/scene/selftest/test_studiobench_delete_through_more_menu.pyrename to tests/studio/studiobench/scene/selftest/test_studiobench_delete_on_the_action_bar.pyindex c5cc43ade37..bb9f5c10c33 100644--- a/tests/studio/studiobench/scene/selftest/test_studiobench_delete_through_more_menu.py+++ b/tests/studio/studiobench/scene/selftest/test_studiobench_delete_on_the_action_bar.py@@ -1,18 +1,16 @@# SPDX-License-Identifier: AGPL-3.0-only# Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0-"""`delete_message` reaches Delete where the app puts it: the last item of the reply's More menu.+"""`delete_message` reaches Delete where the app puts it: a button on the reply's action bar.-#12735 took Delete off the assistant action bar and made it the More menu's last item. The scene-still looked for a "Delete message" button on the bar, waited out `ACTION_BAR_WAIT_MS` for it, and-reported `delete_message: NOT RUN -- no Delete button`, which fails the real-path session's-liveness gate on every pull request.+#12735 moved Delete off the assistant action bar into the More menu, and #13615 put it back on the+bar as an inline button. Each move left the scene looking in the old place, waiting out its bound+and reporting `delete_message: NOT RUN`, which fails the real-path session's liveness gate.Two checks. The first runs the shipped `DELETE_JS` and `dom.js` in node against a shim of the-handful of DOM calls they make, so the menu walk is exercised rather than re-implemented. The-second reads thread.tsx and requires every control name the scene asks for to still be rendered-there, so the next move of a control fails here, with its name, instead of as a NOT RUN in a-browser job.+handful of DOM calls they make, so the lookup is exercised rather than re-implemented. The second+reads thread.tsx and requires every control name the scene asks for to still be rendered there, so+the next move of a control fails here, with its name, instead of as a NOT RUN in a browser job."""from __future__ import annotations@@ -40,10 +38,8 @@ HARNESS_JS = r"""const fs = require("fs");const domSrc = fs.readFileSync(process.argv[2], "utf8");const deleteSrc = fs.readFileSync(process.argv[3], "utf8");-const menuNames = JSON.parse(process.argv[4]);+const barNames = JSON.parse(process.argv[4]);-// A node matches a selector when the selector is in its `sel` list: dom.js reads the app through-// a short fixed list of selectors, and a real matcher would only be a second thing to get wrong.const node = (sel, attrs, kids) => {const self = {sel: sel,@@ -68,42 +64,27 @@ const node = (sel, attrs, kids) => {return self;};-const state = { menuOpen: false, escapes: 0, menuLookups: 0 };-// The portal mounting is a change to body's children, delivered to observers as the app's would be.+const state = { escapes: 0 };const observers = [];class MutationObserver {constructor(cb) { this.cb = cb; }observe() { observers.push(this); }disconnect() { const i = observers.indexOf(this); if (i >= 0) observers.splice(i, 1); }}-const setMenu = (open) => {- state.menuOpen = open;- for (const o of observers.slice()) o.cb();-};-// The menu mounts this many paints after the trigger is pressed, as a portal does a commit later.-let paintsUntilMenu = 0;const user = node(['[data-role]', '[data-role="user"]'], {});let messages = [user];--// Radix: the trigger opens on pointerdown, an item selects on click.-const more = node(["button"], {- "aria-label": "More",- on: (ev) => { if (ev && ev.type === "pointerdown") paintsUntilMenu = 3; },-});-const bar = node([".aui-assistant-action-bar-root"], {}, [more]);-const assistant = node(['[data-role]', '[data-role="assistant"]'], {}, [bar]);-messages.push(assistant);--const items = menuNames.map((name) => node([".aui-action-bar-more-item"], {- text: name,+let assistant = null;+const buttons = barNames.map((name) => node(["button"], {+ "aria-label": name,click: () => {if (name !== "Delete") return;- setMenu(false);assistant.isConnected = false;messages = messages.filter((m) => m !== assistant);},}));-const menu = node([".aui-action-bar-more-content"], {}, items);+const bar = node([".aui-assistant-action-bar-root"], {}, buttons);+assistant = node(['[data-role]', '[data-role="assistant"]'], {}, [bar]);+messages.push(assistant);const document = {body: { sel: ["body"] },@@ -111,14 +92,10 @@ const document = {querySelectorAll: (s) => {if (s === "[data-role]") return messages;if (s === '[data-role="assistant"]') return messages.filter((m) => m === assistant);- if (s === ".aui-action-bar-more-content") {- state.menuLookups += 1;- return state.menuOpen ? [menu] : [];- }return [];},dispatchEvent: (ev) => {- if (ev && ev.key === "Escape") { setMenu(false); state.escapes += 1; }+ if (ev && ev.key === "Escape") state.escapes += 1;return true;},};@@ -127,10 +104,7 @@ class PointerEvent { constructor(type, init) { this.type = type; Object.assign(tclass KeyboardEvent { constructor(type, init) { this.type = type; Object.assign(this, init || {}); } }const window = {};-window.__sbNextPaint = () => new Promise((r) => setTimeout(() => {- if (paintsUntilMenu > 0 && --paintsUntilMenu === 0) setMenu(true);- r();-}, 5));+window.__sbNextPaint = () => new Promise((r) => setTimeout(r, 5));window.addEventListener = () => {};(new Function("window", "document", "PointerEvent", "MutationObserver", domSrc))(@@ -142,16 +116,14 @@ const run = (new Function())(window, document, PointerEvent, KeyboardEvent, performance);run({ timeoutMs: 2000, waitForButtonMs: 300 }).then((out) => {- out.menuOpenAfter = state.menuOpen;out.escapes = state.escapes;- out.menuLookups = state.menuLookups;console.log(JSON.stringify(out));process.exit(0);}, (err) => { console.error(String((err && err.stack) || err)); process.exit(1); });"""-def _run(menu_names: list[str]) -> dict:+def _run(bar_names: list[str]) -> dict:node = shutil.which("node")if node is None:pytest.skip("node is not installed")@@ -161,7 +133,7 @@ def _run(menu_names: list[str]) -> dict:delete_js = Path(tmp) / "delete.js"delete_js.write_text(DELETE_JS.strip(), encoding = "utf-8")done = subprocess.run(- [node, str(harness), str(DOM_JS), str(delete_js), json.dumps(menu_names)],+ [node, str(harness), str(DOM_JS), str(delete_js), json.dumps(bar_names)],capture_output = True,text = True,timeout = 60,@@ -170,23 +142,18 @@ def _run(menu_names: list[str]) -> dict:return json.loads(done.stdout.strip().splitlines()[-1])-def test_delete_opens_the_more_menu_and_selects_its_delete_item():- out = _run(["Edit response", "Fork in new chat", "Delete"])+def test_delete_clicks_the_bar_button_and_the_reply_leaves():+ out = _run(["Copy", "Edit response", "Delete", "More"])assert out["ran"] is True, out- assert out["ms"] is not None, "the reply never left the document after Delete was selected"+ assert out["ms"] is not None, "the reply never left the document after Delete was clicked"assert (out["before"], out["after"]) == (2, 1), out- # The menu mounts three paints late. The document-wide lookup for it runs on the first look- # and when body's children change, not once per paint while waiting.- assert out["menuLookups"] <= 2, out+ assert out["escapes"] == 0, "nothing was opened, so nothing should be dismissed"-def test_a_menu_without_delete_is_reported_and_closed():- out = _run(["Edit response", "Fork in new chat"])+def test_a_bar_without_delete_is_reported_not_run():+ out = _run(["Copy", "Edit response", "More"])assert out["ran"] is False- assert "no Delete item in the More menu" in out["reason"], out["reason"]- assert (- out["menuOpenAfter"] is False and out["escapes"] == 1- ), "a menu the action opened and could not use must be closed, or it covers the next action"+ assert "no Delete button" in out["reason"], out["reason"]def _names_the_scene_asks_for() -> tuple[set[str], set[str]]:@@ -232,9 +199,10 @@ def test_every_control_the_scene_asks_for_is_still_rendered():message's action bar renders in thread.tsx."""tsx = _assistant_bar_source(THREAD_TSX.read_text(encoding = "utf-8"))buttons, items = _names_the_scene_asks_for()- assert (- {"More", "Copy"} <= buttons and "Delete" in items- ), "parsed fewer control names than the scene uses; this check would pass on nothing"+ assert {+ "Copy",+ "Delete",+ } <= buttons, "parsed fewer control names than the scene uses; this check would pass on nothing"tooltips = set(re.findall(r"tooltip=\"([^\"]+)\"", tsx))# An item's label is its last line of text before the closing tag. Its attributes can hold# arrow functions, so the opening tag cannot be skipped with a `[^>]*` match.diff --git a/tests/studio/test_deep_research_frontend_contract.py b/tests/studio/test_deep_research_frontend_contract.pyindex 0c04f16975c..3156a3ca43a 100644--- a/tests/studio/test_deep_research_frontend_contract.py+++ b/tests/studio/test_deep_research_frontend_contract.py@@ -186,17 +186,26 @@ def test_research_presentation_is_integrated() -> None:assert "<ResearchMessage />" in threadassert "if (researchRunId) return null" in threadassert "!researchRunId &&" in thread- # A research message has no Delete. Since #12735 Delete is a More-menu item whose hook reports- # `hidden` for research messages, and the item renders nothing when hidden; before that the- # bar's button returned null on the same condition. Either spelling, the gate must be there.+ # A research message has no Delete. The hook reports `hidden` for research messages, and every+ # component that renders Delete from it renders nothing when hidden. That component has been a+ # bar button, a More-menu item (#12735) and a bar button again (#13615), so it is found by the+ # hook it calls rather than by its name.delete_hook = thread.split("function useDeleteMessage()", 1)[1].split("\n}\n", 1)[0]assert re.search(r"hidden:\s*Boolean\(\s*researchRunId\s*\|\|\s*ownsResearchMessage\s*\)", delete_hook)- delete_item = thread.split("const DeleteMessageMenuItem: FC = () => {", 1)[1].split(- "\n};\n", 1- )[0]- assert re.search(r"if\s*\(\s*hidden\s*\)\s*\{?\s*return null", delete_item)+ delete_controls = {+ name: body+ for name, body in re.findall(+ r"^const (\w+): FC = \(\) => \{\n([\s\S]*?)\n\};\n", thread, re.M+ )+ if "useDeleteMessage()" in body+ }+ assert delete_controls, "no thread.tsx component renders Delete through useDeleteMessage()"+ for name, body in delete_controls.items():+ assert re.search(+ r"if\s*\(\s*hidden\s*\)\s*\{?\s*return null", body+ ), f"{name} renders Delete without the research-message gate"assert "ResearchMessageRunIdContext = createContext<string | null>(null)" in threadassert "researchReplyOwnsRun(boundResearchAssistantMessageId, messageId)" in threadassert "<ResearchMessageRunIdContext.Provider value={researchRunId}>" in threaddiff --git a/tests/studio/test_thread_harness_controls_exist.py b/tests/studio/test_thread_harness_controls_exist.pyindex 20d66ed74a2..fddc9dcd357 100644--- a/tests/studio/test_thread_harness_controls_exist.py+++ b/tests/studio/test_thread_harness_controls_exist.py@@ -3,10 +3,11 @@"""Every action-bar control the thread browser harnesses ask for is still rendered there.-#12735 took Delete off the assistant action bar and made it the last item of the More menu.+#12735 took Delete off the assistant action bar and made it the last item of the More menu;playwright_heavy_thread.py kept asking for a "Delete message" button, so its delete action couldnot run, and probe_dismiss_guard.py kept attacking that button, so every one of its cases would-have errored. Both sit behind earlier steps of the same CI job, which hid the breakage until those+have errored. #13615 then put Delete back on the bar as an inline button while the harnesses+still opened the More menu for it. Both sit behind earlier steps of the same CI job, which hid the breakage until thosesteps went green. This reads the labels the harnesses ask for and requires each to be rendered bythe assistant action bar in thread.tsx, so the next move of a control fails here, with its name."""@@ -85,10 +86,11 @@ def test_the_scan_reads_the_controls_the_harnesses_use():buttons, items = _asked_for()assert {"More"} <= buttons["tests/studio/playwright_heavy_thread.py"]assert {"More", "Copy"} <= buttons["tests/studio/probe_dismiss_guard.py"]- assert "Delete" in items["tests/studio/playwright_heavy_thread.py"]- assert "Delete" in items["tests/studio/playwright_thread_weight.py"]+ # Delete is an inline bar button since #13615, so both harnesses ask for it as one.+ assert "Delete" in buttons["tests/studio/playwright_heavy_thread.py"]+ assert "Delete" in buttons["tests/studio/playwright_thread_weight.py"]tooltips, menu_items = _rendered(THREAD_TSX.read_text(encoding = "utf-8"))- assert {"Copy", "More"} <= tooltips and "Delete" in menu_items, (+ assert {"Copy", "More", "Delete"} <= tooltips and menu_items, ("parsed fewer controls out of thread.tsx than the assistant bar renders; ""the check below would pass on nothing")