@@ -689,6 +689,41 @@ describe("threadHistoryPaging", () => {
689689 expect ( bounded . projection . visibleTurnItems ) . toEqual ( actionable . visibleTurnItems ) ;
690690 } ) ;
691691
692+ it ( "keeps agent-only turns visible when checkpoint file lists fill the byte budget" , ( ) => {
693+ const items = Array . from ( { length : 3 } , ( _ , turn ) => {
694+ const first = makeRow ( turn * 5 ) ;
695+ const prompt = {
696+ ...first ,
697+ item : {
698+ ...first . item ,
699+ type : "user_message" as const ,
700+ createdBy : "agent" as const ,
701+ creationSource : "provider" as const ,
702+ inputIntent : "turn_start" as const ,
703+ messageId : MessageId . make ( `agent-prompt-${ turn } ` ) ,
704+ text : `Step ${ turn } ` ,
705+ attachments : [ ] ,
706+ } ,
707+ } as OrchestrationV2ProjectedTurnItem ;
708+ return [ prompt , ...Array . from ( { length : 4 } , ( _ , index ) => makeRow ( turn * 5 + index + 1 ) ) ] ;
709+ } ) . flat ( ) ;
710+ const files = Array . from (
711+ { length : 15_000 } ,
712+ ( _ , index ) =>
713+ `work/ws-${ index % 40 } /.jj/repo/store/extra/${ index . toString ( 16 ) . padStart ( 40 , "0" ) } ` ,
714+ ) ;
715+ const projection = {
716+ ...makeProjection ( items ) ,
717+ checkpoints : [ { id : "checkpoint-1" , files } ] ,
718+ } as unknown as ReturnType < typeof makeProjection > ;
719+
720+ const bounded = buildBoundedThreadProjection ( { projection, snapshotSequence : 1 } ) ;
721+
722+ expect ( bounded . projection . visibleTurnItems ) . toHaveLength ( items . length ) ;
723+ expect ( bounded . hasMoreHistory ) . toBe ( false ) ;
724+ expect ( bounded . payloadBudgetExceeded ) . toBe ( true ) ;
725+ } ) ;
726+
692727 it ( "keeps paged historical plan detail in the turn item and only status in its artifact" , ( ) => {
693728 const detail = "Implement the historical plan exactly.\n" . repeat ( 1_000 ) ;
694729 const item = {
0 commit comments