@@ -157,11 +157,11 @@ describe("work entry labels", () => {
157157 ) ;
158158
159159 it . each ( [
160- [ "preview_click" , "Clicked in the preview browser" , "browser" ] ,
161- [ "task_status" , "Got delegated task status" , "t3-code" ] ,
160+ [ "preview_click" , "Clicked in the preview browser" ] ,
161+ [ "task_status" , "Got delegated task status" ] ,
162162 ] as const ) (
163- "uses the completed %s call presentation for a settled legacy tool " ,
164- ( tool , summary , summaryToolIcon ) => {
163+ "renders a settled legacy %s call directly with its completed presentation " ,
164+ ( tool , label ) => {
165165 const rows = deriveMessagesTimelineRows ( {
166166 timelineEntries : [
167167 {
@@ -180,9 +180,12 @@ describe("work entry labels", () => {
180180 turnDiffSummaryByAssistantMessageId : new Map ( ) ,
181181 revertTurnCountByUserMessageId : new Map ( ) ,
182182 } ) ;
183- expect ( rows ) . toMatchObject ( [
184- { kind : "work-toggle" , hiddenCount : 1 , summary, summaryToolIcon } ,
185- ] ) ;
183+ const directRow = rows . find ( ( row ) => row . kind === "work" ) ;
184+ expect ( directRow ) . toMatchObject ( {
185+ groupedEntries : [ expect . objectContaining ( { id : "tool-1" } ) ] ,
186+ isExpandedToolGroup : false ,
187+ displayLabel : label ,
188+ } ) ;
186189 } ,
187190 ) ;
188191} ) ;
@@ -741,14 +744,96 @@ describe("deriveMessagesTimelineRows", () => {
741744 "user-entry" ,
742745 "turn-fold:turn-1" ,
743746 "assistant-first-entry" ,
744- "work-toggle:work- entry-1" ,
747+ "work-entry-1" ,
745748 "assistant-final-entry" ,
746749 ] ) ;
747750 expect (
748751 expandedRows . find ( ( row ) => row . kind === "turn-fold" && row . expanded === true ) ,
749752 ) . toBeDefined ( ) ;
750753 } ) ;
751754
755+ it ( "keeps a tool group after the terminal response visible when the turn is folded" , ( ) => {
756+ const turnId = TurnId . make ( "turn-1" ) ;
757+ const timelineEntries = [
758+ {
759+ id : "work-entry-before-text" ,
760+ kind : "work" as const ,
761+ createdAt : "2026-01-01T00:00:01Z" ,
762+ entry : {
763+ id : "work-before-text" ,
764+ createdAt : "2026-01-01T00:00:01Z" ,
765+ turnId,
766+ label : "Status updated" ,
767+ tone : "info" as const ,
768+ } ,
769+ } ,
770+ {
771+ id : "assistant-final-entry" ,
772+ kind : "message" as const ,
773+ createdAt : "2026-01-01T00:00:05Z" ,
774+ message : {
775+ id : "assistant-final" as never ,
776+ role : "assistant" as const ,
777+ text : "I could not finish the task." ,
778+ turnId,
779+ createdAt : "2026-01-01T00:00:05Z" ,
780+ updatedAt : "2026-01-01T00:00:06Z" ,
781+ streaming : false ,
782+ } ,
783+ } ,
784+ ...Array . from ( { length : 3 } , ( _ , index ) => ( {
785+ id : `work-entry-after-text-${ index } ` ,
786+ kind : "work" as const ,
787+ createdAt : `2026-01-01T00:00:0${ index + 7 } Z` ,
788+ entry : {
789+ id : `work-after-text-${ index } ` ,
790+ createdAt : `2026-01-01T00:00:0${ index + 7 } Z` ,
791+ turnId,
792+ label : "Ran command" ,
793+ tone : "tool" as const ,
794+ itemType : "command_execution" as const ,
795+ toolLifecycleStatus : "completed" as const ,
796+ } ,
797+ } ) ) ,
798+ ] ;
799+
800+ const rows = deriveMessagesTimelineRows ( {
801+ timelineEntries,
802+ latestTurn : {
803+ turnId,
804+ state : "error" ,
805+ startedAt : "2026-01-01T00:00:00Z" ,
806+ completedAt : "2026-01-01T00:00:10Z" ,
807+ } ,
808+ isWorking : false ,
809+ activeTurnStartedAt : null ,
810+ turnDiffSummaryByAssistantMessageId : new Map ( ) ,
811+ revertTurnCountByUserMessageId : new Map ( ) ,
812+ } ) ;
813+
814+ expect ( rows . map ( ( row ) => row . id ) ) . toEqual ( [
815+ "turn-fold:turn-1" ,
816+ "assistant-final-entry" ,
817+ "work-toggle:work-entry-after-text-0" ,
818+ "assistant-meta:assistant-final" ,
819+ ] ) ;
820+ expect ( rows . at ( - 2 ) ) . toMatchObject ( {
821+ kind : "work-toggle" ,
822+ hiddenCount : 3 ,
823+ summary : "Ran 3 commands" ,
824+ } ) ;
825+ expect ( rows . at ( - 1 ) ) . toMatchObject ( {
826+ kind : "assistant-meta" ,
827+ message : { id : "assistant-final" } ,
828+ showAssistantCopyButton : true ,
829+ } ) ;
830+ expect ( rows . at ( - 3 ) ) . toMatchObject ( {
831+ kind : "message" ,
832+ showAssistantMeta : false ,
833+ showAssistantCopyButton : false ,
834+ } ) ;
835+ } ) ;
836+
752837 it ( "folds all assistant messages before the terminal message" , ( ) => {
753838 const timelineEntries = [
754839 {
@@ -827,6 +912,18 @@ describe("deriveMessagesTimelineRows", () => {
827912 streaming : false ,
828913 } ,
829914 } ,
915+ {
916+ id : "work-entry-before-message" ,
917+ kind : "work" ,
918+ createdAt : "2026-01-01T00:00:07Z" ,
919+ entry : {
920+ id : "work-before-message" ,
921+ createdAt : "2026-01-01T00:00:07Z" ,
922+ turnId : "turn-1" as never ,
923+ label : "Status updated" ,
924+ tone : "info" as const ,
925+ } ,
926+ } ,
830927 {
831928 id : "assistant-commentary-entry" ,
832929 kind : "message" ,
@@ -1135,7 +1232,7 @@ describe("deriveMessagesTimelineRows", () => {
11351232 } ) ;
11361233 } ) ;
11371234
1138- it ( "labels a single completed tool call without summarizing it " , ( ) => {
1235+ it ( "renders a single completed tool call directly " , ( ) => {
11391236 const rows = deriveMessagesTimelineRows ( {
11401237 timelineEntries : [
11411238 {
@@ -1195,11 +1292,64 @@ describe("deriveMessagesTimelineRows", () => {
11951292 revertTurnCountByUserMessageId : new Map ( ) ,
11961293 } ) ;
11971294
1198- expect ( rows . map ( ( row ) => row . kind ) ) . toEqual ( [ "working" , "work-toggle" , "message" , "work-live" ] ) ;
1199- expect ( rows . find ( ( row ) => row . kind === "work-toggle" ) ) . toMatchObject ( {
1200- hiddenCount : 1 ,
1201- summary : "rg toolCall" ,
1295+ expect ( rows . map ( ( row ) => row . kind ) ) . toEqual ( [ "working" , "work" , "message" , "work-live" ] ) ;
1296+ expect ( rows . find ( ( row ) => row . kind === "work" ) ) . toMatchObject ( {
1297+ groupedEntries : [ { id : "completed-command" , command : "rg toolCall" } ] ,
1298+ isExpandedToolGroup : false ,
1299+ displayLabel : "rg toolCall" ,
1300+ } ) ;
1301+ } ) ;
1302+
1303+ it ( "renders one tool call directly after collapsing its lifecycle updates" , ( ) => {
1304+ const turnId = TurnId . make ( "turn-1" ) ;
1305+ const rows = deriveMessagesTimelineRows ( {
1306+ timelineEntries : [
1307+ {
1308+ id : "command-started-entry" ,
1309+ kind : "work" ,
1310+ createdAt : "2026-01-01T00:00:05Z" ,
1311+ entry : {
1312+ id : "command-started" ,
1313+ createdAt : "2026-01-01T00:00:05Z" ,
1314+ turnId,
1315+ toolCallId : "call-1" ,
1316+ label : "Running rg" ,
1317+ command : "rg toolCall" ,
1318+ tone : "tool" as const ,
1319+ itemType : "command_execution" as const ,
1320+ toolLifecycleStatus : "inProgress" as const ,
1321+ } ,
1322+ } ,
1323+ {
1324+ id : "command-completed-entry" ,
1325+ kind : "work" ,
1326+ createdAt : "2026-01-01T00:00:06Z" ,
1327+ entry : {
1328+ id : "command-completed" ,
1329+ createdAt : "2026-01-01T00:00:06Z" ,
1330+ turnId,
1331+ toolCallId : "call-1" ,
1332+ label : "Ran rg" ,
1333+ command : "rg toolCall" ,
1334+ tone : "tool" as const ,
1335+ itemType : "command_execution" as const ,
1336+ toolLifecycleStatus : "completed" as const ,
1337+ } ,
1338+ } ,
1339+ ] ,
1340+ expandedTurnIds : new Set ( [ turnId ] ) ,
1341+ isWorking : false ,
1342+ activeTurnStartedAt : null ,
1343+ turnDiffSummaryByAssistantMessageId : new Map ( ) ,
1344+ revertTurnCountByUserMessageId : new Map ( ) ,
1345+ } ) ;
1346+
1347+ expect ( rows . find ( ( row ) => row . kind === "work" ) ) . toMatchObject ( {
1348+ groupedEntries : [ { id : "command-completed" , toolCallId : "call-1" } ] ,
1349+ isExpandedToolGroup : false ,
1350+ displayLabel : "rg toolCall" ,
12021351 } ) ;
1352+ expect ( rows . some ( ( row ) => row . kind === "work-toggle" ) ) . toBe ( false ) ;
12031353 } ) ;
12041354
12051355 it ( "keeps separated in-progress tool runs visible" , ( ) => {
0 commit comments