fix(app): close an inline rename that submits the row's current title

Saving the title another client had just set left the row's title where it was, so the
saved phase waited forever with the field read-only and the row's press and menu handlers
off. A submit matching the current title now closes without a request.
This commit is contained in:
Mohamed Boudra
2026-11-10 10:12:14 +01:00
parent d274dc5431
commit 8901862465
2 changed files with 32 additions and 1 deletions
@@ -249,6 +249,36 @@ test.describe("Sidebar workspace rename", () => {
}
});
test("submitting the title another client just set closes the field without saving", async ({
page,
}) => {
const workspace = await seedWorkspace({ repoPrefix: "sidebar-rename-external-same-" });
try {
const gate = await installDaemonWebSocketGate(page);
await page.setViewportSize({ width: 1280, height: 800 });
await gotoAppShell(page);
const row = page.getByTestId(workspaceRowTestId(workspace.workspaceId));
const input = page.getByTestId(workspaceRenameInputTestId(workspace.workspaceId));
await chooseRenameFromKebab(page, workspace.workspaceId);
await expect(input).toBeFocused();
await renameFromAnotherClient(page, gate, workspace, "External title");
await input.fill("External title");
await page.keyboard.press("Enter");
await expect(input).toHaveCount(0);
await expect(row).toContainText("External title");
expect(gate.getClientRequestCount("workspace.title.set.request")).toBe(0);
// The row is a row again: its menu opens and renames.
await chooseRenameFromKebab(page, workspace.workspaceId);
await expect(input).toBeFocused();
} finally {
await workspace.cleanup();
}
});
test("below the lg breakpoint renaming opens the modal", async ({ page }) => {
const workspace = await seedWorkspace({ repoPrefix: "sidebar-rename-modal-" });
@@ -71,7 +71,8 @@ export function useSidebarWorkspaceRename(
(text: string) => {
if (session.kind !== "inline") return;
const title = text.trim();
if (title.length === 0 || title === session.initialValue) {
// Saving the title the row already has would never move it, so `saved` would never end.
if (title.length === 0 || title === session.initialValue || title === currentTitle) {
setSession(CLOSED);
return;
}