mirror of
https://github.com/HKUDS/nanobot.git
synced 2026-08-07 21:08:34 +03:00
fix(webui): simplify temporary chat closing
This commit is contained in:
@@ -252,7 +252,6 @@ export const ChatList = memo(function ChatList({
|
||||
running={running}
|
||||
onSelect={onSelect}
|
||||
onClose={onCloseTemporaryChat}
|
||||
actionMenuPortalContainer={actionMenuPortalContainer}
|
||||
/>
|
||||
) : null}
|
||||
{limitedGroups.map((group, index) => {
|
||||
@@ -522,7 +521,6 @@ function TemporaryChatSection({
|
||||
running,
|
||||
onSelect,
|
||||
onClose,
|
||||
actionMenuPortalContainer,
|
||||
}: {
|
||||
sessions: ChatSummary[];
|
||||
activeKey: string | null;
|
||||
@@ -530,7 +528,6 @@ function TemporaryChatSection({
|
||||
running: ReadonlySet<string>;
|
||||
onSelect: (key: string) => void;
|
||||
onClose?: (key: string) => void;
|
||||
actionMenuPortalContainer?: HTMLElement | null;
|
||||
}) {
|
||||
const { t } = useTranslation();
|
||||
|
||||
@@ -571,35 +568,14 @@ function TemporaryChatSection({
|
||||
</button>
|
||||
<SessionActivityIndicator state={running.has(session.chatId) ? "running" : null} />
|
||||
{onClose ? (
|
||||
<DropdownMenu modal={false}>
|
||||
<DropdownMenuTrigger
|
||||
className={cn(
|
||||
"inline-flex h-6 w-6 shrink-0 items-center justify-center rounded-md text-muted-foreground/75 opacity-40 transition-opacity",
|
||||
"hover:bg-sidebar-accent hover:text-sidebar-foreground group-hover:opacity-100",
|
||||
"focus-visible:opacity-100",
|
||||
active && "opacity-100",
|
||||
)}
|
||||
aria-label={t("chat.actions", { title })}
|
||||
>
|
||||
<MoreHorizontal className="h-3.5 w-3.5" />
|
||||
</DropdownMenuTrigger>
|
||||
<DropdownMenuContent
|
||||
align="end"
|
||||
className={ACTION_MENU_CONTENT_CLASS}
|
||||
portalContainer={actionMenuPortalContainer}
|
||||
onCloseAutoFocus={(event) => event.preventDefault()}
|
||||
>
|
||||
<DropdownMenuItem
|
||||
aria-label={t("temporaryChat.closeAction")}
|
||||
className="whitespace-nowrap"
|
||||
tone="destructive"
|
||||
onSelect={() => onClose(session.key)}
|
||||
>
|
||||
<X className="h-4 w-4 shrink-0" />
|
||||
{t("common.close")}
|
||||
</DropdownMenuItem>
|
||||
</DropdownMenuContent>
|
||||
</DropdownMenu>
|
||||
<button
|
||||
type="button"
|
||||
aria-label={t("temporaryChat.closeAction", { title })}
|
||||
onClick={() => onClose(session.key)}
|
||||
className="inline-flex h-6 w-6 shrink-0 items-center justify-center rounded-md text-muted-foreground/60 transition-colors hover:bg-destructive/10 hover:text-destructive focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/60"
|
||||
>
|
||||
<X className="h-3.5 w-3.5" aria-hidden />
|
||||
</button>
|
||||
) : null}
|
||||
</div>
|
||||
</li>
|
||||
|
||||
@@ -54,7 +54,7 @@
|
||||
"description": "Not saved to history or memory. Reloading, closing, or losing the connection ends these chats. Requests still go to your model provider, and tool actions may leave changes.",
|
||||
"clear": "Clear temporary chat",
|
||||
"sectionTitle": "Temporary chats",
|
||||
"closeAction": "Close temporary chat"
|
||||
"closeAction": "Close temporary chat: {{title}}"
|
||||
},
|
||||
"sidebar": {
|
||||
"navigation": "Sidebar navigation",
|
||||
|
||||
@@ -54,7 +54,7 @@
|
||||
"description": "No se guarda en el historial ni en la memoria. Recargar, cerrar o perder la conexión finaliza estos chats. Las solicitudes siguen llegando al proveedor del modelo y las herramientas pueden dejar cambios.",
|
||||
"clear": "Borrar chat temporal",
|
||||
"sectionTitle": "Chats temporales",
|
||||
"closeAction": "Cerrar chat temporal"
|
||||
"closeAction": "Cerrar chat temporal: {{title}}"
|
||||
},
|
||||
"sidebar": {
|
||||
"navigation": "Navegación de la barra lateral",
|
||||
|
||||
@@ -54,7 +54,7 @@
|
||||
"description": "Elle n’est enregistrée ni dans l’historique ni dans la mémoire. Recharger, fermer ou perdre la connexion met fin à ces discussions. Les requêtes sont tout de même envoyées au fournisseur du modèle et les outils peuvent laisser des modifications.",
|
||||
"clear": "Effacer la discussion temporaire",
|
||||
"sectionTitle": "Discussions temporaires",
|
||||
"closeAction": "Fermer la discussion temporaire"
|
||||
"closeAction": "Fermer la discussion temporaire : {{title}}"
|
||||
},
|
||||
"sidebar": {
|
||||
"navigation": "Navigation de la barre latérale",
|
||||
|
||||
@@ -54,7 +54,7 @@
|
||||
"description": "Tidak disimpan ke riwayat atau memori. Memuat ulang, menutup, atau kehilangan koneksi akan mengakhiri obrolan ini. Permintaan tetap dikirim ke penyedia model dan tindakan alat dapat meninggalkan perubahan.",
|
||||
"clear": "Hapus obrolan sementara",
|
||||
"sectionTitle": "Obrolan sementara",
|
||||
"closeAction": "Tutup obrolan sementara"
|
||||
"closeAction": "Tutup obrolan sementara: {{title}}"
|
||||
},
|
||||
"sidebar": {
|
||||
"navigation": "Navigasi bilah samping",
|
||||
|
||||
@@ -54,7 +54,7 @@
|
||||
"description": "履歴やメモリには保存されません。再読み込み、ページを閉じる操作、接続切断で一時チャットは終了します。リクエストは引き続きモデルプロバイダーに送信され、ツール操作による変更は残る場合があります。",
|
||||
"clear": "一時チャットを消去",
|
||||
"sectionTitle": "一時チャット",
|
||||
"closeAction": "一時チャットを閉じる"
|
||||
"closeAction": "一時チャット「{{title}}」を閉じる"
|
||||
},
|
||||
"sidebar": {
|
||||
"navigation": "サイドバーのナビゲーション",
|
||||
|
||||
@@ -54,7 +54,7 @@
|
||||
"description": "기록이나 메모리에 저장되지 않습니다. 새로고침, 페이지 닫기 또는 연결 끊김 시 임시 채팅이 종료됩니다. 요청은 계속 모델 제공업체로 전송되며 도구 작업의 변경 사항은 남을 수 있습니다.",
|
||||
"clear": "임시 채팅 지우기",
|
||||
"sectionTitle": "임시 채팅",
|
||||
"closeAction": "임시 채팅 닫기"
|
||||
"closeAction": "임시 채팅 닫기: {{title}}"
|
||||
},
|
||||
"sidebar": {
|
||||
"navigation": "사이드바 탐색",
|
||||
|
||||
@@ -54,7 +54,7 @@
|
||||
"description": "Não é salvo no histórico nem na memória. Recarregar, fechar ou perder a conexão encerra estes chats. As solicitações ainda são enviadas ao provedor do modelo, e as ações das ferramentas podem deixar alterações.",
|
||||
"clear": "Limpar chat temporário",
|
||||
"sectionTitle": "Chats temporários",
|
||||
"closeAction": "Fechar chat temporário"
|
||||
"closeAction": "Fechar chat temporário: {{title}}"
|
||||
},
|
||||
"sidebar": {
|
||||
"navigation": "Navegação da barra lateral",
|
||||
|
||||
@@ -54,7 +54,7 @@
|
||||
"description": "Không được lưu vào lịch sử hoặc bộ nhớ. Tải lại, đóng trang hoặc mất kết nối sẽ kết thúc các cuộc trò chuyện này. Yêu cầu vẫn được gửi đến nhà cung cấp mô hình và thao tác công cụ có thể để lại thay đổi.",
|
||||
"clear": "Xóa trò chuyện tạm thời",
|
||||
"sectionTitle": "Trò chuyện tạm thời",
|
||||
"closeAction": "Đóng trò chuyện tạm thời"
|
||||
"closeAction": "Đóng trò chuyện tạm thời: {{title}}"
|
||||
},
|
||||
"sidebar": {
|
||||
"navigation": "Điều hướng thanh bên",
|
||||
|
||||
@@ -54,7 +54,7 @@
|
||||
"description": "不会保存到历史记录或记忆。刷新、关闭页面或连接中断后,临时聊天会结束。请求仍会发送给模型提供商,工具操作也可能留下更改。",
|
||||
"clear": "清空临时聊天",
|
||||
"sectionTitle": "临时聊天",
|
||||
"closeAction": "关闭临时聊天"
|
||||
"closeAction": "关闭临时聊天:{{title}}"
|
||||
},
|
||||
"sidebar": {
|
||||
"navigation": "侧边栏导航",
|
||||
|
||||
@@ -54,7 +54,7 @@
|
||||
"description": "不會儲存至歷史記錄或記憶。重新載入、關閉頁面或連線中斷後,臨時聊天會結束。請求仍會傳送給模型供應商,工具操作也可能留下變更。",
|
||||
"clear": "清空臨時聊天",
|
||||
"sectionTitle": "臨時聊天",
|
||||
"closeAction": "關閉臨時聊天"
|
||||
"closeAction": "關閉臨時聊天:{{title}}"
|
||||
},
|
||||
"sidebar": {
|
||||
"navigation": "側邊欄導覽",
|
||||
|
||||
@@ -469,10 +469,9 @@ describe("App layout", () => {
|
||||
expect(screen.getByText("Temporary chat")).toBeInTheDocument();
|
||||
expect(screen.queryByRole("button", { name: "Temporary chat" })).not.toBeInTheDocument();
|
||||
|
||||
fireEvent.pointerDown(within(sidebar).getByRole("button", {
|
||||
name: "Topic actions for first private message",
|
||||
}), { button: 0 });
|
||||
fireEvent.click(await screen.findByRole("menuitem", { name: "Close temporary chat" }));
|
||||
fireEvent.click(within(sidebar).getByRole("button", {
|
||||
name: "Close temporary chat: first private message",
|
||||
}));
|
||||
await waitFor(() => expect(window.location.hash).toBe(secondHash));
|
||||
expect(within(sidebar).queryByRole("button", {
|
||||
name: "first private message",
|
||||
|
||||
@@ -179,14 +179,9 @@ describe("ChatList", () => {
|
||||
fireEvent.click(within(section).getByRole("button", { name: "Private planning" }));
|
||||
expect(onSelect).toHaveBeenCalledWith("temporary:temporary-one");
|
||||
|
||||
fireEvent.pointerDown(
|
||||
within(section).getByRole("button", { name: "Topic actions for Private planning" }),
|
||||
{ button: 0 },
|
||||
);
|
||||
const closeItem = await screen.findByRole("menuitem", { name: "Close temporary chat" });
|
||||
expect(closeItem).toHaveTextContent("Close");
|
||||
expect(closeItem).toHaveClass("whitespace-nowrap");
|
||||
fireEvent.click(closeItem);
|
||||
fireEvent.click(within(section).getByRole("button", {
|
||||
name: "Close temporary chat: Private planning",
|
||||
}));
|
||||
expect(onClose).toHaveBeenCalledWith("temporary:temporary-one");
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user