@@ -35,10 +35,10 @@ describe("buildPatchCacheKey", () => {
3535
3636describe ( "getRenderablePatch" , ( ) => {
3737 it . each ( [
38- [ "a/example.ts" , "a/example.ts" ] ,
39- [ "b/example.ts" , "b/example.ts" ] ,
40- [ "a/before.ts" , "b/after.ts" ] ,
41- ] ) ( "preserves repository paths from %s to %s" , ( previousPath , path ) => {
38+ [ "a/example.ts" , "a/example.ts" , "change" ] ,
39+ [ "b/example.ts" , "b/example.ts" , "change" ] ,
40+ [ "a/before.ts" , "b/after.ts" , "rename-changed" ] ,
41+ ] ) ( "preserves repository paths from %s to %s" , ( previousPath , path , type ) => {
4242 const parsed = getRenderablePatch (
4343 [
4444 `diff --git a/${ previousPath } b/${ path } ` ,
@@ -59,7 +59,7 @@ describe("getRenderablePatch", () => {
5959 if ( ! file ) return ;
6060 expect ( resolveFileDiffPath ( file ) ) . toBe ( path ) ;
6161 expect ( resolveFileDiffPreviousPath ( file ) ) . toBe ( previousPath ) ;
62- expect ( buildFileDiffIdentityKey ( file ) ) . toBe ( `${ previousPath } \0${ path } ` ) ;
62+ expect ( buildFileDiffIdentityKey ( file ) ) . toBe ( `${ previousPath } \0${ path } \0 ${ type } ` ) ;
6363 } ) ;
6464
6565 it ( "compacts partial hunk render offsets for virtualized review diffs" , ( ) => {
@@ -137,6 +137,33 @@ describe("diff file reconciliation", () => {
137137 expect ( buildFileDiffRenderKey ( file ) ) . toBe ( key ) ;
138138 } ) ;
139139
140+ it ( "gives a type change its own identity per block" , ( ) => {
141+ const patch = [
142+ "diff --git a/AGENTS.md b/AGENTS.md" ,
143+ "deleted file mode 100644" ,
144+ "--- a/AGENTS.md" ,
145+ "+++ /dev/null" ,
146+ "@@ -1 +0,0 @@" ,
147+ "-duplicated instructions" ,
148+ "diff --git a/AGENTS.md b/AGENTS.md" ,
149+ "new file mode 120000" ,
150+ "--- /dev/null" ,
151+ "+++ b/AGENTS.md" ,
152+ "@@ -0,0 +1 @@" ,
153+ "+CLAUDE.md" ,
154+ ] . join ( "\n" ) ;
155+ const parsed = getRenderablePatch ( patch , "type-change" ) ;
156+ expect ( parsed ?. kind ) . toBe ( "files" ) ;
157+ if ( parsed ?. kind !== "files" ) return ;
158+ const [ deleted , added ] = parsed . files ;
159+ expect ( deleted ?. type ) . toBe ( "deleted" ) ;
160+ expect ( added ?. type ) . toBe ( "new" ) ;
161+ if ( ! deleted || ! added ) return ;
162+
163+ expect ( buildFileDiffIdentityKey ( deleted ) ) . not . toBe ( buildFileDiffIdentityKey ( added ) ) ;
164+ expect ( new Set ( parsed . files . map ( buildFileDiffIdentityKey ) ) . size ) . toBe ( parsed . files . length ) ;
165+ } ) ;
166+
140167 it ( "keeps identities stable and versions local to the changed file" , ( ) => {
141168 const patch = ( secondLine : string ) =>
142169 [
0 commit comments