Skip to content

feat(PLA-105): Vendor chapter UI components from Stage monorepo#6

Merged
dastratakos merged 6 commits into
mainfrom
dastratakos/pla-105-vendor-chapter-ui-components
Apr 28, 2026
Merged

feat(PLA-105): Vendor chapter UI components from Stage monorepo#6
dastratakos merged 6 commits into
mainfrom
dastratakos/pla-105-vendor-chapter-ui-components

Conversation

@dastratakos

@dastratakos dastratakos commented Apr 28, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Vendors the four chapter rendering components (pierre-diff-viewer, hunk-highlight-overlay, file-header, text-selection-popup) from the Stage monorepo into web/src/components/chapter/, replacing useChapterContext/useFocusedLines with explicit prop callbacks (PLA-105).
  • Inlines the supporting types and helpers from @stage/types and @stage/ui (diff-types.ts, file-status.ts, use-is-mac.ts) and adds shadcn-vendored Checkbox / Tooltip primitives so nothing imports from monorepo paths or oRPC.
  • Adds @pierre/diffs, @radix-ui/react-checkbox, and @radix-ui/react-tooltip to package.json, simplifies pierre-diff-viewer to a render-layer-only component (no comment form, no diff-settings/theme contexts), and stubs text-selection-popup as a no-op for V1.
  • Replaces the placeholder App.tsx with a hand-crafted fixture that supplies key-change line refs and viewed/focus state via useState, exercising the chapter components end-to-end.

Test plan

  • npx tsc --noEmit -p web/tsconfig.json — clean
  • npm run lint — clean
  • npm run build and npm run build:web — succeed
  • npm test — 12/12 pass
  • npm run dev:web and load http://localhost:5173 — fixture renders with diff, key-change highlight, and viewed-state checkbox

🤖 Generated with Claude Code


Open in Stage

Copies the diff-rendering components needed for chapter playback into
web/src/components/chapter/, replacing the monorepo's useChapterContext
/ useFocusedLines coupling with explicit prop callbacks. text-selection-
popup is a no-op stub for V1, and pierre-diff-viewer drops the comment-
form/oRPC plumbing per PLA-105.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a new "Chapter" UI module for code diff visualization, featuring a PierreDiffViewer that wraps @pierre/diffs and includes an interactive LineHighlightOverlay for highlighting key changes. It also adds a FileHeader component, UI primitives for checkboxes and tooltips, and various utilities for theme detection and DOM line targeting. Feedback focuses on moving runtime libraries to the main dependencies list, fixing a potential bug where referential equality on LineRef objects could cause UI flickering, removing dead code related to hover logic, and correcting a hydration mismatch in the useIsMac hook.

Comment thread package.json
Comment thread web/src/components/chapter/hunk-highlight-overlay.tsx Outdated
Comment thread web/src/components/chapter/pierre-diff-viewer.tsx Outdated
Comment thread web/src/lib/use-is-mac.ts Outdated
Comment thread web/src/App.tsx
* Match prior overlay measurements by LineRef coordinates instead of
  object identity, so parents that recreate refs across renders don't
  flicker the highlight boxes.
* Drop the dead isHoveringRef guard from pierre-diff-viewer since the
  hover utility is disabled.
* Default useIsMac SSR snapshot to false to avoid a hydration mismatch
  on non-Mac systems.
* Fix the fixture patch hunk header so its line counts match the body.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Comment thread web/src/components/chapter/hunk-highlight-overlay.tsx
Comment thread web/src/components/chapter/hunk-highlight-overlay.tsx
Comment thread web/src/components/chapter/file-header.tsx
Comment thread web/src/components/chapter/rendered-line-target.ts
Comment thread web/src/components/chapter/pierre-diff-viewer.tsx Outdated
The LineHighlightOverlay references --hunk-highlight-bg / -border /
-focused-bg / -focused-border for its key-change boxes, and FileHeader
sticks via --content-top. Define defaults in :root so the overlay is
visible and the file header sticks correctly out of the box.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Comment thread web/src/components/chapter/pierre-diff-viewer.tsx
When a leading or trailing hunk has additionCount === 0 (fully-deleted
files, pure deletion hunks) the previous math returned an inverted
range whose end preceded its start. Return null instead so consumers
like getKeyChangeFileLineRange skip the file rather than producing an
invalid SelectedLineRange.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@dastratakos dastratakos requested a review from charleslpan April 28, 2026 04:56
@dastratakos dastratakos changed the title Vendor chapter UI components from Stage monorepo (PLA-105) feat (PLA-105): Vendor chapter UI components from Stage monorepo Apr 28, 2026
@dastratakos dastratakos changed the title feat (PLA-105): Vendor chapter UI components from Stage monorepo feat(PLA-105): Vendor chapter UI components from Stage monorepo Apr 28, 2026
@dastratakos dastratakos marked this pull request as ready for review April 28, 2026 04:56
Flip the key-change props on PierreDiffViewer and LineHighlightOverlay
from a Set + toggle callback to predicate + mark/unmark, matching the
useViewState API spec'd for PLA-106 so the hook wires up directly. Drop
onLineSelected — V1 has no comment plumbing to consume the selection.

Vendor useLocalStorage / useDiffSettings / syntax-themes from the Stage
monorepo and consume the settings hook from PierreDiffViewer so users
can toggle viewMode, indicators, line-diff type, backgrounds, wrap,
line numbers, and syntax theme; preferences persist in localStorage.
The fixture App.tsx is wrapped with DiffSettingsProvider.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 92f37db. Configure here.

Comment thread web/src/lib/syntax-themes.ts
Vendored verbatim from the Stage monorepo, which uses tabs; reformat
to match the rest of web/src so Biome doesn't drift on the next format.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@dastratakos dastratakos merged commit 8a7106b into main Apr 28, 2026
3 checks passed
@dastratakos dastratakos deleted the dastratakos/pla-105-vendor-chapter-ui-components branch May 4, 2026 05:09
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