diff --git a/client/src/components/Chat/Messages/Content/Parts/DiffView.tsx b/client/src/components/Chat/Messages/Content/Parts/DiffView.tsx index 4e3bb4e900..255084cb58 100644 --- a/client/src/components/Chat/Messages/Content/Parts/DiffView.tsx +++ b/client/src/components/Chat/Messages/Content/Parts/DiffView.tsx @@ -74,8 +74,6 @@ export function parseUnifiedDiff(diff: string): ParsedDiff { return { lines, additions, deletions, hasLineNumbers }; } -const LINE_NUMBER_CLASS = 'w-9 shrink-0 select-none pr-1.5 text-right text-text-tertiary'; - const LINE_MARKERS: Record = { add: '+', del: '-', @@ -83,6 +81,12 @@ const LINE_MARKERS: Record = { hunk: '', }; +/** One number per row keeps the gutter compact: the old line for removals + * (it no longer exists in the new file) and the new line otherwise. */ +function lineNumber(line: DiffLine): number | undefined { + return line.type === 'del' ? line.oldLine : (line.newLine ?? line.oldLine); +} + export default function DiffView({ parsed }: { parsed: ParsedDiff }) { const { lines, hasLineNumbers } = parsed; const firstContentIndex = lines.findIndex((line) => line.type !== 'hunk'); @@ -90,7 +94,7 @@ export default function DiffView({ parsed }: { parsed: ParsedDiff }) { return (
{lines.map((line, index) => { if (line.type === 'hunk') { @@ -116,14 +120,14 @@ export default function DiffView({ parsed }: { parsed: ParsedDiff }) { )} > {hasLineNumbers && ( - <> - {line.oldLine ?? ''} - {line.newLine ?? ''} - + + {lineNumber(line) ?? ''} + )}