@@ -3347,6 +3347,7 @@ describe("v2 run and attempt history", () => {
33473347 id : string ,
33483348 attempt : typeof supersededAttempt | typeof nextAttempt ,
33493349 completedSecond : number ,
3350+ phase ?: "commentary" | "partial_answer" | "final_answer" ,
33503351 ) : TimelineEntry => ( {
33513352 id,
33523353 kind : "message" ,
@@ -3364,6 +3365,7 @@ describe("v2 run and attempt history", () => {
33643365 projectedItem : {
33653366 item : {
33663367 type : "assistant_message" ,
3368+ ...( phase === undefined ? { } : { phase } ) ,
33673369 status : "completed" ,
33683370 completedAt : DateTime . makeUnsafe ( at ( completedSecond ) ) ,
33693371 } ,
@@ -3372,51 +3374,58 @@ describe("v2 run and attempt history", () => {
33723374 const rowsFor = (
33733375 replyCompletedSecond : number ,
33743376 runStatus : "running" | "completed" = "completed" ,
3377+ toolCallVisibility : "showAll" | "zen" = "showAll" ,
3378+ phase ?: "commentary" | "partial_answer" | "final_answer" ,
3379+ nativeSteer = false ,
33753380 ) =>
33763381 deriveMessagesTimelineRows ( {
3377- timelineEntries : [
3378- {
3379- id : "initial-user-entry" ,
3380- kind : "message" ,
3381- createdAt : at ( 0 ) ,
3382- attempt : supersededAttempt ,
3383- message : {
3384- id : MessageId . make ( "initial-user" ) ,
3385- role : "user" ,
3386- text : "Build it" ,
3387- runId,
3388- inputIntent : "turn_start" ,
3382+ toolCallVisibility,
3383+ timelineEntries : (
3384+ [
3385+ {
3386+ id : "initial-user-entry" ,
3387+ kind : "message" ,
33893388 createdAt : at ( 0 ) ,
3390- updatedAt : at ( 0 ) ,
3391- streaming : false ,
3389+ attempt : supersededAttempt ,
3390+ message : {
3391+ id : MessageId . make ( "initial-user" ) ,
3392+ role : "user" ,
3393+ text : "Build it" ,
3394+ runId,
3395+ inputIntent : "turn_start" ,
3396+ createdAt : at ( 0 ) ,
3397+ updatedAt : at ( 0 ) ,
3398+ streaming : false ,
3399+ } ,
33923400 } ,
3393- } ,
3394- {
3395- id : "old-work-entry" ,
3396- kind : "work" ,
3397- createdAt : at ( 1 ) ,
3398- attempt : supersededAttempt ,
3399- entry : { id : "old-work" , createdAt : at ( 1 ) , runId, label : "Read" , tone : "tool" } ,
3400- } ,
3401- assistantEntry ( "old-reply-entry" , supersededAttempt , replyCompletedSecond ) ,
3402- {
3403- id : "steer-user-entry" ,
3404- kind : "message" ,
3405- createdAt : at ( 10 ) ,
3406- attempt : nextAttempt ,
3407- message : {
3408- id : MessageId . make ( "steer-user" ) ,
3409- role : "user" ,
3410- text : "What are you working on?" ,
3411- runId,
3412- inputIntent : "steer" ,
3401+ {
3402+ id : "old-work-entry" ,
3403+ kind : "work" ,
3404+ createdAt : at ( 1 ) ,
3405+ attempt : supersededAttempt ,
3406+ entry : { id : "old-work" , createdAt : at ( 1 ) , runId, label : "Read" , tone : "tool" } ,
3407+ } ,
3408+ assistantEntry ( "status-entry" , supersededAttempt , 1 , "commentary" ) ,
3409+ assistantEntry ( "old-reply-entry" , supersededAttempt , replyCompletedSecond , phase ) ,
3410+ {
3411+ id : "steer-user-entry" ,
3412+ kind : "message" ,
34133413 createdAt : at ( 10 ) ,
3414- updatedAt : at ( 10 ) ,
3415- streaming : false ,
3414+ attempt : nextAttempt ,
3415+ message : {
3416+ id : MessageId . make ( "steer-user" ) ,
3417+ role : "user" ,
3418+ text : "What are you working on?" ,
3419+ runId,
3420+ inputIntent : "steer" ,
3421+ createdAt : at ( 10 ) ,
3422+ updatedAt : at ( 10 ) ,
3423+ streaming : false ,
3424+ } ,
34163425 } ,
3417- } ,
3418- assistantEntry ( "new-reply-entry" , nextAttempt , 14 ) ,
3419- ] ,
3426+ assistantEntry ( "new-reply-entry" , nextAttempt , 14 ) ,
3427+ ] satisfies ReadonlyArray < TimelineEntry >
3428+ ) . map ( ( entry ) => ( nativeSteer ? { ... entry , attempt : nextAttempt } : entry ) ) ,
34203429 latestRun : {
34213430 runId,
34223431 status : runStatus ,
@@ -3428,23 +3437,33 @@ describe("v2 run and attempt history", () => {
34283437 supportsConversationRollback : false ,
34293438 } ) ;
34303439
3431- it . each ( [ "running" , "completed" ] as const ) (
3432- "keeps a reply that finished before the steer visible while the run is %s" ,
3433- ( runStatus ) => {
3434- const rows = rowsFor ( 4 , runStatus ) ;
3435- expect ( rows . some ( ( row ) => row . kind === "attempt-fold" ) ) . toBe ( false ) ;
3436- expect ( rows . map ( ( row ) => row . id ) ) . toContain ( "old-reply-entry" ) ;
3440+ it . each ( [
3441+ [ "final_answer" , 4 , true ] ,
3442+ [ "final_answer" , 11 , true ] ,
3443+ [ "commentary" , 4 , false ] ,
3444+ [ "commentary" , 11 , false ] ,
3445+ [ "partial_answer" , 11 , false ] ,
3446+ [ undefined , 4 , true ] ,
3447+ [ undefined , 11 , false ] ,
3448+ ] as const ) (
3449+ "retains phase %s ending at %s only when it is a final reply: %s" ,
3450+ ( phase , completedSecond , retained ) => {
3451+ for ( const runStatus of [ "running" , "completed" ] as const ) {
3452+ for ( const visibility of [ "showAll" , "zen" ] as const ) {
3453+ const rows = rowsFor ( completedSecond , runStatus , visibility , phase ) ;
3454+ expect ( rows . some ( ( row ) => row . id === "old-reply-entry" ) ) . toBe ( retained ) ;
3455+ if ( phase !== undefined && runStatus === "completed" ) {
3456+ const nativeRows = rowsFor ( completedSecond , runStatus , visibility , phase , true ) ;
3457+ expect ( nativeRows . some ( ( row ) => row . id === "old-reply-entry" ) ) . toBe ( retained ) ;
3458+ expect ( nativeRows . some ( ( row ) => row . id === "status-entry" ) ) . toBe ( false ) ;
3459+ }
3460+ if ( runStatus === "completed" ) {
3461+ expect ( rows . some ( ( row ) => row . id === "status-entry" ) ) . toBe ( false ) ;
3462+ }
3463+ }
3464+ }
34373465 } ,
34383466 ) ;
3439-
3440- it ( "folds a reply the steer cut off as partial output" , ( ) => {
3441- const rows = rowsFor ( 11 , "running" ) ;
3442- expect ( rows . find ( ( row ) => row . kind === "attempt-fold" ) ) . toMatchObject ( {
3443- attemptId : supersededAttempt . id ,
3444- label : "Superseded attempt" ,
3445- } ) ;
3446- expect ( rows . map ( ( row ) => row . id ) ) . not . toContain ( "old-reply-entry" ) ;
3447- } ) ;
34483467 } ) ;
34493468
34503469 it ( "hides the interruption request while keeping intervening work and the result" , ( ) => {
0 commit comments