@@ -3290,6 +3290,7 @@ describe("v2 run and attempt history", () => {
32903290 id : string ,
32913291 attempt : typeof supersededAttempt | typeof nextAttempt ,
32923292 completedSecond : number ,
3293+ phase ?: "commentary" | "partial_answer" | "final_answer" ,
32933294 ) : TimelineEntry => ( {
32943295 id,
32953296 kind : "message" ,
@@ -3307,6 +3308,7 @@ describe("v2 run and attempt history", () => {
33073308 projectedItem : {
33083309 item : {
33093310 type : "assistant_message" ,
3311+ ...( phase === undefined ? { } : { phase } ) ,
33103312 status : "completed" ,
33113313 completedAt : DateTime . makeUnsafe ( at ( completedSecond ) ) ,
33123314 } ,
@@ -3315,51 +3317,58 @@ describe("v2 run and attempt history", () => {
33153317 const rowsFor = (
33163318 replyCompletedSecond : number ,
33173319 runStatus : "running" | "completed" = "completed" ,
3320+ toolCallVisibility : "showAll" | "zen" = "showAll" ,
3321+ phase ?: "commentary" | "partial_answer" | "final_answer" ,
3322+ nativeSteer = false ,
33183323 ) =>
33193324 deriveMessagesTimelineRows ( {
3320- timelineEntries : [
3321- {
3322- id : "initial-user-entry" ,
3323- kind : "message" ,
3324- createdAt : at ( 0 ) ,
3325- attempt : supersededAttempt ,
3326- message : {
3327- id : MessageId . make ( "initial-user" ) ,
3328- role : "user" ,
3329- text : "Build it" ,
3330- runId,
3331- inputIntent : "turn_start" ,
3325+ toolCallVisibility,
3326+ timelineEntries : (
3327+ [
3328+ {
3329+ id : "initial-user-entry" ,
3330+ kind : "message" ,
33323331 createdAt : at ( 0 ) ,
3333- updatedAt : at ( 0 ) ,
3334- streaming : false ,
3332+ attempt : supersededAttempt ,
3333+ message : {
3334+ id : MessageId . make ( "initial-user" ) ,
3335+ role : "user" ,
3336+ text : "Build it" ,
3337+ runId,
3338+ inputIntent : "turn_start" ,
3339+ createdAt : at ( 0 ) ,
3340+ updatedAt : at ( 0 ) ,
3341+ streaming : false ,
3342+ } ,
33353343 } ,
3336- } ,
3337- {
3338- id : "old-work-entry" ,
3339- kind : "work" ,
3340- createdAt : at ( 1 ) ,
3341- attempt : supersededAttempt ,
3342- entry : { id : "old-work" , createdAt : at ( 1 ) , runId, label : "Read" , tone : "tool" } ,
3343- } ,
3344- assistantEntry ( "old-reply-entry" , supersededAttempt , replyCompletedSecond ) ,
3345- {
3346- id : "steer-user-entry" ,
3347- kind : "message" ,
3348- createdAt : at ( 10 ) ,
3349- attempt : nextAttempt ,
3350- message : {
3351- id : MessageId . make ( "steer-user" ) ,
3352- role : "user" ,
3353- text : "What are you working on?" ,
3354- runId,
3355- inputIntent : "steer" ,
3344+ {
3345+ id : "old-work-entry" ,
3346+ kind : "work" ,
3347+ createdAt : at ( 1 ) ,
3348+ attempt : supersededAttempt ,
3349+ entry : { id : "old-work" , createdAt : at ( 1 ) , runId, label : "Read" , tone : "tool" } ,
3350+ } ,
3351+ assistantEntry ( "status-entry" , supersededAttempt , 1 , "commentary" ) ,
3352+ assistantEntry ( "old-reply-entry" , supersededAttempt , replyCompletedSecond , phase ) ,
3353+ {
3354+ id : "steer-user-entry" ,
3355+ kind : "message" ,
33563356 createdAt : at ( 10 ) ,
3357- updatedAt : at ( 10 ) ,
3358- streaming : false ,
3357+ attempt : nextAttempt ,
3358+ message : {
3359+ id : MessageId . make ( "steer-user" ) ,
3360+ role : "user" ,
3361+ text : "What are you working on?" ,
3362+ runId,
3363+ inputIntent : "steer" ,
3364+ createdAt : at ( 10 ) ,
3365+ updatedAt : at ( 10 ) ,
3366+ streaming : false ,
3367+ } ,
33593368 } ,
3360- } ,
3361- assistantEntry ( "new-reply-entry" , nextAttempt , 14 ) ,
3362- ] ,
3369+ assistantEntry ( "new-reply-entry" , nextAttempt , 14 ) ,
3370+ ] satisfies ReadonlyArray < TimelineEntry >
3371+ ) . map ( ( entry ) => ( nativeSteer ? { ... entry , attempt : nextAttempt } : entry ) ) ,
33633372 latestRun : {
33643373 runId,
33653374 status : runStatus ,
@@ -3371,23 +3380,33 @@ describe("v2 run and attempt history", () => {
33713380 supportsConversationRollback : false ,
33723381 } ) ;
33733382
3374- it . each ( [ "running" , "completed" ] as const ) (
3375- "keeps a reply that finished before the steer visible while the run is %s" ,
3376- ( runStatus ) => {
3377- const rows = rowsFor ( 4 , runStatus ) ;
3378- expect ( rows . some ( ( row ) => row . kind === "attempt-fold" ) ) . toBe ( false ) ;
3379- expect ( rows . map ( ( row ) => row . id ) ) . toContain ( "old-reply-entry" ) ;
3383+ it . each ( [
3384+ [ "final_answer" , 4 , true ] ,
3385+ [ "final_answer" , 11 , true ] ,
3386+ [ "commentary" , 4 , false ] ,
3387+ [ "commentary" , 11 , false ] ,
3388+ [ "partial_answer" , 11 , false ] ,
3389+ [ undefined , 4 , true ] ,
3390+ [ undefined , 11 , false ] ,
3391+ ] as const ) (
3392+ "retains phase %s ending at %s only when it is a final reply: %s" ,
3393+ ( phase , completedSecond , retained ) => {
3394+ for ( const runStatus of [ "running" , "completed" ] as const ) {
3395+ for ( const visibility of [ "showAll" , "zen" ] as const ) {
3396+ const rows = rowsFor ( completedSecond , runStatus , visibility , phase ) ;
3397+ expect ( rows . some ( ( row ) => row . id === "old-reply-entry" ) ) . toBe ( retained ) ;
3398+ if ( phase !== undefined && runStatus === "completed" ) {
3399+ const nativeRows = rowsFor ( completedSecond , runStatus , visibility , phase , true ) ;
3400+ expect ( nativeRows . some ( ( row ) => row . id === "old-reply-entry" ) ) . toBe ( retained ) ;
3401+ expect ( nativeRows . some ( ( row ) => row . id === "status-entry" ) ) . toBe ( false ) ;
3402+ }
3403+ if ( runStatus === "completed" ) {
3404+ expect ( rows . some ( ( row ) => row . id === "status-entry" ) ) . toBe ( false ) ;
3405+ }
3406+ }
3407+ }
33803408 } ,
33813409 ) ;
3382-
3383- it ( "folds a reply the steer cut off as partial output" , ( ) => {
3384- const rows = rowsFor ( 11 , "running" ) ;
3385- expect ( rows . find ( ( row ) => row . kind === "attempt-fold" ) ) . toMatchObject ( {
3386- attemptId : supersededAttempt . id ,
3387- label : "Superseded attempt" ,
3388- } ) ;
3389- expect ( rows . map ( ( row ) => row . id ) ) . not . toContain ( "old-reply-entry" ) ;
3390- } ) ;
33913410 } ) ;
33923411
33933412 it ( "hides the interruption request while keeping intervening work and the result" , ( ) => {
0 commit comments