@@ -23,51 +23,64 @@ import type { ReviewNoteData } from "@/common/types/review";
2323// Shared type for diff line types
2424export type DiffLineType = "add" | "remove" | "context" | "header" ;
2525
26- // Helper function for getting diff line background color
26+ // Helper function for getting diff line background color.
27+ // Keep backgrounds subtle so the diff reads like a code block, not a highlighter.
2728const getDiffLineBackground = ( type : DiffLineType ) : string => {
2829 switch ( type ) {
2930 case "add" :
30- return "rgba(46, 160, 67, 0.15 )" ;
31+ return "color-mix(in srgb, var(--color-success), transparent 90% )" ;
3132 case "remove" :
32- return "rgba(248, 81, 73, 0.15)" ;
33+ return "color-mix(in srgb, var(--color-danger), transparent 90%)" ;
34+ case "header" :
35+ return "color-mix(in srgb, var(--color-accent), transparent 92%)" ;
36+ case "context" :
3337 default :
3438 return "transparent" ;
3539 }
3640} ;
3741
38- // Helper function for getting diff line text color
39- const getDiffLineColor = ( type : DiffLineType ) : string => {
42+ const getDiffLineBorderColor = ( type : DiffLineType ) : string => {
4043 switch ( type ) {
4144 case "add" :
42- return "#4caf50 " ;
45+ return "color-mix(in srgb, var(--color-success), transparent 35%) " ;
4346 case "remove" :
44- return "#f44336 " ;
47+ return "color-mix(in srgb, var(--color-danger), transparent 35%) " ;
4548 case "header" :
46- return "#2196f3 " ;
49+ return "color-mix(in srgb, var(--color-accent), transparent 45%) " ;
4750 case "context" :
4851 default :
49- return "var(--color-text) " ;
52+ return "transparent " ;
5053 }
5154} ;
5255
53- // Helper function for getting line content color
56+ // Helper function for getting line content color.
57+ // Only headers/context are tinted; actual code stays the normal foreground color.
5458const getLineContentColor = ( type : DiffLineType ) : string => {
5559 switch ( type ) {
5660 case "header" :
57- return "#2196f3 " ;
61+ return "var(--color-accent-light) " ;
5862 case "context" :
5963 return "var(--color-text-secondary)" ;
6064 case "add" :
6165 case "remove" :
66+ default :
6267 return "var(--color-text)" ;
6368 }
6469} ;
6570
66- // Helper function for computing contrast color for add/remove indicators
71+ // Used for the +/- marker and line numbers.
6772const getContrastColor = ( type : DiffLineType ) : string => {
68- return type === "add" || type === "remove"
69- ? "color-mix(in srgb, var(--color-text-secondary), white 50%)"
70- : "var(--color-text-secondary)" ;
73+ switch ( type ) {
74+ case "add" :
75+ return "var(--color-success-light)" ;
76+ case "remove" :
77+ return "var(--color-danger-soft)" ;
78+ case "header" :
79+ return "var(--color-accent-light)" ;
80+ case "context" :
81+ default :
82+ return "var(--color-text-secondary)" ;
83+ }
7184} ;
7285
7386/**
@@ -115,7 +128,12 @@ export const DiffContainer: React.FC<
115128 const showOverflowControls = clampContent && isOverflowing ;
116129
117130 return (
118- < div className = { cn ( "relative m-0 rounded bg-code-bg py-1.5 [&_*]:text-[inherit]" , className ) } >
131+ < div
132+ className = { cn (
133+ "relative m-0 rounded-sm border border-border-light bg-code-bg py-1.5 [&_*]:text-[inherit]" ,
134+ className
135+ ) }
136+ >
119137 < div
120138 ref = { contentRef }
121139 className = { cn (
@@ -271,12 +289,15 @@ export const DiffRenderer: React.FC<DiffRendererProps> = ({
271289 return (
272290 < div
273291 key = { line . originalIndex }
274- className = "block w-full"
275- style = { { background : getDiffLineBackground ( chunk . type ) } }
292+ className = "block w-full border-l-2 border-transparent"
293+ style = { {
294+ background : getDiffLineBackground ( chunk . type ) ,
295+ borderLeftColor : getDiffLineBorderColor ( chunk . type ) ,
296+ } }
276297 >
277298 < div
278- className = "flex px-2 font-mono whitespace-pre"
279- style = { { color : getDiffLineColor ( chunk . type ) } }
299+ className = "font-monospace flex px-2 whitespace-pre"
300+ style = { { color : "var(--color-text)" } }
280301 >
281302 < span
282303 className = "inline-block w-1 shrink-0 text-center"
@@ -451,6 +472,7 @@ export const SelectableDiffRenderer = React.memo<SelectableDiffRendererProps>(
451472 filePath,
452473 fontSize,
453474 maxHeight,
475+ className,
454476 onReviewNote,
455477 onLineClick,
456478 searchConfig,
@@ -556,7 +578,7 @@ export const SelectableDiffRenderer = React.memo<SelectableDiffRendererProps>(
556578 // Show loading state while highlighting
557579 if ( ! highlightedChunks || highlightedLineData . length === 0 ) {
558580 return (
559- < DiffContainer fontSize = { fontSize } maxHeight = { maxHeight } >
581+ < DiffContainer fontSize = { fontSize } maxHeight = { maxHeight } className = { className } >
560582 < div style = { { opacity : 0.5 , padding : "8px" } } > Processing...</ div >
561583 </ DiffContainer >
562584 ) ;
@@ -566,7 +588,7 @@ export const SelectableDiffRenderer = React.memo<SelectableDiffRendererProps>(
566588 const lines = content . split ( "\n" ) . filter ( ( line ) => line . length > 0 ) ;
567589
568590 return (
569- < DiffContainer fontSize = { fontSize } maxHeight = { maxHeight } >
591+ < DiffContainer fontSize = { fontSize } maxHeight = { maxHeight } className = { className } >
570592 { highlightedLineData . map ( ( lineInfo , displayIndex ) => {
571593 const isSelected = isLineSelected ( displayIndex ) ;
572594 const indicator = lineInfo . type === "add" ? "+" : lineInfo . type === "remove" ? "-" : " " ;
@@ -576,12 +598,13 @@ export const SelectableDiffRenderer = React.memo<SelectableDiffRendererProps>(
576598 < div
577599 className = { cn (
578600 SELECTABLE_DIFF_LINE_CLASS ,
579- "block w-full relative cursor-text group"
601+ "block w-full relative cursor-text group border-l-2 border-transparent "
580602 ) }
581603 style = { {
582604 background : isSelected
583605 ? "hsl(from var(--color-review-accent) h s l / 0.2)"
584606 : getDiffLineBackground ( lineInfo . type ) ,
607+ borderLeftColor : getDiffLineBorderColor ( lineInfo . type ) ,
585608 } }
586609 >
587610 < span className = "absolute top-1/2 left-1 z-[1] -translate-y-1/2" >
@@ -618,8 +641,8 @@ export const SelectableDiffRenderer = React.memo<SelectableDiffRendererProps>(
618641 </ Tooltip >
619642 </ span >
620643 < div
621- className = "flex px-2 font-mono whitespace-pre"
622- style = { { color : getDiffLineColor ( lineInfo . type ) } }
644+ className = "font-monospace flex px-2 whitespace-pre"
645+ style = { { color : "var(--color-text)" } }
623646 >
624647 < span
625648 className = "inline-block w-1 shrink-0 text-center"
0 commit comments