@@ -141,30 +141,65 @@ describe("ChatRow - inline diff stats and actions", () => {
141141 expect ( screen . getByText ( "-0" ) ) . toBeInTheDocument ( )
142142 } )
143143
144- it ( "preserves jump-to-file affordance for newFileCreated" , ( ) => {
144+ it . each ( [
145+ [ "appliedDiff" , "@@ -1,1 +1,1 @@\n-old\n+new\n" ] ,
146+ [ "editedExistingFile" , "@@ -1,1 +1,1 @@\n-old\n+new\n" ] ,
147+ [ "newFileCreated" , "+new file" ] ,
148+ [ "searchAndReplace" , "-a\n-b\n+c\n" ] ,
149+ [ "search_and_replace" , "-a\n-b\n+c\n" ] ,
150+ [ "search_replace" , "-a\n-b\n+c\n" ] ,
151+ [ "edit" , "@@ -1,1 +1,1 @@\n-old\n+new\n" ] ,
152+ [ "edit_file" , "@@ -1,1 +1,1 @@\n-old\n+new\n" ] ,
153+ [ "apply_patch" , "@@ -1,1 +1,1 @@\n-old\n+new\n" ] ,
154+ [ "apply_diff" , "@@ -1,1 +1,1 @@\n-old\n+new\n" ] ,
155+ [ "insertContent" , "@@ -1,1 +1,1 @@\n-old\n+new\n" ] ,
156+ ] ) ( "shows jump-to-file affordance for %s" , ( tool , diff ) => {
145157 const message = createToolAskMessage ( {
146- tool : "newFileCreated" ,
147- path : "src/new-file.ts" ,
148- content : "+new file" ,
149- diffStats : { added : 1 , removed : 0 } ,
158+ tool,
159+ path : "src/file.ts" ,
160+ diff,
161+ lineNumber : 0 ,
162+ diffStats : { added : 1 , removed : 1 } ,
150163 } )
151164
152165 const { container } = renderChatRow ( message )
153166 const openFileIcon = container . querySelector ( ".codicon-link-external" ) as HTMLElement | null
154167
155168 expect ( openFileIcon ) . toBeInTheDocument ( )
156169 if ( ! openFileIcon ) {
157- throw new Error ( " Expected external link icon for newFileCreated" )
170+ throw new Error ( ` Expected external link icon for ${ tool } ` )
158171 }
159172
160173 fireEvent . click ( openFileIcon )
161174
162175 expect ( mockPostMessage ) . toHaveBeenCalledWith ( {
163176 type : "openFile" ,
164- text : "./src/new- file.ts" ,
177+ text : "./src/file.ts" ,
165178 } )
166179 } )
167180
181+ it ( "does not show jump-to-file affordance when path is missing" , ( ) => {
182+ const message = createToolAskMessage ( {
183+ tool : "appliedDiff" ,
184+ diff : "@@ -1,1 +1,1 @@\n-old\n+new\n" ,
185+ diffStats : { added : 1 , removed : 1 } ,
186+ } )
187+
188+ const { container } = renderChatRow ( message )
189+ expect ( container . querySelector ( ".codicon-link-external" ) ) . not . toBeInTheDocument ( )
190+ } )
191+
192+ it ( "does not show jump-to-file affordance for non-file tools" , ( ) => {
193+ const message = createToolAskMessage ( {
194+ tool : "executeCommand" ,
195+ command : "echo hello" ,
196+ content : "hello" ,
197+ } )
198+
199+ const { container } = renderChatRow ( message )
200+ expect ( container . querySelector ( ".codicon-link-external" ) ) . not . toBeInTheDocument ( )
201+ } )
202+
168203 it ( "preserves protected and outside-workspace messaging in unified branch" , ( ) => {
169204 const outsideWorkspaceMessage = createToolAskMessage ( {
170205 tool : "searchAndReplace" ,
0 commit comments