Skip to content

[design-doctor effort high] replacement clone of sourcebot#2: [design-doctor test] sourcebot-1154: Commit diff viewer#29

Draft
rohanneilkapoor wants to merge 15 commits into
bench/source-pr-base/design-doctor-feature-parity-expanded-20260610-152904Z/sourcebot-1154from
bench/design-doctor-effort-ab-20260617-171404/high/sourcebot-pr2-replacement-2
Draft

[design-doctor effort high] replacement clone of sourcebot#2: [design-doctor test] sourcebot-1154: Commit diff viewer#29
rohanneilkapoor wants to merge 15 commits into
bench/source-pr-base/design-doctor-feature-parity-expanded-20260610-152904Z/sourcebot-1154from
bench/design-doctor-effort-ab-20260617-171404/high/sourcebot-pr2-replacement-2

Conversation

@rohanneilkapoor

Copy link
Copy Markdown

Replacement Design Doctor reasoning-effort A/B clone for #2.

Variant: high.

This branch adds a no-op commit on top of the original PR head so the file contents are equivalent while GitHub checks stay isolated to this test PR.

Replaces contaminated setup PR: #26.

brendan-kellam and others added 15 commits April 28, 2026 10:32
Adds a `commit` pathType to the browse routes
(`/browse/<repo>@<branch>/-/commit/<sha>[/<file>]`) that renders a
placeholder CommitDiffPanel. Refactors browse path helpers into a
discriminated `BrowseProps` union so commitSha is required only for
pathType: 'commit'.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Wires up @codemirror/merge (via react-codemirror-merge) inside
CommitDiffPanel with a static before/after demo. Adds a CodeDiff
component that owns its language extension + view ref so each pane
can reconfigure its language compartment independently.

Also gates the react-grab dev scripts behind DEBUG_ENABLE_REACT_GRAP
so they don't load on every dev page render.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Replace the CodeMirror MergeView-based commit diff rendering with a DOM
based split-view that renders directly from git's hunks, inspired by
Chrome DevTools' DiffView. Per-file editor instances and the matching
getFileSource fetches are gone — a 50-file commit drops from ~100
network requests to 0, and per-row render cost from a full editor mount
to a synchronous Lezer highlight + grid emit.

- New `LightweightDiffViewer` builds a single 2-column subgrid with
  hunk headers spanning both sides; each cell uses `subgrid` so line
  numbers, markers, and content align across all rows.
- Pure helpers split out: `hunkParser` (body string → DiffLine[]),
  `splitPairing` (DiffLine[] → SplitRow[]).
- `presentableDiff` from @codemirror/merge supplies character-level
  intra-line diff highlighting on paired modifications.
- Lezer highlight code lifted from `lightweightCodeHighlighter` into
  `lib/codeHighlight` so both files share the helper.
- Drop `react-codemirror-merge` and `commitDiffEditor`. Long lines wrap
  via `whitespace-pre-wrap break-words` + `minmax(0, 1fr)` on the grid.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
- File path header now sticks to the top of the scroll viewport while
  scrolling through that file's diff, using the negative-yOffset trick
  to compensate for the virtualizer's translateY positioning. Same
  pattern as searchResultsPanel/fileMatchContainer.
- Lightweight diff viewer's grid uses `minmax(<min>, max-content)` for
  line-number and marker columns so they don't collapse to zero width
  when one side of the diff is entirely blank (fully-added or
  fully-deleted files), keeping the right pane aligned across files.
- Drop the column gap between left and right panes and instead draw a
  `border-r` separator on the left cells for a cleaner divider.
- Hunk header gets an optional className so the first hunk renders with
  just `border-b` (the file header above already provides the top
  border), while subsequent hunks render with `border-y` between them.
- Drop the per-row footer padding in the virtualizer; rows now sit
  flush against each other.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
- New `DiffStat` component renders GitHub-style additions/deletions
  counts with a 5-square indicator scaled log-ish to total change size.
  Added on the right of each file row header and on the right of the
  "N files changed" subheader for the commit total. Hidden when there
  are no line-level changes (pure renames).
- Each file row gets a `CopyIconButton` next to the path (copies
  newPath, falling back to oldPath) and a `CommitActionLink` that
  opens the file at the commit. Deleted files link to the old path
  at the parent commit so the user lands on the file's last existing
  state rather than a 404.
- `repoName`, `commitSha`, and `parentSha` are plumbed from the panel
  through `FileDiffList` to `FileDiffRow` to support the new link.
- `computeChangeCounts` is memoized per file in the row.

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

History panel rows in both the bottom panel and the commits page are now
clickable — they navigate to the matching commit diff via router.push,
with closest('button, a') short-circuit so inner action buttons keep
their own behavior. Bottom-panel history rows also highlight via
bg-accent when their commit is the one currently being viewed.

Commit diff header now uses AuthorsAvatarGroup + getCommitAuthors +
formatAuthorsText, matching latestCommitInfo and historyRow — co-authors
parsed from the commit body show up correctly.

When the URL trailing path matches one of the commit's files, that file
is moved to the top of the FileDiffList rather than scrolled to. Avoids
estimateSize-based scroll inaccuracy and works regardless of which side
of a rename the URL points to.

Lightweight diff viewer short-circuits with "Diff too large to display"
for files containing lines over 1000 chars, matching the cutoff in
lightweightCodeHighlighter.

