fix: improve voice playback, diagnostics and workspace controls

This commit is contained in:
illusia committed 2026-11-13 19:49:31 +08:00
1 parent 72d7e6e013
commit e82116239a
34 files changed
+502 -147

No files matched your search

+2
View File
@@ -6,6 +6,7 @@ export interface ConnectionFailure {
interface ConnectionOptions {
onSocket(socket: WebSocket | null): void;
onSocketOpen?(): void;
onMessage(message: unknown): void;
onAudio(frame: Uint8Array): void;
onClose(event: CloseEvent): void;
@@ -72,6 +73,7 @@ export function createVoiceConnection(options: ConnectionOptions) {
options.onSocket(socket);
socket.onopen = () => {
if (!isCurrent(record)) clean(() => socket.close(1000));
else options.onSocketOpen?.();
};
socket.onmessage = event => {
if (!isCurrent(record) || record.socket !== socket || socket.readyState !== WebSocket.OPEN) return;