Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

feat(human): add live voice session controls

Steven Enamakelab3377dbce9f
diff --git a/app/src/components/settings/panels/LiveVoicePanel.test.tsx b/app/src/components/settings/panels/LiveVoicePanel.test.tsx
index ab454f4af4..1ed6b5bd04 100644
--- a/app/src/components/settings/panels/LiveVoicePanel.test.tsx
+++ b/app/src/components/settings/panels/LiveVoicePanel.test.tsx
@@ -110,7 +110,9 @@ describe('LiveVoicePanel', () => {
expect(api.updateLiveVoiceSettings).toHaveBeenCalledWith({ default_provider: 'gemini' })
);
await screen.findByText('Saved.');
- expect(within(screen.getByTestId('live-voice-provider-gemini')).getByText('Default')).toBeTruthy();
+ expect(
+ within(screen.getByTestId('live-voice-provider-gemini')).getByText('Default')
+ ).toBeTruthy();
});
it('saves a BYOK key and re-fetches providers', async () => {
@@ -168,7 +170,11 @@ describe('LiveVoicePanel', () => {
fireEvent.click(screen.getByTestId('live-voice-test-button-elevenlabs-hosted'));
await screen.findByText('Working');
- api.testLiveVoiceProvider.mockResolvedValueOnce({ ok: false, latency_ms: null, error: 'bad key' });
+ api.testLiveVoiceProvider.mockResolvedValueOnce({
+ ok: false,
+ latency_ms: null,
+ error: 'bad key',
+ });
fireEvent.click(screen.getByTestId('live-voice-test-button-gemini'));
await screen.findByText('Test failed: bad key');
diff --git a/app/src/features/human/HumanPage.tsx b/app/src/features/human/HumanPage.tsx
index c636c1687a..55d2def10d 100644
--- a/app/src/features/human/HumanPage.tsx
+++ b/app/src/features/human/HumanPage.tsx
@@ -13,6 +13,7 @@ import {
selectSpeakReplies,
} from '../../store/mascotSlice';
import { HUMAN_VOICE_REALTIME_ENABLED, HUMAN_VOICE_SHOW_BOTH } from '../../utils/config';
+import LiveVoiceControls, { type LiveVoicePhase } from './LiveVoiceControls';
import {
CustomGifMascot,
getMascotPalette,
@@ -21,7 +22,6 @@ import {
RiveMascot,
} from './Mascot';
import { useMascotManifest } from './Mascot/manifest/useMascotManifest';
-import LiveVoiceControls, { type LiveVoicePhase } from './LiveVoiceControls';
import { useHumanMascot } from './useHumanMascot';
import { IDLE_REALTIME_VOICE_AUDIO, type RealtimeVoiceAudio } from './voice/amplitudeLipsync';
import { useAmplitudeLipsync } from './voice/useAmplitudeLipsync';
diff --git a/app/src/features/human/LiveVoiceControls.test.tsx b/app/src/features/human/LiveVoiceControls.test.tsx
index 034282c3d3..92432f8610 100644
--- a/app/src/features/human/LiveVoiceControls.test.tsx
+++ b/app/src/features/human/LiveVoiceControls.test.tsx
@@ -8,9 +8,7 @@ import type { LiveVoiceSession } from './voice/live/useLiveVoiceSession';
const session = vi.hoisted(() => ({ current: null as unknown as LiveVoiceSession }));
-vi.mock('./voice/live/useLiveVoiceSession', () => ({
- useLiveVoiceSession: () => session.current,
-}));
+vi.mock('./voice/live/useLiveVoiceSession', () => ({ useLiveVoiceSession: () => session.current }));
function makeSession(over: Partial<LiveVoiceSession> = {}): LiveVoiceSession {
return {
diff --git a/app/src/features/human/LiveVoiceControls.tsx b/app/src/features/human/LiveVoiceControls.tsx
index 91d1d3ca49..e804322284 100644
--- a/app/src/features/human/LiveVoiceControls.tsx
+++ b/app/src/features/human/LiveVoiceControls.tsx
@@ -43,13 +43,10 @@ export interface LiveVoiceControlsProps {
onPhaseChange?: (phase: LiveVoicePhase) => void;
}
-const TOOL_VARIANT: Record<LiveVoiceToolCall['status'], 'primary' | 'success' | 'danger' | 'neutral'> =
- {
- running: 'primary',
- ok: 'success',
- failed: 'danger',
- cancelled: 'neutral',
- };
+const TOOL_VARIANT: Record<
+ LiveVoiceToolCall['status'],
+ 'primary' | 'success' | 'danger' | 'neutral'
+> = { running: 'primary', ok: 'success', failed: 'danger', cancelled: 'neutral' };
const TOOL_LABEL_KEY: Record<LiveVoiceToolCall['status'], string> = {
running: 'voice.live.toolRunning',
@@ -182,9 +179,7 @@ export default function LiveVoiceControls({
{recent.map((line, index) => (
<p
key={`${index}-${line.role}`}
- className={
- line.role === 'user' ? 'text-content-muted' : 'font-medium text-content'
- }
+ className={line.role === 'user' ? 'text-content-muted' : 'font-medium text-content'}
data-role={line.role}>
{line.text}
</p>
diff --git a/app/src/features/human/chatMascot/ChatMascotDock.test.tsx b/app/src/features/human/chatMascot/ChatMascotDock.test.tsx
index 3f4d2fe8b7..648884f87e 100644
--- a/app/src/features/human/chatMascot/ChatMascotDock.test.tsx
+++ b/app/src/features/human/chatMascot/ChatMascotDock.test.tsx
@@ -3,7 +3,11 @@ import { describe, expect, it } from 'vitest';
import { selectChatMascotDismissed, selectChatMascotExpanded } from '../../../store/mascotSlice';
import { renderWithProviders } from '../../../test/test-utils';
-import { type ChatMascotContextValue, ChatMascotProvider, useChatMascot } from './ChatMascotContext';
+import {
+ type ChatMascotContextValue,
+ ChatMascotProvider,
+ useChatMascot,
+} from './ChatMascotContext';
import ChatMascotDock from './ChatMascotDock';
const renderDock = (expanded = false, dismissed = false) =>
diff --git a/app/src/features/human/voice/live/liveVoiceSocket.test.ts b/app/src/features/human/voice/live/liveVoiceSocket.test.ts
index 8a364b5c1f..ee95951d00 100644
--- a/app/src/features/human/voice/live/liveVoiceSocket.test.ts
+++ b/app/src/features/human/voice/live/liveVoiceSocket.test.ts
@@ -45,12 +45,9 @@ describe('parseLiveVoiceEvent', () => {
expect(parseLiveVoiceEvent('{"type":"turn_complete"}')).toEqual({ type: 'turn_complete' });
});
- it.each(['not json', '42', 'null', '{"type":"bogus"}', '{"kind":"ready"}'])(
- 'rejects %s',
- raw => {
- expect(parseLiveVoiceEvent(raw)).toBeNull();
- }
- );
+ it.each(['not json', '42', 'null', '{"type":"bogus"}', '{"kind":"ready"}'])('rejects %s', raw => {
+ expect(parseLiveVoiceEvent(raw)).toBeNull();
+ });
});
describe('LiveVoiceSocket', () => {
@@ -101,10 +98,7 @@ describe('LiveVoiceSocket', () => {
socket.sendText('hi');
socket.interrupt();
expect(ws.sent[1]).toBe(frame);
- expect(ws.jsonFrames().slice(1)).toEqual([
- { type: 'text', text: 'hi' },
- { type: 'interrupt' },
- ]);
+ expect(ws.jsonFrames().slice(1)).toEqual([{ type: 'text', text: 'hi' }, { type: 'interrupt' }]);
socket.stop();
expect(ws.jsonFrames().at(-1)).toEqual({ type: 'stop' });
diff --git a/app/src/features/human/voice/live/pcmCaptureWorklet.test.ts b/app/src/features/human/voice/live/pcmCaptureWorklet.test.ts
index 712fda5fe3..0dd7b78f41 100644
--- a/app/src/features/human/voice/live/pcmCaptureWorklet.test.ts
+++ b/app/src/features/human/voice/live/pcmCaptureWorklet.test.ts
@@ -62,9 +62,7 @@ describe('pcm-capture-processor asset', () => {
it('downsamples 48 kHz to 16 kHz PCM16 in 100 ms frames', () => {
const Ctor = loadProcessor(48_000)[PCM_CAPTURE_PROCESSOR_NAME];
- const proc = new Ctor({
- processorOptions: { targetSampleRate: 16_000, frameSamples: 1_600 },
- });
+ const proc = new Ctor({ processorOptions: { targetSampleRate: 16_000, frameSamples: 1_600 } });
// 100 ms of 48 kHz audio in 128-sample render quanta, constant 0.5.
const quantum = new Float32Array(128).fill(0.5);
for (let i = 0; i < Math.ceil(4_800 / 128); i += 1) {
diff --git a/app/src/features/human/voice/live/pcmPlayer.test.ts b/app/src/features/human/voice/live/pcmPlayer.test.ts
index a5d5c97777..052f2727a0 100644
--- a/app/src/features/human/voice/live/pcmPlayer.test.ts
+++ b/app/src/features/human/voice/live/pcmPlayer.test.ts
@@ -1,7 +1,7 @@
import { describe, expect, it, vi } from 'vitest';
import { FakeAudioContext, pcmBytes } from '../../../../test/liveVoiceFakes';
-import { PcmPlayer, pcm16ToFloat32, rms } from './pcmPlayer';
+import { pcm16ToFloat32, PcmPlayer, rms } from './pcmPlayer';
function makePlayer(onPlayingChange = vi.fn()) {
const ctx = new FakeAudioContext();
diff --git a/app/src/features/human/voice/live/useLiveVoiceSession.test.tsx b/app/src/features/human/voice/live/useLiveVoiceSession.test.tsx
index 164f8db153..aded632d71 100644
--- a/app/src/features/human/voice/live/useLiveVoiceSession.test.tsx
+++ b/app/src/features/human/voice/live/useLiveVoiceSession.test.tsx
@@ -242,7 +242,13 @@ describe('useLiveVoiceSession', () => {
expect(result.current.toolCalls.map(c => c.status)).toEqual(['running', 'running', 'running']);
act(() => {
- ws.emit({ type: 'tool_finished', call_id: 'c1', name: 'web_search', ok: true, cancelled: false });
+ ws.emit({
+ type: 'tool_finished',
+ call_id: 'c1',
+ name: 'web_search',
+ ok: true,
+ cancelled: false,
+ });
ws.emit({ type: 'tool_finished', call_id: 'c2', name: 'gmail', ok: false, cancelled: false });
ws.emit({ type: 'tool_finished', call_id: 'zz', name: 'late', ok: false, cancelled: true });
});
diff --git a/app/src/features/human/voice/live/useLiveVoiceSession.ts b/app/src/features/human/voice/live/useLiveVoiceSession.ts
index 25ea250094..46cb937a07 100644
--- a/app/src/features/human/voice/live/useLiveVoiceSession.ts
+++ b/app/src/features/human/voice/live/useLiveVoiceSession.ts
@@ -20,8 +20,12 @@ import { trackAnalyticsEvent } from '../../../../components/analytics';
import { socketService } from '../../../../services/socketService';
import { useAppDispatch } from '../../../../store/hooks';
import { loadThreadMessages } from '../../../../store/threadSlice';
-import { LiveVoiceSocket, type LiveVoiceEvent, resolveLiveVoiceUrl } from './liveVoiceSocket';
-import { LIVE_VOICE_INPUT_SAMPLE_RATE, type PcmCapture, startPcmCapture } from './pcmCaptureWorklet';
+import { type LiveVoiceEvent, LiveVoiceSocket, resolveLiveVoiceUrl } from './liveVoiceSocket';
+import {
+ LIVE_VOICE_INPUT_SAMPLE_RATE,
+ type PcmCapture,
+ startPcmCapture,
+} from './pcmCaptureWorklet';
import { PcmPlayer } from './pcmPlayer';
import { READBACK_PREFIX } from './readbackPrefix';
@@ -305,7 +309,11 @@ export function useLiveVoiceSession(): LiveVoiceSession {
spokenRef.current.clear();
resRef.current.threadId = opts?.threadId ?? null;
setThreadId(opts?.threadId ?? null);
- log('[session] start provider=%s has_thread=%s', opts?.provider ?? 'default', !!opts?.threadId);
+ log(
+ '[session] start provider=%s has_thread=%s',
+ opts?.provider ?? 'default',
+ !!opts?.threadId
+ );
let url: string;
try {
diff --git a/app/src/services/api/liveVoiceApi.test.ts b/app/src/services/api/liveVoiceApi.test.ts
index 2dc13f85bc..bd573bcdb9 100644
--- a/app/src/services/api/liveVoiceApi.test.ts
+++ b/app/src/services/api/liveVoiceApi.test.ts
@@ -56,7 +56,10 @@ describe('liveVoiceApi', () => {
});
it('normalises settings with null blocks', async () => {
- mocks.callCoreRpc.mockResolvedValueOnce({ default_provider: 'sarvam', sarvam: { speaker: 'x' } });
+ mocks.callCoreRpc.mockResolvedValueOnce({
+ default_provider: 'sarvam',
+ sarvam: { speaker: 'x' },
+ });
await expect(fetchLiveVoiceSettings()).resolves.toEqual({
default_provider: 'sarvam',
gemini: { model: null, voice: null, language: null },