refactor(desktop): port v2 DiffPane to @pierre/diffs CodeView
Merged
KI
6mo ago+1007+1007+0123456789012345678901234567890123456789-871-871-012345678901234567890123456789
Summary
- Upgrade
@pierre/diffsto 1.2.2 and replace the customVirtualizer+ DOM-querying scroll glue (ScrollToFile/findLineElement/data-diff-pathselectors) with the newCodeViewAPI.scrollTo({ type: "line", side })now drives jump-to-comment, including LEFT vs RIGHT side disambiguation so a deletion-side comment lands on the deletion line. - Split per-file
useDiffAnnotationsinto a singleuseDiffAnnotationsByPathquery soCodeViewcan render every file's annotations from one source. - Delete
DiffFileEntry/WorkspaceDiff/useInViewand theexpandedFileslazy-load plumbing —CodeViewhandles virtualization itself.
DiffFocusSide is threaded from the comments list (CommentsSection → useReviewTab → WorkspaceSidebar) through openDiffPane into DiffPaneData.focusSide, then consumed by the scroll effect.
Test plan
- Open a workspace with a PR. Click a review comment in the sidebar Review tab — diff opens and scrolls to the commented line; LEFT comments land on the deletion side, RIGHT comments on the addition side.
- Click the same comment again — diff re-scrolls (focus tick bumps).
- "Open in new diff tab" from a comment row works.
- Toggle "Show comments in diff" off — comment annotations disappear; re-enable and they come back.
- Toggle "Expand unchanged lines" in the per-file header.
- Collapse / re-expand a file via the header; mark viewed; discard unstaged changes via the menu.
- Open a workspace with no PR — no stale annotations leak through.
- Renamed file: comment anchored on the old path still surfaces in the diff.
Summary by cubic
Ported the v2 DiffPane to @pierre/diffs CodeView for simpler rendering, side-aware jump-to-comment, and built-in virtualization with sticky headers. Added header slots, caps for huge files, a pane-wide persisted expand-unchanged toggle, small a11y fixes, and a follow-ups plan for gutter utility and line selection.
-
Refactors
- Upgraded
@pierre/diffsto1.2.2and replaced the custom Virtualizer + DOM querying withCodeView. - Added
useDiffCodeViewItems,useDiffCodeViewScroll, anduseDiffCodeViewTheme; consolidated annotations intouseDiffAnnotationsByPathwith rename support. - Introduced
DiffHeaderPrefixandDiffHeaderMetadata;CodeViewnow handles virtualization and sticky headers. - Threaded
DiffFocusSidefrom comments to diff;scrollTo({ type: "line", side })lands on the correct side. - Capped
tokenizeMaxLineLength,tokenizeMaxLength, andmaxLineDiffLength; removed redundantCodeViewconfig and deletedDiffFileEntry,WorkspaceDiff,useInView, andexpandedFilesplumbing. - Moved “Expand unchanged” to the pane header via
DiffPaneHeaderExtrasand persisted it asuseSettings.expandUnchanged; revealed Discard on focus and made loading/error text copyable.
- Upgraded
-
Migration
onOpenInDiff(path, line?, openInNewTab?, side?)now takesside?: DiffFocusSide.DiffPaneDataaddsfocusSideand removesexpandedFiles.
Summary by CodeRabbit
-
New Features
- Review comments can now open diffs focused on the correct side (additions or deletions).
- New "Show unchanged regions" toggle and preference to control whether unchanged lines are expanded.
-
Improvements
- Redesigned diff viewer for smoother scrolling, faster rendering, and more reliable file-focused navigation.
- Enhanced per-file header controls: viewed flag, expand/collapse toggle, copy-path and discard actions.
-
Documentation
- Added follow-up notes outlining future diff-pane enhancements and QA items.