The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.
Rust agent-orchestrationai-agentsai-assistantdesktopllmlocal-firstmcppersonal-aiprivacyrustsecond-braintauri
style(voiceNotes): reformat voice note player and e2e spec
Steven Enamakel898616a779c0
diff --git a/app/src/features/human/chatMascot/ChatMascotOverlay.tsx b/app/src/features/human/chatMascot/ChatMascotOverlay.tsxindex bc6b5584a2..f224a17aab 100644--- a/app/src/features/human/chatMascot/ChatMascotOverlay.tsx+++ b/app/src/features/human/chatMascot/ChatMascotOverlay.tsx@@ -113,9 +113,7 @@ const ChatMascotOverlay = () => {// lip-sync); the rAF loop only exists while it speaks.const liveLipsync = useAmplitudeLipsync(liveAudioRef, livePhase === 'speaking');const face = liveLipsync.active || replayViseme !== null ? 'speaking' : classicFace;- const visemeCode = liveLipsync.active- ? liveLipsync.visemeCode- : replayViseme ?? classicViseme;+ const visemeCode = liveLipsync.active ? liveLipsync.visemeCode : (replayViseme ?? classicViseme);const mascotColor = useAppSelector(selectMascotColor);const customPrimary = useAppSelector(selectCustomPrimaryColor);diff --git a/app/src/features/voiceNotes/VoiceNotePlayer.tsx b/app/src/features/voiceNotes/VoiceNotePlayer.tsxindex f1157f1a64..7961f29291 100644--- a/app/src/features/voiceNotes/VoiceNotePlayer.tsx+++ b/app/src/features/voiceNotes/VoiceNotePlayer.tsx@@ -19,8 +19,8 @@ import {import Slider from '../../components/ui/Slider';import { cn } from '../../lib/cn';import { useT } from '../../lib/i18n/I18nContext';-import { formatDuration, readVoiceNote } from './voiceNoteApi';import { proceduralVisemes } from '../human/voice/ttsClient';+import { formatDuration, readVoiceNote } from './voiceNoteApi';export interface VoiceNotePlayerProps {noteId?: string;@@ -62,15 +62,18 @@ function VoiceNotePlayerBody({const totalMs = loadedMs ?? durationMs ?? 0;const frames = visemes?.length ? visemes : proceduralVisemes(speechText, totalMs);- const publishMascot = useCallback((active: boolean, atMs = 0) => {- if (!mascotPlayback) return;- let viseme = 'sil';- if (active) {- const frame = frames.find(item => atMs >= item.start_ms && atMs < item.end_ms);- viseme = frame?.viseme ?? 'sil';- }- window.dispatchEvent(new CustomEvent('voice-note-mascot', { detail: { active, viseme } }));- }, [frames, mascotPlayback]);+ const publishMascot = useCallback(+ (active: boolean, atMs = 0) => {+ if (!mascotPlayback) return;+ let viseme = 'sil';+ if (active) {+ const frame = frames.find(item => atMs >= item.start_ms && atMs < item.end_ms);+ viseme = frame?.viseme ?? 'sil';+ }+ window.dispatchEvent(new CustomEvent('voice-note-mascot', { detail: { active, viseme } }));+ },+ [frames, mascotPlayback]+ );const [loading, setLoading] = useState(false);const [error, setError] = useState(false);@@ -122,8 +125,14 @@ function VoiceNotePlayerBody({setPositionMs(0);publishMascot(false);});- audio.addEventListener('pause', () => { setPlaying(false); publishMascot(false); });- audio.addEventListener('play', () => { setPlaying(true); publishMascot(true, audio.currentTime * 1000); });+ audio.addEventListener('pause', () => {+ setPlaying(false);+ publishMascot(false);+ });+ audio.addEventListener('play', () => {+ setPlaying(true);+ publishMascot(true, audio.currentTime * 1000);+ });audioRef.current = audio;return audio;}, [noteId, src, publishMascot]);diff --git a/app/test/e2e/specs/chat-voice-note.spec.ts b/app/test/e2e/specs/chat-voice-note.spec.tsindex 1725b4e85c..c51af7d09f 100644--- a/app/test/e2e/specs/chat-voice-note.spec.ts+++ b/app/test/e2e/specs/chat-voice-note.spec.ts@@ -1,7 +1,12 @@// @ts-nocheck/** Full mocked recording -> transcription -> assistant speech -> reload flow. */import { waitForApp } from '../helpers/app-helpers';-import { chatMounted, clickByTitle, getSelectedThreadId, waitForAssistantReplyContaining } from '../helpers/chat-harness';+import {+ chatMounted,+ clickByTitle,+ getSelectedThreadId,+ waitForAssistantReplyContaining,+} from '../helpers/chat-harness';import { clickElement, clickTestId, textExists, waitForTestId } from '../helpers/element-helpers';import { resetApp } from '../helpers/reset-app';import { navigateViaHash } from '../helpers/shared-flows';@@ -16,12 +21,21 @@ function silentWavBase64() {const samples = new Uint8Array(sampleRate / 2);const bytes = new Uint8Array(44 + samples.length);const view = new DataView(bytes.buffer);- const tag = (offset, value) => [...value].forEach((char, index) => (bytes[offset + index] = char.charCodeAt(0)));- tag(0, 'RIFF'); view.setUint32(4, 36 + samples.length, true); tag(8, 'WAVE');- tag(12, 'fmt '); view.setUint32(16, 16, true); view.setUint16(20, 1, true);- view.setUint16(22, 1, true); view.setUint32(24, sampleRate, true);- view.setUint32(28, sampleRate, true); view.setUint16(32, 1, true);- view.setUint16(34, 8, true); tag(36, 'data'); view.setUint32(40, samples.length, true);+ const tag = (offset, value) =>+ [...value].forEach((char, index) => (bytes[offset + index] = char.charCodeAt(0)));+ tag(0, 'RIFF');+ view.setUint32(4, 36 + samples.length, true);+ tag(8, 'WAVE');+ tag(12, 'fmt ');+ view.setUint32(16, 16, true);+ view.setUint16(20, 1, true);+ view.setUint16(22, 1, true);+ view.setUint32(24, sampleRate, true);+ view.setUint32(28, sampleRate, true);+ view.setUint16(32, 1, true);+ view.setUint16(34, 8, true);+ tag(36, 'data');+ view.setUint32(40, samples.length, true);bytes.set(samples, 44);return Buffer.from(bytes).toString('base64');}@@ -37,10 +51,13 @@ describe('Chat voice notes', () => {setMockBehavior('audioTranscriptionText', TRANSCRIPT);setMockBehavior('audioSpeechBase64', AUDIO_B64);setMockBehavior('audioSpeechMime', 'audio/wav');- setMockBehavior('audioSpeechVisemes', JSON.stringify([- { viseme: 'aa', start_ms: 0, end_ms: 180 },- { viseme: 'PP', start_ms: 180, end_ms: 420 },- ]));+ setMockBehavior(+ 'audioSpeechVisemes',+ JSON.stringify([+ { viseme: 'aa', start_ms: 0, end_ms: 180 },+ { viseme: 'PP', start_ms: 180, end_ms: 420 },+ ])+ );setMockBehavior('llmStreamScript', JSON.stringify([{ text: REPLY }, { finish: 'stop' }]));});@@ -58,20 +75,33 @@ describe('Chat voice notes', () => {await navigateViaHash('/chat');await browser.waitUntil(async () => await chatMounted(), { timeout: 15_000 });expect(await clickByTitle('New thread', 8_000)).toBe(true);- const threadId = await browser.waitUntil(async () => await getSelectedThreadId(), { timeout: 8_000 });+ const threadId = await browser.waitUntil(async () => await getSelectedThreadId(), {+ timeout: 8_000,+ });// The browser recorder emits a valid short WAV so both stored user and synthesized// assistant audio can be decoded by the real player without a microphone/device.await browser.execute(wav => {const raw = Uint8Array.from(atob(wav), char => char.charCodeAt(0));- Object.defineProperty(navigator, 'mediaDevices', { configurable: true, value: {- getUserMedia: async () => ({ getTracks: () => [{ stop() {} }] }),- } });+ Object.defineProperty(navigator, 'mediaDevices', {+ configurable: true,+ value: { getUserMedia: async () => ({ getTracks: () => [{ stop() {} }] }) },+ });window.MediaRecorder = class {- static isTypeSupported() { return true; }- constructor() { this.state = 'inactive'; this.mimeType = 'audio/wav'; this.listeners = {}; }- addEventListener(type, fn) { this.listeners[type] = fn; }- start() { this.state = 'recording'; }+ static isTypeSupported() {+ return true;+ }+ constructor() {+ this.state = 'inactive';+ this.mimeType = 'audio/wav';+ this.listeners = {};+ }+ addEventListener(type, fn) {+ this.listeners[type] = fn;+ }+ start() {+ this.state = 'recording';+ }stop() {this.state = 'inactive';this.listeners.dataavailable?.({ data: new Blob([raw], { type: 'audio/wav' }) });@@ -87,14 +117,24 @@ describe('Chat voice notes', () => {await clickTestId('voice-note-send');await browser.waitUntil(async () => await textExists(TRANSCRIPT), { timeout: 20_000 });await waitForAssistantReplyContaining(REPLY, 60_000);- await browser.waitUntil(async () => (await browser.$$('[data-testid="voice-note-player"]')).length === 2, { timeout: 30_000 });+ await browser.waitUntil(+ async () => (await browser.$$('[data-testid="voice-note-player"]')).length === 2,+ { timeout: 30_000 }+ );await browser.refresh();await waitForApp();await navigateViaHash('/chat');await browser.waitUntil(async () => await chatMounted(), { timeout: 20_000 });- await browser.execute(tid => window.__OPENHUMAN_STORE__?.dispatch({ type: 'thread/setSelectedThread', payload: tid }), threadId);- await browser.waitUntil(async () => (await browser.$$('[data-testid="voice-note-player"]')).length === 2, { timeout: 30_000 });+ await browser.execute(+ tid =>+ window.__OPENHUMAN_STORE__?.dispatch({ type: 'thread/setSelectedThread', payload: tid }),+ threadId+ );+ await browser.waitUntil(+ async () => (await browser.$$('[data-testid="voice-note-player"]')).length === 2,+ { timeout: 30_000 }+ );expect(await textExists(REPLY)).toBe(true);await clickTestId('voice-note-transcript-toggle');await browser.waitUntil(async () => await textExists(TRANSCRIPT), { timeout: 5_000 });@@ -102,7 +142,13 @@ describe('Chat voice notes', () => {const playButtons = await browser.$$('[data-testid="voice-note-toggle"]');expect(playButtons.length).toBe(2);await clickElement(playButtons[1]);- await browser.waitUntil(async () => (await browser.$$('[data-testid="voice-note-toggle"]'))[1]?.getAttribute('aria-label').then(label => label?.toLowerCase().includes('pause')), { timeout: 5_000 });+ await browser.waitUntil(+ async () =>+ (await browser.$$('[data-testid="voice-note-toggle"]'))[1]+ ?.getAttribute('aria-label')+ .then(label => label?.toLowerCase().includes('pause')),+ { timeout: 5_000 }+ );await clickElement((await browser.$$('[data-testid="voice-note-toggle"]'))[1]);});});