This commit is contained in:
2026-10-24 16:34:02 +08:00
parent 99e5687ce0
commit 7119e04a65
24 changed files with 553 additions and 39 deletions
+16
View File
@@ -85,6 +85,22 @@ describe('chat-run socket reconnect handling', () => {
socketState.sockets = []
})
it('removes cancelled resume listeners without disturbing the current request', async () => {
const { resumeSession } = await import('../../packages/client/src/api/hermes/chat')
const controller = new AbortController()
const oldReply = vi.fn()
resumeSession('session-1', oldReply, 'default', 'chat-run', controller.signal)
const socket = socketState.sockets[0]
controller.abort()
expect(socket.__listenerCount('resumed')).toBe(0)
const currentReply = vi.fn()
resumeSession('session-1', currentReply, 'default')
socket.__trigger('resumed', { session_id: 'session-1', messages: [], isWorking: false, events: [] })
expect(oldReply).not.toHaveBeenCalled()
expect(currentReply).toHaveBeenCalledOnce()
expect(socket.__listenerCount('resumed')).toBe(0)
})
it('keeps transient mobile disconnects alive and resumes after reconnect', async () => {
const { startRunViaSocket } = await import('../../packages/client/src/api/hermes/chat')
const onEvent = vi.fn()