@@ -16,17 +16,21 @@ const sessionRow = vi.hoisted(() => ({
1616const resolveEmbeddedAgentRunProgressStateMock = vi . hoisted ( ( ) => vi . fn ( ) ) ;
1717const loadGatewaySessionRowMock = vi . hoisted ( ( ) => vi . fn ( ) ) ;
1818const projectChatDisplayMessageMock = vi . hoisted ( ( ) => vi . fn ( ( message : unknown ) => message ) ) ;
19+ const listAccessorSessionEntriesReadOnlyMock = vi . hoisted ( ( ) => vi . fn ( ) ) ;
1920const loadAccessorSessionEntryReadOnlyMock = vi . hoisted ( ( ) => vi . fn ( ) ) ;
2021const loadGatewaySessionEntryReadOnlyMock = vi . hoisted ( ( ) => vi . fn ( ) ) ;
2122const readSessionMessageCountAsyncMock = vi . hoisted ( ( ) => vi . fn ( ) ) ;
23+ const resolveTranscriptSessionKeyBySessionIdMock = vi . hoisted ( ( ) => vi . fn ( ) ) ;
2224const runtimeConfigState = vi . hoisted ( ( ) => ( { value : { } as Record < string , unknown > } ) ) ;
2325
2426vi . mock ( "../config/io.js" , ( ) => ( { getRuntimeConfig : ( ) => runtimeConfigState . value } ) ) ;
2527vi . mock ( "../config/sessions/session-accessor.js" , async ( importOriginal ) => {
2628 const actual = await importOriginal < typeof import ( "../config/sessions/session-accessor.js" ) > ( ) ;
2729 return {
2830 ...actual ,
31+ listSessionEntriesReadOnly : listAccessorSessionEntriesReadOnlyMock ,
2932 loadSessionEntryReadOnly : loadAccessorSessionEntryReadOnlyMock ,
33+ resolveTranscriptSessionKeyBySessionId : resolveTranscriptSessionKeyBySessionIdMock ,
3034 } ;
3135} ) ;
3236vi . mock ( "./chat-display-projection.js" , ( ) => ( {
@@ -110,10 +114,12 @@ describe("createTranscriptUpdateBroadcastHandler", () => {
110114 beforeEach ( ( ) => {
111115 vi . clearAllMocks ( ) ;
112116 resolveEmbeddedAgentRunProgressStateMock . mockReturnValue ( undefined ) ;
117+ listAccessorSessionEntriesReadOnlyMock . mockReturnValue ( [ ] ) ;
113118 loadAccessorSessionEntryReadOnlyMock . mockReturnValue ( undefined ) ;
114119 loadGatewaySessionEntryReadOnlyMock . mockReturnValue ( { entry : undefined , storePath : "" } ) ;
115120 loadGatewaySessionRowMock . mockReturnValue ( sessionRow ) ;
116121 readSessionMessageCountAsyncMock . mockResolvedValue ( undefined ) ;
122+ resolveTranscriptSessionKeyBySessionIdMock . mockReturnValue ( undefined ) ;
117123 loadGatewaySessionRowMock . mockReturnValue ( sessionRow ) ;
118124 runtimeConfigState . value = { } ;
119125 sessionRow . key = "agent:main:main" ;
@@ -735,6 +741,13 @@ describe("createTranscriptUpdateBroadcastHandler", () => {
735741 secondSessionKey : "agent:main:global" ,
736742 agentId : "main" ,
737743 } ,
744+ {
745+ name : "a marker-only update and its canonical transcript key" ,
746+ firstSessionKey : "agent:main:main" ,
747+ secondSessionKey : "agent:main:main" ,
748+ agentId : "main" ,
749+ markerOnly : true ,
750+ } ,
738751 {
739752 name : "an ownerless global update in its configured fixed store" ,
740753 firstSessionKey : "global" ,
@@ -759,17 +772,27 @@ describe("createTranscriptUpdateBroadcastHandler", () => {
759772 } ) ,
760773 ) ;
761774 loadAccessorSessionEntryReadOnlyMock . mockReturnValue ( { sessionId : "sess-main" } ) ;
775+ if ( scenario . markerOnly ) {
776+ listAccessorSessionEntriesReadOnlyMock . mockReturnValue ( [
777+ { key : scenario . firstSessionKey , entry : { sessionId : "sess-main" } } ,
778+ ] ) ;
779+ resolveTranscriptSessionKeyBySessionIdMock . mockReturnValue ( scenario . firstSessionKey ) ;
780+ }
762781 const { broadcastToConnIds, handler } = createHandler ( false ) ;
763782
764783 const firstTask = handler ( {
765784 message : { role : "assistant" , content : [ { type : "text" , text : "first" } ] } ,
766785 messageId : "ordered-1" ,
767- target : {
768- agentId : scenario . agentId ,
769- sessionId : "sess-main" ,
770- sessionKey : scenario . firstSessionKey ,
771- storePath : "/tmp/explicit-sessions.json" ,
772- } ,
786+ ...( scenario . markerOnly
787+ ? { sessionFile : `sqlite:${ scenario . agentId } :sess-main:/tmp/explicit-sessions.json` }
788+ : {
789+ target : {
790+ agentId : scenario . agentId ,
791+ sessionId : "sess-main" ,
792+ sessionKey : scenario . firstSessionKey ,
793+ storePath : "/tmp/explicit-sessions.json" ,
794+ } ,
795+ } ) ,
773796 } ) ;
774797 await vi . waitFor ( ( ) => expect ( readSessionMessageCountAsyncMock ) . toHaveBeenCalledOnce ( ) ) ;
775798 const secondTask = handler ( {
0 commit comments