@@ -8,6 +8,8 @@ import { ChatHistorySidebar } from "@/components/chat/ChatHistorySidebar";
88import { useLocale } from "@/i18n" ;
99import type { ChatHistorySummary } from "@/lib/chat/chatHistory" ;
1010import type { WorkspaceProject } from "@/lib/settings" ;
11+ import type { SidebarBatchDeleteOptions } from "@/lib/sidebar/batchDelete" ;
12+ import { deleteSidebarConversations } from "@/lib/sidebar/batchDelete" ;
1113import {
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