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: prompt More menu for Fork and Bookmark, and no composer scrollbar flash (#16866)

Michael Han300baedb6740
diff --git a/studio/frontend/src/components/assistant-ui/thread.tsx b/studio/frontend/src/components/assistant-ui/thread.tsx
index 95d18a48faa..882616e30c0 100644
--- a/studio/frontend/src/components/assistant-ui/thread.tsx
+++ b/studio/frontend/src/components/assistant-ui/thread.tsx
@@ -150,7 +150,6 @@ import {
} from "@/features/chat";
import { TooltipIconButton } from "@/components/assistant-ui/tooltip-icon-button";
import {
- BookmarkTurnButton,
BookmarkTurnMenuItem,
TurnNavigator,
} from "@/components/assistant-ui/turn-navigation";
@@ -429,7 +428,7 @@ import {
ReadAloudIcon,
} from "@/lib/action-bar-icons";
import { ForkIcon } from "@/lib/fork-icon";
-import { markComposerScrollEdges } from "@/lib/composer-scroll-fade";
+import { markComposerScrollable, markComposerScrollEdges } from "@/lib/composer-scroll-fade";
import { cn } from "@/lib/utils";
import {
ActionBarMorePrimitive,
@@ -3303,8 +3302,13 @@ const Composer: FC<{
const handleEditorHeightChange = useCallback(
(height: number, meta: { rowHeight: number }) => {
setEditorHeight(height);
- if (meta.rowHeight <= 0) return;
const el = inputRef.current;
+ // Drafts set without typing change only the height.
+ if (el) {
+ markComposerScrollable(el);
+ markComposerScrollEdges(el);
+ }
+ if (meta.rowHeight <= 0) return;
if (el && !lineMetricsRef.current) {
const cs = getComputedStyle(el);
const lineHeight = Number.parseFloat(cs.lineHeight) || 24;
@@ -5829,6 +5833,9 @@ const Composer: FC<{
onInputCapture={(event) =>
markComposerScrollEdges(event.currentTarget)
}
+ onFocusCapture={(event) =>
+ markComposerScrollEdges(event.currentTarget)
+ }
// Capture, so inputProps keeps the handlers it already owns.
onKeyDownCapture={notePlainPasteChord}
onKeyUpCapture={endPlainPasteChord}
@@ -8669,8 +8676,12 @@ const DeleteMessageButton: FC = () => {
);
};
+// A thin diagonal reads small at the shared size.
+const EDIT_GLYPH = "size-[calc(var(--icon-size)*1.049)]";
const MORE_MENU_CONTENT_CLASS =
"aui-action-bar-more-content dropdown-surface z-50 min-w-32 max-h-(--radix-dropdown-menu-content-available-height) flex flex-col overflow-hidden rounded-xl bg-popover px-[calc(8px*var(--ui-space-scale,1))] py-2 text-popover-foreground shadow-[0_2px_8px_-2px_rgba(0,0,0,0.16)]";
+const MORE_MENU_ITEM_CLASS =
+ "aui-action-bar-more-item flex cursor-pointer select-none items-center gap-2 rounded-md px-3 py-2 text-sm outline-none hover:bg-accent hover:text-accent-foreground focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50";
// Loaded on first use: the dialog is not part of the first screen.
const LazyRewindDialog = lazy(() =>
@@ -8767,7 +8778,7 @@ const EditAssistantMessageButton: FC = () => {
<HugeiconsIcon
icon={Edit03Icon}
strokeWidth={1.75}
- className="size-icon"
+ className={EDIT_GLYPH}
/>
</TooltipIconButton>
);
@@ -9114,20 +9125,59 @@ const UserActionBar: FC = () => {
<HugeiconsIcon
icon={Edit03Icon}
strokeWidth={1.75}
- className="size-icon"
+ className={EDIT_GLYPH}
/>
</TooltipIconButton>
</ActionBarPrimitive.Edit>
)}
- <BookmarkTurnButton />
<RewindMessageButton />
<ForkCountBadge />
- <ForkMessageButton />
<DeleteMessageButton />
+ <UserMoreMenu />
</UserMessageActionBar>
);
};
+const UserMoreMenu: FC = () => {
+ const triggerRef = useRef<HTMLButtonElement>(null);
+ const collisionPadding = useWindowChromeCollisionPadding(undefined);
+ const { forkMessage, forkDisabled } = useForkMessageAction();
+ return (
+ // Non-modal: see AssistantActionBar.
+ <ActionBarMorePrimitive.Root modal={false}>
+ <ActionBarMorePrimitive.Trigger asChild={true}>
+ <TooltipIconButton
+ ref={triggerRef}
+ tooltip="More"
+ className="data-[state=open]:bg-accent"
+ >
+ <HugeiconsIcon icon={MoreHorizontalIcon} strokeWidth={1.75} className="size-icon" />
+ </TooltipIconButton>
+ </ActionBarMorePrimitive.Trigger>
+ <ActionBarMorePrimitive.Content
+ side="bottom"
+ align="end"
+ collisionPadding={collisionPadding}
+ onCloseAutoFocus={(e) => e.preventDefault()}
+ className={MORE_MENU_CONTENT_CLASS}
+ >
+ <div className="min-h-0 flex-1 overflow-x-hidden overflow-y-auto">
+ <MenuDismissGuard triggerRef={triggerRef} />
+ <ActionBarMorePrimitive.Item
+ disabled={forkDisabled}
+ onSelect={() => void forkMessage()}
+ className={MORE_MENU_ITEM_CLASS}
+ >
+ <HugeiconsIcon icon={ForkIcon} strokeWidth={1.75} className="size-[calc(var(--icon-size)*0.97)]" />
+ Fork from here
+ </ActionBarMorePrimitive.Item>
+ <BookmarkTurnMenuItem ownTurn={true} className={MORE_MENU_ITEM_CLASS} />
+ </div>
+ </ActionBarMorePrimitive.Content>
+ </ActionBarMorePrimitive.Root>
+ );
+};
+
const EditComposer: FC = () => {
const aui = useAui();
const sendShortcut = useChatPreferencesStore((s) => s.sendShortcut);
diff --git a/studio/frontend/src/components/assistant-ui/turn-navigation.tsx b/studio/frontend/src/components/assistant-ui/turn-navigation.tsx
index 32f8579d456..d49c449f3f4 100644
--- a/studio/frontend/src/components/assistant-ui/turn-navigation.tsx
+++ b/studio/frontend/src/components/assistant-ui/turn-navigation.tsx
@@ -34,7 +34,6 @@ import {
turnOpenerIdAt,
} from "@/components/assistant-ui/thread-turns";
import { THREAD_GUTTER_SHIFT_PROPERTY } from "@/components/assistant-ui/thread-gutter";
-import { TooltipIconButton } from "@/components/assistant-ui/tooltip-icon-button";
import { useDetachThreadFromBottom } from "@/components/assistant-ui/use-intent-aware-autoscroll";
import {
useBookmarkedTurnsStore,
@@ -89,48 +88,26 @@ function useTurnBookmark(
return { bookmarked, toggle: () => toggleBookmarkedTurn(threadId, openerId) };
}
-// gated so a disabled rail mounts no thread subscriptions per message
-export const BookmarkTurnButton: FC = () => {
- const enabled = useChatPreferencesStore((state) => state.showTurnNavigation);
- return enabled ? <BookmarkTurnButtonInner /> : null;
-};
+type BookmarkTurnMenuItemProps = { className?: string; ownTurn?: boolean };
-const BookmarkTurnButtonInner: FC = () => {
- const t = useT();
- const turnBookmark = useTurnBookmark(true);
- if (!turnBookmark) {
- return null;
- }
- return (
- <TooltipIconButton
- tooltip={t(
- turnBookmark.bookmarked ? "turns.removeBookmark" : "turns.bookmark",
- )}
- aria-pressed={turnBookmark.bookmarked}
- onClick={turnBookmark.toggle}
- >
- <HugeiconsIcon
- icon={BookmarkIcon}
- strokeWidth={1.75}
- className={cn("size-icon", turnBookmark.bookmarked && "fill-current")}
- />
- </TooltipIconButton>
- );
-};
-
-export const BookmarkTurnMenuItem: FC<{ className?: string }> = ({
- className,
-}) => {
+// gated so a disabled rail mounts no thread subscriptions per message
+export const BookmarkTurnMenuItem: FC<BookmarkTurnMenuItemProps> = (props) => {
const enabled = useChatPreferencesStore((state) => state.showTurnNavigation);
- return enabled ? <BookmarkTurnMenuItemInner className={className} /> : null;
+ return enabled ? <BookmarkTurnMenuItemInner {...props} /> : null;
};
-const BookmarkTurnMenuItemInner: FC<{ className?: string }> = ({
+const BookmarkTurnMenuItemInner: FC<BookmarkTurnMenuItemProps> = ({
className,
+ ownTurn = false,
}) => {
const t = useT();
- const turnBookmark = useTurnBookmark(false);
- if (!turnBookmark) {
+ // Without the rail a bookmark has nowhere to show.
+ const railShown = useAuiState(
+ ({ thread }) =>
+ threadTurns(thread.messages).openerIds.length >= MIN_NAVIGATOR_TURNS,
+ );
+ const turnBookmark = useTurnBookmark(ownTurn);
+ if (!railShown || !turnBookmark) {
return null;
}
return (
diff --git a/studio/frontend/src/index.css b/studio/frontend/src/index.css
index c7bc02f5171..2b457c437cb 100644
--- a/studio/frontend/src/index.css
+++ b/studio/frontend/src/index.css
@@ -3214,6 +3214,11 @@ html[data-chat-font] .aui-root {
padding-right: calc(2.625rem * var(--ui-space-scale, 1));
}
+ /* Not while the frame eases to a new height (markComposerScrollEdges). */
+ .unsloth-composer-editor .unsloth-composer-input:not([data-scrollable]) {
+ overflow-y: hidden;
+ }
+
/* 6px wider (and as much more padding) so the scrollbar sits near the composer's edge. */
.unsloth-composer-line .unsloth-composer-editor .unsloth-composer-input {
width: calc(100% + 0.375rem * var(--ui-space-scale, 1));
diff --git a/studio/frontend/src/lib/composer-scroll-fade.ts b/studio/frontend/src/lib/composer-scroll-fade.ts
index 3fa9c0de3a0..51f5a040f5f 100644
--- a/studio/frontend/src/lib/composer-scroll-fade.ts
+++ b/studio/frontend/src/lib/composer-scroll-fade.ts
@@ -2,7 +2,8 @@
// Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0
/** Flags the composer edges with text scrolled past, for index.css's fades. Next frame, after autosize;
- bottom needs over half a line past the padding, which typing alone leaves hidden. */
+ bottom needs over half a line past the padding, which typing alone leaves hidden.
+ `data-scrollable`: past max rows only, so the easing frame never flashes a scrollbar. */
export function markComposerScrollEdges(el: HTMLTextAreaElement): void {
requestAnimationFrame(() => {
const style = getComputedStyle(el);
@@ -14,5 +15,12 @@ export function markComposerScrollEdges(el: HTMLTextAreaElement): void {
"data-fade-bottom",
el.scrollHeight - (el.scrollTop + el.clientHeight) > slack,
);
+ markComposerScrollable(el);
});
}
+
+/** For callers running after autosize. */
+export function markComposerScrollable(el: HTMLTextAreaElement): void {
+ const sized = Number.parseFloat(el.style.height) || el.clientHeight;
+ el.toggleAttribute("data-scrollable", el.scrollHeight > sized + 1);
+}
diff --git a/studio/frontend/tests/chat-rewind.test.ts b/studio/frontend/tests/chat-rewind.test.ts
index 75d5899209b..6140433b66f 100644
--- a/studio/frontend/tests/chat-rewind.test.ts
+++ b/studio/frontend/tests/chat-rewind.test.ts
@@ -115,7 +115,7 @@ test("the composer opens the rewind picker instead of sending /rewind", () => {
assert.ok(intercept < submit.indexOf("interceptSend(event)"));
assert.match(
thread,
- /<RewindMessageButton \/>\s*<ForkCountBadge \/>\s*<ForkMessageButton \/>/,
+ /<RewindMessageButton \/>\s*<ForkCountBadge \/>/,
);
});
diff --git a/studio/frontend/tests/message-action-bar-defaults.test.ts b/studio/frontend/tests/message-action-bar-defaults.test.ts
index 3bc16294beb..8146c0313c9 100644
--- a/studio/frontend/tests/message-action-bar-defaults.test.ts
+++ b/studio/frontend/tests/message-action-bar-defaults.test.ts
@@ -60,13 +60,16 @@ test("a reply's bar ends in Delete then More; its More menu has no Delete", () =
assert.ok(!bar.slice(menuAt).includes("Delete"));
});
-test("a prompt's bar is Copy, Edit, Rewind, Fork and Delete, with no More menu", () => {
+test("a prompt's bar is Copy, Edit, Rewind, Delete, then More with Fork and Bookmark", () => {
const bar = component("UserActionBar");
assert.match(
bar,
- /<RewindMessageButton \/>\s*<ForkCountBadge \/>\s*<ForkMessageButton \/>\s*<DeleteMessageButton \/>\s*<\/UserMessageActionBar>/,
+ /<RewindMessageButton \/>\s*<ForkCountBadge \/>\s*<DeleteMessageButton \/>\s*<UserMoreMenu \/>\s*<\/UserMessageActionBar>/,
);
- assert.ok(!THREAD.includes("UserMoreMenu"));
+ assert.ok(!bar.includes("ForkMessageButton"));
+ assert.ok(!bar.includes("Bookmark"));
+ const menu = component("UserMoreMenu");
+ assert.ok(menu.indexOf("Fork from here") < menu.indexOf("<BookmarkTurnMenuItem ownTurn={true}"));
});
test("the reply footer and bar wrap, so the wider bar never scrolls a narrow thread", () => {
diff --git a/studio/frontend/tests/turn-navigation-layout.test.ts b/studio/frontend/tests/turn-navigation-layout.test.ts
index 444289c939b..7bcf114dca1 100644
--- a/studio/frontend/tests/turn-navigation-layout.test.ts
+++ b/studio/frontend/tests/turn-navigation-layout.test.ts
@@ -32,3 +32,11 @@ test("turn navigation is on by default and stays off once turned off", async ()
assert.match(prefs, /showTurnNavigation: true,/);
assert.match(prefs, /showTurnNavigation: saved\?\.showTurnNavigation !== false,/);
});
+
+test("Bookmark is offered only once the rail shows, from the rail's own turn minimum", () => {
+ const source = readSrc("components/assistant-ui/turn-navigation.tsx");
+ const item = source.slice(source.indexOf("const BookmarkTurnMenuItemInner"));
+ assert.match(item, /threadTurns\(thread\.messages\)\.openerIds\.length >= MIN_NAVIGATOR_TURNS/);
+ assert.match(item, /if \(!railShown \|\| !turnBookmark\) \{\n\s*return null;/);
+ assert.match(source, /if \(openerIds\.length < MIN_NAVIGATOR_TURNS\) \{\n\s*return null;/);
+});