@@ -22,6 +22,7 @@ function toolCall(overrides: Partial<ParsedToolCall>): ParsedToolCall {
2222 status : overrides . status ?? "completed" ,
2323 locations : overrides . locations ,
2424 content : overrides . content ,
25+ rawOutput : overrides . rawOutput ,
2526 } ;
2627}
2728
@@ -191,6 +192,59 @@ describe("extractCloudFileContent", () => {
191192 expect ( result ) . toEqual ( { content : "edited content" , touched : true } ) ;
192193 } ) ;
193194
195+ // A file_unchanged read carries Claude Code's "Wasted call ..." dedup
196+ // sentinel instead of the file body, so it must never be treated as content.
197+ const fileUnchangedRead = ( id : string ) : ParsedToolCall =>
198+ toolCall ( {
199+ toolCallId : id ,
200+ kind : "read" ,
201+ locations : [ { path : "src/app.ts" } ] ,
202+ rawOutput : { type : "file_unchanged" } ,
203+ content : textContent (
204+ "```\nWasted call — file unchanged since your last Read. Refer to that earlier tool_result instead.\n```" ,
205+ ) ,
206+ } ) ;
207+
208+ it . each ( [
209+ {
210+ name : "read alone yields no content (dedup sentinel not shown)" ,
211+ calls : [ fileUnchangedRead ( "tc-unchanged" ) ] ,
212+ expected : { content : null , touched : false } ,
213+ } ,
214+ {
215+ name : "read after a real read keeps the real content" ,
216+ calls : [
217+ toolCall ( {
218+ toolCallId : "tc-read" ,
219+ kind : "read" ,
220+ locations : [ { path : "src/app.ts" } ] ,
221+ content : textContent ( "real content" ) ,
222+ } ) ,
223+ fileUnchangedRead ( "tc-unchanged" ) ,
224+ ] ,
225+ expected : { content : "real content" , touched : true } ,
226+ } ,
227+ {
228+ name : "read after a write keeps the written content" ,
229+ calls : [
230+ toolCall ( {
231+ toolCallId : "tc-write" ,
232+ kind : "write" ,
233+ locations : [ { path : "src/app.ts" } ] ,
234+ content : diffContent ( "src/app.ts" , "written content" ) ,
235+ } ) ,
236+ fileUnchangedRead ( "tc-unchanged" ) ,
237+ ] ,
238+ expected : { content : "written content" , touched : true } ,
239+ } ,
240+ ] ) ( "file_unchanged $name" , ( { calls, expected } ) => {
241+ const result = extractCloudFileContent (
242+ makeToolCalls ( ...calls ) ,
243+ "src/app.ts" ,
244+ ) ;
245+ expect ( result ) . toEqual ( expected ) ;
246+ } ) ;
247+
194248 it ( "marks deleted files as touched with null content" , ( ) => {
195249 const calls = makeToolCalls (
196250 toolCall ( {
0 commit comments