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: Regenerate title in the chat header menu (#13574)

Michael Han2e94e0f6aede
diff --git a/studio/frontend/src/features/chat/components/chat-header-menu.tsx b/studio/frontend/src/features/chat/components/chat-header-menu.tsx
index 58f895268b0..b8b3a09196e 100644
--- a/studio/frontend/src/features/chat/components/chat-header-menu.tsx
+++ b/studio/frontend/src/features/chat/components/chat-header-menu.tsx
@@ -41,12 +41,14 @@ import {
PinIcon,
PinOffIcon,
PlusSignIcon,
+ Refresh01Icon,
ViewIcon,
ViewOffSlashIcon,
} from "@hugeicons/core-free-icons";
import { HugeiconsIcon, type IconSvgElement } from "@hugeicons/react";
import { ForkIcon } from "@/lib/fork-icon";
import type { ReactNode } from "react";
+import { useChatRuntimeStore } from "../stores/chat-runtime-store";
import {
type ActiveChatMenu,
useActiveChatMenuStore,
@@ -56,6 +58,7 @@ import {
chatExportOptions,
exportConversationByFormat,
getSidebarItemThreadIds,
+ regenerateChatTitleWithToast,
} from "./chat-row-menu";
import { OpenChatFolderItem, UploadToChatFolderItem } from "./open-chat-folder-item";
@@ -152,6 +155,9 @@ function ChatMenuItems({ menu }: { menu: ActiveChatMenu }) {
const favorite = useChatFavoritesStore((state) =>
state.chatIds.includes(menu.item.id),
);
+ const generating = useChatRuntimeStore((s) =>
+ getSidebarItemThreadIds(menu.item).some((id) => Boolean(s.runningByThreadId[id])),
+ );
// As the Library exports one: each thread behind the chat, a comparison's two included.
const exportAs = async (format: ConversationExportFormat) => {
try {
@@ -169,6 +175,13 @@ function ChatMenuItems({ menu }: { menu: ActiveChatMenu }) {
<Item icon={Edit03Icon} onSelect={menu.rename} shortcut="renameChat">
{t("common.rename")}
</Item>
+ <Item
+ icon={Refresh01Icon}
+ onSelect={() => void regenerateChatTitleWithToast(menu.item)}
+ disabled={generating}
+ >
+ {t("library.menu.regenerateTitle")}
+ </Item>
<Item
icon={menu.pinned ? PinOffIcon : PinIcon}
onSelect={menu.togglePin}
diff --git a/studio/frontend/src/features/chat/components/chat-row-menu.ts b/studio/frontend/src/features/chat/components/chat-row-menu.ts
index 1f8f147add9..6e7371d45ba 100644
--- a/studio/frontend/src/features/chat/components/chat-row-menu.ts
+++ b/studio/frontend/src/features/chat/components/chat-row-menu.ts
@@ -6,6 +6,7 @@
// carried their own.
import { sandboxHasFiles } from "@/components/assistant-ui/sandbox-reveal";
+import { toast } from "@/lib/toast";
import {
CONVERSATION_MARKDOWN_FORMAT,
@@ -215,6 +216,24 @@ export async function regenerateChatTitle(
}
}
+/** The Library's and the chat header's Regenerate title, with the same toasts. */
+export async function regenerateChatTitleWithToast(chat: SidebarItem): Promise<void> {
+ // A fast refresh would only flash the toast.
+ const toastId = `regenerate-title-${chat.id}`;
+ const slow = setTimeout(() => toast.loading("Regenerating title...", { id: toastId }), 400);
+ const outcome = await regenerateChatTitle(chat);
+ clearTimeout(slow);
+ // Another request for this chat is running and owns the toast.
+ if (outcome === "busy") return;
+ if (outcome === "empty") {
+ toast.error("This chat has no messages to title yet.", { id: toastId });
+ } else if (outcome === "failed") {
+ toast.error("Could not regenerate the title.", { id: toastId });
+ } else {
+ toast.dismiss(toastId);
+ }
+}
+
async function regenerateChatTitleNow(
item: SidebarItem,
run: { expired: boolean },
diff --git a/studio/frontend/src/features/chat/index.ts b/studio/frontend/src/features/chat/index.ts
index 65d0056e275..74916d4c2ab 100644
--- a/studio/frontend/src/features/chat/index.ts
+++ b/studio/frontend/src/features/chat/index.ts
@@ -379,6 +379,7 @@ export {
getSidebarItemThreadIds,
recordedSandboxSessionIds,
regenerateChatTitle,
+ regenerateChatTitleWithToast,
sandboxSessionIdsHolding,
type ConversationExportFormat,
} from "./components/chat-row-menu";
diff --git a/studio/frontend/src/features/library/chats/chats-library.tsx b/studio/frontend/src/features/library/chats/chats-library.tsx
index 4bad84afdf5..9783de6777f 100644
--- a/studio/frontend/src/features/library/chats/chats-library.tsx
+++ b/studio/frontend/src/features/library/chats/chats-library.tsx
@@ -38,7 +38,7 @@ import {
normalizeSectionName,
notifyChatHistoryUpdated,
rangeBetween,
- regenerateChatTitle,
+ regenerateChatTitleWithToast,
removeCustomSectionWithUndo,
renameChatItem,
showForkCreatedToast,
@@ -206,22 +206,6 @@ const SECTION_SORTS: SortChoice<SectionSortKey>[] = [
const NO_CHATS: SidebarItem[] = [];
-async function regenerateChatTitleWithToast(chat: SidebarItem): Promise<void> {
- // A fast refresh would only flash the toast.
- const toastId = `regenerate-title-${chat.id}`;
- const slow = setTimeout(() => toast.loading("Regenerating title...", { id: toastId }), 400);
- const outcome = await regenerateChatTitle(chat);
- clearTimeout(slow);
- // Another request for this chat is running and owns the toast.
- if (outcome === "busy") return;
- if (outcome === "empty") {
- toast.error("This chat has no messages to title yet.", { id: toastId });
- } else if (outcome === "failed") {
- toast.error("Could not regenerate the title.", { id: toastId });
- } else {
- toast.dismiss(toastId);
- }
-}
function isDateField(key: string): key is DateField {
return (DATE_FIELDS as readonly string[]).includes(key);
diff --git a/studio/frontend/tests/chat-title-refresh.test.ts b/studio/frontend/tests/chat-title-refresh.test.ts
index ee4187a07ae..88620492eba 100644
--- a/studio/frontend/tests/chat-title-refresh.test.ts
+++ b/studio/frontend/tests/chat-title-refresh.test.ts
@@ -273,12 +273,33 @@ test("the Library's Regenerate title is off while any of the chat's panes is gen
test("a second Regenerate title while one runs leaves the running request's toast alone", () => {
const source = readFileSync(
- new URL("../src/features/library/chats/chats-library.tsx", import.meta.url),
+ new URL("../src/features/chat/components/chat-row-menu.ts", import.meta.url),
"utf8",
).replace(/\s+/g, " ");
const fn = source.slice(
source.indexOf("async function regenerateChatTitleWithToast"),
- source.indexOf("function isDateField"),
+ source.indexOf("async function regenerateChatTitleNow"),
);
assert.match(fn, /if \(outcome === "busy"\) return; if \(outcome === "empty"\)/);
});
+
+test("the chat header menu offers Regenerate title like the Library, off while generating", () => {
+ const menu = readFileSync(
+ new URL("../src/features/chat/components/chat-header-menu.tsx", import.meta.url),
+ "utf8",
+ );
+ assert.match(
+ menu,
+ /icon=\{Refresh01Icon\}\s*onSelect=\{\(\) => void regenerateChatTitleWithToast\(menu\.item\)\}\s*disabled=\{generating\}/,
+ );
+ assert.match(menu, /t\("library\.menu\.regenerateTitle"\)/);
+ assert.match(
+ menu,
+ /getSidebarItemThreadIds\(menu\.item\)\.some\(\(id\) => Boolean\(s\.runningByThreadId\[id\]\)\)/,
+ );
+ const library = readFileSync(
+ new URL("../src/features/library/chats/chats-library.tsx", import.meta.url),
+ "utf8",
+ );
+ assert.match(library, /regenerateTitle: \(chat\) => void regenerateChatTitleWithToast\(chat\)/);
+});