PathHeader's breadcrumb measurement reserved 175px for "copy button and
padding"; the actual reservation needed is ~40px. Reduced so breadcrumbs
no longer collapse prematurely on wide layouts.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
- Lift `truncateSha` (was a private helper in getDiffToolComponent) to
  `lib/utils` so PathHeader can reuse it. The branch/ref display now
  renders a 40-char SHA as `abc1234`, preserving any `^` / `~N` suffix.
- Hide the `·` separator and the path's CopyIconButton when there's no
  path (repo root). Previously a dangling `·` and copy button rendered
  with nothing between them.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Adds a `path` query/tool parameter to restrict diff output to changes
touching a single file via git's `-- <pathspec>` separator. Refactors
the route handler to use the shared `getDiffRequestSchema`.

Fixes SOU-1154 (sourcebot-dev#1154)

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
- Move single-file commit diffs from `/-/commit/<sha>/<path>` to
  `/-/blob/<path>?ref=<sha>&diff=true`, keeping the user's browsing
  revision in the URL. `/-/commit/<sha>` still renders the full
  multi-file diff.
- New `FocusedCommitDiffPanel` with status row (file status badge +
  authors + relative commit date + "View full commit" + DiffStat +
  exit-X) and path-filtered `getDiff` so only the single file's diff
  is fetched.
- New preview banner in `CodePreviewPanel` when `?ref=` is set, with a
  close button that strips the param.
- Make `PathHeader`'s revision clickable, linking to that ref's full
  commit view.
- New `HoverPrefetchLink` defers Next.js prefetching until hover; used
  in history rows to avoid firing many prefetches on render.
- Hide the bottom panel on `/-/commit/` views.
- Extract `getFileStatus` / `StatusBadge` to a shared `fileStatus.tsx`.
- Workaround Radix Tooltip + RSC re-render bug (drop `asChild` from
  `<TooltipTrigger>`, add `key={commitSha}`) so X / Browse-files
  buttons survive client navigation between commits.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@rohanneilkapoor rohanneilkapoor added the softlight:review Force Softlight review label Jun 17, 2026
<CommitMessage subject={subject} body={commitResponse.body} />
</div>
<Tooltip key={commitSha}>
<TooltipTrigger>

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Header controls render with an extra nested button box

The action and close controls in the commit diff and file-preview headers are wired with an extra interactive layer around each button, which can surface a stray outline, doubled focus stops, and uneven hover feedback. They should feel like the single, clean controls used elsewhere in the commit views.

Prompt to fix with AI
This is a comment left during a design review.

Comment:
**Header controls render with an extra nested button box**
The action and close controls in the commit diff and file-preview headers are wired with an extra interactive layer around each button, which can surface a stray outline, doubled focus stops, and uneven hover feedback. They should feel like the single, clean controls used elsewhere in the commit views.

Issue:
All three new headers render `<TooltipTrigger>` (no asChild) directly wrapping `<Button asChild ...>` which itself Slots into a `<Link>`. Because Radix `TooltipTrigger` defaults to rendering its own `<button>`, the result is a `<button>` wrapping the Button's `<a>` — a nested interactive element with a redundant default button box, two focus targets, and hover/focus styling applied to the inner anchor only. fullCommitDiffPanel.tsx L79, focusedCommitDiffPanel.tsx L156, codePreviewPanel.tsx L105.

Suggested fix:
Add `asChild` to each `<TooltipTrigger>` in fullCommitDiffPanel.tsx (L79, Browse files), focusedCommitDiffPanel.tsx (L156, Exit diff view), and codePreviewPanel.tsx (L105, Close preview), matching commitParts.tsx CommitActionLink.

How can I resolve this? Keep the fix scoped to the PR-touched UI and preserve existing design-system patterns.

path,
pathType: 'blob',
})}
aria-label="Exit diff view"

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Close and exit controls don't match the shared icon action

The close and exit controls in the focused diff and file-preview headers are built by hand instead of matching the shared icon action used on the file rows, so their sizing, tooltip, and hover behavior can drift from the rest of the commit views. Reusing the standard control keeps these affordances consistent and predictable.

Prompt to fix with AI
This is a comment left during a design review.

Comment:
**Close and exit controls don't match the shared icon action**
The close and exit controls in the focused diff and file-preview headers are built by hand instead of matching the shared icon action used on the file rows, so their sizing, tooltip, and hover behavior can drift from the rest of the commit views. Reusing the standard control keeps these affordances consistent and predictable.

Issue:
focusedCommitDiffPanel.tsx (L156) and codePreviewPanel.tsx (L105) inline-build an icon-only ghost action: `<Tooltip><TooltipTrigger><Button asChild variant="ghost" size="icon" className="h-6 w-6 text-muted-foreground"><Link aria-label=...><X/></Link></Button></TooltipTrigger><TooltipContent>...`.

Suggested fix:
Replace the inline Tooltip+Button+Link X controls in focusedCommitDiffPanel.tsx and codePreviewPanel.tsx with `<CommitActionLink href=... label="Exit diff view"|"Close preview" icon={<X className="h-4 w-4"/>} />`, which also resolves the asChild issue for these two controls.

How can I resolve this? Keep the fix scoped to the PR-touched UI and preserve existing design-system patterns.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

softlight:review Force Softlight review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants