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
fix(studio): preserve chat search position on close (#13437)
Eyera1d3a81a5b5cc
diff --git a/studio/frontend/src/features/find-in-page/components/find-bar.tsx b/studio/frontend/src/features/find-in-page/components/find-bar.tsxindex 95d68de4650..00352154686 100644--- a/studio/frontend/src/features/find-in-page/components/find-bar.tsx+++ b/studio/frontend/src/features/find-in-page/components/find-bar.tsx@@ -200,7 +200,7 @@ export default function FindBar({// Only when closing dropped focus on the floor. Anywhere else and the reader moved it.const focused = document.activeElement;if (focused !== null && focused !== document.body) return;- origin.focus();+ origin.focus({ preventScroll: true });};}, []);diff --git a/studio/frontend/src/features/find-in-page/components/find-in-page.tsx b/studio/frontend/src/features/find-in-page/components/find-in-page.tsxindex 39d2b2fc93a..21fbeaf26b7 100644--- a/studio/frontend/src/features/find-in-page/components/find-in-page.tsx+++ b/studio/frontend/src/features/find-in-page/components/find-in-page.tsx@@ -275,7 +275,7 @@ export function FindInPage({ enabled = true }: { enabled?: boolean }) {typeof origin.focus === "function" &&(active === null || active === document.body)) {- origin.focus();+ origin.focus({ preventScroll: true });}});}, []);diff --git a/studio/frontend/tests/find-in-page.test.ts b/studio/frontend/tests/find-in-page.test.tsindex 6bf82ae6520..562b208b720 100644--- a/studio/frontend/tests/find-in-page.test.ts+++ b/studio/frontend/tests/find-in-page.test.ts@@ -2738,7 +2738,7 @@ test("closing the bar hands focus back to where it came from", async () => {const capture = FIND_BAR.indexOf("const active = document.activeElement");const takeFocus = FIND_BAR.indexOf("input.select();");assert.ok(capture > 0 && capture < takeFocus);- assert.match(FIND_BAR, /origin\.focus\(\);/);+ assert.match(FIND_BAR, /origin\.focus\(\{ preventScroll: true \}\);/);// First answer only: StrictMode replays the effect, and by the second run the field has focus.assert.match(FIND_BAR, /originRef\.current === null &&/);// Against the bar's element, not `data-find-skip`, which the composer carries.diff --git a/tests/studio/playwright_find_in_page.py b/tests/studio/playwright_find_in_page.pyindex 42df3459fef..2c806534436 100644--- a/tests/studio/playwright_find_in_page.py+++ b/tests/studio/playwright_find_in_page.py@@ -201,6 +201,52 @@ def check_counting(page, engine: str, mode: str, mod: str) -> None:close_bar(page)+def check_close_preserves_position(page, engine: str, mode: str, mod: str) -> None:+ search_page = new_page(page.context)+ try:+ for outer_scroll in (False, True):+ search_page.evaluate("outer => window.__findSmoke.setOuterScroll(outer)", outer_scroll)+ origin = search_page.locator('[data-find-scope] .mx-auto > .rounded-xl').first+ origin.evaluate("element => { element.tabIndex = 0; }")+ for dismiss in ("Escape", "button"):+ origin.focus()+ open_bar(search_page, mod)+ field = search_page.locator('[role="search"] input')+ field.fill("")+ search_page.wait_for_function("() => !window.__findSmoke.counter()")+ field.fill("unsloth")+ search_page.wait_for_function("() => !!window.__findSmoke.counter()")+ for _ in range(10):+ field.press("Enter")+ search_page.wait_for_timeout(300)+ before = search_page.evaluate("() => window.__findSmoke.scrollTop()")+ if dismiss == "Escape":+ close_bar(search_page)+ else:+ search_page.get_by_role("button", name = "Close find", exact = True).click()+ search_page.wait_for_function("() => !window.__findSmoke.state().open")+ search_page.evaluate(+ "() => new Promise(resolve => requestAnimationFrame(() => requestAnimationFrame(resolve)))"+ )+ after = search_page.evaluate("() => window.__findSmoke.scrollTop()")+ layout = "outer scroller" if outer_scroll else "chat scroller"+ check(+ engine,+ mode,+ f"{dismiss} preserves the search position in the {layout}",+ before > 500 and abs(after - before) <= 1,+ f"scrollTop {before} -> {after}",+ )+ check(+ engine,+ mode,+ f"{dismiss} restores focus in the {layout}",+ origin.evaluate("element => document.activeElement === element"),+ )+ finally:+ search_page.close()++def check_walk(page, engine: str, mode: str, mod: str) -> None:open_bar(page, mod)page.keyboard.type("unsloth")@@ -703,6 +749,7 @@ def check_skip_attribute(page, engine: str, mode: str, mod: str) -> None:def run_page(page, engine: str, mode: str, mod: str) -> None:for probe in (+ check_close_preserves_position,check_chord,check_counting,check_walk,