Skip to content

Commit 6abc0be

Browse files
authored
Merge pull request Stack-Cairn#225 from NotToday1024/feat/issue-211-bulk-delete
feat(sidebar): support multi-select conversation deletion
2 parents 0560e63 + 0c716be commit 6abc0be

13 files changed

Lines changed: 1391 additions & 157 deletions

File tree

crates/agent-gateway/web/src/app/sidebar/GatewaySidebarContainer.tsx

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ import { ChatHistorySidebar } from "@/components/chat/ChatHistorySidebar";
88
import { useLocale } from "@/i18n";
99
import type { ChatHistorySummary } from "@/lib/chat/chatHistory";
1010
import type { WorkspaceProject } from "@/lib/settings";
11+
import type { SidebarBatchDeleteOptions } from "@/lib/sidebar/batchDelete";
12+
import { deleteSidebarConversations } from "@/lib/sidebar/batchDelete";
1113
import {
1214
selectConversations,
1315
selectListState,
@@ -226,6 +228,28 @@ export function GatewaySidebarContainer(props: GatewaySidebarContainerProps) {
226228
void store.remove(id);
227229
});
228230

231+
const handleDeleteConversations = useStableCallback(
232+
async (ids: readonly string[], options?: SidebarBatchDeleteOptions) => {
233+
if (sectionsDisabled) {
234+
return { deletedIds: [], failedIds: [...ids], skippedIds: [] };
235+
}
236+
clearMutationErrors();
237+
return deleteSidebarConversations(
238+
ids,
239+
async (id) => {
240+
const existing = store.peek(id);
241+
if (existing?.isPending === true || isLocalDraftConversationId(id)) {
242+
store.removeLocal(id);
243+
props.onLocalDraftDeleted(id);
244+
return true;
245+
}
246+
return store.remove(id);
247+
},
248+
options,
249+
);
250+
},
251+
);
252+
229253
const handleLoadMore = useStableCallback(() => {
230254
if (sectionsDisabled) {
231255
return;
@@ -350,6 +374,7 @@ export function GatewaySidebarContainer(props: GatewaySidebarContainerProps) {
350374
onShareConversation={props.onShareConversation}
351375
onOpenSharedConversations={props.onOpenSharedConversations}
352376
onDeleteConversation={handleDeleteConversation}
377+
onDeleteConversations={handleDeleteConversations}
353378
onLoadMore={handleLoadMore}
354379
onCloseSidebar={props.onCloseSidebar}
355380
onOpenSettings={props.onOpenSettings}

0 commit comments

Comments
 (0)