@@ -89,6 +89,7 @@ interface SessionReviewTabProps {
8989 comments ?: LineComment [ ]
9090 focusedComment ?: { file : string ; id : string } | null
9191 onFocusedCommentChange ?: ( focus : { file : string ; id : string } | null ) => void
92+ focusedFile ?: string
9293 onScrollRef ?: ( el : HTMLDivElement ) => void
9394 classes ?: {
9495 root ?: string
@@ -213,6 +214,7 @@ function SessionReviewTab(props: SessionReviewTabProps) {
213214 diffStyle = { props . diffStyle }
214215 onDiffStyleChange = { props . onDiffStyleChange }
215216 onViewFile = { props . onViewFile }
217+ focusedFile = { props . focusedFile }
216218 readFile = { readFile }
217219 onLineComment = { props . onLineComment }
218220 comments = { props . comments }
@@ -480,12 +482,29 @@ export default function Page() {
480482 }
481483
482484 const kinds = createMemo ( ( ) => {
485+ const merge = ( a : "add" | "del" | "mix" | undefined , b : "add" | "del" | "mix" ) => {
486+ if ( ! a ) return b
487+ if ( a === b ) return a
488+ return "mix" as const
489+ }
490+
491+ const normalize = ( p : string ) => p . replaceAll ( "\\\\" , "/" ) . replace ( / \/ + $ / , "" )
492+
483493 const out = new Map < string , "add" | "del" | "mix" > ( )
484494 for ( const diff of diffs ( ) ) {
495+ const file = normalize ( diff . file )
485496 const add = diff . additions > 0
486497 const del = diff . deletions > 0
487498 const kind = add && del ? "mix" : add ? "add" : del ? "del" : "mix"
488- out . set ( diff . file , kind )
499+
500+ out . set ( file , kind )
501+
502+ const parts = file . split ( "/" )
503+ for ( const [ idx ] of parts . slice ( 0 , - 1 ) . entries ( ) ) {
504+ const dir = parts . slice ( 0 , idx + 1 ) . join ( "/" )
505+ if ( ! dir ) continue
506+ out . set ( dir , merge ( out . get ( dir ) , kind ) )
507+ }
489508 }
490509 return out
491510 } )
@@ -1084,12 +1103,15 @@ export default function Page() {
10841103 const [ tree , setTree ] = createStore ( {
10851104 reviewScroll : undefined as HTMLDivElement | undefined ,
10861105 pendingDiff : undefined as string | undefined ,
1106+ activeDiff : undefined as string | undefined ,
10871107 } )
10881108
10891109 const reviewScroll = ( ) => tree . reviewScroll
10901110 const setReviewScroll = ( value : HTMLDivElement | undefined ) => setTree ( "reviewScroll" , value )
10911111 const pendingDiff = ( ) => tree . pendingDiff
10921112 const setPendingDiff = ( value : string | undefined ) => setTree ( "pendingDiff" , value )
1113+ const activeDiff = ( ) => tree . activeDiff
1114+ const setActiveDiff = ( value : string | undefined ) => setTree ( "activeDiff" , value )
10931115
10941116 const showAllFiles = ( ) => {
10951117 if ( fileTreeTab ( ) !== "changes" ) return
@@ -1151,6 +1173,7 @@ export default function Page() {
11511173 const focusReviewDiff = ( path : string ) => {
11521174 const current = view ( ) . review . open ( ) ?? [ ]
11531175 if ( ! current . includes ( path ) ) view ( ) . review . setOpen ( [ ...current , path ] )
1176+ setActiveDiff ( path )
11541177 setPendingDiff ( path )
11551178 }
11561179
@@ -1697,6 +1720,7 @@ export default function Page() {
16971720 diffs = { diffs }
16981721 view = { view }
16991722 diffStyle = "unified"
1723+ focusedFile = { activeDiff ( ) }
17001724 onLineComment = { ( comment ) => addCommentToContext ( { ...comment , origin : "review" } ) }
17011725 comments = { comments . all ( ) }
17021726 focusedComment = { comments . focus ( ) }
@@ -2046,6 +2070,7 @@ export default function Page() {
20462070 </ StickyAddButton >
20472071 </ Tabs . List >
20482072 </ div >
2073+
20492074 < Tabs . Content value = "empty" class = "flex flex-col h-full overflow-hidden contain-strict" >
20502075 < Show when = { activeTab ( ) === "empty" } >
20512076 < div class = "relative pt-2 flex-1 min-h-0 overflow-hidden" >
@@ -2597,6 +2622,7 @@ export default function Page() {
25972622 diffStyle = { layout . review . diffStyle ( ) }
25982623 onDiffStyleChange = { layout . review . setDiffStyle }
25992624 onScrollRef = { setReviewScroll }
2625+ focusedFile = { activeDiff ( ) }
26002626 onLineComment = { ( comment ) => addCommentToContext ( { ...comment , origin : "review" } ) }
26012627 comments = { comments . all ( ) }
26022628 focusedComment = { comments . focus ( ) }
@@ -2664,6 +2690,7 @@ export default function Page() {
26642690 allowed = { diffFiles ( ) }
26652691 kinds = { kinds ( ) }
26662692 draggable = { false }
2693+ active = { activeDiff ( ) }
26672694 onFileClick = { ( node ) => focusReviewDiff ( node . path ) }
26682695 />
26692696 </ Show >
0 commit comments