Skip to content

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.

Studio: line the composer up with the chat column in the macOS Desktop app (#13965)

Michael Han7d33eff36bc5
diff --git a/studio/frontend/src/components/assistant-ui/composer-column-inset.ts b/studio/frontend/src/components/assistant-ui/composer-column-inset.ts
index bd02d9a4bf3..e07a8b5039e 100644
--- a/studio/frontend/src/components/assistant-ui/composer-column-inset.ts
+++ b/studio/frontend/src/components/assistant-ui/composer-column-inset.ts
@@ -32,13 +32,27 @@ export function composerColumnInset(
: viewport.rtl
? [scrollbar, 0]
: [0, scrollbar];
- const contentLeft =
- viewport.left + viewport.borderLeft + gutterLeft + viewport.paddingLeft;
- const contentRight =
- viewport.right - viewport.borderRight - gutterRight - viewport.paddingRight;
+ return composerInsetFromColumn(
+ {
+ left:
+ viewport.left + viewport.borderLeft + gutterLeft + viewport.paddingLeft,
+ right:
+ viewport.right -
+ viewport.borderRight -
+ gutterRight -
+ viewport.paddingRight,
+ },
+ dock,
+ );
+}
+
+export function composerInsetFromColumn(
+ column: { left: number; right: number },
+ dock: { left: number; right: number },
+): { left: number; right: number } {
return {
- left: Math.max(0, contentLeft - dock.left),
- right: Math.max(0, dock.right - contentRight),
+ left: Math.max(0, column.left - dock.left),
+ right: Math.max(0, dock.right - column.right),
};
}
diff --git a/studio/frontend/src/components/assistant-ui/thread.tsx b/studio/frontend/src/components/assistant-ui/thread.tsx
index f4189d2ac19..7d718e32ef4 100644
--- a/studio/frontend/src/components/assistant-ui/thread.tsx
+++ b/studio/frontend/src/components/assistant-ui/thread.tsx
@@ -54,6 +54,7 @@ import { UserMessageActionBar, UserMessageFooter } from "@/components/assistant-
import { useActionBarFocusReveal } from "@/components/assistant-ui/use-action-bar-focus-reveal";
import {
composerColumnInset,
+ composerInsetFromColumn,
readViewportBox,
} from "@/components/assistant-ui/composer-column-inset";
import { MessageTiming } from "@/components/assistant-ui/message-timing";
@@ -2578,16 +2579,34 @@ const ThreadComposerDock: FC<{
":scope > .aui-thread-viewport",
);
if (!dock || !inner || !viewport) return;
+ const resizeObserver = new ResizeObserver(() => apply());
+ let observedFooter: Element | null = null;
const apply = () => {
- const inset = composerColumnInset(
- readViewportBox(viewport),
- dock.getBoundingClientRect(),
+ // The footer is the real column box: WebKit's both-edges gutter reserves 2x the scrollbar on the right, clientWidth 1x.
+ const footer = viewport.querySelector(
+ ":scope > .aui-thread-viewport-footer",
);
+ if (footer && footer !== observedFooter) {
+ if (observedFooter) resizeObserver.unobserve(observedFooter);
+ resizeObserver.observe(footer);
+ observedFooter = footer;
+ }
+ const dockRect = dock.getBoundingClientRect();
+ const footerRect = footer?.getBoundingClientRect();
+ // The footer scrolls sideways with the content; the composer does not.
+ const inset = footerRect
+ ? composerInsetFromColumn(
+ {
+ left: footerRect.left + viewport.scrollLeft,
+ right: footerRect.right + viewport.scrollLeft,
+ },
+ dockRect,
+ )
+ : composerColumnInset(readViewportBox(viewport), dockRect);
inner.style.setProperty("--composer-dock-inset-left", `${inset.left}px`);
inner.style.setProperty("--composer-dock-inset-right", `${inset.right}px`);
};
apply();
- const resizeObserver = new ResizeObserver(apply);
resizeObserver.observe(viewport);
resizeObserver.observe(dock);
return () => resizeObserver.disconnect();
diff --git a/studio/frontend/tests/composer-column-inset.test.ts b/studio/frontend/tests/composer-column-inset.test.ts
index 91e2c40427d..aaa043270e4 100644
--- a/studio/frontend/tests/composer-column-inset.test.ts
+++ b/studio/frontend/tests/composer-column-inset.test.ts
@@ -4,11 +4,15 @@
import assert from "node:assert/strict";
import test from "node:test";
-import { composerColumnInset } from "../src/components/assistant-ui/composer-column-inset.ts";
+import {
+ composerColumnInset,
+ composerInsetFromColumn,
+} from "../src/components/assistant-ui/composer-column-inset.ts";
import { readSrc } from "./helpers/kit.ts";
const DOCK_INNER_RULE =
/\.unsloth-composer-dock-inner \{\s*padding-left: var\(--composer-dock-inset-left/;
+const FOOTER_COLUMN_CALL = /left: footerRect\.left \+ viewport\.scrollLeft/;
const NARROW_DOCK_RULE = /data-thread-narrow\]\) \.unsloth-composer-dock-inner/;
const base = {
@@ -68,6 +72,18 @@ test("a one-sided gutter with a border, as the Windows low-scale viewport has",
);
});
+test("a measured column box wins over the computed one", () => {
+ assert.deepEqual(
+ composerInsetFromColumn(
+ { left: 300, right: 1394 },
+ { left: 290, right: 1430 },
+ ),
+ { left: 10, right: 36 },
+ );
+ const thread = readSrc("components/assistant-ui/thread.tsx");
+ assert.match(thread, FOOTER_COLUMN_CALL);
+});
+
test("the dock pads from the measured inset, not a fixed gutter", () => {
const css = readSrc("index.css");
assert.match(css, DOCK_INNER_RULE);