@@ -759,7 +759,9 @@ const SidebarThreadRow = memo(function SidebarThreadRow(props: SidebarThreadRowP
759759 : "text-muted-foreground/40"
760760 } `}
761761 >
762- { formatRelativeTimeLabel ( thread . updatedAt ?? thread . createdAt ) }
762+ { formatRelativeTimeLabel (
763+ thread . latestUserMessageAt ?? thread . updatedAt ?? thread . createdAt ,
764+ ) }
763765 </ span >
764766 ) }
765767 </ span >
@@ -1115,6 +1117,11 @@ const SidebarProjectItem = memo(function SidebarProjectItem(props: SidebarProjec
11151117 ) ,
11161118 [ allSidebarThreads ] ,
11171119 ) ;
1120+ // Keep a ref so callbacks can read the latest map without appearing in
1121+ // dependency arrays (avoids invalidating every thread-row memo on each
1122+ // thread-list change).
1123+ const sidebarThreadByKeyRef = useRef ( sidebarThreadByKey ) ;
1124+ sidebarThreadByKeyRef . current = sidebarThreadByKey ;
11181125 // All threads from the representative + other member environments are
11191126 // already fetched into allSidebarThreads, so we can use them directly.
11201127 const projectThreads = allSidebarThreads ;
@@ -1458,7 +1465,7 @@ const SidebarProjectItem = memo(function SidebarProjectItem(props: SidebarProjec
14581465
14591466 if ( clicked === "mark-unread" ) {
14601467 for ( const threadKey of threadKeys ) {
1461- const thread = sidebarThreadByKey . get ( threadKey ) ;
1468+ const thread = sidebarThreadByKeyRef . current . get ( threadKey ) ;
14621469 markThreadUnread ( threadKey , thread ?. latestTurn ?. completedAt ) ;
14631470 }
14641471 clearSelection ( ) ;
@@ -1479,7 +1486,7 @@ const SidebarProjectItem = memo(function SidebarProjectItem(props: SidebarProjec
14791486
14801487 const deletedThreadKeys = new Set ( threadKeys ) ;
14811488 for ( const threadKey of threadKeys ) {
1482- const thread = sidebarThreadByKey . get ( threadKey ) ;
1489+ const thread = sidebarThreadByKeyRef . current . get ( threadKey ) ;
14831490 if ( ! thread ) continue ;
14841491 await deleteThread ( scopeThreadRef ( thread . environmentId , thread . id ) , {
14851492 deletedThreadKeys,
@@ -1493,7 +1500,6 @@ const SidebarProjectItem = memo(function SidebarProjectItem(props: SidebarProjec
14931500 deleteThread ,
14941501 markThreadUnread ,
14951502 removeFromSelection ,
1496- sidebarThreadByKey ,
14971503 ] ,
14981504 ) ;
14991505
@@ -1622,12 +1628,7 @@ const SidebarProjectItem = memo(function SidebarProjectItem(props: SidebarProjec
16221628 const api = readLocalApi ( ) ;
16231629 if ( ! api ) return ;
16241630 const threadKey = scopedThreadKey ( threadRef ) ;
1625- const thread =
1626- projectThreads . find (
1627- ( projectThread ) =>
1628- projectThread . environmentId === threadRef . environmentId &&
1629- projectThread . id === threadRef . threadId ,
1630- ) ?? null ;
1631+ const thread = sidebarThreadByKeyRef . current . get ( threadKey ) ?? null ;
16311632 if ( ! thread ) return ;
16321633 const threadWorkspacePath = thread . worktreePath ?? project . cwd ?? null ;
16331634 const clicked = await api . contextMenu . show (
@@ -1689,7 +1690,6 @@ const SidebarProjectItem = memo(function SidebarProjectItem(props: SidebarProjec
16891690 deleteThread ,
16901691 markThreadUnread ,
16911692 project . cwd ,
1692- projectThreads ,
16931693 ] ,
16941694 ) ;
16951695
0 commit comments