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.
Python agentaichatgptdeepseekfine-tuninggemmaimage-generationllamallmllmsopenaipythonqwenreinforcement-learningself-hostedstable-diffusiontext-to-speechttsuiunsloth
Studio: bulk chat management multi-select move/pin/archive/export/delete (#8745)
Nilay127439556728
diff --git a/studio/frontend/src/features/chat/hooks/use-chat-sidebar-items.ts b/studio/frontend/src/features/chat/hooks/use-chat-sidebar-items.tsindex 398b3b771fc..f59ff9be720 100644--- a/studio/frontend/src/features/chat/hooks/use-chat-sidebar-items.ts+++ b/studio/frontend/src/features/chat/hooks/use-chat-sidebar-items.ts@@ -200,20 +200,30 @@ export async function renameChatItem();}-export async function archiveChatItem(- item: SidebarItem,+async function collectItemThreadIds(+ items: SidebarItem[],+ args: { includeArchived?: boolean } = {},+): Promise<string[]> {+ const ids = new Set<string>();+ for (const item of items) {+ if (item.type === "single") {+ ids.add(item.id);+ continue;+ }+ const pair = await listStoredChatThreads({ pairId: item.id, ...args });+ for (const thread of pair) ids.add(thread.id);+ }+ return Array.from(ids);+}++export async function archiveChatItems(+ items: SidebarItem[],activeId: string | undefined,onSelect: (view: { mode: "single"; newThreadNonce: string }) => void,): Promise<void> {- const threadIds: string[] =- item.type === "single"- ? [item.id]- : (- await listStoredChatThreads({- pairId: item.id,- includeArchived: true,- })- ).map((t) => t.id);+ const threadIds = await collectItemThreadIds(items, {+ includeArchived: true,+ });requestPromptQueueStop(threadIds);@@ -225,7 +235,7 @@ export async function archiveChatItem(threadIds.map((id) => updateStoredChatThread(id, { archived: true })),);- if (activeId === item.id) {+ if (activeId !== undefined && items.some((item) => item.id === activeId)) {useChatRuntimeStore.getState().setActiveThreadId(null);onSelect({ mode: "single", newThreadNonce: crypto.randomUUID() });}@@ -233,6 +243,14 @@ export async function archiveChatItem(notifyChatHistoryUpdated();}+export async function archiveChatItem(+ item: SidebarItem,+ activeId: string | undefined,+ onSelect: (view: { mode: "single"; newThreadNonce: string }) => void,+): Promise<void> {+ return archiveChatItems([item], activeId, onSelect);+}+export async function archiveAllChatItems(activeId?: string,onSelect?: (view: { mode: "single"; newThreadNonce: string }) => void,@@ -286,16 +304,13 @@ export async function unarchiveChatItem(item: SidebarItem): Promise<void> {notifyChatHistoryUpdated();}-export async function deleteChatItem(- item: SidebarItem,+export async function deleteChatItems(+ items: SidebarItem[],activeId: string | undefined,onSelect: (view: { mode: "single"; newThreadNonce: string }) => void,args: { deleteFiles?: boolean } = {},) {- const threadIds: string[] =- item.type === "single"- ? [item.id]- : (await listStoredChatThreads({ pairId: item.id })).map((t) => t.id);+ const threadIds = await collectItemThreadIds(items);// Stop queued prompts and in-flight streams before deleting.requestPromptQueueStop(threadIds);@@ -315,7 +330,7 @@ export async function deleteChatItem(markChatThreadsDeleted(threadIds);notifyChatHistoryUpdated();- if (activeId === item.id) {+ if (activeId !== undefined && items.some((item) => item.id === activeId)) {useChatRuntimeStore.getState().setActiveThreadId(null);onSelect({ mode: "single", newThreadNonce: crypto.randomUUID() });}@@ -332,3 +347,12 @@ export async function deleteChatItem(throw error;}}++export async function deleteChatItem(+ item: SidebarItem,+ activeId: string | undefined,+ onSelect: (view: { mode: "single"; newThreadNonce: string }) => void,+ args: { deleteFiles?: boolean } = {},+) {+ return deleteChatItems([item], activeId, onSelect, args);+}diff --git a/studio/frontend/src/features/chat/index.ts b/studio/frontend/src/features/chat/index.tsindex 24453e265ce..3fd30b60f34 100644--- a/studio/frontend/src/features/chat/index.ts+++ b/studio/frontend/src/features/chat/index.ts@@ -244,7 +244,10 @@ export {EXPORT_FORMATS_LIST,buildFineTuneJsonl,bulkExportConversationsByScope,+ exportBulkConversationsMerged,+ exportBulkConversationsSeparate,exportFineTuneJsonl,+ type ConvExportFormat,type FineTuneFormat,} from "./prompt-storage/prompt-storage-dialog";export {@@ -259,7 +262,9 @@ export {export {archiveAllChatItems,archiveChatItem,+ archiveChatItems,deleteChatItem,+ deleteChatItems,renameChatItem,unarchiveChatItem,useChatSidebarItems,diff --git a/studio/frontend/src/features/settings/components/manage-chats-view.tsx b/studio/frontend/src/features/settings/components/manage-chats-view.tsxnew file mode 100644index 00000000000..ab51c943fc0--- /dev/null+++ b/studio/frontend/src/features/settings/components/manage-chats-view.tsx@@ -0,0 +1,448 @@+// SPDX-License-Identifier: AGPL-3.0-only+// Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0++import {+ AlertDialog,+ AlertDialogAction,+ AlertDialogCancel,+ AlertDialogContent,+ AlertDialogDescription,+ AlertDialogFooter,+ AlertDialogHeader,+ AlertDialogTitle,+} from "@/components/ui/alert-dialog";+import { Button } from "@/components/ui/button";+import { Checkbox } from "@/components/ui/checkbox";+import {+ DropdownMenu,+ DropdownMenuContent,+ DropdownMenuItem,+ DropdownMenuSeparator,+ DropdownMenuTrigger,+} from "@/components/ui/dropdown-menu";+import {+ type ConvExportFormat,+ EXPORT_FORMATS_LIST,+ type SidebarItem,+ archiveChatItems,+ deleteChatItems,+ exportBulkConversationsMerged,+ exportBulkConversationsSeparate,+ moveChatItemToProject,+ rangeBetween,+ useChatPreferencesStore,+ useChatProjects,+ useChatRuntimeStore,+ useChatSidebarItems,+ usePinnedChatsStore,+} from "@/features/chat";+import { isDownloadCancelled } from "@/lib/native-files";+import { toast } from "@/lib/toast";+import {+ Archive02Icon,+ Delete02Icon,+ Download01Icon,+ Folder01Icon,+ PinIcon,+} from "@hugeicons/core-free-icons";+import { HugeiconsIcon } from "@hugeicons/react";+import { useNavigate, useRouterState } from "@tanstack/react-router";+import { useRef, useState } from "react";+import { useSettingsDialogStore } from "../stores/settings-dialog-store";++const MANAGE_PAGE_SIZE = 20;++function formatCreatedAt(ms: number): string {+ return new Date(ms).toLocaleDateString(undefined, {+ year: "numeric",+ month: "long",+ day: "numeric",+ });+}++function chatCount(n: number): string {+ return n === 1 ? "1 chat" : `${n} chats`;+}++export function ManageChatsView() {+ const { items } = useChatSidebarItems({ requireMessages: false });+ const { projects } = useChatProjects();+ const navigate = useNavigate();+ const closeSettings = useSettingsDialogStore((s) => s.closeDialog);+ const storeThreadId = useChatRuntimeStore((s) => s.activeThreadId);+ // Open chat id from the route: compare panes only live in the search params.+ const openChatId = useRouterState({+ select: (s) => {+ if (!s.location.pathname.startsWith("/chat")) return undefined;+ const search = s.location.search as Record<string, string | undefined>;+ return search.thread ?? search.compare ?? storeThreadId ?? undefined;+ },+ });+ const pinnedIds = usePinnedChatsStore((s) => s.pinnedIds);+ const setPinned = usePinnedChatsStore((s) => s.setPinned);+ const alwaysDeleteChatFiles = useChatPreferencesStore(+ (s) => s.alwaysDeleteChatFiles,+ );++ const [selectedIds, setSelectedIds] = useState<Set<string>>(new Set());+ const [visibleCount, setVisibleCount] = useState(MANAGE_PAGE_SIZE);+ const [confirmingDelete, setConfirmingDelete] = useState(false);+ const [busy, setBusy] = useState(false);+ const lastToggledId = useRef<string | null>(null);++ const visible = items.slice(0, visibleCount);+ const selectedItems = items.filter((item) => selectedIds.has(item.id));+ const selectedCount = selectedItems.length;+ const allVisibleSelected =+ visible.length > 0 && visible.every((item) => selectedIds.has(item.id));+ const allSelectedPinned =+ selectedCount > 0 &&+ selectedItems.every((item) => pinnedIds.includes(item.id));+ const projectNames = new Map(projects.map((p) => [p.id, p.name]));++ function toggleRow(index: number, shiftKey: boolean) {+ const rowId = visible[index].id;+ const target = !selectedIds.has(rowId);+ const anchorId = lastToggledId.current;+ // Anchor on the chat id, not the row index: the list re-sorts by updatedAt,+ // so an index anchor would range over rows the user never picked.+ const ids =+ shiftKey && anchorId !== null+ ? rangeBetween(+ visible.map((item) => item.id),+ anchorId,+ rowId,+ )+ : [rowId];+ setSelectedIds((prev) => {+ const next = new Set(prev);+ for (const id of ids) {+ if (target) next.add(id);+ else next.delete(id);+ }+ return next;+ });+ lastToggledId.current = rowId;+ }++ function toggleAllVisible() {+ setSelectedIds(+ allVisibleSelected ? new Set() : new Set(visible.map((item) => item.id)),+ );+ lastToggledId.current = null;+ }++ function openChat(item: SidebarItem) {+ // Carry the row's project, as the sidebar does: without it ChatPage briefly+ // runs the chat under the project it was already on.+ const project = item.projectId ? { project: item.projectId } : {};+ navigate({+ to: "/chat",+ search:+ item.type === "single"+ ? { thread: item.id, ...project }+ : { compare: item.id, ...project },+ });+ closeSettings();+ }++ function resetView(view: { newThreadNonce: string }) {+ navigate({ to: "/chat", search: { new: view.newThreadNonce } });+ }++ async function run(+ action: () => Promise<void>,+ success: string,+ failure: string,+ ) {+ setBusy(true);+ try {+ await action();+ setSelectedIds(new Set());+ toast.success(success);+ } catch (err) {+ toast.error(failure, {+ description: err instanceof Error ? err.message : undefined,+ });+ } finally {+ setBusy(false);+ }+ }++ const handleArchive = () =>+ run(+ () => archiveChatItems(selectedItems, openChatId, resetView),+ `Archived ${chatCount(selectedCount)}`,+ "Failed to archive chats",+ );++ const handleDelete = () =>+ run(+ () =>+ // Honour the same preference as the sidebar delete, or the selected+ // chats leave orphan sandbox folders behind.+ deleteChatItems(selectedItems, openChatId, resetView, {+ deleteFiles: alwaysDeleteChatFiles,+ }),+ `Deleted ${chatCount(selectedCount)}`,+ "Failed to delete chats",+ );++ const handleMove = (projectId: string | null) =>+ run(+ async () => {+ await Promise.all(+ selectedItems.map((item) => moveChatItemToProject(item, projectId)),+ );+ },+ projectId+ ? `Moved ${chatCount(selectedCount)} to ${projectNames.get(projectId) ?? "project"}`+ : `Moved ${chatCount(selectedCount)} to Recents`,+ "Failed to move chats",+ );++ function handleTogglePin() {+ const ids = selectedItems.map((item) => item.id);+ setPinned(ids, !allSelectedPinned);+ toast.success(+ `${allSelectedPinned ? "Unpinned" : "Pinned"} ${chatCount(ids.length)}`,+ );+ setSelectedIds(new Set());+ }++ async function handleExport(format: ConvExportFormat, merged: boolean) {+ const threadIds = selectedItems.flatMap(+ (item) => item.threadIds ?? [item.id],+ );+ const basename = `selected-chats-${new Date().toISOString().slice(0, 10)}`;+ try {+ if (merged) {+ await exportBulkConversationsMerged(threadIds, format, basename);+ } else {+ await exportBulkConversationsSeparate(threadIds, format, basename);+ }+ } catch (error) {+ if (!isDownloadCancelled(error)) toast.error("Export failed.");+ }+ }++ if (items.length === 0) {+ return (+ <p className="py-8 text-center text-sm text-muted-foreground">+ No chats.+ </p>+ );+ }++ const actionsDisabled = busy || selectedCount === 0;++ return (+ <div className="flex flex-col gap-4">+ <div className="flex flex-wrap items-center gap-2">+ <div className="flex flex-1 items-center gap-3 px-1">+ <Checkbox+ checked={+ allVisibleSelected+ ? true+ : selectedCount > 0+ ? "indeterminate"+ : false+ }+ onCheckedChange={toggleAllVisible}+ aria-label="Select all visible chats"+ title="Select all visible"+ />+ <span className="text-xs text-muted-foreground">+ {selectedCount > 0+ ? `${chatCount(selectedCount)} selected`+ : chatCount(items.length)}+ </span>+ </div>+ <DropdownMenu>+ <DropdownMenuTrigger asChild={true}>+ <Button variant="outline" size="sm" disabled={actionsDisabled}>+ <HugeiconsIcon+ icon={Folder01Icon}+ strokeWidth={1.75}+ className="size-3.5 mr-1.5"+ />+ Move+ </Button>+ </DropdownMenuTrigger>+ <DropdownMenuContent align="end" className="w-52">+ <DropdownMenuItem+ disabled={selectedItems.every((item) => !item.projectId)}+ onSelect={() => void handleMove(null)}+ >+ Recents+ </DropdownMenuItem>+ {projects.map((project) => (+ <DropdownMenuItem+ key={project.id}+ onSelect={() => void handleMove(project.id)}+ >+ <HugeiconsIcon+ icon={Folder01Icon}+ strokeWidth={1.75}+ className="size-4"+ />+ <span className="truncate">{project.name}</span>+ </DropdownMenuItem>+ ))}+ </DropdownMenuContent>+ </DropdownMenu>+ <Button+ variant="outline"+ size="sm"+ disabled={actionsDisabled}+ onClick={handleTogglePin}+ >+ <HugeiconsIcon+ icon={PinIcon}+ strokeWidth={1.75}+ className="size-3.5 mr-1.5"+ />+ {allSelectedPinned ? "Unpin" : "Pin"}+ </Button>+ <Button+ variant="outline"+ size="sm"+ disabled={actionsDisabled}+ onClick={() => void handleArchive()}+ >+ <HugeiconsIcon+ icon={Archive02Icon}+ strokeWidth={1.75}+ className="size-3.5 mr-1.5"+ />+ Archive+ </Button>+ <DropdownMenu>+ <DropdownMenuTrigger asChild={true}>+ <Button variant="outline" size="sm" disabled={actionsDisabled}>+ <HugeiconsIcon+ icon={Download01Icon}+ strokeWidth={1.75}+ className="size-3.5 mr-1.5"+ />+ Export+ </Button>+ </DropdownMenuTrigger>+ <DropdownMenuContent align="end" className="w-56">+ {EXPORT_FORMATS_LIST.map(({ fmt, label }) => (+ <DropdownMenuItem+ key={`m-${fmt}`}+ onSelect={() => void handleExport(fmt, true)}+ >+ {label} (combined)+ </DropdownMenuItem>+ ))}+ <DropdownMenuSeparator />+ {EXPORT_FORMATS_LIST.map(({ fmt, label }) => (+ <DropdownMenuItem+ key={`s-${fmt}`}+ onSelect={() => void handleExport(fmt, false)}+ >+ {label} (per chat)+ </DropdownMenuItem>+ ))}+ </DropdownMenuContent>+ </DropdownMenu>+ <Button+ variant="outline"+ size="sm"+ disabled={actionsDisabled}+ onClick={() => setConfirmingDelete(true)}+ className="text-destructive hover:text-destructive hover:border-destructive/60"+ >+ <HugeiconsIcon+ icon={Delete02Icon}+ strokeWidth={1.75}+ className="size-3.5 mr-1.5"+ />+ Delete+ </Button>+ </div>++ <div>+ <div className="flex items-center gap-4 border-b border-border/60 px-1 pb-2 text-xs font-semibold text-foreground">+ <span className="w-4 shrink-0" />+ <span className="flex-1">Name</span>+ <span className="w-28 shrink-0">Project</span>+ <span className="w-32 shrink-0">Date created</span>+ </div>+ {visible.map((item, index) => (+ <div+ key={item.id}+ className="group flex items-center gap-4 border-b border-border/40 px-1 py-2.5 text-sm last:border-0 hover:bg-muted/40"+ >+ <Checkbox+ checked={selectedIds.has(item.id)}+ onClick={(e) => toggleRow(index, e.shiftKey)}+ aria-label={`Select "${item.title}"`}+ />+ <button+ type="button"+ onClick={() => openChat(item)}+ className="min-w-0 flex-1 truncate text-left hover:underline"+ title={item.title}+ >+ {item.title}+ </button>+ <span className="w-28 shrink-0 truncate text-muted-foreground">+ {item.projectId ? (projectNames.get(item.projectId) ?? "") : ""}+ </span>+ <span className="w-32 shrink-0 text-muted-foreground tabular-nums">+ {formatCreatedAt(item.createdAt)}+ </span>+ </div>+ ))}+ {items.length > visibleCount ? (+ <div className="flex justify-center pt-3">+ <Button+ variant="outline"+ size="sm"+ onClick={() => setVisibleCount(visibleCount + MANAGE_PAGE_SIZE)}+ >+ Show more ({items.length - visibleCount})+ </Button>+ </div>+ ) : null}+ </div>++ <AlertDialog+ open={confirmingDelete}+ onOpenChange={(o) => {+ if (!o) setConfirmingDelete(false);+ }}+ >+ <AlertDialogContent>+ <AlertDialogHeader>+ <AlertDialogTitle>+ Delete {chatCount(selectedCount)}+ </AlertDialogTitle>+ <AlertDialogDescription>+ Delete the{" "}+ {selectedCount === 1+ ? "selected chat"+ : `${selectedCount} selected chats`}+ ? This cannot be undone.+ </AlertDialogDescription>+ </AlertDialogHeader>+ <AlertDialogFooter>+ <AlertDialogCancel>Cancel</AlertDialogCancel>+ <AlertDialogAction+ variant="destructive"+ onClick={() => {+ setConfirmingDelete(false);+ void handleDelete();+ }}+ >+ Delete+ </AlertDialogAction>+ </AlertDialogFooter>+ </AlertDialogContent>+ </AlertDialog>+ </div>+ );+}diff --git a/studio/frontend/src/features/settings/tabs/data-tab.tsx b/studio/frontend/src/features/settings/tabs/data-tab.tsxindex 6a417d1e568..83a2bc62a83 100644--- a/studio/frontend/src/features/settings/tabs/data-tab.tsx+++ b/studio/frontend/src/features/settings/tabs/data-tab.tsx@@ -70,6 +70,7 @@ import { useNavigate, useRouterState } from "@tanstack/react-router";import { useEffect, useRef, useState } from "react";import { ArchivedChatsView } from "../components/archived-chats-dialog";import { ArchivedMediaView } from "../components/archived-media-dialog";+import { ManageChatsView } from "../components/manage-chats-view";import { SettingsRow } from "../components/settings-row";import { SettingsSection } from "../components/settings-section";import { UploadedFilesView } from "../components/uploaded-files-dialog";@@ -103,7 +104,7 @@ export function DataTab() {const [archiveConfirmOpen, setArchiveConfirmOpen] = useState(false);// Subpages swap the Data tab body instead of opening nested dialogs.const [subpage, setSubpage] = useState<- "main" | "archived" | "archived-images" | "archived-videos" | "files"+ "main" | "manage" | "archived" | "archived-images" | "archived-videos" | "files">(archivedRequested ? SUBPAGE_FOR_SHELF[archivedRequested] : "main");const [count, setCount] = useState<number | null>(null);const [exporting, setExporting] = useState(false);@@ -474,6 +475,35 @@ export function DataTab() {}};+ if (subpage === "manage") {+ return (+ <div className="flex flex-col gap-6">+ <header className="flex items-center gap-2">+ <button+ type="button"+ onClick={() => setSubpage("main")}+ aria-label={t("settings.data.backToData")}+ className="inline-flex size-7 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-muted hover:text-foreground"+ >+ <HugeiconsIcon icon={ArrowLeft01Icon} className="size-4" />+ </button>+ <h1 className="text-xl font-semibold font-heading">+ {t("settings.data.title")}+ </h1>+ </header>+ <div className="flex flex-col gap-1">+ <h2 className="text-sm font-semibold">+ {t("settings.data.manageChats")}+ </h2>+ <p className="text-xs text-muted-foreground">+ {t("settings.data.manageChatsDescription")}+ </p>+ </div>+ <ManageChatsView />+ </div>+ );+ }+if (subpage === "archived") {return (<div className="flex flex-col gap-6">@@ -670,6 +700,19 @@ export function DataTab() {</div></SettingsRow>+ <SettingsRow+ label={t("settings.data.manageChats")}+ description={t("settings.data.manageChatsDescription")}+ >+ <Button+ variant="outline"+ size="sm"+ onClick={() => setSubpage("manage")}+ >+ {t("settings.data.manageAction")}+ </Button>+ </SettingsRow>+<SettingsRowlabel={t("settings.data.archivedChats")}description={t("settings.data.archivedChatsDescription")}diff --git a/studio/frontend/src/i18n/locales/ar.ts b/studio/frontend/src/i18n/locales/ar.tsindex a6f3e8ea4f7..cf19ebe5b74 100644--- a/studio/frontend/src/i18n/locales/ar.ts+++ b/studio/frontend/src/i18n/locales/ar.ts@@ -1112,6 +1112,9 @@ export const ar = {archivedVideos: "الفيديوهات المؤرشفة",archivedVideosDescription: "اعرض الفيديوهات التي أرشفتها وأدرها.",manageAction: "إدارة",+ manageChats: "إدارة المحادثات",+ manageChatsDescription:+ "حدد عدة محادثات لنقلها أو تثبيتها أو أرشفتها أو تصديرها أو حذفها.",exportArchivedChats: "تصدير",exportingArchivedChats: "جارٍ التصدير...",exportedOneArchivedChat: "تم تصدير محادثة مؤرشفة واحدة",diff --git a/studio/frontend/src/i18n/locales/de.ts b/studio/frontend/src/i18n/locales/de.tsindex 1cbfba4e32e..d2d7f4fde22 100644--- a/studio/frontend/src/i18n/locales/de.ts+++ b/studio/frontend/src/i18n/locales/de.ts@@ -1150,6 +1150,9 @@ export const de = {archivedVideos: "Archivierte Videos",archivedVideosDescription: "Videos anzeigen und verwalten, die du archiviert hast.",manageAction: "Verwalten",+ manageChats: "Chats verwalten",+ manageChatsDescription:+ "Wählen Sie mehrere Chats aus, um sie zu verschieben, anzupinnen, zu archivieren, zu exportieren oder zu löschen.",exportArchivedChats: "Exportieren",exportingArchivedChats: "Wird exportiert...",exportedOneArchivedChat: "1 archivierter Chat exportiert",diff --git a/studio/frontend/src/i18n/locales/en.ts b/studio/frontend/src/i18n/locales/en.tsindex f198362f45d..5b7814c9d55 100644--- a/studio/frontend/src/i18n/locales/en.ts+++ b/studio/frontend/src/i18n/locales/en.ts@@ -1106,6 +1106,9 @@ export const en = {archivedVideos: "Archived videos",archivedVideosDescription: "View and manage videos you have archived.",manageAction: "Manage",+ manageChats: "Manage chats",+ manageChatsDescription:+ "Select multiple chats to move, pin, archive, export, or delete.",exportArchivedChats: "Export",exportingArchivedChats: "Exporting...",exportedOneArchivedChat: "Exported 1 archived chat",diff --git a/studio/frontend/src/i18n/locales/es.ts b/studio/frontend/src/i18n/locales/es.tsindex cf90bf4da6c..5fe5c481c33 100644--- a/studio/frontend/src/i18n/locales/es.ts+++ b/studio/frontend/src/i18n/locales/es.ts@@ -1140,6 +1140,9 @@ export const es = {archivedVideos: "Vídeos archivados",archivedVideosDescription: "Consulta y gestiona los vídeos que has archivado.",manageAction: "Gestionar",+ manageChats: "Gestionar chats",+ manageChatsDescription:+ "Selecciona varios chats para moverlos, fijarlos, archivarlos, exportarlos o eliminarlos.",exportArchivedChats: "Exportar",exportingArchivedChats: "Exportando...",exportedOneArchivedChat: "Se exportó 1 chat archivado",diff --git a/studio/frontend/src/i18n/locales/fr.ts b/studio/frontend/src/i18n/locales/fr.tsindex e493acb98a4..5225a111587 100644--- a/studio/frontend/src/i18n/locales/fr.ts+++ b/studio/frontend/src/i18n/locales/fr.ts@@ -1148,6 +1148,9 @@ export const fr = {archivedVideos: "Vidéos archivées",archivedVideosDescription: "Consultez et gérez les vidéos que vous avez archivées.",manageAction: "Gérer",+ manageChats: "Gérer les discussions",+ manageChatsDescription:+ "Sélectionnez plusieurs discussions pour les déplacer, les épingler, les archiver, les exporter ou les supprimer.",exportArchivedChats: "Exporter",exportingArchivedChats: "Exportation...",exportedOneArchivedChat: "1 discussion archivée a été exportée",diff --git a/studio/frontend/src/i18n/locales/hi.ts b/studio/frontend/src/i18n/locales/hi.tsindex ad40d05d250..c607150c7bb 100644--- a/studio/frontend/src/i18n/locales/hi.ts+++ b/studio/frontend/src/i18n/locales/hi.ts@@ -1118,6 +1118,9 @@ export const hi = {archivedVideos: "संग्रहित वीडियो",archivedVideosDescription: "आपके द्वारा संग्रहित किए गए वीडियो देखें और प्रबंधित करें।",manageAction: "प्रबंधित करें",+ manageChats: "चैट प्रबंधित करें",+ manageChatsDescription:+ "कई चैट चुनें और उन्हें स्थानांतरित, पिन, संग्रहित, निर्यात या हटाएं।",exportArchivedChats: "एक्सपोर्ट करें",exportingArchivedChats: "एक्सपोर्ट हो रहा है...",exportedOneArchivedChat: "1 संग्रहित चैट एक्सपोर्ट की गई",diff --git a/studio/frontend/src/i18n/locales/it.ts b/studio/frontend/src/i18n/locales/it.tsindex 28fe34bc626..2a3c643c950 100644--- a/studio/frontend/src/i18n/locales/it.ts+++ b/studio/frontend/src/i18n/locales/it.ts@@ -1113,6 +1113,9 @@ export const it = {archivedVideos: "Video archiviati",archivedVideosDescription: "Visualizza e gestisci i video che hai archiviato.",manageAction: "Gestisci",+ manageChats: "Gestisci chat",+ manageChatsDescription:+ "Seleziona più chat da spostare, fissare, archiviare, esportare o eliminare.",exportArchivedChats: "Esporta",exportingArchivedChats: "Esportazione...",exportedOneArchivedChat: "1 chat archiviata esportata",diff --git a/studio/frontend/src/i18n/locales/ja.ts b/studio/frontend/src/i18n/locales/ja.tsindex 59755ed8b3a..f722eaca425 100644--- a/studio/frontend/src/i18n/locales/ja.ts+++ b/studio/frontend/src/i18n/locales/ja.ts@@ -1088,6 +1088,9 @@ export const ja = {archivedVideos: "アーカイブ済み動画",archivedVideosDescription: "アーカイブした動画を表示・管理します。",manageAction: "管理",+ manageChats: "チャットを管理",+ manageChatsDescription:+ "複数のチャットを選択して移動、ピン留め、アーカイブ、エクスポート、削除できます。",exportArchivedChats: "エクスポート",exportingArchivedChats: "エクスポート中...",exportedOneArchivedChat: "アーカイブ済みチャット 1 件をエクスポートしました",diff --git a/studio/frontend/src/i18n/locales/ko.ts b/studio/frontend/src/i18n/locales/ko.tsindex d6c743e4379..c701c423727 100644--- a/studio/frontend/src/i18n/locales/ko.ts+++ b/studio/frontend/src/i18n/locales/ko.ts@@ -1110,6 +1110,9 @@ export const ko = {archivedVideos: "보관된 동영상",archivedVideosDescription: "보관한 동영상을 확인하고 관리합니다.",manageAction: "관리",+ manageChats: "채팅 관리",+ manageChatsDescription:+ "여러 채팅을 선택해 이동, 고정, 보관, 내보내기 또는 삭제할 수 있습니다.",exportArchivedChats: "내보내기",exportingArchivedChats: "내보내는 중...",exportedOneArchivedChat: "보관된 채팅 1개를 내보냈습니다",diff --git a/studio/frontend/src/i18n/locales/pt-br.ts b/studio/frontend/src/i18n/locales/pt-br.tsindex dd884c34076..59aff338953 100644--- a/studio/frontend/src/i18n/locales/pt-br.ts+++ b/studio/frontend/src/i18n/locales/pt-br.ts@@ -1125,6 +1125,9 @@ export const ptBR = {archivedVideos: "Vídeos arquivados",archivedVideosDescription: "Veja e gerencie os vídeos que você arquivou.",manageAction: "Gerenciar",+ manageChats: "Gerenciar chats",+ manageChatsDescription:+ "Selecione vários chats para mover, fixar, arquivar, exportar ou excluir.",exportArchivedChats: "Exportar",exportingArchivedChats: "Exportando...",exportedOneArchivedChat: "1 chat arquivado exportado",diff --git a/studio/frontend/src/i18n/locales/ru.ts b/studio/frontend/src/i18n/locales/ru.tsindex ed320d9dd72..e487e34f121 100644--- a/studio/frontend/src/i18n/locales/ru.ts+++ b/studio/frontend/src/i18n/locales/ru.ts@@ -1122,6 +1122,9 @@ export const ru = {archivedVideos: "Архивные видео",archivedVideosDescription: "Просмотр и управление видео, которые вы архивировали.",manageAction: "Управлять",+ manageChats: "Управление чатами",+ manageChatsDescription:+ "Выберите несколько чатов, чтобы переместить, закрепить, архивировать, экспортировать или удалить их.",exportArchivedChats: "Экспорт",exportingArchivedChats: "Экспорт…",exportedOneArchivedChat: "Экспортирован 1 архивный чат",diff --git a/studio/frontend/src/i18n/locales/zh-CN.ts b/studio/frontend/src/i18n/locales/zh-CN.tsindex be672f30fc1..0ce553f4020 100644--- a/studio/frontend/src/i18n/locales/zh-CN.ts+++ b/studio/frontend/src/i18n/locales/zh-CN.ts@@ -1082,6 +1082,8 @@ export const zhCN = {archivedVideos: "已归档的视频",archivedVideosDescription: "查看和管理你归档的视频。",manageAction: "管理",+ manageChats: "管理聊天",+ manageChatsDescription: "选择多个聊天进行移动、置顶、归档、导出或删除。",exportArchivedChats: "导出",exportingArchivedChats: "正在导出...",exportedOneArchivedChat: "已导出 1 个归档聊天",diff --git a/studio/frontend/tests/manage-chats-bulk-selection.test.ts b/studio/frontend/tests/manage-chats-bulk-selection.test.tsnew file mode 100644index 00000000000..b80d5c7659f--- /dev/null+++ b/studio/frontend/tests/manage-chats-bulk-selection.test.ts@@ -0,0 +1,115 @@+// SPDX-License-Identifier: AGPL-3.0-only+// Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0++// Bulk pin/unpin ordering, and the scope the header checkbox claims. The .tsx+// view pulls in the whole app, so it is read as text; the store runs for real.++import assert from "node:assert/strict";+import { readFile } from "node:fs/promises";+import test from "node:test";++import {+ installLocalStorageFake,+ registerBundlerResolver,+} from "./helpers/kit.ts";++registerBundlerResolver();+installLocalStorageFake();++const { usePinnedChatsStore } = await import(+ "../src/features/chat/stores/pinned-chats-store.ts"+);+const { rangeBetween } = await import(+ "../src/features/chat/utils/row-selection.ts"+);++async function manageChatsSource(): Promise<string> {+ return await readFile(+ new URL(+ "../src/features/settings/components/manage-chats-view.tsx",+ import.meta.url,+ ),+ "utf8",+ );+}++function reset(ids: string[] = []): void {+ usePinnedChatsStore.setState({ pinnedIds: ids });+}++test("pinning a selection prepends only the chats that were not pinned", () => {+ reset(["b"]);+ usePinnedChatsStore.getState().setPinned(["a", "b", "c"], true);+ // b keeps its place; a and c lead, as a single pin does.+ assert.deepEqual(usePinnedChatsStore.getState().pinnedIds, ["a", "c", "b"]);+});++test("pinning an already pinned selection is a no-op, not a reorder", () => {+ reset(["a", "b"]);+ const before = usePinnedChatsStore.getState().pinnedIds;+ usePinnedChatsStore.getState().setPinned(["a", "b"], true);+ assert.equal(usePinnedChatsStore.getState().pinnedIds, before);+});++test("unpinning a selection drops exactly those ids and keeps the rest ordered", () => {+ reset(["a", "b", "c", "d"]);+ usePinnedChatsStore.getState().setPinned(["b", "d"], false);+ assert.deepEqual(usePinnedChatsStore.getState().pinnedIds, ["a", "c"]);+});++test("unpinning ids that were never pinned leaves the list alone", () => {+ reset(["a"]);+ usePinnedChatsStore.getState().setPinned(["x", "y"], false);+ assert.deepEqual(usePinnedChatsStore.getState().pinnedIds, ["a"]);+});++test("an empty selection changes nothing in either direction", () => {+ reset(["a", "b"]);+ usePinnedChatsStore.getState().setPinned([], true);+ assert.deepEqual(usePinnedChatsStore.getState().pinnedIds, ["a", "b"]);+ usePinnedChatsStore.getState().setPinned([], false);+ assert.deepEqual(usePinnedChatsStore.getState().pinnedIds, ["a", "b"]);+});++test("a shift range survives the list re-sorting between the two clicks", () => {+ // A background stream re-sorts the list by updatedAt mid-selection; the+ // anchor must still name the chat it was set on.+ const before = ["a", "b", "c", "d"];+ const after = ["d", "a", "b", "c"];+ // Anchor on "b", then shift-click "c" after the reorder: still exactly b..c.+ assert.deepEqual(rangeBetween(after, "b", "c"), ["b", "c"]);+ // An index anchor would instead sweep a..c, deleting "a" unasked.+ assert.equal(before.indexOf("b"), 1);+ assert.equal(after[1], "a");+ assert.deepEqual(rangeBetween(after, after[1], "c"), ["a", "b", "c"]);+});++test("the shift anchor is stored as a chat id, not a row index", async () => {+ const src = await manageChatsSource();+ assert.match(src, /useRef<string \| null>\(null\)/);+ assert.match(src, /rangeBetween\(/);+ // An index anchor addresses whatever row now sits at the saved position.+ assert.doesNotMatch(src, /lastToggledIndex/);+});++test("bulk delete passes the always-delete-files preference through", async () => {+ const src = await manageChatsSource();+ // Without this, deleteChatItems defaults args to {} and sends+ // delete_files:false, keeping every selected chat's sandbox.+ assert.match(+ src,+ /useChatPreferencesStore\(\s*\(s\) => s\.alwaysDeleteChatFiles,?\s*\)/,+ );+ assert.match(+ src,+ /deleteChatItems\(selectedItems, openChatId, resetView, \{\s*deleteFiles: alwaysDeleteChatFiles,\s*\}\)/,+ );+});++test("the header checkbox says it selects the visible chats, which is what it does", async () => {+ const src = await manageChatsSource();+ // Rows sit behind a "Show more", so the label must not promise the whole list.+ assert.match(src, /onCheckedChange=\{toggleAllVisible\}/);+ assert.match(src, /aria-label="Select all visible chats"/);+ assert.doesNotMatch(src, /aria-label="Select all chats"/);+});diff --git a/studio/frontend/tests/manage-chats-open-project.test.ts b/studio/frontend/tests/manage-chats-open-project.test.tsnew file mode 100644index 00000000000..b21cb4b5598--- /dev/null+++ b/studio/frontend/tests/manage-chats-open-project.test.ts@@ -0,0 +1,40 @@+// SPDX-License-Identifier: AGPL-3.0-only+// Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0++// Opening a managed row must carry the row's project the way the sidebar does.+// The .tsx view pulls in the whole app, so it is read as text.++import assert from "node:assert/strict";+import { readFile } from "node:fs/promises";+import test from "node:test";++async function openChatSource(): Promise<string> {+ const src = await readFile(+ new URL(+ "../src/features/settings/components/manage-chats-view.tsx",+ import.meta.url,+ ),+ "utf8",+ );+ const start = src.indexOf("function openChat(");+ assert.ok(start !== -1, "openChat not found in manage-chats-view.tsx");+ const end = src.indexOf("\n }", start);+ assert.ok(end !== -1, "openChat body not delimited");+ return src.slice(start, end);+}++test("openChat passes the row's project so ChatPage does not reuse the old one", async () => {+ const body = await openChatSource();+ assert.match(body, /item\.projectId/);+ assert.match(body, /project:/);+});++test("openChat carries the project for both single and compare rows", async () => {+ const body = await openChatSource();+ for (const key of ["thread:", "compare:"]) {+ const at = body.indexOf(key);+ assert.ok(at !== -1, `${key} branch not found`);+ // The spread that adds the project sits in the same object literal.+ assert.match(body.slice(at, at + 120), /\.\.\.project/);+ }+});