@@ -99,16 +99,10 @@ vi.mock("./reply/agent-runner.runtime.js", () => ({
9999 } ,
100100} ) ) ;
101101
102- vi . mock ( "./reply/commands-compact.runtime.js" , async ( importOriginal ) => {
103- const actual = await importOriginal < typeof import ( "./reply/commands-compact.runtime.js" ) > ( ) ;
104- return {
105- ...actual ,
106- incrementCompactionCount : ( params : Parameters < typeof actual . incrementCompactionCount > [ 0 ] ) =>
107- actual . incrementCompactionCount ( { ...params , expectedSession : undefined } ) ,
108- isCurrentSessionEntry : ( ) => true ,
109- isEmbeddedAgentRunAbortableForCompaction : ( ) => false ,
110- } ;
111- } ) ;
102+ vi . mock ( "./reply/commands-compact.runtime.js" , async ( importOriginal ) => ( {
103+ ...( await importOriginal < typeof import ( "./reply/commands-compact.runtime.js" ) > ( ) ) ,
104+ isEmbeddedAgentRunAbortableForCompaction : ( ) => false ,
105+ } ) ) ;
112106
113107let capturedGetReplyFromConfig : GetReplyFromConfig | undefined ;
114108installTriggerHandlingReplyHarness ( ( impl ) => {
@@ -551,13 +545,17 @@ describe("trigger handling", () => {
551545 const storePath = join ( home , "compact-main.sessions.json" ) ;
552546 const cfg = makeCfg ( home ) ;
553547 cfg . session = { ...cfg . session , store : storePath } ;
554- mockSuccessfulCompaction ( ) ;
555-
556548 const request = {
557549 Body : "/compact focus on decisions" ,
558550 From : "+1003" ,
559551 To : "+2000" ,
560552 } ;
553+ const sessionKey = resolveSessionKey ( "per-sender" , request , undefined , "main" ) ;
554+ await replaceSessionEntry (
555+ { storePath, sessionKey } ,
556+ { sessionId : "compact-main-session" , updatedAt : Date . now ( ) } ,
557+ ) ;
558+ mockSuccessfulCompaction ( ) ;
561559
562560 const res = await getReplyFromConfig (
563561 {
@@ -570,7 +568,6 @@ describe("trigger handling", () => {
570568 const text = maybeReplyText ( res ) ;
571569 expect ( text ) . toMatch ( / ^ ⚙ ️ C o m p a c t e d / u) ;
572570 expect ( getCompactEmbeddedAgentSessionMock ( ) ) . toHaveBeenCalledOnce ( ) ;
573- const sessionKey = resolveSessionKey ( "per-sender" , request , undefined , "main" ) ;
574571 expect ( loadSessionEntry ( { storePath, sessionKey } ) ?. compactionCount ) . toBe ( 1 ) ;
575572 } ) ;
576573 } ) ;
@@ -580,13 +577,19 @@ describe("trigger handling", () => {
580577 getCompactEmbeddedAgentSessionMock ( ) . mockReset ( ) ;
581578 mockSuccessfulCompaction ( ) ;
582579 const cfg = makeCfg ( home ) ;
583- cfg . session = { ...cfg . session , store : join ( home , "compact-worker.sessions.json" ) } ;
580+ const storePath = join ( home , "compact-worker.sessions.json" ) ;
581+ const sessionKey = "agent:worker1:telegram:12345" ;
582+ cfg . session = { ...cfg . session , store : storePath } ;
583+ await replaceSessionEntry (
584+ { storePath, sessionKey } ,
585+ { sessionId : "compact-worker-session" , updatedAt : Date . now ( ) } ,
586+ ) ;
584587 const res = await getReplyFromConfig (
585588 {
586589 Body : "/compact" ,
587590 From : "+1004" ,
588591 To : "+2000" ,
589- SessionKey : "agent:worker1:telegram:12345" ,
592+ SessionKey : sessionKey ,
590593 CommandAuthorized : true ,
591594 } ,
592595 { } ,
0 commit comments