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: expanded composer fills the chat area, net of attachments (#15650)
Michael Hana674707fe881
diff --git a/studio/frontend/src/components/assistant-ui/thread.tsx b/studio/frontend/src/components/assistant-ui/thread.tsxindex d0485e2fa46..7096970ea7b 100644--- a/studio/frontend/src/components/assistant-ui/thread.tsx+++ b/studio/frontend/src/components/assistant-ui/thread.tsx@@ -146,6 +146,7 @@ import {import { TooltipIconButton } from "@/components/assistant-ui/tooltip-icon-button";import {IntentAwareScrollProvider,+ useDetachThreadFromBottom,useIntentAwareAutoScroll,useIsThreadAtBottom,useScrollThreadToBottom,@@ -488,6 +489,7 @@ import { extractTaggedText, updateThreadMessage } from "@/features/chat/utils/upimport { useComposerPillFit } from "@/hooks/use-composer-pill-fit";import { useIsMobile } from "@/hooks/use-mobile";import { useUiSpaceScale } from "@/hooks/use-ui-space-scale";+import { useExpandedComposerFill } from "./use-expanded-composer-fill";import { watchComposerClearance } from "@/lib/toast-offset";const PageDragContext = createContext(false);@@ -3109,10 +3111,29 @@ const Composer: FC<{const oneRowHeight = Math.round(40 * uiSpaceScale);const [editorHeight, setEditorHeight] = useState(40);const [isWritingExpanded, setIsWritingExpanded] = useState(false);+ const detachFromBottom = useDetachThreadFromBottom();+ const scrollThreadToBottom = useScrollThreadToBottom();+ const threadEmpty = useAuiState(({ thread }) => thread.isEmpty);const toggleWritingExpanded = () => {setIsWritingExpanded((expanded) => !expanded);inputRef.current?.focus({ preventScroll: true });};+ // Welcome page: the bottom pin's stabilizer padding shifted the expanded frame up. On every+ // transition (button, Escape, send), so collapsing always re-pins the toolbar into view.+ const wasExpandedRef = useRef(false);+ useLayoutEffect(() => {+ const was = wasExpandedRef.current;+ wasExpandedRef.current = isWritingExpanded;+ if (!threadEmpty || was === isWritingExpanded) {+ return;+ }+ if (isWritingExpanded) {+ detachFromBottom();+ } else {+ window.requestAnimationFrame(() => scrollThreadToBottom("instant"));+ }+ }, [isWritingExpanded, threadEmpty, detachFromBottom, scrollThreadToBottom]);+ useExpandedComposerFill(editorRef, isWritingExpanded && !isDictating);// Cache line metrics so getComputedStyle runs once, not per keystroke.const lineMetricsRef = useRef<{ lineHeight: number; padding: number } | null>(null,diff --git a/studio/frontend/src/components/assistant-ui/use-expanded-composer-fill.ts b/studio/frontend/src/components/assistant-ui/use-expanded-composer-fill.tsnew file mode 100644index 00000000000..02a54c559b6--- /dev/null+++ b/studio/frontend/src/components/assistant-ui/use-expanded-composer-fill.ts@@ -0,0 +1,86 @@+// 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 { type RefObject, useLayoutEffect } from "react";++const FILL_VAR = "--composer-fill-height";+const EDGE_GAP_PX = 16;+const SETTLE_MS = 400;+const SCROLLS = /(auto|scroll)/;++function cssPx(el: Element | null | undefined, prop: "paddingTop"): number {+ return el ? Number.parseFloat(getComputedStyle(el)[prop]) || 0 : 0;+}++function scrollParent(el: HTMLElement): HTMLElement | null {+ for (let node = el.parentElement; node; node = node.parentElement) {+ if (SCROLLS.test(getComputedStyle(node).overflowY)) {+ return node;+ }+ }+ return null;+}++function availableHeight(root: HTMLElement, compare: boolean): number {+ const rootRect = root.getBoundingClientRect();+ // A conversation docks the composer beside the viewport, not inside it.+ const dock = root.closest(".aui-thread-composer-dock");+ if (dock || compare) {+ const panes = compare+ ? document.querySelector('[data-tour="chat-compare-view"]')+ : dock?.parentElement?.querySelector(".aui-thread-viewport");+ const top =+ (panes?.getBoundingClientRect().top ?? 0) + cssPx(panes, "paddingTop");+ return rootRect.bottom - (top + EDGE_GAP_PX);+ }+ // Not the scroller's padding: --aui-scroll-stabilizer adds some for a frame.+ const scroller = scrollParent(root);+ const bottom = Math.min(+ scroller?.getBoundingClientRect().bottom ?? window.innerHeight,+ window.innerHeight,+ );+ return bottom - EDGE_GAP_PX - (rootRect.top + (scroller?.scrollTop ?? 0));+}++export function useExpandedComposerFill(+ editorRef: RefObject<HTMLElement | null>,+ expanded: boolean,+ compare = false,+): void {+ useLayoutEffect(() => {+ const editor = editorRef.current;+ const root =+ editor?.closest<HTMLElement>("[data-writing-expanded]") ?? null;+ if (!(expanded && editor && root)) {+ return;+ }+ const measure = () => {+ const chrome =+ root.getBoundingClientRect().height -+ editor.getBoundingClientRect().height;+ const next = `${Math.max(0, Math.floor(availableHeight(root, compare) - chrome))}px`;+ if (root.style.getPropertyValue(FILL_VAR) !== next) {+ root.style.setProperty(FILL_VAR, next);+ }+ };+ measure();+ const observer = new ResizeObserver(measure);+ observer.observe(root);+ window.addEventListener("resize", measure);+ let frame = 0;+ const settleUntil = performance.now() + SETTLE_MS;+ const settle = () => {+ measure();+ if (performance.now() < settleUntil) {+ frame = window.requestAnimationFrame(settle);+ }+ };+ frame = window.requestAnimationFrame(settle);+ return () => {+ observer.disconnect();+ window.removeEventListener("resize", measure);+ window.cancelAnimationFrame(frame);+ root.style.removeProperty(FILL_VAR);+ };+ }, [editorRef, expanded, compare]);+}diff --git a/studio/frontend/src/features/chat/shared-composer.tsx b/studio/frontend/src/features/chat/shared-composer.tsxindex 6765b1e81bd..94237fd5441 100644--- a/studio/frontend/src/features/chat/shared-composer.tsx+++ b/studio/frontend/src/features/chat/shared-composer.tsx@@ -22,6 +22,7 @@ import {thinkToggleAriaLabel,} from "@/components/assistant-ui/think-aria-label";import { ComposerDraftPreview } from "@/components/assistant-ui/composer-draft-preview";+import { useExpandedComposerFill } from "@/components/assistant-ui/use-expanded-composer-fill";import { useChatPreferencesStore } from "./stores/chat-preferences-store";import {composerSubmitIntent,@@ -1223,6 +1224,7 @@ export function SharedComposer({setIsWritingExpanded((expanded) => !expanded);textareaRef.current?.focus({ preventScroll: true });};+ useExpandedComposerFill(editorRef, isWritingExpanded, true);const addFilesUntracked = useCallback(async (input: FileList | readonly File[] | null) => {diff --git a/studio/frontend/src/index.css b/studio/frontend/src/index.cssindex fe1bbfb57b1..0e7800e6aba 100644--- a/studio/frontend/src/index.css+++ b/studio/frontend/src/index.css@@ -3300,14 +3300,14 @@ html[data-chat-font] .aui-root {--composer-fade-bottom: calc(1rem * var(--ui-space-scale, 1));}- /* max(): at 480px tall the clamp is 192px, under the twelve-row compact- height, so expanding would clip. svh, since dvh tracks Safari's bar. */- /* Either composer root: the thread's form or compare's wrapper. */+ /* --composer-fill-height: useExpandedComposerFill; the clamp is the first-frame fallback. */[data-writing-expanded="true"] .unsloth-composer-editor {height: max(var(--composer-editor-height, calc(40px * var(--ui-space-scale, 1))),- clamp(8rem, calc(80svh - 12rem), 42rem)+ var(--composer-fill-height, clamp(8rem, calc(80svh - 12rem), 42rem)));+ /* Instant: easing in read as the bottom edge creeping. */+ transition: none;}.aui-thread-welcome-center {@@ -3316,15 +3316,9 @@ html[data-chat-font] .aui-root {.aui-thread-welcome-center:has([data-writing-expanded="true"]) {padding-top: calc(1rem * var(--ui-space-scale, 1));+ transition: none;}- /* Welcome: grows by the pt-[27.5dvh] given up, so the bottom edge stays put and it expands upward. */- .aui-thread-welcome-center:not(:has(.unsloth-files-panel)) [data-writing-expanded="true"] .unsloth-composer-editor {- height: calc(- var(--composer-editor-height, calc(40px * var(--ui-space-scale, 1))) + 27.5dvh - 1rem *- var(--ui-space-scale, 1)- );- }.unsloth-composer-plus {@apply relative flex size-9 shrink-0 cursor-pointer items-center justify-center rounded-full text-foreground transition-colors hover:bg-muted-foreground/15 disabled:cursor-not-allowed disabled:opacity-40;diff --git a/studio/frontend/tests/ui-font-size-scales-spacing.test.ts b/studio/frontend/tests/ui-font-size-scales-spacing.test.tsindex 627f274e69f..10b9611854a 100644--- a/studio/frontend/tests/ui-font-size-scales-spacing.test.ts+++ b/studio/frontend/tests/ui-font-size-scales-spacing.test.ts@@ -161,9 +161,9 @@ test("the titlebar reserves room for its controls, which stay in the band", () =});test("the composer's one-row clamp is one row at any size", () => {- // The editor box wins over the input's min-height, so all four clamps (the welcome expansion included) and the JS floor move together.+ // The editor box wins over the input's min-height, so the clamps and the JS floor move together.const clamps = CSS.match(/calc\(40px \* var\(--ui-space-scale, 1\)\)/g) ?? [];- assert.equal(clamps.length, 4, "a 40px composer clamp is still fixed");+ assert.equal(clamps.length, 3, "a 40px composer clamp is still fixed");const thread = readSrc("components/assistant-ui/thread.tsx");assert.match(thread, /const oneRowHeight = Math\.round\(40 \* uiSpaceScale\);/);assert.doesNotMatch(thread, /Math\.max\(40, editorHeight\)/);