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: open a long chat at its latest message on Chromium (#17351)
Daniel Hanc74b6cfc8268
diff --git a/studio/frontend/src/components/assistant-ui/use-intent-aware-autoscroll.tsx b/studio/frontend/src/components/assistant-ui/use-intent-aware-autoscroll.tsxindex a8963b4b2fc..3d0b972b0e8 100644--- a/studio/frontend/src/components/assistant-ui/use-intent-aware-autoscroll.tsx+++ b/studio/frontend/src/components/assistant-ui/use-intent-aware-autoscroll.tsx@@ -3,6 +3,7 @@"use client";+import { ROW_DISTANT_ATTRIBUTE } from "@/components/assistant-ui/distant-rows";import { useChatPreferencesStore } from "@/features/chat/stores/chat-preferences-store";import { useAui, useAuiEvent } from "@assistant-ui/react";import {@@ -182,6 +183,10 @@ export function useIntentAwareAutoScroll(): {let scrollKeyAt = Number.NEGATIVE_INFINITY;let pointerHeld = false;let insertionRemainder = 0;+ // distant-rows.ts skipped or released a row since the last scroll event. Chromium can clamp+ // scrollTop while it swaps the row's size, and the scroll event then reads an unchanged+ // scrollHeight: without this a long chat opening at its bottom read as a scroll up.+ let rowsToggledSinceScroll = false;const distanceFromBottom = (): number => {if (el.scrollHeight <= el.clientHeight) {@@ -515,7 +520,7 @@ export function useIntentAwareAutoScroll(): {// behind it, is a clamp (something below shrank as a new row landed), not the user.const clamped =lastDistanceFromBottom <= AT_BOTTOM_THRESHOLD_PX &&- scrollHeight !== lastScrollHeight &&+ (scrollHeight !== lastScrollHeight || rowsToggledSinceScroll) &&!keyed &&!pointerHeld;if (@@ -532,6 +537,7 @@ export function useIntentAwareAutoScroll(): {}}+ rowsToggledSinceScroll = false;lastScrollTop = scrollTop;lastClientWidth = clientWidth;lastClientHeight = clientHeight;@@ -599,7 +605,10 @@ export function useIntentAwareAutoScroll(): {requestTick();};- const onMutation = (): void => {+ const onMutation = (records: MutationRecord[]): void => {+ if (records.some((record) => record.attributeName === ROW_DISTANT_ATTRIBUTE)) {+ rowsToggledSinceScroll = true;+ }if (el.ownerDocument.hidden) {onLayoutChange();return;@@ -644,6 +653,7 @@ export function useIntentAwareAutoScroll(): {"aria-hidden","aria-expanded","data-state",+ ROW_DISTANT_ATTRIBUTE,],});el.addEventListener("wheel", onWheel, { passive: true });diff --git a/studio/frontend/tests/chat-autoscroll-shrink-intent.test.ts b/studio/frontend/tests/chat-autoscroll-shrink-intent.test.tsindex 0c448db8bb5..7bc0247a865 100644--- a/studio/frontend/tests/chat-autoscroll-shrink-intent.test.ts+++ b/studio/frontend/tests/chat-autoscroll-shrink-intent.test.ts@@ -31,7 +31,7 @@ test("leaving a pinned bottom as the page changes height, with no key or pointerconst body = between("const onScroll = () => {", "\n };");assert.match(body,- /const clamped =\s*lastDistanceFromBottom <= AT_BOTTOM_THRESHOLD_PX &&\s*scrollHeight !== lastScrollHeight &&\s*!keyed &&\s*!pointerHeld;/,+ /const clamped =\s*lastDistanceFromBottom <= AT_BOTTOM_THRESHOLD_PX &&\s*\(scrollHeight !== lastScrollHeight \|\| rowsToggledSinceScroll\) &&\s*!keyed &&\s*!pointerHeld;/,"a row below shrinking as the next one lands pulls scrollTop up in the same event; detaching there stops the stream following",);assert.match(HOOK, /el\.addEventListener\("pointerdown", onPointerDown, \{ passive: true \}\);/, "a scrollbar drag starts with a pointerdown on the viewport");@@ -40,6 +40,22 @@ test("leaving a pinned bottom as the page changes height, with no key or pointerassert.match(HOOK, /el\.ownerDocument\.removeEventListener\("pointerup", onPointerUp, true\);/);});+test("a distant row skipped or released at a pinned bottom is a clamp, even when scrollHeight reads unchanged", () => {+ // Chromium, 200 turns, fresh load: a row swapping in or out of content-visibility moved scrollTop+ // up 259 px with scrollHeight the same by the scroll event; read as a scroll up, the chat opened+ // up to 23,000 px above its last message in half of the loads.+ assert.match(HOOK, /import \{ ROW_DISTANT_ATTRIBUTE \} from "@\/components\/assistant-ui\/distant-rows";/);+ const observe = between("mutationObserver.observe(el, {", "});");+ assert.match(observe, /attributeFilter: \[[^\]]*ROW_DISTANT_ATTRIBUTE,?\s*\]/, "the toggle reaches the hook");+ const mutation = between("const onMutation = (records: MutationRecord[]): void => {", "\n };");+ assert.match(+ mutation,+ /if \(records\.some\(\(record\) => record\.attributeName === ROW_DISTANT_ATTRIBUTE\)\) \{\s*rowsToggledSinceScroll = true;\s*\}/,+ );+ const body = between("const onScroll = () => {", "\n };");+ assert.match(body, /rowsToggledSinceScroll = false;\s*lastScrollTop = scrollTop;/, "one scroll event consumes the toggle");+});+test("the correction resyncs the height baseline with the others", () => {const body = between("adjustImplRef.current = (", "const onWheel = ");assert.match(body, /lastScrollTop = el\.scrollTop;\s*lastDistanceFromBottom = distanceFromBottom\(\);\s*lastScrollHeight = el\.scrollHeight;/);diff --git a/studio/frontend/tests/desktop-webkit-paths.test.ts b/studio/frontend/tests/desktop-webkit-paths.test.tsindex 5f4b3139a2d..b3afe9bc8b8 100644--- a/studio/frontend/tests/desktop-webkit-paths.test.ts+++ b/studio/frontend/tests/desktop-webkit-paths.test.ts@@ -17,7 +17,7 @@ test("a fence body becomes skippable only once it carries its measured height",const measure = defer.slice(defer.indexOf("measure.current = () => {"), defer.indexOf("setState({ measured: true, window: next, pins });"));assert.ok(measure.indexOf("region.style.setProperty(FENCE_HEIGHT_PROPERTY, declared);") >= 0, "the measure that first marks a fence measured writes its height before it does");const autoscroll = readSrc("components/assistant-ui/use-intent-aware-autoscroll.tsx");- assert.match(autoscroll, /const onMutation = \(\): void => \{\s*if \(el\.ownerDocument\.hidden\) \{\s*onLayoutChange\(\);\s*return;\s*\}\s*layoutChanged = true;\s*if \(!parkIfHeld\(\)\) \{\s*extendFollow\(\);\s*\}\s*requestTick\(\);\s*\};/, "a mutation on a shown page never forces layout, following stays the frame loop's job; a hidden page runs no frames, so it pins at once and a reply that ends there is at the bottom when the tab comes back");+ assert.match(autoscroll, /const onMutation = \(records: MutationRecord\[\]\): void => \{\s*if \(records\.some\(\(record\) => record\.attributeName === ROW_DISTANT_ATTRIBUTE\)\) \{\s*rowsToggledSinceScroll = true;\s*\}\s*if \(el\.ownerDocument\.hidden\) \{\s*onLayoutChange\(\);\s*return;\s*\}\s*layoutChanged = true;\s*if \(!parkIfHeld\(\)\) \{\s*extendFollow\(\);\s*\}\s*requestTick\(\);\s*\};/, "a mutation on a shown page never forces layout, following stays the frame loop's job; a hidden page runs no frames, so it pins at once and a reply that ends there is at the bottom when the tab comes back");assert.match(autoscroll, /const adjustForContentInsertedAbove = useCallback\(\(deltaPx: number\) => \{\s*adjustImplRef\.current\(deltaPx\);\s*return userDetachedRef\.current;\s*\}, \[\]\);/, "the hold learns whether its correction was written, even when the engine rounded it to nothing");});