@@ -50,7 +50,7 @@ it("commits a cached activity summary with its transcript row", () => {
5050 const row = summaryContainer . querySelector ( '[data-chat-row-key="cached"]' ) ;
5151 expect ( row ) . not . toBeNull ( ) ;
5252 expect ( row ?. querySelector ( ".chat-activity-group__summary" ) ?. textContent ) . toContain ( "1 read" ) ;
53- expect ( row ?. querySelector ( ".chat-tool-failure" ) ?. textContent ) . toBe ( "1 failed" ) ;
53+ expect ( row ?. querySelector ( ".chat-tool-failure" ) ) . toBeNull ( ) ;
5454} ) ;
5555
5656function read ( id : string , overrides : Record < string , unknown > = { } ) {
@@ -178,35 +178,32 @@ it.each([
178178 [ "work" , "anonymous" ] ,
179179 [ "work" , "missing-card" ] ,
180180 [ "work" , "matched" ] ,
181- ] as const ) (
182- "retains prepared failures exactly once in %s summaries (%s)" ,
183- async ( kind , pairing ) => {
184- const message = createAssistantMessage (
185- pairing === "missing-card"
186- ? [ { type : "text" , text : "Operation details unavailable" } ]
187- : [
188- read ( "call-failed" ) ,
189- createToolResultBlock ( "call-failed" , "read" , "Permission denied" , { isError : true } ) ,
190- ] ,
191- {
192- activity : [
193- preparedOutcome ( "failed" , pairing === "matched" ? "call-failed" : null , {
194- itemId : "prepared-failure" ,
195- title : "Read file" ,
196- } ) ,
181+ ] as const ) ( "leaves a prepared failure to its row in %s summaries (%s)" , async ( kind , pairing ) => {
182+ const message = createAssistantMessage (
183+ pairing === "missing-card"
184+ ? [ { type : "text" , text : "Operation details unavailable" } ]
185+ : [
186+ read ( "call-failed" ) ,
187+ createToolResultBlock ( "call-failed" , "read" , "Permission denied" , { isError : true } ) ,
197188 ] ,
198- } ,
199- ) ;
200- for ( const expanded of [ false , true ] ) {
201- const summary = await renderSummary ( [ message ] , kind , { expanded } ) ;
202- expect ( summary ?. textContent ) . toContain ( kind === "work" ? "Worked for 1 second" : "1 read" ) ;
203- expect ( summary ?. textContent ?. match ( / 1 f a i l e d / gu) ) . toHaveLength ( 1 ) ;
204- if ( kind === "work" ) {
205- expect ( summary ?. textContent ?. includes ( "1 tool call" ) ) . toBe ( expanded ) ;
206- }
189+ {
190+ activity : [
191+ preparedOutcome ( "failed" , pairing === "matched" ? "call-failed" : null , {
192+ itemId : "prepared-failure" ,
193+ title : "Read file" ,
194+ } ) ,
195+ ] ,
196+ } ,
197+ ) ;
198+ for ( const expanded of [ false , true ] ) {
199+ const summary = await renderSummary ( [ message ] , kind , { expanded } ) ;
200+ expect ( summary ?. textContent ) . toContain ( kind === "work" ? "Worked for 1 second" : "1 read" ) ;
201+ expect ( summary ?. textContent ) . not . toContain ( "failed" ) ;
202+ if ( kind === "work" ) {
203+ expect ( summary ?. textContent ?. includes ( "1 tool call" ) ) . toBe ( expanded ) ;
207204 }
208- } ,
209- ) ;
205+ }
206+ } ) ;
210207
211208it . each ( [ "activity" , "work" ] as const ) (
212209 "uses current prepared outcomes in %s summaries" ,
@@ -237,14 +234,13 @@ it.each(["activity", "work"] as const)(
237234 expect ( summary ?. textContent ) . not . toContain ( "failed" ) ;
238235 if ( kind === "work" ) {
239236 expect ( summary ?. textContent ) . not . toContain ( "tool call" ) ;
240- expect ( summary ?. querySelector ( ".chat-work-group__outcomes" ) ) . toBeNull ( ) ;
241237 }
242238 expect ( summary ?. querySelector ( ".chat-tool-failure" ) ) . toBeNull ( ) ;
243239 } ,
244240) ;
245241
246242it . each ( [ "blocked" , "skipped" , undefined ] as const ) (
247- "retains %s outcomes when completed work is expanded " ,
243+ "keeps blocked and unknown but not skipped outcomes in completed work (%s) " ,
248244 async ( status ) => {
249245 const message = createAssistantMessage ( [ ] , {
250246 activity : [ preparedOutcome ( "completed" , null , { itemId : "outcome" , status } ) ] ,
@@ -253,31 +249,34 @@ it.each(["blocked", "skipped", undefined] as const)(
253249 const summary = await renderSummary ( [ message ] , "work" , { expanded } ) ;
254250 expect ( summary ?. textContent ) . toContain ( "Worked for 1 second" ) ;
255251 expect ( summary ?. textContent ?. includes ( "1 tool call" ) ) . toBe ( expanded ) ;
256- expect ( summary ?. textContent ) . toContain ( `1 ${ status ?? "unknown" } ` ) ;
257252 if ( status === "skipped" ) {
258- expect ( summary ?. textContent ?. match ( / 1 s k i p p e d / g) ) . toHaveLength ( 1 ) ;
259- expect ( summary ?. textContent ) . not . toMatch ( / b l o c k e d | f a i l e d / ) ;
253+ expect ( summary ?. textContent ) . not . toMatch ( / s k i p p e d | b l o c k e d | f a i l e d / ) ;
254+ } else {
255+ expect ( summary ?. textContent ) . toContain ( `1 ${ status ?? "unknown" } ` ) ;
260256 }
261257 }
262258 } ,
263259) ;
264260
265- it . each ( [ 0 , 10 ] ) ( "keeps failures visible without a duration (%i calls)" , async ( total ) => {
266- const message = createAssistantMessage (
267- Array . from ( { length : total } ) . flatMap ( ( _ , index ) => [
268- read ( `call-${ index } ` ) ,
269- createToolResultBlock ( `call-${ index } ` , "read" , index < 2 ? "Unavailable" : "Loaded" , {
270- isError : index < 2 ,
271- } ) ,
272- ] ) ,
273- ) ;
274- const summary = await renderSummary ( total ? [ message ] : [ ] , "work" , {
275- durationMs : null ,
276- prepareHistory : true ,
277- } ) ;
278- const text = summary ?. textContent ?. replace ( / \s + / gu, " " ) . trim ( ) ;
279- expect ( text ) . toBe ( total ? "Worked · 2 failed" : "Worked" ) ;
280- } ) ;
261+ it . each ( [ 0 , 10 ] ) (
262+ "does not tally recovered failures in completed work (%i calls)" ,
263+ async ( total ) => {
264+ const message = createAssistantMessage (
265+ Array . from ( { length : total } ) . flatMap ( ( _ , index ) => [
266+ read ( `call-${ index } ` ) ,
267+ createToolResultBlock ( `call-${ index } ` , "read" , index < 2 ? "Unavailable" : "Loaded" , {
268+ isError : index < 2 ,
269+ } ) ,
270+ ] ) ,
271+ ) ;
272+ const summary = await renderSummary ( total ? [ message ] : [ ] , "work" , {
273+ durationMs : null ,
274+ prepareHistory : true ,
275+ } ) ;
276+ const text = summary ?. textContent ?. replace ( / \s + / gu, " " ) . trim ( ) ;
277+ expect ( text ) . toBe ( "Worked" ) ;
278+ } ,
279+ ) ;
281280
282281async function workSummaryText ( messages : Record < string , unknown > [ ] ) {
283282 return ( await renderSummary ( messages , "work" , { durationMs : null , expanded : true } ) ) ?. textContent
@@ -311,7 +310,7 @@ it.each([
311310 content : isError ? "Command failed" : "Command completed" ,
312311 isError,
313312 } ) ) ,
314- expected : "Worked · 2 tool calls · 1 failed " ,
313+ expected : "Worked · 2 tool calls" ,
315314 } ,
316315 ...[ false , true ] . map ( ( reverse ) => {
317316 const prepared = readResult ( "prepared" , true , { activity : [ preparedOutcome ( ) ] } ) ;
@@ -327,7 +326,7 @@ it.each([
327326 return {
328327 name : `mixed history, reverse=${ reverse } ` ,
329328 messages,
330- expected : "Worked · 2 tool calls · 1 failed " ,
329+ expected : "Worked · 2 tool calls" ,
331330 } ;
332331 } ) ,
333332 ...[ "empty" , "hidden" , "suppressed" ] . map ( ( kind ) => ( {
@@ -346,7 +345,7 @@ it.each([
346345 } ) ,
347346 readResult ( "visible" ) ,
348347 ] ,
349- expected : "Worked · 1 tool call · 1 failed " ,
348+ expected : "Worked · 1 tool call" ,
350349 } ) ) ,
351350 ...[ "raw" , "blocked" , "skipped" ] . map ( ( kind ) => ( {
352351 name : `${ kind } steering skip` ,
@@ -365,7 +364,7 @@ it.each([
365364 } ) ,
366365 } ) ,
367366 ] ,
368- expected : ` Worked · 1 tool call · 1 ${ kind === " blocked" ? "blocked" : "skipped" } ` ,
367+ expected : kind === "blocked" ? " Worked · 1 tool call · 1 blocked" : "Worked · 1 tool call" ,
369368 } ) ) ,
370369 {
371370 name : "unpaired anonymous raw call does not claim an unknown outcome" ,
@@ -424,15 +423,10 @@ it.each([
424423 ) ;
425424 const { container, draw } = mountGroup ( history . messages ) ;
426425 await draw ( false ) ;
427- if ( isError ) {
428- const summary = container . querySelector ( ".chat-activity-group__summary" ) ;
429- expect ( summary ?. textContent ) . toContain ( "1 command" ) ;
430- expect ( summary ?. textContent ) . toContain ( "1 failed" ) ;
431- expect ( container . querySelector ( ".chat-tool-row__title" ) ) . toBeNull ( ) ;
432- return ;
433- }
434426 expect ( container . querySelector ( ".chat-activity-group__summary" ) ) . toBeNull ( ) ;
435427 expect ( container . querySelector ( ".chat-tool-row__title" ) ?. textContent ) . toBe ( title ) ;
428+ // The step's own row carries its outcome now that groups no longer count it.
429+ expect ( container . querySelector ( ".chat-tool-failure" ) !== null ) . toBe ( isError ) ;
436430 expect ( container . querySelector ( ".chat-progress-card-receipt" ) ) . toBeNull ( ) ;
437431 await draw ( true ) ;
438432 expect (
0 commit comments