@@ -106,6 +106,7 @@ import { formatRelativeTimeLabel, parseTimestampDate } from "../timestampFormat"
106106import type { SidebarThreadSummary } from "../types" ;
107107import { cn } from "~/lib/utils" ;
108108import {
109+ buildBulkTitleRegenerationContextMenuItem ,
109110 formatWorkingDurationLabel ,
110111 firstValidTimestampMs ,
111112 hasUnseenCompletion ,
@@ -1938,6 +1939,18 @@ export default function SidebarV2() {
19381939 serverConfigs . get ( thread . environmentId ) ?. environment . capabilities . threadSnooze === true &&
19391940 canSnooze ( thread , { now : selectionNow . toISOString ( ) } ) ,
19401941 ) ;
1942+ const titleRegenerationThreads = selectedThreads . filter (
1943+ ( thread ) =>
1944+ serverConfigs . get ( thread . environmentId ) ?. environment . capabilities
1945+ . threadTitleRegeneration === true ,
1946+ ) ;
1947+ const regeneratableTitleThreads = titleRegenerationThreads . filter (
1948+ ( thread ) => thread . titleRegeneration == null ,
1949+ ) ;
1950+ const titleRegenerationMenuItem = buildBulkTitleRegenerationContextMenuItem ( {
1951+ supportedCount : titleRegenerationThreads . length ,
1952+ actionableCount : regeneratableTitleThreads . length ,
1953+ } ) ;
19411954 const snoozePresets = resolveSnoozePresets ( new Date ( ) ) ;
19421955 const clicked = await settlePromise ( ( ) =>
19431956 api . contextMenu . show (
@@ -1955,6 +1968,7 @@ export default function SidebarV2() {
19551968 } ,
19561969 ]
19571970 : [ ] ) ,
1971+ ...( titleRegenerationMenuItem ? [ titleRegenerationMenuItem ] : [ ] ) ,
19581972 { id : "mark-unread" , label : `Mark unread (${ count } )` } ,
19591973 { id : "delete" , label : `Delete (${ count } )` , destructive : true } ,
19601974 ] ,
@@ -1979,6 +1993,28 @@ export default function SidebarV2() {
19791993 }
19801994 return ;
19811995 }
1996+ if ( clicked . value === "regenerate-title" ) {
1997+ for ( const thread of regeneratableTitleThreads ) {
1998+ const result = await updateThreadMetadata ( {
1999+ environmentId : thread . environmentId ,
2000+ input : { threadId : thread . id , regenerateTitle : true } ,
2001+ } ) ;
2002+ if ( result . _tag === "Success" ) continue ;
2003+ if ( ! isAtomCommandInterrupted ( result ) ) {
2004+ const error = squashAtomCommandFailure ( result ) ;
2005+ toastManager . add (
2006+ stackedThreadToast ( {
2007+ type : "error" ,
2008+ title : "Failed to regenerate thread titles" ,
2009+ description : error instanceof Error ? error . message : "An error occurred." ,
2010+ } ) ,
2011+ ) ;
2012+ }
2013+ return ;
2014+ }
2015+ clearSelection ( ) ;
2016+ return ;
2017+ }
19822018 if ( clicked . value === "settle" ) {
19832019 // Post-settle navigation must skip threads settling in this same
19842020 // batch — they are all leaving the card block together. Rows that
@@ -2050,6 +2086,7 @@ export default function SidebarV2() {
20502086 markThreadUnread ,
20512087 removeFromSelection ,
20522088 serverConfigs ,
2089+ updateThreadMetadata ,
20532090 ] ,
20542091 ) ;
20552092
0 commit comments