feat(web): wire WebSocket chat with streaming and conversation switching (#120) (#136)
All checks were successful
ci/woodpecker/push/ci Pipeline was successful

Co-authored-by: Jason Woltje <jason@diversecanvas.com>
Co-committed-by: Jason Woltje <jason@diversecanvas.com>
This commit was merged in pull request #136.
This commit is contained in:
2026-03-15 18:09:14 +00:00
committed by jason.woltje
parent ea800e3f14
commit d0999a8e37
4 changed files with 120 additions and 42 deletions

View File

@@ -9,7 +9,24 @@ export function getSocket(): Socket {
socket = io(`${GATEWAY_URL}/chat`, {
withCredentials: true,
autoConnect: false,
transports: ['websocket', 'polling'],
});
// Reset singleton reference when socket is fully closed so the next
// getSocket() call creates a fresh instance instead of returning a
// closed/dead socket.
socket.on('disconnect', () => {
socket = null;
});
}
return socket;
}
/** Tear down the singleton socket and reset the reference. */
export function destroySocket(): void {
if (socket) {
socket.offAny();
socket.disconnect();
socket = null;
}
}