@@ -55,6 +55,7 @@ function fixture(history: SessionMessage[], respond: (request: any, call: number
5555 process . env . HOME = root ;
5656 process . env . USERPROFILE = root ;
5757 const requests : any [ ] = [ ] ;
58+ const notices : SessionMessage [ ] = [ ] ;
5859 const settings = {
5960 model : "test-vision" ,
6061 contextWindow : 256 * 1024 ,
@@ -79,14 +80,15 @@ function fixture(history: SessionMessage[], respond: (request: any, call: number
7980 } ) ,
8081 getResolvedSettings : ( ) => settings ,
8182 renderMarkdown : ( text ) => text ,
82- onAssistantMessage : ( ) => { } ,
83+ onAssistantMessage : ( message ) => notices . push ( message ) ,
8384 } ) ;
8485 const internal = manager as any ;
8586 internal . saveSessionMessages ( "compact-test" , history ) ;
8687 return {
8788 manager,
8889 internal,
8990 requests,
91+ notices,
9092 settings,
9193 root,
9294 read : ( ) => manager . listSessionMessages ( "compact-test" ) ,
@@ -104,13 +106,25 @@ test("manual compaction reports whether it changed history", async () => {
104106 const empty = fixture ( [ ] ) ;
105107 assert . equal ( await empty . compact ( ) , false ) ;
106108 assert . equal ( empty . requests . length , 0 ) ;
109+ assert . deepEqual (
110+ empty . notices . map ( ( item ) => item . content ) ,
111+ [ "Compacting conversation..." ]
112+ ) ;
107113 const short = fixture ( [ message ( "only" ) ] ) ;
108114 assert . equal ( await short . compact ( ) , false ) ;
109115 assert . equal ( short . requests . length , 0 ) ;
110116 const history = [ message ( "older" ) , message ( "reply" , "assistant" ) , message ( "tail" ) ] ;
111117 const ready = fixture ( history ) ;
112118 assert . equal ( await ready . compact ( ) , true ) ;
113119 assert . equal ( ready . requests . length , 1 ) ;
120+ assert . deepEqual (
121+ ready . notices . map ( ( item ) => [ item . role , item . content ] ) ,
122+ [
123+ [ "assistant" , "Compacting conversation..." ] ,
124+ [ "user" , "Conversation compacted." ] ,
125+ ]
126+ ) ;
127+ assert . ok ( ready . notices . every ( ( notice ) => ! ready . read ( ) . some ( ( item ) => item . id === notice . id ) ) ) ;
114128 assert . deepEqual (
115129 ready
116130 . read ( )
0 commit comments