-
Notifications
You must be signed in to change notification settings - Fork 0
[design-doctor capture-replay baseline] clone of sourcebot#2: [design-doctor test] sourcebot-1154: Commit diff viewer #24
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: bench/source-pr-base/design-doctor-feature-parity-expanded-20260610-152904Z/sourcebot-1154
Are you sure you want to change the base?
Changes from all commits
00784f2
059240a
3b53335
dbc4d14
7fe2972
4c33b60
29ed7b9
3e20e0d
df906c4
5c36e73
038edcc
5b7b01b
fae7b72
0a11df8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| 'use client'; | ||
|
|
||
| import { CopyIconButton } from "@/app/(app)/components/copyIconButton"; | ||
| import { useToast } from "@/components/hooks/use-toast"; | ||
| import Link from "next/link"; | ||
| import { Fragment, useCallback } from "react"; | ||
| import { getBrowsePath } from "../../../hooks/utils"; | ||
|
|
||
| interface CommitHashLineProps { | ||
| repoName: string; | ||
| commitHash: string; | ||
| parents: string[]; | ||
| } | ||
|
|
||
| export const CommitHashLine = ({ repoName, commitHash, parents }: CommitHashLineProps) => { | ||
| const { toast } = useToast(); | ||
|
|
||
| const onCopyHash = useCallback(() => { | ||
| navigator.clipboard.writeText(commitHash).then(() => { | ||
| toast({ description: "✅ Copied commit SHA to clipboard" }); | ||
| }); | ||
| return true; | ||
| }, [commitHash, toast]); | ||
|
|
||
| return ( | ||
| <div className="text-xs font-mono text-muted-foreground flex flex-row items-center gap-1"> | ||
| {parents.length > 0 && ( | ||
| <> | ||
| <span> | ||
| {parents.length} parent{parents.length > 1 ? 's' : ''} | ||
| </span> | ||
| {parents.map((parent, i) => ( | ||
| <Fragment key={parent}> | ||
| {i > 0 && <span>+</span>} | ||
| <Link | ||
| href={getBrowsePath({ | ||
| repoName, | ||
| path: '', | ||
| pathType: 'commit', | ||
| commitSha: parent, | ||
| })} | ||
| className="underline hover:text-foreground" | ||
| title={parent} | ||
| > | ||
| {parent.slice(0, 7)} | ||
| </Link> | ||
| </Fragment> | ||
| ))} | ||
| </> | ||
| )} | ||
| <span>commit {commitHash.slice(0, 7)}</span> | ||
| <CopyIconButton onCopy={onCopyHash} /> | ||
| </div> | ||
| ); | ||
| }; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| 'use client'; | ||
|
|
||
| import { CommitBody, CommitBodyToggle } from "@/app/(app)/browse/components/commitParts"; | ||
| import { useState } from "react"; | ||
|
|
||
| interface CommitMessageProps { | ||
| subject: string; | ||
| body: string; | ||
| } | ||
|
|
||
| export const CommitMessage = ({ subject, body }: CommitMessageProps) => { | ||
| const [isBodyExpanded, setIsBodyExpanded] = useState(false); | ||
| const hasBody = body.trim().length > 0; | ||
|
|
||
| return ( | ||
| <> | ||
| <div className="flex flex-row items-center gap-2"> | ||
| <h1 className="text-lg font-semibold">{subject}</h1> | ||
| {hasBody && ( | ||
| <CommitBodyToggle | ||
| pressed={isBodyExpanded} | ||
| onPressedChange={setIsBodyExpanded} | ||
| /> | ||
| )} | ||
| </div> | ||
| {hasBody && isBodyExpanded && ( | ||
| <CommitBody body={body} className="rounded max-h-[40vh] overflow-y-auto" /> | ||
This comment was marked as outdated.
Sorry, something went wrong.
This comment was marked as outdated.
Sorry, something went wrong. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Commit description sits too tight under its title When you expand a commit's description, it butts right up against the title with no space between them, so the two run together as one dense block. A little breathing room lets the description read clearly as its own section. Prompt to fix with AI |
||
| )} | ||
| </> | ||
| ); | ||
| }; | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,97 @@ | ||
| import { FileDiff } from "@/features/git"; | ||
|
|
||
| const TOTAL_SQUARES = 5; | ||
|
|
||
| // Count `+`/`-` lines across all hunks in a file. | ||
| export const computeChangeCounts = (file: FileDiff) => { | ||
| let additions = 0; | ||
| let deletions = 0; | ||
| for (const hunk of file.hunks) { | ||
| for (const raw of hunk.body.split('\n')) { | ||
| if (raw.startsWith('+')) { | ||
| additions++; | ||
| } else if (raw.startsWith('-')) { | ||
| deletions++; | ||
| } | ||
| } | ||
| } | ||
| return { additions, deletions }; | ||
| }; | ||
|
|
||
| // Sum line-level change counts across multiple files. | ||
| export const computeTotalChangeCounts = (files: FileDiff[]) => { | ||
| let additions = 0; | ||
| let deletions = 0; | ||
| for (const file of files) { | ||
| const counts = computeChangeCounts(file); | ||
| additions += counts.additions; | ||
| deletions += counts.deletions; | ||
| } | ||
| return { additions, deletions }; | ||
| }; | ||
|
|
||
| // Map a total change count to a number of filled squares (0–5) using a | ||
| // log-ish scale so tiny diffs still show one square and huge diffs cap out. | ||
| // Mirrors GitHub's diffstat indicator behavior. | ||
| const filledSquaresForTotal = (total: number): number => { | ||
| if (total === 0) { | ||
| return 0; | ||
| } | ||
| if (total < 5) { | ||
| return 1; | ||
| } | ||
| if (total < 10) { | ||
| return 2; | ||
| } | ||
| if (total < 30) { | ||
| return 3; | ||
| } | ||
| if (total < 100) { | ||
| return 4; | ||
| } | ||
| return 5; | ||
| }; | ||
|
|
||
| interface DiffStatProps { | ||
| additions: number; | ||
| deletions: number; | ||
| } | ||
|
|
||
| export const DiffStat = ({ additions, deletions }: DiffStatProps) => { | ||
| const total = additions + deletions; | ||
|
|
||
| // Skip rendering when there are no line-level changes (e.g. pure renames). | ||
| if (total === 0) { | ||
| return null; | ||
| } | ||
|
|
||
| const filled = filledSquaresForTotal(total); | ||
| const greenCount = Math.round((filled * additions) / total); | ||
| const redCount = filled - greenCount; | ||
| const emptyCount = TOTAL_SQUARES - filled; | ||
|
|
||
| return ( | ||
| <div | ||
| className="flex flex-row items-center gap-2 text-xs flex-shrink-0 font-mono" | ||
| title={`${additions} additions, ${deletions} deletions`} | ||
| > | ||
| {additions > 0 && ( | ||
| <span className="text-green-700 dark:text-green-400">+{additions}</span> | ||
| )} | ||
| {deletions > 0 && ( | ||
| <span className="text-red-700 dark:text-red-400">-{deletions}</span> | ||
| )} | ||
| <div className="flex flex-row gap-px"> | ||
| {Array.from({ length: greenCount }).map((_, i) => ( | ||
| <span key={`g-${i}`} className="w-2 h-2 bg-green-500 dark:bg-green-400 rounded-[1px]" /> | ||
| ))} | ||
| {Array.from({ length: redCount }).map((_, i) => ( | ||
| <span key={`r-${i}`} className="w-2 h-2 bg-red-500 dark:bg-red-400 rounded-[1px]" /> | ||
| ))} | ||
| {Array.from({ length: emptyCount }).map((_, i) => ( | ||
| <span key={`e-${i}`} className="w-2 h-2 bg-border rounded-[1px]" /> | ||
| ))} | ||
| </div> | ||
| </div> | ||
| ); | ||
| }; |





Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
'Previewing an older version' banner is indented from the file header
The banner shown when you preview a file at an older revision starts further in than the file path header directly above it, so its left edge looks misaligned with the rest of the view. Matching the edge lets the banner read as a calm, deliberate part of the page.
Prompt to fix with AI
Developer output
goal crop locatorx1=285, y1=44, x2=815, y2=150x1=285, y1=44, x2=815, y2=150Gridded crops
Before
After
Full gridded screenshots
Before
After