11import { basename , dirname } from "node:path/posix" ;
22import type { FileDiffMetadata } from "@pierre/diffs" ;
3+ import { normalizeDiffPath } from "../../core/diffPaths" ;
34import type { AgentAnnotation , DiffFile } from "../../core/types" ;
45
56export interface FileListEntry {
@@ -22,12 +23,15 @@ export type SidebarEntry = FileListEntry | FileGroupEntry;
2223
2324/** Build the filename-first label shown inside one sidebar row. */
2425function sidebarFileName ( file : DiffFile ) {
25- if ( ! file . previousPath || file . previousPath === file . path ) {
26- return basename ( file . path ) ;
26+ const path = normalizeDiffPath ( file . path ) ?? file . path ;
27+ const previousPath = normalizeDiffPath ( file . previousPath ) ;
28+
29+ if ( ! previousPath || previousPath === path ) {
30+ return basename ( path ) ;
2731 }
2832
29- const previousName = basename ( file . previousPath ) ;
30- const nextName = basename ( file . path ) ;
33+ const previousName = basename ( previousPath ) ;
34+ const nextName = basename ( path ) ;
3135 return previousName === nextName ? nextName : `${ previousName } -> ${ nextName } ` ;
3236}
3337
@@ -91,7 +95,11 @@ export function filterReviewFiles(files: DiffFile[], query: string): DiffFile[]
9195 }
9296
9397 return files . filter ( ( file ) => {
94- const haystack = [ file . path , file . previousPath , file . agent ?. summary ]
98+ const haystack = [
99+ normalizeDiffPath ( file . path ) ,
100+ normalizeDiffPath ( file . previousPath ) ,
101+ file . agent ?. summary ,
102+ ]
95103 . filter ( Boolean )
96104 . join ( " " )
97105 . toLowerCase ( ) ;
@@ -105,7 +113,8 @@ export function buildSidebarEntries(files: DiffFile[]): SidebarEntry[] {
105113 let activeGroup : string | null = null ;
106114
107115 files . forEach ( ( file , index ) => {
108- const group = dirname ( file . path ) ;
116+ const path = normalizeDiffPath ( file . path ) ?? file . path ;
117+ const group = dirname ( path ) ;
109118 const nextGroup = group === "." ? null : group ;
110119
111120 if ( nextGroup !== activeGroup ) {
@@ -148,10 +157,9 @@ export function fileLabelParts(file: DiffFile | undefined): {
148157 return { filename : "No file selected" , stateLabel : null } ;
149158 }
150159
151- const baseLabel =
152- file . previousPath && file . previousPath !== file . path
153- ? `${ file . previousPath } -> ${ file . path } `
154- : file . path ;
160+ const path = normalizeDiffPath ( file . path ) ?? file . path ;
161+ const previousPath = normalizeDiffPath ( file . previousPath ) ;
162+ const baseLabel = previousPath && previousPath !== path ? `${ previousPath } -> ${ path } ` : path ;
155163
156164 // Determine state label for special cases
157165 let stateLabel : string | null = null ;
0 commit comments