@@ -22,6 +22,7 @@ import type { PendingNewTask } from "../../state/use-pending-new-tasks";
2222import { useThreadPr , type ThreadPr } from "../../state/use-thread-pr" ;
2323import type { HomeGroupDisplayAction } from "../home/homeListItems" ;
2424import { ThreadSwipeable } from "../home/thread-swipe-actions" ;
25+ import { buildThreadTitleRegenerationMenuItems } from "./thread-title-regeneration-menu" ;
2526import { resolveThreadStatus } from "./threadPresentation" ;
2627import { ThreadSearchMatchExcerpt } from "./thread-search-match" ;
2728
@@ -430,6 +431,8 @@ export const ThreadListRow = memo(function ThreadListRow(props: {
430431 readonly onSelectThread : ( thread : EnvironmentThreadShell ) => void ;
431432 readonly onArchiveThread : ( thread : EnvironmentThreadShell ) => void ;
432433 readonly onDeleteThread : ( thread : EnvironmentThreadShell ) => void ;
434+ readonly onRegenerateThreadTitle : ( thread : EnvironmentThreadShell ) => void ;
435+ readonly titleRegenerationSupported : boolean ;
433436 readonly onSwipeableWillOpen : ( methods : SwipeableMethods ) => void ;
434437 readonly onSwipeableClose : ( methods : SwipeableMethods ) => void ;
435438 readonly simultaneousSwipeGesture ?: ComponentProps <
@@ -451,7 +454,8 @@ export const ThreadListRow = memo(function ThreadListRow(props: {
451454 const pressedBackgroundColor = useThemeColor ( "--color-subtle" ) ;
452455 const selectedBackgroundColor = useThemeColor ( "--color-user-bubble" ) ;
453456
454- const { thread, onSelectThread, onArchiveThread, onDeleteThread } = props ;
457+ const { thread, onSelectThread, onArchiveThread, onDeleteThread, onRegenerateThreadTitle } =
458+ props ;
455459 const status = resolveThreadStatus ( thread ) ;
456460 const pr = useThreadPr ( thread , props . projectCwd ) ;
457461 const timestamp = relativeTime (
@@ -471,6 +475,21 @@ export const ThreadListRow = memo(function ThreadListRow(props: {
471475
472476 const handleDelete = useCallback ( ( ) => onDeleteThread ( thread ) , [ onDeleteThread , thread ] ) ;
473477 const handleArchive = useCallback ( ( ) => onArchiveThread ( thread ) , [ onArchiveThread , thread ] ) ;
478+ const handleRegenerateTitle = useCallback (
479+ ( ) => onRegenerateThreadTitle ( thread ) ,
480+ [ onRegenerateThreadTitle , thread ] ,
481+ ) ;
482+ const menuActions = useMemo < MenuAction [ ] > (
483+ ( ) => [
484+ THREAD_ROW_MENU_ACTIONS [ 0 ] ! ,
485+ ...buildThreadTitleRegenerationMenuItems ( {
486+ supported : props . titleRegenerationSupported ,
487+ isRegenerating : thread . titleRegeneration != null ,
488+ } ) ,
489+ THREAD_ROW_MENU_ACTIONS [ 1 ] ! ,
490+ ] ,
491+ [ props . titleRegenerationSupported , thread . titleRegeneration ] ,
492+ ) ;
474493 const primaryAction = useMemo (
475494 ( ) => ( {
476495 accessibilityLabel : `Archive ${ thread . title } ` ,
@@ -483,9 +502,10 @@ export const ThreadListRow = memo(function ThreadListRow(props: {
483502 const handleMenuAction = useCallback (
484503 ( { nativeEvent } : { readonly nativeEvent : { readonly event : string } } ) => {
485504 if ( nativeEvent . event === "archive" ) handleArchive ( ) ;
505+ if ( nativeEvent . event === "regenerate-title" ) handleRegenerateTitle ( ) ;
486506 if ( nativeEvent . event === "delete" ) handleDelete ( ) ;
487507 } ,
488- [ handleArchive , handleDelete ] ,
508+ [ handleArchive , handleDelete , handleRegenerateTitle ] ,
489509 ) ;
490510
491511 const statusPill = effectiveStatus ? (
@@ -674,7 +694,7 @@ export const ThreadListRow = memo(function ThreadListRow(props: {
674694 // ControlPillMenu injects onLongPress into the row and anchors the
675695 // token-styled dropdown to it; taps and swipes are untouched.
676696 < ControlPillMenu
677- actions = { THREAD_ROW_MENU_ACTIONS }
697+ actions = { menuActions }
678698 onPressAction = { handleMenuAction }
679699 shouldOpenOnLongPress
680700 >
0 commit comments