diff --git a/packages/web/src/components/voice/SoundController.tsx b/packages/web/src/components/voice/SoundController.tsx index 5e0f8689..5514db5b 100644 --- a/packages/web/src/components/voice/SoundController.tsx +++ b/packages/web/src/components/voice/SoundController.tsx @@ -12,6 +12,10 @@ function getSfxVolume(): number { export function SoundController() { const audioManager = AudioManager.getInstance(); const currentUser = useAuthStore((s) => s.user); + // Federation-aware self-ID: in federated calls, LiveKit participant identity + // uses homeUserId (from the home instance), not the local snowflake ID. + // Without this, the SoundController thinks our own presence is a stranger. + const myId = currentUser?.homeUserId || currentUser?.id; // Refs to track previous states const isInitialMount = useRef(true); @@ -86,28 +90,28 @@ export function SoundController() { if (state.isLiveKitConnected && !justDisconnected) { // Someone joined voice (Others only) state.participants.forEach(p => { - if (!prevParticipantIds.current.has(p.userId) && p.userId !== currentUser?.id) { + if (!prevParticipantIds.current.has(p.userId) && p.userId !== myId) { audioManager.playSound('user_join', sfxOpts); } }); // Someone left voice (Others only) prevParticipantIds.current.forEach(userId => { - if (!currentParticipantIds.has(userId) && userId !== currentUser?.id) { + if (!currentParticipantIds.has(userId) && userId !== myId) { audioManager.playSound('user_leave', sfxOpts); } }); // Someone started screen sharing (Others only) state.participants.forEach(p => { - if (p.isScreenSharing && !prevScreenShareUserIds.current.has(p.userId) && p.userId !== currentUser?.id) { + if (p.isScreenSharing && !prevScreenShareUserIds.current.has(p.userId) && p.userId !== myId) { audioManager.playSound('stream_user_joined', sfxOpts); } }); // Someone stopped screen sharing (Others only) prevScreenShareUserIds.current.forEach(userId => { - if (!currentScreenShareUserIds.has(userId) && userId !== currentUser?.id) { + if (!currentScreenShareUserIds.has(userId) && userId !== myId) { audioManager.playSound('stream_user_left', sfxOpts); } }); @@ -179,7 +183,7 @@ export function SoundController() { if (incomingCallLoop.current) incomingCallLoop.current.stop(); if (outgoingCallLoop.current) outgoingCallLoop.current.stop(); }; - }, [audioManager, currentUser?.id]); + }, [audioManager, myId]); return null; }