Repository navigation
Conversation
A rename, or a push from another thread's turn, re-rendered every mounted sidebar row: each row subscribed to whole-sidebar collections, and the thread-list model rebuilt every node, so memo(ThreadRow) never held. - Replace the sidebar entries Map context with a per-QueryClient store fed by the query cache, with per-thread useSyncExternalStore subscriptions. - Cache sidebar thread DTOs on their derived host name and display title, not on the identity of the resources objects. - Reuse unchanged thread-list tree nodes, items and groups across rebuilds. - Resolve the row selection menu, project names, collapsed ids and the split-drag label without subscribing every row to the whole sidebar. - Read title-mention resources only for titles that can contain mentions. - Keep DnD item id arrays and sectionDnd stable while their contents are unchanged; while idle, a reorder keeps the sortable order until a drag starts (the pinned order, which drives rendering, always updates). Co-Authored-By: Claude Opus 5.5 <[email protected]>
The DnD item-id sharing kept a module-level Map keyed by container id, and section-group reuse a module-level Map keyed by section key. Both were written during render and shared by every mounted list. The item ids now live in the hook's own state; section groups are keyed by their first item in a WeakMap. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
ymichael
force-pushed
the
bb/fix-ask-user-question-typing-lag-with-many-threa-thr_fhvv59u7d7
branch
from
November 16, 2026 21:36
0cbd3b2 to
e788be7
Compare
ymichael
deleted the
bb/fix-ask-user-question-typing-lag-with-many-threa-thr_fhvv59u7d7
branch
November 16, 2026 22:02
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Human comments
What was wrong
A change to one thread re-rendered every mounted sidebar row, along with each row's context-menu, dropdown and tooltip subtree. Rows subscribed to whole-sidebar collections:
Mapcontext;SidebarProjectsContext, used for a project-name lookup;useThreadSelectionMenu→useSidebarData();threadById).On top of that,
useSidebarThreadsrebuilt every thread DTO whenever those resources changed, and the thread-list model rebuilt every tree node, DnD state object and sortable id array, somemo(ThreadRow)never held. This came out of the Discord report of Ask User Question typing lag with ~500 threads. Typing in the question form did not reproduce (0 sidebar renders onmainand on v0.49.0); the sidebar fan-out the reporter's agent described did. Repro and numbers are in the issue draft in bb threadthr_fhvv59u7d7.What changed
apps/app/src/lib/sidebar-thread-entries.ts: the provider and context are gone. A per-QueryClient store reads the sidebar-navigation and archived caches, falling back to the cached bootstrap like the query'splaceholderData, and notifies only the thread ids whose entry changed.useSidebarThreadEntryis a keyeduseSyncExternalStore.useSidebarThreadActionsand split-drag mentions look entries up when they run, not during render.plugin-sidebar-hooks.ts: thread DTOs are cached on their entry plus the derived host name and display title.ThreadTitleMentions.tsx:ThreadTitleMentionsContentreads the resources with conditionaluse()only when the title can contain a mention. A stable getter context letsuseSidebarThreadSplitresolve the drag label when the drag starts.collapsedThreadIdsno longer depends onthreads;sectionDndandSortableContextids stay stable while unchanged.How you verified
Same 501-thread fixture on a
pnpm start:worktreeinstance,react-dom/profilingbuild, fiber-counting hook; 39 sidebar rows mounted.main*For a rename of a child thread, its parent row also re-renders, because it shows its children's rollup.
Tests:
PluginThreadList.row-isolation.test.tsxuses the real thread-list plugin with the app's title-mention resources. It checks that a thread update renders only that thread's row, that typing in a question form renders no row, and that a row still moves when its sort order changes while idle. The first check fails onmainwith 59 rows.sidebar-thread-entries.test.tsx: changing one entry re-renders only that entry's consumers; the cached bootstrap is read before the query has data.useSectionThreadDnd.projection.test.tsx: the pinned order follows a pin reorder while idle. This fails without the pinned exception.pnpm exec turbo run test typecheck lint --filter=bb-plugin-thread-list,turbo run typecheck lint --filter=@bb/app, and targeted@bb/appsidebar, plugin-title, overlay and title-mention tests pass.bb thread list) and the pinned order updated live.🤖 Generated with Claude Code