-
Notifications
You must be signed in to change notification settings - Fork 0
[design-doctor effort xhigh] replacement clone of sourcebot#2: [design-doctor test] sourcebot-1154: Commit diff viewer #30
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
6338227
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" /> | ||
|
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. Expanded commit description hugs the title with no breathing room When you expand the commit description on the commit page, the description panel butts directly against the commit title with no separation, while the author and commit lines below it have clear spacing. A small gap above the description matches the surrounding rhythm and makes the expanded state feel balanced rather than crowded. 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); | ||
|
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. Change dots can hide that a file also had deletions On a file with one line added and one line removed, the little change-indicator squares show only the 'added' color, so at a glance the file looks purely additive even though its own +/- count clearly shows a removed line. The squares should agree with the count beside them. Prompt to fix with AI |
||
| 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.
Parent commit links stay underlined at rest
In the commit details line, the parent commit links are always underlined, while every other commit and revision link in the file browser only underlines when you hover. Matching the hover-only style would make these links feel consistent and a little less busy in the dense metadata row.
Prompt to fix with AI
Developer output
goal crop locatorx1=290, y1=95, x2=720, y2=175x1=290, y1=95, x2=720, y2=175Gridded crops
Before
After
Full gridded screenshots
Before
After