Repository navigation
Done
Description
Area
apps/web
Steps to reproduce
- Run T3 Code with a workspace that has many mounted active/pinned/expanded sidebar threads (e.g. 50 to 200+ rows), multiple threads with large linked PR stacks (14 to 20+ PRs), and several draft sessions.
- Hover sweep: Move the pointer rapidly across multiple sidebar thread cards and PR badges.
- New Thread: Click "New Thread" from an active server thread (especially when
defaultThreadEnvModeis unset /nullandt3.jsonis cold or revalidating, or with multiple draft sessions present). - Navigation: Click or keyboard-navigate between sidebar rows in a large thread list.
- Settle and advance: Settle the active thread (via button, keyboard shortcut, or drag-to-settle) so the app advances to the next eligible thread or a new draft.
Expected behavior
- Sweeping the pointer across sidebar rows should cancel superseded hover targets instead of queuing lag or detaching the active popup from the pointer.
- Clicking "New Thread" should transition promptly without O(rows x drafts) selector scans, full-list geometry reads on pure route changes, or cold
t3.jsonRPC stalls. - Switching focus across rows in a large sidebar should remain responsive without full-DOM scans on each
focusin. - Settling an eligible idle thread (where an optimistic settlement overlay is already applied) should advance immediately instead of blocking on the full
thread.settleserver RPC round-trip.
Actual behavior
Static inspection of main at c89ca0a2f2 (including locked @base-ui/[email protected]) identified four bottlenecks behind noticeable UI sluggishness in daily use. All file and line citations below are verified from source at c89ca0a2f2; per-frame Chromium runtime attribution is still pending a production trace.
1. Rapid sidebar hover / PR flyout lag (not fully covered by #39971)
- 0 ms instant-open across adjacent rows: Both the main sidebar list (
apps/web/src/components/Sidebar.tsx:3449-3454) and search results (Sidebar.tsx:3314-3319) use<TooltipProvider delay={150} closeDelay={0} timeout={400}>. Once any tooltip in the group opens, Base UI'sFloatingDelayGroupputs subsequent sibling hovers into 0 ms instant-open mode (timeout={400}), so fast pointer sweeps across rich thread cards can open each crossed row's popup synchronously without a target-change dwell. - Unbounded visible-PR rendering and repeated chain derivation:
ThreadPullRequestsMiniList(apps/web/src/components/ThreadStatusIndicators.tsx:492-560) renders every visible linked PR (after filteringstack-dismissedtombstones viavisibleThreadPullRequests) with no item cap. (fix(web): sidebar thread hover card stays within the window with many PRs #39971 caps the row hover card to 5 lines, which helps height, but leaves repeated pre-filter derivation and instant-open sweep behavior unaddressed.)visibleThreadPullRequests(packages/shared/src/threadPullRequests.ts:4-8) allocates a fresh filtered array on every call, so multi-PR threads repeatedly filter, derive chains, and sort acrossuseLinkedThreadPullRequest,resolveThreadPullRequestBadge, andThreadPullRequestsMiniList(packages/source-control-core/src/shared/threadPullRequests.ts:151, 193, 290, 369). - Outer tooltip work on closed rows: While
TooltipPortalkeeps popup DOM descendants unmounted when closed,SidebarThreadTooltip(apps/web/src/components/sidebar/SidebarThreadRow.tsx:256-404) still executes its hooks and JSX construction on closed-row renders, and each row mounts multiple Base UI<Tooltip>roots (SidebarThreadRow.tsx:872-888, 1327, 1514, 1533, 1729;ThreadStatusIndicators.tsx:476). Extendingapps/web/src/components/ui/shared-tooltip.tsxwith a cancellable target-change dwell timer and lazy body render would avoid mounting/computing superseded hover cards during rapid sweeps.
2. Slow "New Thread" (1 to 2 seconds; partially overlaps #21479)
- O(mounted rows x draft sessions) Zustand selector scan: Every mounted
SidebarThreadRowsubscribes touseThreadHasUnsentDraft(threadRef)(SidebarThreadRow.tsx:735), callinggetComposerDraftState->resolveComposerDraftKey(apps/web/src/composerDraftStore.ts:1609-1634, 1668-1677, 4749-4753). Whenever a server thread has no directstate.draftsByThreadKey[scopedKey]entry (the common case),resolveComposerDraftKeyenumeratesObject.entries(state.draftThreadsByThreadKey)to matchenvironmentIdandthreadId(composerDraftStore.ts:1622-1629). Each draft-store notification runs this O(rows x drafts) scan synchronously across all mounted rows even when every selector returnsfalseand React renders zero rows. AWeakMap<Record<string, DraftThreadState>, ReadonlyMap<string, string>>keyed onstate.draftThreadsByThreadKeymakes this O(1) per row. - Conditional pre-navigation
readT3ProjectFileawait: On the direct draft path (apps/web/src/hooks/useHandleNewThread.ts:202-234, 281-373, 408-460,t3ProjectFileDefaults.ts:11-28), whendefaultThreadEnvMode === null,resolveDefaultEnvMode()awaitsreadT3ProjectFile(projectCommands.ts:103-107,staleTimeMs: 30_000,idleTtlMs: 5 min). perf(web): paint new-thread drafts from cached state #21479 addresses the landing page, but explicitly leaves other New Thread entry points on the blocking defaults flow. - Full-list geometry reads on draft route change:
listMotionLayoutKeyincludesrouteDraftIdForRows(Sidebar.tsx:2040-2063). Changing it triggersuseLayoutEffect->shiftGuardRef.current.update()(Sidebar.shiftGuard.ts:23-29, 110-126, readingoffsetTopon every direct<ul>child) andlistMotionRef.current.update(...)(Sidebar.motion.ts:127-147, readingoffsetTop/offsetLeft/offsetWidth/offsetHeighton every eligible direct child). KeyinglistMotionLayoutKeyon actual ordered rendered draft row IDs avoids full-list scans on pure route changes. - Server-to-draft
ChatViewunmount/remount: Switching between server threads keepsChatViewmounted, whereas navigating from a server thread to a new draft renders<ChatView key={target.draftId} ... routeKind="draft" />(apps/web/src/components/ThreadRouteView.tsx:77-96, 169-225), unmounting and remountingChatView(preservinghandoffKeypromotion continuity needs care if unified).
3. General sidebar navigation slowdown with large thread counts (related to #39933, #39934, #40893)
- O(N) DOM query and filter on every row
focusin: Inapps/web/src/lib/sidebarTree.ts:19-26, 72-80,onFocusruns on everyfocusinthat resolves to a sidebar row and callsvisibleRows().indexOf(row), runningroot.querySelectorAll("[data-sidebar-row]")plus.closest('[hidden], [inert], [aria-hidden="true"]')and.matches(":disabled")across every mounted row to savefocusedIndex. - Route-dependent subscriptions in
Sidebar:SidebarcallsuseHandleNewThread()(Sidebar.tsx:1004, 1014-1020,useHandleNewThread.ts:496-538), subscribing the sidebar shell to route target, active thread shell, and draft store state even though only the New Thread click handler needs them.
4. Slow settle-and-advance (2 to 5 seconds; tracked by open PR #27309)
- Both
attemptSettle(Sidebar.tsx:1654-1683, used by click, keyboard shortcut viauseThreadLifecycle.tsx:710-720, multi-select atSidebar.tsx:2521, and sweep at:1884-1888) and drag-to-settle (Sidebar.tsx:2214-2234) awaitsettleThread(threadRef)before callingnavigateAfterSettle?.(), even thoughthreadEnvironment.settle(packages/client-runtime/src/state/threadCommands.ts:535-552) already applies an optimistic settlement overlay immediately for eligible idle threads. When no eligible next card exists in the ordered list, advancing callshandleNewThread(Sidebar.tsx:1642), compounding directly into Add open-in-editor feature with Cmd+O shortcut #2. - Open PR fix(web): settling the open thread advances immediately #27309 already proposes advancing immediately on settle/snooze.
Related issues and PRs
- Open PRs covering parts of this: fix(web): settling the open thread advances immediately #27309 (immediate settle-advance), perf(web): paint new-thread drafts from cached state #21479 (cached landing new-thread draft), fix(web): sidebar thread hover card stays within the window with many PRs #39971 (cap PR rows in sidebar hover card).
- Related open sidebar performance issues: Opening the web app with 300 sidebar threads on Windows re-renders every row twice more because provider model arrays are compared by identity (about 640 ms of main-thread work) #39933, Every sidebar thread row re-renders twice on load on Windows because row hooks subscribe to the whole server-config map for one boolean (about 430 ms at 300 threads) #39934, [Bug] Sidebar fetches details for every linked issue at startup, triggering slow-request warnings #40893.
Impact
Major degradation or frequent failure
Version or commit
main @ c89ca0a
Environment
Windows 11, T3 Code desktop / web client (pingdotgg/t3code main at c89ca0a2f2)
Workaround
None for hover lag or settle-advance blocking; keeping active/expanded sidebar thread counts and draft counts low reduces #2 and #3.
Metadata
Metadata
Assignees
Labels
No labels
Activity
royalaid commentedon Nov 22, 2026
Opened PR #41102 (
perf(web): fix sidebar hover lag, slow New Thread, and settle navigation wait) with fixes and regression tests for all four symptoms reported here:<SharedTooltipProvider>with cancellable open/switch dwell, scroll dismissal via<TooltipScrollDismissArea>,WeakMap-cached PR stack derivation inthreadPullRequests.ts, and an 8-item hover preview cap with+N moreexpansion.WeakMapreverse index for draft sessions incomposerDraftStore.ts, prefetchedt3.jsonwith a synchronous fast path for fresh/optimistic reads (and explicit refresh/retry on stale or failed prefetches), and click-time New Thread context resolution.sidebarTree.tswith structural-only invalidation (zero DOM scans on non-row content updates while preserving focus restoration on row removal and inline rename dismissal).Validated locally with
vp check(0 errors), 3-package typecheck, React Compiler coverage, 187 targeted unit + Chromium browser tests, and a live parallel T3 Code instance against an isolated snapshot of a 1,177-thread database.juliusmarminge commentedon Dec 1, 2026
#46827, now on main: Repeated sidebar and hover-preview PR chain derivation and sorting now reuse cached results for unchanged linked-PR arrays, including arrays containing dismissed stack links.
Not done: The issue also asks for cancellable hover dwell and lazy tooltip work, faster New Thread creation, fewer sidebar focus and layout scans, and immediate settle-and-advance; this merge does not implement those changes.
Closing; open a new issue if what is left still matters to you.