@@ -192,7 +192,14 @@ function ThreadNavigationSidebarPane(
192192 }
193193 return matches ;
194194 } , [ threadSearch . matches ] ) ;
195- const matchedThreadKeys = new Set ( threadSearch . matches . map ( threadSearchMatchKey ) ) ;
195+ // listItems and the values it derives from: the compiler can't memoize them because they stay
196+ // live across later hook calls. A new listItems hands LegendList new data and re-registers every
197+ // thread jump shortcut, which re-renders the app-root keyboard command provider and resends the
198+ // native command list.
199+ const matchedThreadKeys = useMemo (
200+ ( ) => new Set ( threadSearch . matches . map ( threadSearchMatchKey ) ) ,
201+ [ threadSearch . matches ] ,
202+ ) ;
196203 const projectScopeKey = options . selectedProjectKey ;
197204 const resolvedProjectKey = resolveScratchProjectScopeKey ( projectScopeKey , projects , {
198205 sidebarProjectGroupingMode : options . projectGroupingMode ,
@@ -231,17 +238,22 @@ function ThreadNavigationSidebarPane(
231238 ) ,
232239 [ projectScopes ] ,
233240 ) ;
234- const selectedProjectScope =
235- projectScopes . find ( ( scope ) => scope . key === resolvedProjectKey ) ?? null ;
241+ const selectedProjectScope = useMemo (
242+ ( ) => projectScopes . find ( ( scope ) => scope . key === resolvedProjectKey ) ?? null ,
243+ [ projectScopes , resolvedProjectKey ] ,
244+ ) ;
236245 const selectedProjectKey = selectedProjectScope ?. key ?? null ;
237- const selectedProjectRefs =
238- selectedProjectScope === null
239- ? null
240- : new Set (
241- selectedProjectScope . projectRefs . map ( ( projectRef ) =>
242- scopedProjectKey ( projectRef . environmentId , projectRef . projectId ) ,
246+ const selectedProjectRefs = useMemo (
247+ ( ) =>
248+ selectedProjectScope === null
249+ ? null
250+ : new Set (
251+ selectedProjectScope . projectRefs . map ( ( projectRef ) =>
252+ scopedProjectKey ( projectRef . environmentId , projectRef . projectId ) ,
253+ ) ,
243254 ) ,
244- ) ;
255+ [ selectedProjectScope ] ,
256+ ) ;
245257 const projectByKey = useMemo ( ( ) => {
246258 const map = new Map < string , EnvironmentProject > ( ) ;
247259 for ( const project of projects ) {
@@ -299,7 +311,7 @@ function ThreadNavigationSidebarPane(
299311 // Up/down menu availability for every card, computed once per section per
300312 // rebuild (see computeThreadMoveAvailability): per-thread planner calls made
301313 // list construction quadratic, and this list rebuilds on every minute tick.
302- const threadMoveAvailability = ( ( ) => {
314+ const threadMoveAvailability = useMemo ( ( ) => {
303315 const sectionAvailability = ( section : "pinned" | "active" ) =>
304316 computeThreadMoveAvailability ( {
305317 allThreads : threads ,
@@ -321,8 +333,18 @@ function ThreadNavigationSidebarPane(
321333 ...sectionAvailability ( "pinned" ) ,
322334 ...( workingShelfEnabled ? [ ] : sectionAvailability ( "active" ) ) ,
323335 ] ) ;
324- } ) ( ) ;
325- const threadListV2Layout = ( ( ) => {
336+ } , [
337+ activeReorderEnvironmentIds ,
338+ now ,
339+ pendingOrder ,
340+ pinReorderEnvironmentIds ,
341+ queuedThreadKeys ,
342+ settlementEnvironmentIds ,
343+ snoozeEnvironmentIds ,
344+ threads ,
345+ workingShelfEnabled ,
346+ ] ) ;
347+ const threadListV2Layout = useMemo ( ( ) => {
326348 threadListInboxReturns . observe ( workingShelfEnabled ? threads : null ) ;
327349 return buildThreadListV2Items ( {
328350 pendingOrder,
@@ -343,7 +365,24 @@ function ThreadNavigationSidebarPane(
343365 settledShelfExpanded,
344366 selectedThreadKey : props . selectedThreadKey ?? null ,
345367 } ) ;
346- } ) ( ) ;
368+ } , [
369+ matchedThreadKeys ,
370+ now ,
371+ options . selectedEnvironmentId ,
372+ pendingOrder ,
373+ props . searchQuery ,
374+ props . selectedThreadKey ,
375+ queuedThreadKeys ,
376+ selectedProjectScope ,
377+ settledShelfExpanded ,
378+ settledVisibleCount ,
379+ settlementEnvironmentIds ,
380+ snoozeEnvironmentIds ,
381+ snoozedShelfExpanded ,
382+ threads ,
383+ workingShelfEnabled ,
384+ workingShelfExpanded ,
385+ ] ) ;
347386 const nextSnoozeWakeAt = threadListV2Layout . nextSnoozeWakeAt ;
348387 useEffect ( ( ) => {
349388 if ( nextSnoozeWakeAt === null ) return ;
@@ -359,7 +398,7 @@ function ThreadNavigationSidebarPane(
359398 // unchanged: after a clamped fire (wake beyond the 32-bit setTimeout
360399 // range) the boundary string is identical and the chain would die.
361400 } , [ nextSnoozeWakeAt , snoozeWakeTick ] ) ;
362- const listItems = ( ( ) : readonly SidebarListItem [ ] => {
401+ const listItems = useMemo ( ( ) : readonly SidebarListItem [ ] => {
363402 const v2SearchQuery = props . searchQuery . trim ( ) . toLocaleLowerCase ( ) ;
364403 const v2PendingTasks = pendingTasks . filter (
365404 ( pendingTask ) =>
@@ -398,7 +437,21 @@ function ThreadNavigationSidebarPane(
398437 } ) ;
399438 }
400439 return items ;
401- } ) ( ) ;
440+ } , [
441+ nowMinute ,
442+ options . selectedEnvironmentId ,
443+ pendingTasks ,
444+ props . searchQuery ,
445+ queuedThreadKeys ,
446+ threadMoveAvailability ,
447+ selectedProjectRefs ,
448+ settledShelfExpanded ,
449+ shelfPreferencesLoaded ,
450+ snoozedShelfExpanded ,
451+ snoozeEnvironmentIds ,
452+ threadListV2Layout ,
453+ workingShelfExpanded ,
454+ ] ) ;
402455 const listMenuActions = [
403456 {
404457 id : "environment" ,
0 commit comments