Skip to content

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

fix: ignore voice output claims while voice is disabled

[._.]/ Adam Eivy423082f67270
diff --git a/server/sockets/voice.js b/server/sockets/voice.js
index 36f727163a..719aae564c 100644
--- a/server/sockets/voice.js
+++ b/server/sockets/voice.js
@@ -416,8 +416,19 @@ export const registerVoiceHandlers = (socket) => {
// focused/visible (or where the user explicitly clicked "speak here") becomes
// the single recipient of `voice:speak`. Last claim wins; the previous holder
// is notified via voice:output:detached so its UI can reflect the handoff.
- socket.on('voice:output:claim', () => {
- claimVoiceOutput(socket);
+ // Ignored while voice is disabled: every tab claims on each focus/visibility
+ // change, and proactive speech is refused when disabled anyway. Candidates
+ // stay registered, so enabling voice later still lazily elects a recipient.
+ // Re-check the connection after the await: a tab that disconnected mid-read
+ // was already released and must not be re-added as primary.
+ socket.on('voice:output:claim', async () => {
+ try {
+ const cfg = await getVoiceConfig();
+ if (!cfg.enabled || socket.connected === false) return;
+ claimVoiceOutput(socket);
+ } catch (err) {
+ console.error(`❌ voice: output claim failed: ${err.message}`);
+ }
});
// ---------------------------------------------------------------------------
diff --git a/server/sockets/voice.test.js b/server/sockets/voice.test.js
index 3099e2def4..c60ad8ec06 100644
--- a/server/sockets/voice.test.js
+++ b/server/sockets/voice.test.js
@@ -54,6 +54,7 @@ const {
const { transcribe } = await import('../services/voice/stt.js');
const { synthesize } = await import('../services/voice/tts.js');
const { runTurn } = await import('../services/voice/pipeline.js');
+const { getVoiceConfig } = await import('../services/voice/config.js');
const {
attachHost: attachCallHost,
__resetCallSession,
@@ -273,6 +274,7 @@ describe('voice:text turn recovery', () => {
});
describe('voice:output single-recipient wiring', () => {
+ const flush = () => new Promise((resolve) => setTimeout(resolve, 0));
beforeEach(() => __resetVoiceOutput());
it('registers a candidate only after the tab announces voice:output:available', () => {
@@ -301,7 +303,7 @@ describe('voice:output single-recipient wiring', () => {
expect(tab.emitted.filter((e) => e.event === 'voice:speak')).toHaveLength(1);
});
- it('claiming routes proactive output to the claiming tab, not another', () => {
+ it('claiming routes proactive output to the claiming tab, not another', async () => {
const a = makeFakeSocket();
const b = makeFakeSocket();
registerVoiceHandlers(a);
@@ -310,6 +312,7 @@ describe('voice:output single-recipient wiring', () => {
b.fire('voice:output:available');
// b is the active tab and claims output.
b.fire('voice:output:claim');
+ await flush();
const io = { emit: () => { throw new Error('must not broadcast'); } };
emitVoiceOutput(io, 'voice:speak', { sentence: 'ping' });
@@ -317,7 +320,7 @@ describe('voice:output single-recipient wiring', () => {
expect(b.emitted.filter((e) => e.event === 'voice:speak')).toHaveLength(1);
});
- it('disconnecting the primary promotes another announced tab', () => {
+ it('disconnecting the primary promotes another announced tab', async () => {
const a = makeFakeSocket();
const b = makeFakeSocket();
registerVoiceHandlers(a);
@@ -325,11 +328,22 @@ describe('voice:output single-recipient wiring', () => {
a.fire('voice:output:available');
b.fire('voice:output:available');
a.fire('voice:output:claim');
+ await flush();
expect(getVoiceOutputSocket()).toBe(a);
a.fire('disconnect');
expect(getVoiceOutputSocket()).toBe(b);
});
+
+ it('ignores output claims while voice is disabled', async () => {
+ getVoiceConfig.mockResolvedValueOnce({ enabled: false });
+ const a = makeFakeSocket();
+ registerVoiceHandlers(a);
+ a.fire('voice:output:available');
+ a.fire('voice:output:claim');
+ await flush();
+ expect(a.emitted.filter((e) => e.event === 'voice:output:primary')).toHaveLength(0);
+ });
});
describe('call host opening line', () => {