Repository navigation
refactor(sidebar): split WorktreeList into a worktree-list module - #14465
Conversation
WorktreeList.tsx was 6.8k lines behind an `eslint-disable max-lines`. Break it into `sidebar/worktree-list/`: the container keeps store wiring and composition, the virtualized viewport keeps layout, and the drag, reveal, virtualization, row-model, and row-render concerns each get their own file. Every file now fits the oxlint budget, so the suppression and its baseline entry are gone. Behaviour-preserving. The only deliberate cleanups are duplicate branches folded into shared helpers (drop-preview state updates, status-hover fallback, the two identical scroll-to-index reveal branches) and a dead sticky-header-index ref. Tests that asserted on WorktreeList.tsx source text or imported its named helpers now point at the module that owns them.
….tsx # Conflicts: # src/renderer/src/components/sidebar/WorktreeList.tsx # src/renderer/src/components/sidebar/worktree-list-imported-rows.test.ts
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (81)
📝 WalkthroughWalkthroughThe worktree sidebar was decomposed into focused modules for row rendering, state derivation, virtualization, reveal handling, keyboard navigation, and drag-and-drop. New hooks and components manage filters, grouping, host visibility, dialogs, workspace status, external worktrees, selection, scrolling, and active-row accessibility. Tests now reference the extracted modules directly, and the former ✨ Finishing Touches 💡 2⚔️ Resolve merge conflicts 💡
🛠️ Fix failing CI checks 💡
📝 Generate docstrings
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Follow-up to #14465 / #14467. Keep the landed extract and reorganize the flat worktree-list dump into drag/, headers/, reveal/, rows/, scroll/, and viewport/. Fold tiny modules into their owners, move leftover sidebar-root files into the module, and retarget imports and source-path tests. Layout-only; no behavior change.
* refactor(sidebar): group worktree-list files by domain Follow-up to #14465 / #14467. Keep the landed extract and reorganize the flat worktree-list dump into drag/, headers/, reveal/, rows/, scroll/, and viewport/. Fold tiny modules into their owners, move leftover sidebar-root files into the module, and retarget imports and source-path tests. Layout-only; no behavior change. * fix(sidebar): merge duplicate virtual-rows imports Inlining virtual-row-dom-attributes left a second import from the same module, which fails audit:code-quality:native --deny-warnings. * refactor(sidebar): condense indentation comments Shorten explanations to focus on the essential why, removing redundant detail and improving readability without changing functionality. * refactor: organize worktree-list into lifecycle dest folders * fix react doctor * fix: update reliability-gates path after worktree-list reorg host-filtering.test.ts moved from viewport/ to listing/; keep the runtime-routing.active-server-preference gate pointing at the real file. * Extract workspace status colors to design tokens Define theme-aware color tokens for workspace PR-state indicators (done, in-review, in-progress) to ensure consistent identity across theme switches. Update references to use the new tokens and refactor EmptyState button to use the Button component. * fix(sidebar): stop mutating refs during worktree-list render React Doctor fails static analysis when refs are written in render. Commit reused array identity and the Smart live-signal latch after paint, and return the attention map from the sort memo instead of stashing it on a render-time ref.
* refactor(sidebar): group worktree-list files by domain Follow-up to #14465 / #14467. Keep the landed extract and reorganize the flat worktree-list dump into drag/, headers/, reveal/, rows/, scroll/, and viewport/. Fold tiny modules into their owners, move leftover sidebar-root files into the module, and retarget imports and source-path tests. Layout-only; no behavior change. * fix(sidebar): merge duplicate virtual-rows imports Inlining virtual-row-dom-attributes left a second import from the same module, which fails audit:code-quality:native --deny-warnings. * refactor(sidebar): condense indentation comments Shorten explanations to focus on the essential why, removing redundant detail and improving readability without changing functionality. * refactor: organize worktree-list into lifecycle dest folders * fix react doctor * fix: update reliability-gates path after worktree-list reorg host-filtering.test.ts moved from viewport/ to listing/; keep the runtime-routing.active-server-preference gate pointing at the real file. * Extract workspace status colors to design tokens Define theme-aware color tokens for workspace PR-state indicators (done, in-review, in-progress) to ensure consistent identity across theme switches. Update references to use the new tokens and refactor EmptyState button to use the Button component. * fix(sidebar): stop mutating refs during worktree-list render React Doctor fails static analysis when refs are written in render. Commit reused array identity and the Smart live-signal latch after paint, and return the attention map from the sort memo instead of stashing it on a render-time ref.
…ablyai#14465) WorktreeList.tsx was 6.8k lines behind an `eslint-disable max-lines`. Break it into `sidebar/worktree-list/`: the container keeps store wiring and composition, the virtualized viewport keeps layout, and the drag, reveal, virtualization, row-model, and row-render concerns each get their own file. Every file now fits the oxlint budget, so the suppression and its baseline entry are gone. Behaviour-preserving. The only deliberate cleanups are duplicate branches folded into shared helpers (drop-preview state updates, status-hover fallback, the two identical scroll-to-index reveal branches) and a dead sticky-header-index ref. Tests that asserted on WorktreeList.tsx source text or imported its named helpers now point at the module that owns them.
* refactor(sidebar): group worktree-list files by domain Follow-up to stablyai#14465 / stablyai#14467. Keep the landed extract and reorganize the flat worktree-list dump into drag/, headers/, reveal/, rows/, scroll/, and viewport/. Fold tiny modules into their owners, move leftover sidebar-root files into the module, and retarget imports and source-path tests. Layout-only; no behavior change. * fix(sidebar): merge duplicate virtual-rows imports Inlining virtual-row-dom-attributes left a second import from the same module, which fails audit:code-quality:native --deny-warnings. * refactor(sidebar): condense indentation comments Shorten explanations to focus on the essential why, removing redundant detail and improving readability without changing functionality. * refactor: organize worktree-list into lifecycle dest folders * fix react doctor * fix: update reliability-gates path after worktree-list reorg host-filtering.test.ts moved from viewport/ to listing/; keep the runtime-routing.active-server-preference gate pointing at the real file. * Extract workspace status colors to design tokens Define theme-aware color tokens for workspace PR-state indicators (done, in-review, in-progress) to ensure consistent identity across theme switches. Update references to use the new tokens and refactor EmptyState button to use the Button component. * fix(sidebar): stop mutating refs during worktree-list render React Doctor fails static analysis when refs are written in render. Commit reused array identity and the Smart live-signal latch after paint, and return the attention map from the sort memo instead of stashing it on a render-time ref.
Why
src/renderer/src/components/sidebar/WorktreeList.tsxwas 6,863 lines sitting behind a file-level/* eslint-disable max-lines */— 17x the 400-line.tsxbudget, and one of the largest grandfathered entries inconfig/max-lines-baseline.txt. It held two mega-components (VirtualizedWorktreeViewportat ~3,900 lines andWorktreeListat ~1,650) plus ~40 top-level helpers.What
Everything moves into a nested
sidebar/worktree-list/module (70 files, all within the oxlint budget). No barrel files — every import points at the module that owns the symbol.Container —
WorktreeList.tsx(343 lines) now only does store wiring + hook composition:use-sidebar-worktree-sort-order·use-sidebar-worktree-filters·use-visible-sidebar-worktrees·use-sidebar-host-visible-scope·use-sidebar-section-rows·use-sidebar-worktree-selection·use-worktree-status-mutations·use-sidebar-external-worktree-cards·use-project-group-dialogs·use-effective-collapsed-groups·use-agent-send-target-worktree·use-sidebar-reveal-requestsViewport —
VirtualizedWorktreeViewport.tsxcomposes:use-worktree-list-virtualizer,use-virtual-row-measurement-syncuse-worktree-sidebar-scroll-suppression,use-group-toggle-with-scroll-anchoruse-sidebar-reveal-highlight,use-pending-sidebar-revealuse-worktree-drag-session(geometry),use-worktree-drag-runtime(state/teardown),use-worktree-pointer-drag,use-worktree-native-drag,use-worktree-document-drop,use-workspace-status-row-drag,use-worktree-lineage-drop-commit, plus the imperative commit routinesuse-worktree-sidebar-header-dragRow rendering — a
worktree-virtual-row-dispatchper row type, withworktree-section-header-row,worktree-list-item-row,folder-workspace-virtual-row,worktree-notice-virtual-rows,HostSectionHeader,FolderPathStatusIndicator, and the header action menus split out.The
eslint-disable max-linesand itsconfig/max-lines-baseline.txtentry are removed (ratchet: 344 → 343).Behaviour
Behaviour-preserving. The only deliberate changes are duplicate branches folded into shared helpers:
clearWorktreeDropPreview/applyWorktreeDropPreviewreplace 12 hand-inlinedsetWorktreeDragStatecomparison blocksshowStatusHoverWithoutInsertionLinehelper replaces the two byte-identical status-fallback branches in the pointer-drag flushscrollToIndex+ retry branches in the worktree reveal effect collapse into onecommitStatusOrPinDropreplaces the two identical pin/status commit blocksstickyHeaderIndexesRefthat was written but never readTwo identity-stability points were preserved deliberately, since the extraction could have broken them:
useWorktreeDragSession/useWorktreeDragRuntimememoise their return objects (a fresh object would have defeatedWorktreeCard'sReact.memoviaonCardDragStart— caught byWorktreeList.card-memo-stability.test.tsx), andsetScrollRootRefdepends on individual stable callbacks rather than the hook objects (a changing callback ref is re-invoked withnullevery render, which would have torn down an in-flight drag).Tests
Tests that asserted on
WorktreeList.tsxsource text or imported its named helpers now point at the module that owns them — no assertions were weakened.Verification
pnpm run typecheck(node + cli + web) — cleanpnpm run lint(oxlint, code-quality native + type-aware, reliability gates, max-lines ratchet, localization) — cleanoxlint --config config/oxlint-react-doctor.json— no new warnings (the oneno-adjust-state-on-prop-changewarning is pre-existing, just relocated)pnpm test— 51,772 passed / 117 skipped. One unrelated flake insrc/shared/remote-runtime-shared-control-connection.test.tsunder full-suite load; passes in isolation.card-memo-stability,lineage-child-real-card,lineage-agent-expansion-coupling,status-lane-lineage-drop).