Skip to content

Migrate diff viewer to @pierre/diffs CodeView (render any diff at scale)#17

Merged
mblode merged 5 commits into
mainfrom
claude/rendering-diffs-scale-v0cqK
May 29, 2026
Merged

Migrate diff viewer to @pierre/diffs CodeView (render any diff at scale)#17
mblode merged 5 commits into
mainfrom
claude/rendering-diffs-scale-v0cqK

Conversation

@mblode

@mblode mblode commented May 29, 2026

Copy link
Copy Markdown
Owner

Goal

Migrate the CLI diff viewer (apps/cli) from the per-file PatchDiff architecture to the new virtualization-first CodeView component from @pierre/diffs, following Pierre's "On Rendering Diffs" post. Target: render an entire change set (thousands of files / 1M+ lines) in one virtualized surface, like the DiffsHub playground.

Why a package upgrade is required

CodeView does not exist in the previously pinned @pierre/diffs@1.1.15 — it ships in 1.2.x. This PR bumps to 1.2.4 as the first step.

What changes

  • One <CodeView> for the whole diff instead of a per-file PatchDiff loop. Each file becomes a CodeViewDiffItem whose fileDiff is built client-side via parsePatchFiles(patch).
  • Removes the hand-rolled scale layer that CodeView now owns natively: useScrollAnchor, min-height ResizeObserver pinning, IntersectionObserver active-file tracking, and the deferred-render/placeholder system.
  • Comments preserved via renderAnnotation + renderGutterUtility (per-item annotations, metadata not data).
  • Settings parity with the playground: split/unified (diffStyle), line numbers (disableLineNumbers), word wrap (overflow), backgrounds (disableBackground), indicator style (diffIndicators), light/dark theming + unsafeCSS.
  • Sidebar navigation, collapse/expand, keyboard shortcuts, file watching/polling, whitespace + diff-mode filtering all retained; scroll/active-file now driven by the CodeViewHandle (scrollTo) and onScroll.
  • apps/cli/AGENTS.md and tests updated for the new architecture.

Status

🚧 Draft — dependency bump landed; the viewer rewrite, rewiring, and test updates are being implemented and will be pushed to this branch. Verified via check-types + lint + test (no heavy next build in CI here). Browser UX not yet manually verified.

https://claude.ai/code/session_01JHfEZvA73s1KmXxC99tnQE


Generated by Claude Code

CodeView (the virtualization-first review surface) is only available in
@pierre/diffs 1.2.x. Bump from 1.1.15 to 1.2.4 as the first step of
migrating the diff viewer onto CodeView.

https://claude.ai/code/session_01JHfEZvA73s1KmXxC99tnQE
@vercel

vercel Bot commented May 29, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
diffhub-web Ready Ready Preview, Comment May 29, 2026 10:55pm

Request Review

Render the entire change set in a single virtualization-first <CodeView>
instead of a per-file PatchDiff loop. Each file becomes a controlled
CodeViewDiffItem whose fileDiff is parsed client-side via parsePatchFiles,
ordered by sortFilesAsTree. Comments and the inline comment input ride as
per-item annotations through renderAnnotation; the gutter '+' via
renderGutterUtility; the custom FileDiffHeader via renderCustomHeader.

CodeView now owns virtualization, scroll anchoring, element pooling,
DOM-height management and the worker pool, so the hand-rolled scale layer
is removed: useScrollAnchor, the min-height ResizeObserver pin, the
IntersectionObserver active-file tracking, and the deferred/forceRender
placeholder system. Scroll-to-file is imperative via a DiffViewerHandle;
active-file is derived from onScroll + getRenderedItems().

Tests and AGENTS.md updated for the new architecture.

https://claude.ai/code/session_01JHfEZvA73s1KmXxC99tnQE
Add a settings popover (backgrounds, line numbers, word wrap, indicator
style) and a theme picker (Auto/Light/Dark mode plus a selectable catalog
of all diff themes: the 4 pierre themes and 65 bundled Shiki themes) to the
StatusBar toolbar. Settings and theme selection persist to localStorage and
feed the shared CodeView options.

Lean further on CodeView: set expandUnchanged so unchanged context renders
fully instead of collapsing into 'N unmodified lines' banners.

Build the popover/dropdown surfaces on @base-ui/react primitives matching
the existing shadcn (ui.blode.co) style: new ui/popover, ui/dropdown-menu,
and ui/context-menu components. The blode registry is network-gated in this
environment, so these are authored locally against the same primitive the
registry uses and can be re-synced later.

https://claude.ai/code/session_01JHfEZvA73s1KmXxC99tnQE
Restructure the theme popover to match the reference UX: a root view with
mode (Auto/Light/Dark) plus 'Light theme' and 'Dark theme' rows that drill
into scrollable theme lists with a back button, instead of one flat list.
View resets to root when the popover closes.

https://claude.ai/code/session_01JHfEZvA73s1KmXxC99tnQE
@mblode mblode marked this pull request as ready for review May 29, 2026 23:29
@mblode mblode merged commit 975bef7 into main May 29, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants