Repository navigation
Add <CodeDiff> component for embedding rendered diffs - #8
Merged
Merged
Conversation
<CodeDiff> wraps a ```diff fence (a real unified patch) and emits a data-slot="code-diff" marker around it. The component does no diff rendering itself — it only marks the region so the host (pin) can replace it with a full, syntax-highlighted diff view server-side, keeping the heavy lifting (and Shiki/chroma) out of the bundle and the output static. Distinct from the existing prose <Diff before/after> comparison. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
terraboops
approved these changes
Jul 6, 2026
terraboops
left a comment
Collaborator
There was a problem hiding this comment.
Verified against the host contract, not just in isolation: built this branch and compiled MDX through it — the emitted marker (<div data-slot="code-diff"><pre><code class="language-diff">…) matches pin's codeDiffRe (embed.go#L22-L25) in all three shapes I tested: bare, className passthrough, and mid-document. Patch content survives round-trip. pnpm test 16/16 green. After this merges + releases, pin just bumps bundle.version and embeds go live.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Context — what "code view" is for
These changes support two workflows:
What
A
<CodeDiff>component that wraps a ```diff fence (a real unified patch, e.g.gh pr diff) and emits a `data-slot="code-diff"` marker around it:→
<div data-slot="code-diff"><pre><code class="language-diff">…patch…</code></pre></div>Why this shape
The component does no diff rendering itself — it only marks the region. The host (pin) replaces the marker with a full, syntax-highlighted diff view server-side. That keeps the heavy lifting (and a Shiki/chroma-sized highlighter) out of the bundle, and the rendered output stays static. A plain ```diff fence without the wrapper is left as ordinary highlighted text.
Distinct from the existing prose
<Diff before=… after=…>comparison (which keepsdata-slot="diff").Scope
src/components/ui/code-diff.tsx— the componentsrc/components/index.tsx— exportsrc/components/manifest.ts— regenerated (now 30 components)pnpm test(16) andpnpm typecheckpass; bundle builds.Companion
Host side: bitcomplete/pin
matts/diff-embedadds the post-process that rendersdata-slot="code-diff"regions. After this releases, bump pin'sbundle.versionto pick up the component.🤖 Generated with Claude Code