@@ -990,6 +990,61 @@ describe('KimiTUI resume message replay', () => {
990990 expect ( transcript ) . toContain ( 'hook response 2' ) ;
991991 } ) ;
992992
993+ it ( 'renders replayed compaction records as completed compaction blocks' , async ( ) => {
994+ const driver = await replayIntoDriver ( [
995+ message ( 'user' , [ { type : 'text' , text : 'prompt before compaction' } ] ) ,
996+ {
997+ type : 'compaction' ,
998+ result : {
999+ summary : 'Compacted transcript summary.' ,
1000+ compactedCount : 4 ,
1001+ tokensBefore : 120 ,
1002+ tokensAfter : 24 ,
1003+ } ,
1004+ instruction : 'preserve implementation notes' ,
1005+ } ,
1006+ message ( 'user' , [ { type : 'text' , text : 'prompt after compaction' } ] ) ,
1007+ ] ) ;
1008+
1009+ const compactionEntry = driver . state . transcriptEntries . find (
1010+ ( entry ) => entry . compactionData !== undefined ,
1011+ ) ;
1012+ expect ( compactionEntry ?. compactionData ) . toEqual ( {
1013+ tokensBefore : 120 ,
1014+ tokensAfter : 24 ,
1015+ instruction : 'preserve implementation notes' ,
1016+ } ) ;
1017+ const transcript = stripAnsi ( driver . state . transcriptContainer . render ( 120 ) . join ( '\n' ) ) ;
1018+ expect ( transcript ) . toContain ( 'Compaction complete' ) ;
1019+ expect ( transcript ) . toContain ( '120 → 24 tokens' ) ;
1020+ expect ( transcript ) . toContain ( 'preserve implementation notes' ) ;
1021+ expect ( transcript ) . not . toContain ( 'Compacted transcript summary.' ) ;
1022+ } ) ;
1023+
1024+ it ( 'renders replayed cancelled compaction records as cancelled compaction blocks' , async ( ) => {
1025+ const driver = await replayIntoDriver ( [
1026+ message ( 'user' , [ { type : 'text' , text : 'prompt before cancellation' } ] ) ,
1027+ {
1028+ type : 'compaction' ,
1029+ result : 'cancelled' ,
1030+ instruction : 'preserve implementation notes' ,
1031+ } ,
1032+ message ( 'user' , [ { type : 'text' , text : 'prompt after cancellation' } ] ) ,
1033+ ] ) ;
1034+
1035+ const compactionEntry = driver . state . transcriptEntries . find (
1036+ ( entry ) => entry . compactionData !== undefined ,
1037+ ) ;
1038+ expect ( compactionEntry ?. compactionData ) . toEqual ( {
1039+ result : 'cancelled' ,
1040+ instruction : 'preserve implementation notes' ,
1041+ } ) ;
1042+ const transcript = stripAnsi ( driver . state . transcriptContainer . render ( 120 ) . join ( '\n' ) ) ;
1043+ expect ( transcript ) . toContain ( 'Compaction cancelled' ) ;
1044+ expect ( transcript ) . toContain ( 'preserve implementation notes' ) ;
1045+ expect ( transcript ) . not . toContain ( 'Compaction complete' ) ;
1046+ } ) ;
1047+
9931048 it ( 'renders plan permission and approval replay notices' , async ( ) => {
9941049 const driver = await replayIntoDriver ( [
9951050 { time : REPLAY_TIME , type : 'plan_updated' , enabled : true } ,
0 commit comments