refactor(webui): remove obsolete topic rename dialog mode

This commit is contained in:
chengyongru authored and chengyongru committed 2026-10-18 01:48:42 +08:00
1 parent d9537bcc94
commit c7ab7aa6da
14 files changed
+28 -49

No files matched your search

+5 -5
View File
@@ -165,9 +165,9 @@ const DeleteConfirm = lazy(async () => {
const module = await import("@/components/DeleteConfirm");
return { default: module.DeleteConfirm };
});
const RenameChatDialog = lazy(async () => {
const module = await import("@/components/RenameChatDialog");
return { default: module.RenameChatDialog };
const RenameDialog = lazy(async () => {
const module = await import("@/components/RenameDialog");
return { default: module.RenameDialog };
});
function SurfaceLoadingFallback({ label }: { label?: string }) {
@@ -3156,7 +3156,7 @@ function Shell({
) : null}
{pendingTabRename ? (
<Suspense fallback={null}>
<RenameChatDialog
<RenameDialog
open
title={pendingTabRename.label}
dialogTitle={t("workbench.renameGroupTitle")}
@@ -3169,7 +3169,7 @@ function Shell({
) : null}
{pendingProjectRename ? (
<Suspense fallback={null}>
<RenameChatDialog
<RenameDialog
open
title={pendingProjectRename.label}
dialogTitle={t("chat.renameProjectTitle")}
@@ -12,17 +12,17 @@ import {
} from "@/components/ui/dialog";
import { Input } from "@/components/ui/input";
interface RenameChatDialogProps {
interface RenameDialogProps {
open: boolean;
title: string;
dialogTitle?: string;
description?: string;
placeholder?: string;
dialogTitle: string;
description: string;
placeholder: string;
onCancel: () => void;
onConfirm: (title: string) => void;
}
export function RenameChatDialog({
export function RenameDialog({
open,
title,
dialogTitle,
@@ -30,7 +30,7 @@ export function RenameChatDialog({
placeholder,
onCancel,
onConfirm,
}: RenameChatDialogProps) {
}: RenameDialogProps) {
const { t } = useTranslation();
const [value, setValue] = useState(title);
@@ -54,15 +54,13 @@ export function RenameChatDialog({
}}
>
<DialogHeader className="text-left">
<DialogTitle>{dialogTitle ?? t("chat.renameTitle")}</DialogTitle>
<DialogDescription>
{description ?? t("chat.renameDescription")}
</DialogDescription>
<DialogTitle>{dialogTitle}</DialogTitle>
<DialogDescription>{description}</DialogDescription>
</DialogHeader>
<Input
value={value}
onChange={(event) => setValue(event.target.value)}
placeholder={placeholder ?? t("chat.renamePlaceholder")}
placeholder={placeholder}
autoFocus
maxLength={160}
/>
+12 -6
View File
@@ -1,5 +1,6 @@
import { useRef, useState, type ReactNode } from "react";
import { createPortal } from "react-dom";
import { useTranslation } from "react-i18next";
import { CapabilityMentionToken } from "@/components/CliAppMentionText";
import type { CapabilityMentionSegment } from "@/lib/composer-mention-text";
@@ -7,7 +8,7 @@ import { DeleteConfirm } from "@/components/DeleteConfirm";
import { FileActions } from "@/components/FileActions";
import { InlineTokenHighlight, INLINE_TOKEN_HIGHLIGHT_COLOR } from "@/components/InlineTokenHighlight";
import { MessageLinksMenu, useMessageWebLinks } from "@/components/MessageLinksMenu";
import { RenameChatDialog } from "@/components/RenameChatDialog";
import { RenameDialog } from "@/components/RenameDialog";
import { SessionHandleLabel } from "@/components/SessionHandleLabel";
import { SlashCommandText } from "@/components/SlashCommandText";
import { StartupShell } from "@/components/StartupShell";
@@ -43,12 +44,17 @@ const sessionMention: SessionMention = {
};
function RenamePreview() {
const { t } = useTranslation();
const [open, setOpen] = useState(false);
const [title, setTitle] = useState("组件设计");
return <div className="space-y-4">
<p className="text-sm">{title}</p>
<Button variant="outline" onClick={() => setOpen(true)}>重命名会话</Button>
<RenameChatDialog open={open} title={title} onCancel={() => setOpen(false)}
<Button variant="outline" onClick={() => setOpen(true)}>重命名分组</Button>
<RenameDialog open={open} title={title}
dialogTitle={t("workbench.renameGroupTitle")}
description={t("workbench.renameGroupDescription")}
placeholder={t("workbench.renameGroupPlaceholder")}
onCancel={() => setOpen(false)}
onConfirm={(next) => { setTitle(next); setOpen(false); }} />
<p role="status" className="text-xs text-muted-foreground">保存后更新上方标题。</p>
</div>;
@@ -244,9 +250,9 @@ function CompatibilityPreview() {
const components = "webui/src/components/";
export const shellExamples: ComponentExample[] = [
{ title: "RenameChatDialog · 重命名", files: ["RenameChatDialog"], Preview: RenamePreview,
description: "打开真实重命名对话框,编辑标题并保存。", options: "open 控制显示,title 设置初值,onConfirm 接收去除两端空白的标题。空标题无法保存。",
code: '<RenameChatDialog open={open} title={title} onCancel={close} onConfirm={rename} />' },
{ title: "RenameDialog · 分组与项目改名", files: ["RenameDialog"], Preview: RenamePreview,
description: "预览分组和项目使用的改名弹窗;话题在会话列表中行内改名。", options: "调用方提供 dialogTitle、description 和 placeholder。title 设置初值,onConfirm 接收去除两端空白的标题。空标题无法保存。",
code: '<RenameDialog open={open} title={title} dialogTitle="Rename group" description="Give this group a name." placeholder="Group name" onCancel={close} onConfirm={rename} />' },
{ title: "DeleteConfirm · 删除确认", files: ["DeleteConfirm"], Preview: DeletePreview,
description: "切换单个、批量和关联自动任务的删除确认。", options: "count 控制批量文案;automations 展示关联任务、计划与下次运行时间。确认按钮调用 onConfirm。",
code: '<DeleteConfirm open={open} title="组件设计" count={1} automations={jobs} onCancel={close} onConfirm={remove} />' },
-2
View File
@@ -1763,8 +1763,6 @@
"pin": "Pin",
"unpin": "Unpin",
"rename": "Rename",
"renameTitle": "Rename topic",
"renameDescription": "Change the topic's display name in WebUI.",
"renamePlaceholder": "Topic name",
"renameProjectTitle": "Rename project",
"renameProjectDescription": "Change only this project's name in the WebUI sidebar.",
-2
View File
@@ -1564,8 +1564,6 @@
"pin": "Fijar",
"unpin": "Desfijar",
"rename": "Renombrar",
"renameTitle": "Renombrar tema",
"renameDescription": "Cambia el nombre del tema en WebUI.",
"renamePlaceholder": "Nombre del tema",
"renameProjectTitle": "Renombrar proyecto",
"renameProjectDescription": "Cambia solo el nombre del proyecto en la barra lateral WebUI.",
-2
View File
@@ -1563,8 +1563,6 @@
"pin": "Épingler",
"unpin": "Désépingler",
"rename": "Renommer",
"renameTitle": "Renommer le sujet",
"renameDescription": "Changez le nom du sujet affiché dans WebUI.",
"renamePlaceholder": "Nom du sujet",
"renameProjectTitle": "Renommer le projet",
"renameProjectDescription": "Changez seulement le nom du projet dans la barre latérale WebUI.",
-2
View File
@@ -1563,8 +1563,6 @@
"pin": "Sematkan",
"unpin": "Lepas sematan",
"rename": "Ganti nama",
"renameTitle": "Ubah nama topik",
"renameDescription": "Ubah nama tampilan topik di WebUI.",
"renamePlaceholder": "Nama topik",
"renameProjectTitle": "Ubah nama proyek",
"renameProjectDescription": "Ubah hanya nama proyek di sidebar WebUI.",
-2
View File
@@ -1563,8 +1563,6 @@
"pin": "ピン留め",
"unpin": "ピン留めを解除",
"rename": "名前を変更",
"renameTitle": "トピック名を変更",
"renameDescription": "WebUI に表示するトピック名を変更します。",
"renamePlaceholder": "トピック名",
"renameProjectTitle": "プロジェクト名を変更",
"renameProjectDescription": "WebUI のサイドバーに表示するプロジェクト名だけを変更します。",
-2
View File
@@ -1563,8 +1563,6 @@
"pin": "고정",
"unpin": "고정 해제",
"rename": "이름 변경",
"renameTitle": "주제 이름 변경",
"renameDescription": "WebUI에 표시되는 주제 이름을 변경하세요.",
"renamePlaceholder": "주제 이름",
"renameProjectTitle": "프로젝트 이름 변경",
"renameProjectDescription": "WebUI 사이드바의 프로젝트 이름만 변경하세요.",
-2
View File
@@ -1577,8 +1577,6 @@
"pin": "Fixar",
"unpin": "Desafixar",
"rename": "Renomear",
"renameTitle": "Renomear tópico",
"renameDescription": "Altere o nome do tópico exibido no WebUI.",
"renamePlaceholder": "Nome do tópico",
"renameProjectTitle": "Renomear projeto",
"renameProjectDescription": "Altere apenas o nome do projeto na barra lateral WebUI.",
-2
View File
@@ -1563,8 +1563,6 @@
"pin": "Ghim",
"unpin": "Bỏ ghim",
"rename": "Đổi tên",
"renameTitle": "Đổi tên chủ đề",
"renameDescription": "Đổi tên chủ đề hiển thị trong WebUI.",
"renamePlaceholder": "Tên chủ đề",
"renameProjectTitle": "Đổi tên dự án",
"renameProjectDescription": "Chỉ đổi tên dự án trong thanh bên WebUI.",
-2
View File
@@ -1763,8 +1763,6 @@
"pin": "置顶",
"unpin": "取消置顶",
"rename": "重命名",
"renameTitle": "话题改名",
"renameDescription": "修改 WebUI 中显示的话题名称",
"renamePlaceholder": "话题名称",
"renameProjectTitle": "项目改名",
"renameProjectDescription": "仅修改 WebUI 侧栏中的项目名称",
-2
View File
@@ -1563,8 +1563,6 @@
"pin": "置頂",
"unpin": "取消置頂",
"rename": "重新命名",
"renameTitle": "話題改名",
"renameDescription": "修改 WebUI 中顯示的話題名稱",
"renamePlaceholder": "話題名稱",
"renameProjectTitle": "專案改名",
"renameProjectDescription": "僅修改 WebUI 側欄中的專案名稱",
+2 -7
View File
@@ -1,10 +1,8 @@
import { useState } from "react";
import { act, render, screen, waitFor } from "@testing-library/react";
import userEvent from "@testing-library/user-event";
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
import { ChatList } from "@/components/ChatList";
import { RenameChatDialog } from "@/components/RenameChatDialog";
import type { ChatSummary } from "@/lib/types";
import { mockBrowserFocus } from "./browser-focus";
@@ -15,7 +13,6 @@ const topic: ChatSummary = {
};
function SidebarFocusCase() {
const [rename, setRename] = useState<string | null>(null);
return <>
<ChatList
sessions={[topic, {
@@ -44,12 +41,10 @@ function SidebarFocusCase() {
onToggleArchive={vi.fn()}
onAttachPane={vi.fn()}
onRequestRename={vi.fn().mockResolvedValue(undefined)}
onRequestRenameTab={(_key, title) => setRename(title)}
onRequestRenameProject={(_key, title) => setRename(title)}
onRequestRenameTab={vi.fn()}
onRequestRenameProject={vi.fn()}
/>
<button>Outside destination</button>
<RenameChatDialog open={rename !== null} title={rename ?? ""}
onCancel={() => setRename(null)} onConfirm={() => setRename(null)} />
</>;
}