@@ -718,6 +718,41 @@ describe("threadHistoryPaging", () => {
718718 expect ( bounded . projection . visibleTurnItems ) . toEqual ( actionable . visibleTurnItems ) ;
719719 } ) ;
720720
721+ it ( "keeps agent-only turns visible when checkpoint file lists fill the byte budget" , ( ) => {
722+ const items = Array . from ( { length : 3 } , ( _ , turn ) => {
723+ const first = makeRow ( turn * 5 ) ;
724+ const prompt = {
725+ ...first ,
726+ item : {
727+ ...first . item ,
728+ type : "user_message" as const ,
729+ createdBy : "agent" as const ,
730+ creationSource : "provider" as const ,
731+ inputIntent : "turn_start" as const ,
732+ messageId : MessageId . make ( `agent-prompt-${ turn } ` ) ,
733+ text : `Step ${ turn } ` ,
734+ attachments : [ ] ,
735+ } ,
736+ } as OrchestrationV2ProjectedTurnItem ;
737+ return [ prompt , ...Array . from ( { length : 4 } , ( _ , index ) => makeRow ( turn * 5 + index + 1 ) ) ] ;
738+ } ) . flat ( ) ;
739+ const files = Array . from (
740+ { length : 15_000 } ,
741+ ( _ , index ) =>
742+ `work/ws-${ index % 40 } /.jj/repo/store/extra/${ index . toString ( 16 ) . padStart ( 40 , "0" ) } ` ,
743+ ) ;
744+ const projection = {
745+ ...makeProjection ( items ) ,
746+ checkpoints : [ { id : "checkpoint-1" , files } ] ,
747+ } as unknown as ReturnType < typeof makeProjection > ;
748+
749+ const bounded = buildBoundedThreadProjection ( { projection, snapshotSequence : 1 } ) ;
750+
751+ expect ( bounded . projection . visibleTurnItems ) . toHaveLength ( items . length ) ;
752+ expect ( bounded . hasMoreHistory ) . toBe ( false ) ;
753+ expect ( bounded . payloadBudgetExceeded ) . toBe ( true ) ;
754+ } ) ;
755+
721756 it ( "keeps paged historical plan detail in the turn item and only status in its artifact" , ( ) => {
722757 const detail = "Implement the historical plan exactly.\n" . repeat ( 1_000 ) ;
723758 const item = {
0 commit comments