@@ -191,7 +191,14 @@ function ThreadNavigationSidebarPane(
191191 }
192192 return matches ;
193193 } , [ threadSearch . matches ] ) ;
194- const matchedThreadKeys = new Set ( threadSearch . matches . map ( threadSearchMatchKey ) ) ;
194+ // listItems and the values it derives from: the compiler can't memoize them because they stay
195+ // live across later hook calls. A new listItems hands LegendList new data and re-registers every
196+ // thread jump shortcut, which re-renders the app-root keyboard command provider and resends the
197+ // native command list.
198+ const matchedThreadKeys = useMemo (
199+ ( ) => new Set ( threadSearch . matches . map ( threadSearchMatchKey ) ) ,
200+ [ threadSearch . matches ] ,
201+ ) ;
195202 const projectScopeKey = options . selectedProjectKey ;
196203 const resolvedProjectKey = resolveScratchProjectScopeKey ( projectScopeKey , projects , {
197204 sidebarProjectGroupingMode : options . projectGroupingMode ,
@@ -230,17 +237,22 @@ function ThreadNavigationSidebarPane(
230237 ) ,
231238 [ projectScopes ] ,
232239 ) ;
233- const selectedProjectScope =
234- projectScopes . find ( ( scope ) => scope . key === resolvedProjectKey ) ?? null ;
240+ const selectedProjectScope = useMemo (
241+ ( ) => projectScopes . find ( ( scope ) => scope . key === resolvedProjectKey ) ?? null ,
242+ [ projectScopes , resolvedProjectKey ] ,
243+ ) ;
235244 const selectedProjectKey = selectedProjectScope ?. key ?? null ;
236- const selectedProjectRefs =
237- selectedProjectScope === null
238- ? null
239- : new Set (
240- selectedProjectScope . projectRefs . map ( ( projectRef ) =>
241- scopedProjectKey ( projectRef . environmentId , projectRef . projectId ) ,
245+ const selectedProjectRefs = useMemo (
246+ ( ) =>
247+ selectedProjectScope === null
248+ ? null
249+ : new Set (
250+ selectedProjectScope . projectRefs . map ( ( projectRef ) =>
251+ scopedProjectKey ( projectRef . environmentId , projectRef . projectId ) ,
252+ ) ,
242253 ) ,
243- ) ;
254+ [ selectedProjectScope ] ,
255+ ) ;
244256 const projectByKey = useMemo ( ( ) => {
245257 const map = new Map < string , EnvironmentProject > ( ) ;
246258 for ( const project of projects ) {
@@ -298,7 +310,7 @@ function ThreadNavigationSidebarPane(
298310 // Up/down menu availability for every card, computed once per section per
299311 // rebuild (see computeThreadMoveAvailability): per-thread planner calls made
300312 // list construction quadratic, and this list rebuilds on every minute tick.
301- const threadMoveAvailability = ( ( ) => {
313+ const threadMoveAvailability = useMemo ( ( ) => {
302314 const sectionAvailability = ( section : "pinned" | "active" ) =>
303315 computeThreadMoveAvailability ( {
304316 allThreads : threads ,
@@ -320,8 +332,18 @@ function ThreadNavigationSidebarPane(
320332 ...sectionAvailability ( "pinned" ) ,
321333 ...( workingShelfEnabled ? [ ] : sectionAvailability ( "active" ) ) ,
322334 ] ) ;
323- } ) ( ) ;
324- const threadListV2Layout = ( ( ) => {
335+ } , [
336+ activeReorderEnvironmentIds ,
337+ now ,
338+ pendingOrder ,
339+ pinReorderEnvironmentIds ,
340+ queuedThreadKeys ,
341+ settlementEnvironmentIds ,
342+ snoozeEnvironmentIds ,
343+ threads ,
344+ workingShelfEnabled ,
345+ ] ) ;
346+ const threadListV2Layout = useMemo ( ( ) => {
325347 threadListInboxReturns . observe ( workingShelfEnabled ? threads : null ) ;
326348 return buildThreadListV2Items ( {
327349 pendingOrder,
@@ -342,7 +364,24 @@ function ThreadNavigationSidebarPane(
342364 settledShelfExpanded,
343365 selectedThreadKey : props . selectedThreadKey ?? null ,
344366 } ) ;
345- } ) ( ) ;
367+ } , [
368+ matchedThreadKeys ,
369+ now ,
370+ options . selectedEnvironmentId ,
371+ pendingOrder ,
372+ props . searchQuery ,
373+ props . selectedThreadKey ,
374+ queuedThreadKeys ,
375+ selectedProjectScope ,
376+ settledShelfExpanded ,
377+ settledVisibleCount ,
378+ settlementEnvironmentIds ,
379+ snoozeEnvironmentIds ,
380+ snoozedShelfExpanded ,
381+ threads ,
382+ workingShelfEnabled ,
383+ workingShelfExpanded ,
384+ ] ) ;
346385 const nextSnoozeWakeAt = threadListV2Layout . nextSnoozeWakeAt ;
347386 useEffect ( ( ) => {
348387 if ( nextSnoozeWakeAt === null ) return ;
@@ -358,7 +397,7 @@ function ThreadNavigationSidebarPane(
358397 // unchanged: after a clamped fire (wake beyond the 32-bit setTimeout
359398 // range) the boundary string is identical and the chain would die.
360399 } , [ nextSnoozeWakeAt , snoozeWakeTick ] ) ;
361- const listItems = ( ( ) : readonly SidebarListItem [ ] => {
400+ const listItems = useMemo ( ( ) : readonly SidebarListItem [ ] => {
362401 const v2SearchQuery = props . searchQuery . trim ( ) . toLocaleLowerCase ( ) ;
363402 const v2PendingTasks = pendingTasks . filter (
364403 ( pendingTask ) =>
@@ -397,7 +436,21 @@ function ThreadNavigationSidebarPane(
397436 } ) ;
398437 }
399438 return items ;
400- } ) ( ) ;
439+ } , [
440+ nowMinute ,
441+ options . selectedEnvironmentId ,
442+ pendingTasks ,
443+ props . searchQuery ,
444+ queuedThreadKeys ,
445+ threadMoveAvailability ,
446+ selectedProjectRefs ,
447+ settledShelfExpanded ,
448+ shelfPreferencesLoaded ,
449+ snoozedShelfExpanded ,
450+ snoozeEnvironmentIds ,
451+ threadListV2Layout ,
452+ workingShelfExpanded ,
453+ ] ) ;
401454 const listMenuActions = [
402455 {
403456 id : "environment" ,
0 commit comments