diff --git a/services/frontend/src/App.tsx b/services/frontend/src/App.tsx index 8e8639b..53db327 100644 --- a/services/frontend/src/App.tsx +++ b/services/frontend/src/App.tsx @@ -228,6 +228,7 @@ export default function App() { voiceChannels={voice.voiceChannels} selectedGuild={selectedVoiceGuild} selectedChannel={uiState.selectedVoiceChannel || ""} + micLevel={0} status={voice.voiceStatus} voiceLoading={voice.loading} activeSpeakers={activeSpeakers} diff --git a/services/frontend/src/features/live/hooks/useVoiceControl.ts b/services/frontend/src/features/live/hooks/useVoiceControl.ts index f3728d5..c9fbcda 100644 --- a/services/frontend/src/features/live/hooks/useVoiceControl.ts +++ b/services/frontend/src/features/live/hooks/useVoiceControl.ts @@ -22,6 +22,7 @@ export function useVoiceControl() { activeGuildId: null, activeChannelId: null, activeChannelName: null, + connections: [], }); const { loading, error, execute, clearError } = useAsyncAction(); diff --git a/services/frontend/src/shared/hooks/useAudioPlayback.ts b/services/frontend/src/shared/hooks/useAudioPlayback.ts index 933398d..f13b615 100644 --- a/services/frontend/src/shared/hooks/useAudioPlayback.ts +++ b/services/frontend/src/shared/hooks/useAudioPlayback.ts @@ -1,5 +1,5 @@ // ─── Audio playback hook — receives PCM from WebSocket and plays through Web Audio API ── -import { useCallback, useEffect, useRef, useState } from "react"; +import { useCallback, useEffect, useRef, useState, type RefObject } from "react"; import { createLogger } from "../lib/logger.js"; const logger = createLogger("use-audio-playback"); @@ -17,7 +17,15 @@ const LEVEL_SHAPE = Array.from( /** Reverse lookup: userIdHash → userId, populated by handleIncomingBinary */ const userIdHashToId = new Map(); -export function useAudioPlayback() { +export function useAudioPlayback(): { + isListening: boolean; + levels: number[]; + handleIncomingPcm: (data: { userId: string; pcm: string }) => void; + handleIncomingBinary: (data: ArrayBuffer) => void; + registerUserId: (userId: string) => void; + toggleListening: () => Promise; + audioContextRef: RefObject; +} { const [isListening, setIsListening] = useState(false); const [levels, setLevels] = useState( Array.from({ length: LEVEL_COUNT }, () => 0.04), diff --git a/services/frontend/src/shared/hooks/useAudioTransmit.ts b/services/frontend/src/shared/hooks/useAudioTransmit.ts index 100eab0..5fada86 100644 --- a/services/frontend/src/shared/hooks/useAudioTransmit.ts +++ b/services/frontend/src/shared/hooks/useAudioTransmit.ts @@ -41,9 +41,20 @@ function sendWsCommand( return false; } -export function useAudioTransmit(socketRef: { - readonly current: WebSocket | null; -}) { +export function useAudioTransmit( + socketRef: { + readonly current: WebSocket | null; + }, +): { + isStreaming: boolean; + micError: string | null; + micLevel: number; + toggle: () => Promise; + stopTransmit: () => void; + startTransmit: () => Promise; + stop: () => void; + start: () => Promise; +} { const [isStreaming, setIsStreaming] = useState(false); const [micError, setMicError] = useState(null); const [micLevel, setMicLevel] = useState(0);