@@ -1051,6 +1051,66 @@ describe("EnvironmentThreads", () => {
10511051 expect ( ( yield * SubscriptionRef . get ( harness . threadState ) ) . history . loading ) . toBe ( false ) ;
10521052 } ) ,
10531053 ) ;
1054+ const boundary = ( fields : object , id = "boundary" , ordinal = 2 ) => ( {
1055+ ...command ( id , "completed" , 0 , ordinal ) ,
1056+ ...fields ,
1057+ } ) ;
1058+ const message = (
1059+ inputIntent : "turn_start" | "steer" ,
1060+ createdBy : "agent" | "user" ,
1061+ id = "boundary" ,
1062+ ordinal = 2 ,
1063+ ) =>
1064+ boundary (
1065+ {
1066+ type : "user_message" ,
1067+ messageId : MessageId . make ( id ) ,
1068+ inputIntent,
1069+ createdBy,
1070+ creationSource : "mcp" ,
1071+ text : "Run every check" ,
1072+ attachments : [ ] ,
1073+ } ,
1074+ id ,
1075+ ordinal ,
1076+ ) ;
1077+ it . effect . each ( [
1078+ [ "an agent-started turn" , message ( "turn_start" , "agent" ) , [ "3" ] ] ,
1079+ [
1080+ "a notification" ,
1081+ boundary ( {
1082+ type : "notification" ,
1083+ source : { kind : "delegated_task" , taskIds : [ ] } ,
1084+ outcome : "completed" ,
1085+ summary : "Checks finished" ,
1086+ } ) ,
1087+ [ "3" ] ,
1088+ ] ,
1089+ [ "a steer, paging on to its turn" , message ( "steer" , "user" ) , [ "3" , "2" , "1" ] ] ,
1090+ ] as const ) ( "stops paging earlier history at %s" , ( [ , item , expected ] ) =>
1091+ Effect . gen ( function * ( ) {
1092+ const pages : Record < string , ReadonlyArray < unknown > > = {
1093+ "3" : [ item ] ,
1094+ "2" : [ command ( "work-1" , "completed" , 0 , 1 ) ] ,
1095+ "1" : [ message ( "turn_start" , "user" , "opener" , 0 ) ] ,
1096+ } ;
1097+ const requests : string [ ] = [ ] ;
1098+ const harness = yield * makeHarness ( {
1099+ cached : cachedItem ( command ( "tail" , "completed" , 0 , 3 ) ) ,
1100+ cachedHistory : { historyCursor : "3" , hasMoreHistory : true } ,
1101+ historyHttpClient : HttpClient . make ( ( request , url ) => {
1102+ const cursor = url . searchParams . get ( "cursor" ) ! ;
1103+ requests . push ( cursor ) ;
1104+ const items = ( pages [ cursor ] ?? [ ] ) as ReadonlyArray < OrchestrationV2TurnItem > ;
1105+ return Effect . succeed (
1106+ historyPage ( request , items . map ( localRow ) , String ( Number ( cursor ) - 1 ) ) ,
1107+ ) ;
1108+ } ) ,
1109+ } ) ;
1110+ expect ( yield * harness . loadEarlier ( ) ) . toEqual ( { _tag : "loaded" } ) ;
1111+ expect ( requests ) . toEqual ( expected ) ;
1112+ } ) ,
1113+ ) ;
10541114 it . effect ( "loads deferred work on demand and resumes a failed page" , ( ) =>
10551115 Effect . gen ( function * ( ) {
10561116 const anchor = {
0 commit comments