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: rename sidebar chats in the Rename chat dialog (#13575)

Michael Hanb45c8acc39a4
diff --git a/studio/frontend/src/components/app-sidebar.tsx b/studio/frontend/src/components/app-sidebar.tsx
index a06efcceed2..f9b26bc5e74 100644
--- a/studio/frontend/src/components/app-sidebar.tsx
+++ b/studio/frontend/src/components/app-sidebar.tsx
@@ -3088,25 +3088,12 @@ export function AppSidebar() {
}
type RenameTarget =
- // `inline` is the row's own pill, and a chord has no row under the cursor
- // and may have none on screen at all, so it opens the dialog instead.
- // `rowScope` is the list the pill belongs to. A pinned project chat is two rows at once, and
- // both mounted an autofocused input: the second stole focus and the first's blur cancelled the
- // rename. The row that opened the menu owns the pill.
- | {
- kind: "chat";
- item: SidebarItem;
- current: string;
- inline: boolean;
- rowScope?: string;
- }
+ | { kind: "chat"; item: SidebarItem; current: string }
| { kind: "run"; run: TrainingRunSummary; current: string };
const [renamingTarget, setRenamingTarget] = useState<RenameTarget | null>(
null,
);
const [renameDraft, setRenameDraft] = useState("");
- // Skips the inline rename input's blur-commit when Enter/Escape already handled it.
- const skipRenameBlurRef = useRef(false);
const renameImeRef = useRef(newInputImeState());
// Optimistic title while the debounced sidebar refresh catches up, so the old name doesn't flash.
const [pendingRename, setPendingRename] = useState<{
@@ -3148,15 +3135,9 @@ export function AppSidebar() {
? renameTrimmed !== renamingTarget.current
: renamingTarget.run.display_name != null);
- function openRenameChat(item: SidebarItem, inline = true, rowScope?: string) {
+ function openRenameChat(item: SidebarItem) {
setRenameDraft(item.title);
- setRenamingTarget({
- kind: "chat",
- item,
- current: item.title,
- inline,
- rowScope,
- });
+ setRenamingTarget({ kind: "chat", item, current: item.title });
}
function openRenameRun(run: TrainingRunSummary) {
const current = getTrainingRunDisplayTitle(run);
@@ -3189,34 +3170,6 @@ export function AppSidebar() {
}
}
- // Inline chat rename commits on Enter or blur, cancels on Escape.
- function handleInlineRenameKeyDown(
- event: React.KeyboardEvent<HTMLInputElement>,
- ) {
- // IME Enter/Escape must not finish the rename; check before preventDefault.
- if (imeOwnsInputKeydown(event, renameImeRef.current)) return;
- if (event.key === "Enter") {
- event.preventDefault();
- skipRenameBlurRef.current = true;
- // Commit when changed, else just close, so a no-op Enter doesn't leave the row an input.
- if (renameDirty) void commitRename();
- else setRenamingTarget(null);
- } else if (event.key === "Escape") {
- event.preventDefault();
- skipRenameBlurRef.current = true;
- setRenamingTarget(null);
- }
- }
-
- function handleInlineRenameBlur() {
- if (skipRenameBlurRef.current) {
- skipRenameBlurRef.current = false;
- return;
- }
- if (renameDirty) void commitRename();
- else setRenamingTarget(null);
- }
-
type DeleteTarget =
| { kind: "chat"; item: SidebarItem }
| { kind: "chats"; items: SidebarItem[] }
@@ -3636,7 +3589,7 @@ export function AppSidebar() {
// the chord would look dead and leave a rename waiting to appear when the row came back.
useShortcut("renameChat", () => {
if (sidebarCovered()) return;
- withActiveChat((item) => openRenameChat(item, false));
+ withActiveChat((item) => openRenameChat(item));
});
// The clipboard is outside the app, so writing a hidden chat's contents into it from behind a
// dialog is not something the user can take back by closing the dialog.
@@ -3683,7 +3636,7 @@ export function AppSidebar() {
? { id: item.projectId, name: project?.name ?? "" }
: null,
section: section ? { id: section.id, name: section.name } : null,
- rename: () => openRenameChat(item, false),
+ rename: () => openRenameChat(item),
togglePin: () => togglePinnedChat(item.id),
toggleUnread: () =>
unread
@@ -4556,11 +4509,11 @@ export function AppSidebar() {
/** A chat row's right-click menu, on the same terms as a folder's: the row's own menu for
* one row, the bulk actions for a selection of several. */
- function renderChatContextMenu(item: SidebarItem, list: ChatListContext) {
+ function renderChatContextMenu(item: SidebarItem) {
if (selectionCount <= 1) {
return (
<ContextMenuContent className="unsloth-plus-menu sidebar-row-menu sidebar-menu menu-flat-destructive w-52">
- {renderChatRowMenuItems(item, list, CONTEXT_ROW_MENU)}
+ {renderChatRowMenuItems(item, CONTEXT_ROW_MENU)}
</ContextMenuContent>
);
}
@@ -4610,11 +4563,7 @@ export function AppSidebar() {
/** Every action a chat row offers. Rendered into the 3-dot dropdown and, unchanged, into
* the row's right-click menu, so the two never drift apart. */
- function renderChatRowMenuItems(
- item: SidebarItem,
- list: ChatListContext,
- P: RowMenuParts,
- ) {
+ function renderChatRowMenuItems(item: SidebarItem, P: RowMenuParts) {
const threadIds = getSidebarItemThreadIds(item);
const isPinned = pinnedIdSet.has(item.id);
const moveProjects = recentProjects
@@ -4637,7 +4586,7 @@ export function AppSidebar() {
return (
<>
<P.Item
- onSelect={() => openRenameChat(item, true, list?.scope)}
+ onSelect={() => openRenameChat(item)}
>
<HugeiconsIcon icon={Edit03Icon} strokeWidth={1.75} className="size-icon" />
<span>Rename</span>
@@ -4853,43 +4802,6 @@ export function AppSidebar() {
: "group-has-[.sidebar-row-action:focus-visible]/recent-item:pr-16",
);
- const isRenamingThis =
- renamingTarget?.kind === "chat" &&
- renamingTarget.inline &&
- renamingTarget.item.id === item.id &&
- // The same chat can be on screen twice; only the row the menu was opened from edits.
- renamingTarget.rowScope === list?.scope;
-
- // Inline rename edits the title in place as a rounded pill, no dialog.
- if (isRenamingThis) {
- return (
- <SidebarMenuItem key={item.id} className={itemClass}>
- <input
- autoFocus
- value={renameDraft}
- onChange={(event) => setRenameDraft(event.target.value)}
- onKeyDown={handleInlineRenameKeyDown}
- {...inputImeHandlers(renameImeRef.current)}
- onBlur={() => {
- resetInputIme(renameImeRef.current);
- handleInlineRenameBlur();
- }}
- onFocus={(event) => {
- resetInputIme(renameImeRef.current);
- event.currentTarget.select();
- }}
- maxLength={120}
- aria-label={translate("shell.dialog.renameChat.placeholder")}
- className={cn(
- // No pill or box; edit in place as plain highlighted text.
- "text-foreground h-[calc(30px*var(--ui-space-scale,1))] w-full border-0 bg-transparent py-0 pr-4 text-ui-14p5 leading-ui-19 font-medium tracking-nav outline-none",
- variant === "project" ? "pl-[calc(39px*var(--ui-space-scale,1))]" : "pl-3",
- )}
- />
- </SidebarMenuItem>
- );
- }
-
return (
<ContextMenu key={item.id}>
<ContextMenuTrigger asChild>
@@ -4935,12 +4847,11 @@ export function AppSidebar() {
if (list && handleSelectionClick(event, item, list)) return;
openChatItem(item);
}}
- // The chat opens on the first click and the pill opens on the second, which is
- // what double-clicking a title does everywhere else it renames one.
+ // The chat opens on the first click and the rename dialog on the second.
onDoubleClick={(event) => {
event.preventDefault();
event.stopPropagation();
- openRenameChat(item, true, list?.scope);
+ openRenameChat(item);
}}
>
{isPinned && variant !== "project" && (
@@ -5049,11 +4960,11 @@ export function AppSidebar() {
</button>
)}
>
- {renderChatRowMenuItems(item, list, DROPDOWN_ROW_MENU)}
+ {renderChatRowMenuItems(item, DROPDOWN_ROW_MENU)}
</NonModalDropdownMenu>
</SidebarMenuItem>
</ContextMenuTrigger>
- {renderChatContextMenu(item, list)}
+ {renderChatContextMenu(item)}
</ContextMenu>
);
}
@@ -6370,10 +6281,7 @@ export function AppSidebar() {
</DialogContent>
</Dialog>
<Dialog
- open={
- renamingTarget !== null &&
- (renamingTarget.kind !== "chat" || !renamingTarget.inline)
- }
+ open={renamingTarget !== null}
onOpenChange={(open) => {
if (!open) setRenamingTarget(null);
}}
@@ -6396,6 +6304,11 @@ export function AppSidebar() {
value={renameDraft}
onChange={(event) => setRenameDraft(event.target.value)}
{...inputImeHandlers(renameImeRef.current)}
+ // Selected on open, so typing replaces the title; still ends any lost composition (#5546).
+ onFocus={(event) => {
+ resetInputIme(renameImeRef.current);
+ event.currentTarget.select();
+ }}
onKeyDown={(event) => {
if (imeOwnsInputKeydown(event, renameImeRef.current)) return;
if (event.key === "Enter") {
diff --git a/studio/frontend/tests/chat-rename-ime.test.ts b/studio/frontend/tests/chat-rename-ime.test.ts
index f9d4bd17e64..d2066072c94 100644
--- a/studio/frontend/tests/chat-rename-ime.test.ts
+++ b/studio/frontend/tests/chat-rename-ime.test.ts
@@ -37,12 +37,6 @@ function handler(
node.parent.parent.parent.getText(source).includes("commitRename()")
)
matches.push(node.initializer.expression);
- } else if (inline) {
- if (
- ts.isFunctionDeclaration(node) &&
- node.name?.text === "handleInlineRenameKeyDown"
- )
- matches.push(node);
} else if (
ts.isJsxAttribute(node) &&
node.name.getText(source) === "onKeyDown" &&
@@ -113,7 +107,6 @@ function fixture(file: string, inline: boolean, dirty = true) {
}
for (const [name, file, inline] of [
- ["sidebar inline", "components/app-sidebar.tsx", true],
["sidebar dialog", "components/app-sidebar.tsx", false],
["thread sidebar dialog", "features/chat/thread-sidebar.tsx", false],
] as const) {
@@ -138,21 +131,7 @@ for (const [name, file, inline] of [
}
}
-for (const dirty of [true, false]) {
- test(`sidebar inline: candidate Escape preserves editing (dirty=${dirty})`, () => {
- const f = fixture("components/app-sidebar.tsx", true, dirty);
- f.key("Escape", true);
- f.key("Escape", false, 229);
- assert.deepEqual(f.effects, []);
- assert.equal(f.skipRenameBlurRef.current, false);
- f.key("Escape");
- assert.deepEqual(f.effects, ["prevent", "close"]);
- assert.equal(f.skipRenameBlurRef.current, true);
- });
-}
-
for (const [name, file, inline] of [
- ["sidebar inline", "components/app-sidebar.tsx", true],
["sidebar dialog", "components/app-sidebar.tsx", false],
["thread sidebar dialog", "features/chat/thread-sidebar.tsx", false],
] as const) {
@@ -170,15 +149,6 @@ for (const [name, file, inline] of [
});
}
-test("sidebar inline: a separate idle Pinyin Enter closes an unchanged input", () => {
- const f = fixture("components/app-sidebar.tsx", true, false);
- f.compose(true);
- f.key("Enter", true);
- f.compose(false);
- f.key("Enter", false, 229);
- assert.deepEqual(f.effects, ["prevent", "close"]);
-});
-
for (const [name, file] of [
["sidebar dialog", "components/app-sidebar.tsx"],
["thread sidebar dialog", "features/chat/thread-sidebar.tsx"],
diff --git a/studio/frontend/tests/keyboard-shortcuts.test.ts b/studio/frontend/tests/keyboard-shortcuts.test.ts
index 625f8b86319..d19c388f211 100644
--- a/studio/frontend/tests/keyboard-shortcuts.test.ts
+++ b/studio/frontend/tests/keyboard-shortcuts.test.ts
@@ -1155,40 +1155,26 @@ test("the model picker chord opens without the tour's pin", async () => {
assert.equal((CHAT_PAGE.match(/openModelSelector/g) ?? []).length, 3);
});
-// The inline rename pill is rendered by the row, so it needs the row to be on
-// screen. A chord has no row under the cursor, and the open chat may be behind
-// a collapsed section, past a folder's limit, or on a route with no chat list.
-test("the rename chord does not land in a surface only a row can show", async () => {
- // The chord asks for the dialog; the context menu, which has a row under the
- // cursor by definition, keeps the pill.
+// The chord, the row menus and a double-click all open the Rename chat dialog; there is no in-row editor.
+test("every sidebar chat rename opens the dialog", () => {
assert.match(
APP_SIDEBAR,
- /useShortcut\("renameChat", \(\) => \{[\s\S]*?withActiveChat\(\(item\) => openRenameChat\(item, false\)\);/,
+ /useShortcut\("renameChat", \(\) => \{[\s\S]*?withActiveChat\(\(item\) => openRenameChat\(item\)\);/,
);
- // The menu names the list its row is in, so a chat on screen twice renames in the row the
- // user opened, not in both at once.
+ assert.match(APP_SIDEBAR, /onSelect=\{\(\) => openRenameChat\(item\)\}/);
assert.match(
APP_SIDEBAR,
- /onSelect=\{\(\) => openRenameChat\(item, true, list\?\.scope\)\}/,
+ /onDoubleClick=\{\(event\) => \{[\s\S]*?openRenameChat\(item\);/,
);
+ assert.match(APP_SIDEBAR, /function openRenameChat\(item: SidebarItem\) \{/);
+ assert.match(APP_SIDEBAR, /open=\{renamingTarget !== null\}/);
+ assert.doesNotMatch(APP_SIDEBAR, /isRenamingThis|handleInlineRename|renamingTarget\.inline/);
+ assert.ok(APP_SIDEBAR.includes('t("shell.dialog.renameChat.title")'));
+ // The title opens selected, and focus still resets the IME state.
assert.match(
APP_SIDEBAR,
- /function openRenameChat\(item: SidebarItem, inline = true, rowScope\?: string\)/,
- );
-
- // The pill is gated on it, so a dialog rename cannot also arm a row that is
- // off screen and surprise the user when it comes back.
- assert.match(
- APP_SIDEBAR,
- /const isRenamingThis =\n\s*renamingTarget\?\.kind === "chat" &&\n\s*renamingTarget\.inline &&/,
- );
- // And the dialog takes chats now, which is what its chat strings were always
- // written for.
- assert.match(
- APP_SIDEBAR,
- /\(renamingTarget\.kind !== "chat" \|\| !renamingTarget\.inline\)/,
+ /onFocus=\{\(event\) => \{\s*resetInputIme\(renameImeRef\.current\);\s*event\.currentTarget\.select\(\);/,
);
- assert.ok(APP_SIDEBAR.includes('t("shell.dialog.renameChat.title")'));
});
// Bare Escape has more than one owner. The sidebar answers it while rows are
diff --git a/studio/frontend/tests/sidebar-row-actions.test.ts b/studio/frontend/tests/sidebar-row-actions.test.ts
index 8b93e3065dc..3a56aac1c62 100644
--- a/studio/frontend/tests/sidebar-row-actions.test.ts
+++ b/studio/frontend/tests/sidebar-row-actions.test.ts
@@ -104,11 +104,11 @@ test("a chat row reserves one gutter, whatever its state", () => {
);
});
-// Renaming from the menu is two clicks and a read; the title is right there.
-test("double-clicking a chat title renames it in place", () => {
+// Renaming from the menu is two clicks and a read; a double-click on the title is one gesture.
+test("double-clicking a chat title opens the Rename chat dialog", () => {
assert.match(
APP_SIDEBAR,
- /onDoubleClick=\{\(event\) => \{\n\s*event\.preventDefault\(\);\n\s*event\.stopPropagation\(\);\n\s*openRenameChat\(item, true, list\?\.scope\);\n\s*\}\}/,
+ /onDoubleClick=\{\(event\) => \{\n\s*event\.preventDefault\(\);\n\s*event\.stopPropagation\(\);\n\s*openRenameChat\(item\);\n\s*\}\}/,
);
});
diff --git a/studio/frontend/tests/sidebar-row-menu-and-pinned-folders.test.ts b/studio/frontend/tests/sidebar-row-menu-and-pinned-folders.test.ts
index e53599f3ea1..eafa7acc874 100644
--- a/studio/frontend/tests/sidebar-row-menu-and-pinned-folders.test.ts
+++ b/studio/frontend/tests/sidebar-row-menu-and-pinned-folders.test.ts
@@ -65,25 +65,6 @@ test("the quick-action beside an open menu is revealed with it", () => {
);
});
-// A pinned project chat is two rows at once. Both matched on the chat id, so both mounted an
-// autofocused input: the second stole focus and the first's blur cancelled the rename.
-test("the rename pill belongs to the row its menu was opened from", () => {
- assert.match(
- APP_SIDEBAR,
- /renamingTarget\.item\.id === item\.id &&\n(?:\s*\/\/[^\n]*\n)*\s*renamingTarget\.rowScope === list\?\.scope;/,
- );
- assert.match(
- APP_SIDEBAR,
- /function openRenameChat\(item: SidebarItem, inline = true, rowScope\?: string\)/,
- );
- assert.match(
- APP_SIDEBAR,
- /onSelect=\{\(\) => openRenameChat\(item, true, list\?\.scope\)\}/,
- );
- // The chord has no row under the cursor, so it opens the dialog and names no scope.
- assert.match(APP_SIDEBAR, /openRenameChat\(item, false\)/);
-});
-
// The row toggles its chats, so the folder says which way it is.
test("a folder row's icon follows its disclosure", () => {
assert.match(APP_SIDEBAR, /icon=\{expanded \? Folder02Icon : Folder01Icon\}/);