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: centre the chat column under classic scroll bars in WebKit (#15392)
Michael Han8d0a5aa15235
diff --git a/studio/frontend/src/components/assistant-ui/thread-gutter.ts b/studio/frontend/src/components/assistant-ui/thread-gutter.tsnew file mode 100644index 00000000000..e0e7ebdd6f5--- /dev/null+++ b/studio/frontend/src/components/assistant-ui/thread-gutter.ts@@ -0,0 +1,83 @@+// SPDX-License-Identifier: AGPL-3.0-only+// Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0++export const THREAD_GUTTER_SHIFT_ATTRIBUTE = "data-gutter-shift";+export const THREAD_GUTTER_SHIFT_PROPERTY = "--thread-gutter-shift";++/** The column moves without resizing, so no ResizeObserver fires. */+export const THREAD_GUTTER_CHANGE_EVENT = "unsloth:thread-gutter-change";++export function threadGutterShift(+ scrollbar: number,+ misplaced: boolean,+ rtl: boolean,+): number {+ return misplaced && !rtl && scrollbar > 0 ? scrollbar : 0;+}++let misplacedCache: boolean | null = null;++/** WebKit reserves a flex scroller's both-edges left gutter on the right. */+export function bothEdgesGutterMisplaced(doc: Document = document): boolean {+ if (misplacedCache !== null) {+ return misplacedCache;+ }+ const probe = doc.createElement("div");+ probe.setAttribute("aria-hidden", "true");+ probe.style.cssText =+ "position:fixed;top:0;left:0;display:flex;flex-direction:column;width:100px;height:10px;overflow-y:scroll;scrollbar-gutter:stable both-edges;visibility:hidden;pointer-events:none";+ const content = doc.createElement("div");+ content.style.height = "20px";+ probe.append(content);+ doc.body.append(probe);+ const scrollbar = probe.offsetWidth - probe.clientWidth;+ const leftGap =+ content.getBoundingClientRect().left - probe.getBoundingClientRect().left;+ probe.remove();+ // Unknown until a classic scroll bar shows.+ if (scrollbar > 0) {+ misplacedCache = leftGap < 0.5;+ }+ return misplacedCache ?? false;+}++export function watchThreadGutter(viewport: HTMLElement): () => void {+ if (typeof ResizeObserver === "undefined") {+ return () => undefined;+ }+ let applied = 0;+ const sync = () => {+ const style = getComputedStyle(viewport);+ const scrollbar = Math.max(+ 0,+ viewport.offsetWidth -+ viewport.clientWidth -+ (Number.parseFloat(style.borderLeftWidth) || 0) -+ (Number.parseFloat(style.borderRightWidth) || 0),+ );+ const shift = threadGutterShift(+ scrollbar,+ scrollbar > 0 && bothEdgesGutterMisplaced(viewport.ownerDocument),+ style.direction === "rtl",+ );+ if (shift === applied) {+ return;+ }+ applied = shift;+ viewport.toggleAttribute(THREAD_GUTTER_SHIFT_ATTRIBUTE, shift > 0);+ if (shift > 0) {+ viewport.style.setProperty(THREAD_GUTTER_SHIFT_PROPERTY, `${shift}px`);+ } else {+ viewport.style.removeProperty(THREAD_GUTTER_SHIFT_PROPERTY);+ }+ viewport.dispatchEvent(new Event(THREAD_GUTTER_CHANGE_EVENT));+ };+ const observer = new ResizeObserver(sync);+ observer.observe(viewport);+ sync();+ return () => {+ observer.disconnect();+ viewport.removeAttribute(THREAD_GUTTER_SHIFT_ATTRIBUTE);+ viewport.style.removeProperty(THREAD_GUTTER_SHIFT_PROPERTY);+ };+}diff --git a/studio/frontend/src/components/assistant-ui/thread.tsx b/studio/frontend/src/components/assistant-ui/thread.tsxindex b6c2733f4a5..b7252ab34dc 100644--- a/studio/frontend/src/components/assistant-ui/thread.tsx+++ b/studio/frontend/src/components/assistant-ui/thread.tsx@@ -66,6 +66,10 @@ import { MessageTiming } from "@/components/assistant-ui/message-timing";import { attachThreadFastCopy } from "@/components/assistant-ui/thread-fast-copy";import { attachWheelHoverSuppression } from "@/components/assistant-ui/thread-wheel-hover";import { threadHasResearchMessage } from "@/components/assistant-ui/thread-research-presence";+import {+ THREAD_GUTTER_CHANGE_EVENT,+ watchThreadGutter,+} from "@/components/assistant-ui/thread-gutter";import { observeThreadWidthSteps } from "@/components/assistant-ui/thread-width-steps";import { Reasoning, ReasoningGroup } from "@/components/assistant-ui/reasoning";import { researchReplyOwners } from "@/components/assistant-ui/research-reply-owners";@@ -2117,6 +2121,11 @@ export const Thread: FC<{return attachWheelHoverSuppression(viewportEl);}, [viewportEl]);+ useEffect(() => {+ if (!viewportEl) return;+ return watchThreadGutter(viewportEl);+ }, [viewportEl]);+// composer growth applies immediately because content below the scroll position is invisible.// composer shrink waits until clamping scrollTop is safe or a bottom pin owns the motion.// imperative sizing restores remounted spacers even when composerHeight is unchanged.@@ -2604,7 +2613,11 @@ const ThreadComposerDock: FC<{apply();resizeObserver.observe(viewport);resizeObserver.observe(dock);- return () => resizeObserver.disconnect();+ viewport.addEventListener(THREAD_GUTTER_CHANGE_EVENT, apply);+ return () => {+ resizeObserver.disconnect();+ viewport.removeEventListener(THREAD_GUTTER_CHANGE_EVENT, apply);+ };}, []);return (diff --git a/studio/frontend/src/index.css b/studio/frontend/src/index.cssindex 9667d991a71..f8734135e37 100644--- a/studio/frontend/src/index.css+++ b/studio/frontend/src/index.css@@ -5185,6 +5185,12 @@ html.force-reduced-motion .sidebar-section-drop-line {scrollbar-gutter: stable both-edges;}+/* thread-gutter.ts. Padding, not a border: WebKit snaps borders at fractional zoom and the column drifts off the composer. */+.aui-thread-viewport[data-gutter-shift] {+ scrollbar-gutter: stable;+ padding-left: calc(var(--spacing) * 5 + var(--thread-gutter-shift));+}+.aui-thread-host[data-aui-following] + .aui-thread-root .aui-thread-viewport {overflow-anchor: none;}@@ -5766,6 +5772,10 @@ html[data-find-bar-open] [data-sonner-toaster][data-y-position="top"] {padding-right: calc(1rem * var(--ui-space-scale, 1));}+.chat-full-view-dock .aui-thread-viewport[data-gutter-shift] {+ padding-left: calc(1rem * var(--ui-space-scale, 1) + var(--thread-gutter-shift));+}+.chat-full-view-dock[data-expanded="false"] :is(.chat-thread-pane, .aui-thread-root) {flex: none;}diff --git a/studio/frontend/tests/thread-gutter.test.ts b/studio/frontend/tests/thread-gutter.test.tsnew file mode 100644index 00000000000..564d68fb081--- /dev/null+++ b/studio/frontend/tests/thread-gutter.test.ts@@ -0,0 +1,42 @@+// 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 test from "node:test";++import {+ THREAD_GUTTER_CHANGE_EVENT,+ threadGutterShift,+} from "../src/components/assistant-ui/thread-gutter.ts";+import { readSrc } from "./helpers/kit.ts";++const SHIFT_RULE =+ /\.aui-thread-viewport\[data-gutter-shift\] \{\s*scrollbar-gutter: stable;\s*padding-left: calc\(var\(--spacing\) \* 5 \+ var\(--thread-gutter-shift\)\);/;+const FULL_VIEW_SHIFT_RULE =+ /\.chat-full-view-dock \.aui-thread-viewport\[data-gutter-shift\] \{\s*padding-left: calc\(1rem \* var\(--ui-space-scale, 1\) \+ var\(--thread-gutter-shift\)\);/;+const WATCH_CALL = /watchThreadGutter\(viewportEl\)/;+const DOCK_LISTENER =+ /viewport\.addEventListener\(THREAD_GUTTER_CHANGE_EVENT, apply\)/;++test("a misplaced both-edges gutter shifts the column by one scrollbar", () => {+ assert.equal(threadGutterShift(13, true, false), 13);+});++test("engines that reserve the left gutter, overlay scroll bars and RTL are left alone", () => {+ assert.equal(threadGutterShift(13, false, false), 0);+ assert.equal(threadGutterShift(0, true, false), 0);+ assert.equal(threadGutterShift(13, true, true), 0);+});++test("the shift swaps to a one-sided gutter and pads the left, in both viewport paddings", () => {+ const css = readSrc("index.css");+ assert.match(css, SHIFT_RULE);+ assert.match(css, FULL_VIEW_SHIFT_RULE);+});++test("the composer dock re-measures when the shift moves the column", () => {+ const thread = readSrc("components/assistant-ui/thread.tsx");+ assert.match(thread, WATCH_CALL);+ assert.match(thread, DOCK_LISTENER);+ assert.equal(THREAD_GUTTER_CHANGE_EVENT, "unsloth:thread-gutter-change");+});