Skip to content

feat(git): render diffs with @pierre/diffs (diffs.com)#77

Merged
antfu merged 2 commits into
mainfrom
cyan-tires-argue
Jul 9, 2026
Merged

feat(git): render diffs with @pierre/diffs (diffs.com)#77
antfu merged 2 commits into
mainfrom
cyan-tires-argue

Conversation

@antfubot

@antfubot antfubot commented Jul 8, 2026

Copy link
Copy Markdown
Collaborator

What

Replaces the git plugin's hand-rolled patch renderer — a <pre> that colored whole lines by prefix (+/-/@@) with no syntax highlighting — with diffs.com (@pierre/diffs), a Shiki-based diff rendering library.

Why

The diff surface now gets real syntax highlighting, per-file headers, and a consistent presentation across both places a patch is shown:

  • the working-tree / staged Diff panel (single file), and
  • the commit details view (multi-file commit patch — previously just raw unified text).

Diffs are rendered with the unified layout and classic +/- indicators, using Shiki's vitesse-light / vitesse-dark themes to sit alongside the @antfu/design surfaces. The diff theme follows the app's light/dark toggle.

How

  • DiffPatchView parses the git patch with parsePatchFiles and renders each file with @pierre/diffs/react's FileDiff. Its public props are unchanged, so callers and stories needed no edits. The redundant filename bar in DiffPanelView is dropped since FileDiff renders its own per-file header.
  • A new useColorScheme() hook observes the .dark class on <html> so the Shiki theme stays in sync whenever the theme is toggled (in-app or via Storybook).
  • @pierre/diffs added to the frontend pnpm catalog and the plugin's devDependencies (the SPA is prebuilt into dist at publish time). Its transitive @pierre/theme@1.1.0 trips the repo's no-downgrade supply-chain policy (an earlier version carried provenance, this one doesn't), so it's added to the existing trustPolicyExclude list. The library uses Shiki's pure-JS regex engine, so no WASM is bundled.

Verification

  • eslint, typecheck, and the git plugin's tsdown + Next static-export build all pass
  • git plugin tests: 16/16 pass
  • Verified the parse-and-highlight path headlessly (a real multi-file git diff through parsePatchFilesFileDiff): each file parses, produces syntax-highlighted spans under the vitesse theme, and infers its language. A live browser pass wasn't possible in this ARM64 sandbox (no installable Chromium).

This PR was created with the help of an agent.

Replace the git plugin's line-prefix `<pre>` patch renderer with the
Shiki-based diffs.com library, giving syntax-highlighted, per-file diffs
in both the working-tree/staged diff panel and the multi-file commit
details view. The diff theme tracks the app's light/dark toggle.
@netlify

netlify Bot commented Jul 8, 2026

Copy link
Copy Markdown

Deploy Preview for devfra ready!

Name Link
🔨 Latest commit 171a200
🔍 Latest deploy log https://app.netlify.com/projects/devfra/deploys/6a4f250d51647d0008000a7c
😎 Deploy Preview https://deploy-preview-77--devfra.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

In commit details, each changed file now sits behind a disclosure header
(filename, change icon, +/- counts) that expands to its @pierre/diffs
patch, replacing the separate plain-text "N files changed" list. The
list is kept only as the static-build fallback, where no patch is baked.
@antfu antfu merged commit 990a736 into main Jul 9, 2026
6 of 12 checks passed
@antfu antfu deleted the cyan-tires-argue branch July 9, 2026 08:22
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