Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS
JavaScript ai-agentsdashboarddeveloper-toolsdigital-twinquantified-selfsecond-brainself-hostedtailscale
fix([issue-12599]): emit voice:tts:cancel on barge-in speaking edge (#12719)
[._.]/549863414f58
diff --git a/server/sockets/voice.js b/server/sockets/voice.jsindex 922c53c0ea..078ce4c2d3 100644--- a/server/sockets/voice.js+++ b/server/sockets/voice.js@@ -11,7 +11,7 @@// | voice:speak | voice:output:primary | voice:output:detached// Call host (FaceTime Audio bridge):// Inbound: voice:call:attach | voice:call:audio | voice:call:detach | voice:call:hangup-// Outbound: voice:call:state | voice:call:tts+// Outbound: voice:call:state | voice:call:tts | voice:tts:cancel// Meeting capture (same page, same audio bridge, no LLM — STT only):// Inbound: voice:capture:start | voice:call:audio | voice:capture:stop// Outbound: voice:capture:state@@ -563,13 +563,16 @@ export const registerVoiceHandlers = (socket) => {const view = toInt16Samples(pcm);if (asCallHost) {+ const wasSpeaking = Boolean(call.endpointer.speaking);const utterance = call.endpointer.push(view);- // Barge-in: the caller talking over a reply cancels it, exactly as- // pressing the widget's interrupt does.- if (call.endpointer.speaking && call.busy) {- call.ctrl?.abort();- state.pendingDestructive = null;- socket.emit('voice:interrupt', { reason: 'barge-in' });+ // Barge-in: caller speech onset cancels playback on the host socket+ // whether or not a reply turn is still actively generating.+ if (!wasSpeaking && call.endpointer.speaking) {+ socket.emit('voice:tts:cancel', { reason: 'barge-in' });+ if (call.busy) {+ call.ctrl?.abort();+ state.pendingDestructive = null;+ }}if (!utterance) return;noteCallerSpeech();diff --git a/server/sockets/voice.test.js b/server/sockets/voice.test.jsindex 04096e7965..06037a87c2 100644--- a/server/sockets/voice.test.js+++ b/server/sockets/voice.test.js@@ -700,11 +700,42 @@ describe('voice:capture socket handlers (meeting capture)', () => {await flushMicrotasks();expect(capturedSignal.aborted).toBe(true);- expect(socket.emitted.some((e) => e.event === 'voice:interrupt' && e.payload.reason === 'barge-in')).toBe(true);+ expect(socket.emitted.some((e) => e.event === 'voice:tts:cancel' && e.payload.reason === 'barge-in')).toBe(true);+ expect(socket.emitted.some((e) => e.event === 'voice:interrupt')).toBe(false);releaseFirstTurn({});await flushMicrotasks();});++ it('caller-speech onset after runTurn has resolved emits voice:tts:cancel on speaking edge only', async () => {+ const socket = makeFakeSocket();+ registerVoiceHandlers(socket);+ await socket.fire('voice:call:attach');++ runTurn.mockResolvedValueOnce({ text: 'Hello there' });++ // Complete a turn so call.busy returns to false+ for (let i = 0; i < 14; i += 1) socket.fire('voice:call:audio', { pcm: loudFrame() });+ for (let i = 0; i < 36; i += 1) socket.fire('voice:call:audio', { pcm: silentFrame() });+ await flushMicrotasks();+ expect(runTurn).toHaveBeenCalledTimes(1);++ socket.emitted.length = 0;++ // Caller begins speaking again while call.busy is false:+ socket.fire('voice:call:audio', { pcm: loudFrame() });+ await flushMicrotasks();++ const cancels = socket.emitted.filter((e) => e.event === 'voice:tts:cancel' && e.payload?.reason === 'barge-in');+ expect(cancels).toHaveLength(1);+ expect(socket.emitted.some((e) => e.event === 'voice:interrupt')).toBe(false);++ // Subsequent loud frame during the same utterance must not emit another cancel (onset edge only)+ socket.fire('voice:call:audio', { pcm: loudFrame() });+ await flushMicrotasks();+ const cancelsAfterSecondFrame = socket.emitted.filter((e) => e.event === 'voice:tts:cancel' && e.payload?.reason === 'barge-in');+ expect(cancelsAfterSecondFrame).toHaveLength(1);+ });});describe('voice:call:audio frame alignment', () => {