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