feat(web): add WebSocket transport for message event streaming with SSE fallback (#764)
* feat: add websocket message stream transport * fix: avoid false missing session directories in sidebar * fix: re-probe project root session directories * refactor: use button group for message stream transport * fix: resolve chat input hook dependency warning --------- Co-authored-by: Bohdan Triapitsyn <artmore@protonmail.com>
This commit is contained in:
committed by
GitHub
co-authored by
Bohdan Triapitsyn
parent
fd8972a7d9
commit
bee9d19f3a
@@ -0,0 +1,68 @@
|
||||
import { afterEach, describe, expect, it } from 'bun:test';
|
||||
|
||||
import { createSessionRuntime } from './session-runtime.js';
|
||||
|
||||
describe('session runtime', () => {
|
||||
const runtimes = [];
|
||||
|
||||
afterEach(() => {
|
||||
for (const runtime of runtimes) {
|
||||
runtime.dispose();
|
||||
}
|
||||
runtimes.length = 0;
|
||||
});
|
||||
|
||||
it('broadcasts attention clears through the shared broadcaster', () => {
|
||||
const events = [];
|
||||
const runtime = createSessionRuntime({
|
||||
writeSseEvent() {
|
||||
throw new Error('SSE fallback should not be used when broadcastEvent is provided');
|
||||
},
|
||||
getNotificationClients: () => new Set(),
|
||||
broadcastEvent: (payload) => {
|
||||
events.push(payload);
|
||||
},
|
||||
});
|
||||
runtimes.push(runtime);
|
||||
|
||||
runtime.processOpenCodeSsePayload({
|
||||
type: 'session.status',
|
||||
properties: {
|
||||
sessionID: 'session-1',
|
||||
info: {
|
||||
type: 'busy',
|
||||
},
|
||||
},
|
||||
});
|
||||
runtime.markUserMessageSent('session-1');
|
||||
runtime.processOpenCodeSsePayload({
|
||||
type: 'session.status',
|
||||
properties: {
|
||||
sessionID: 'session-1',
|
||||
info: {
|
||||
type: 'idle',
|
||||
},
|
||||
},
|
||||
});
|
||||
runtime.markSessionViewed('session-1', 'client-1');
|
||||
|
||||
expect(events).toContainEqual({
|
||||
type: 'openchamber:session-status',
|
||||
properties: expect.objectContaining({
|
||||
sessionId: 'session-1',
|
||||
status: 'idle',
|
||||
needsAttention: true,
|
||||
}),
|
||||
});
|
||||
expect(events.at(-1)).toEqual({
|
||||
type: 'openchamber:session-status',
|
||||
properties: {
|
||||
sessionId: 'session-1',
|
||||
status: 'idle',
|
||||
timestamp: expect.any(Number),
|
||||
metadata: {},
|
||||
needsAttention: false,
|
||||
},
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user