Repository navigation
feat(audio): add deafenAudioUntilExplicitJoin setting (LiveKit) - #25491
prlanzarin wants to merge 3 commits into
Conversation
Add a client setting, deafenAudioUntilExplicitJoin (default false, LiveKit only): when the user closes the audio modal without joining, the client no longer forces a muted join, so the user stays deafened and ends up with no audio, thus restoring the ability to opt out of audio that the bbb-webrtc-sfu bridge had. With LiveKit the room connects on entry but audio is not subscribed until the user joins, so "no audio" is achieved by not joining rather than by avoiding the connection. The setting only affects the close-modal path: skip-check flags and any explicit join (microphone, listen-only, echo test) join audio as before. Scoped to LiveKit as the other bridges already have the flag's behavior by default. Enable server-wide via bbb-html5.yml or per-user via the bbb_deafen_audio_until_explicit_join userdata parameter.
…cord With LiveKit the room connects on entry and akka creates the voice record with deafened=false, regardless of whether the user has joined audio at the client level. The client defaults to deafened and only undeafens on an explicit join, so a not-joined user (deafenAudioUntilExplicitJoin, or autoJoin=false) displayed as in-audio to everyone and its deafened state never reached the server. The deafen-sync effect ran only on isDeafened changes; for a never-joined user isDeafened stays at its default, so the single mount-time push raced the voice record creation (SFU -> akka) and was dropped, and never re-fired. Key the sync on voice.joined so it (re)runs once the record exists. voice.deafened now tracks the client for all LiveKit flows (also fixing the pre-existing autoJoin=false).
The userSetDeafened action declared userId: String! but the graphql-actions handler treats it as optional, falling back to the caller's own userId (routing.userId) when omitted - which is how the LiveKit self-deafen path calls it. Declare userId: String so the contract reflects the actual behaviour.
WalkthroughAdds the Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant AudioModalContainer
participant LiveKitObserver
participant GraphQL
AudioModalContainer->>AudioModalContainer: Read deferred-join setting
AudioModalContainer->>LiveKitObserver: Avoid automatic join when enabled
LiveKitObserver->>LiveKitObserver: Check currentUser.voice.joined
LiveKitObserver->>GraphQL: Set deafened state
Possibly related issues
Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
bigbluebutton-html5/imports/ui/components/audio/audio-modal/container.jsx (1)
127-142: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick winAdd regression coverage for the modal-close behavior.
Please cover: LiveKit with the setting enabled (no
joinMiccall), LiveKit with it disabled (mutedjoinMiccall when disconnected), and non-LiveKit (no forced join). This protects the explicit-join contract from future changes.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@bigbluebutton-html5/imports/ui/components/audio/audio-modal/container.jsx` around lines 127 - 142, Add regression tests for the modal-close effect surrounding usingLiveKit, deafenAudioUntilExplicitJoin, isConnected, and isConnecting. Verify that LiveKit with deafenAudioUntilExplicitJoin enabled does not call joinMic, LiveKit with it disabled and disconnected calls joinMic with muteOnStart enabled, and non-LiveKit does not force a join.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@bigbluebutton-html5/imports/ui/components/livekit/component.tsx`:
- Around line 115-129: Update the dependency array of the useEffect that calls
setUserDeafened to include usingAudio, ensuring the effect reruns when the audio
bridge setting changes while preserving the existing guards and update behavior.
---
Nitpick comments:
In `@bigbluebutton-html5/imports/ui/components/audio/audio-modal/container.jsx`:
- Around line 127-142: Add regression tests for the modal-close effect
surrounding usingLiveKit, deafenAudioUntilExplicitJoin, isConnected, and
isConnecting. Verify that LiveKit with deafenAudioUntilExplicitJoin enabled does
not call joinMic, LiveKit with it disabled and disconnected calls joinMic with
muteOnStart enabled, and non-LiveKit does not force a join.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: 2d541714-fc05-40bb-9ece-cf098c206698
📒 Files selected for processing (7)
bbb-graphql-server/metadata/actions.graphqlbigbluebutton-html5/imports/ui/Types/meetingClientSettings.tsbigbluebutton-html5/imports/ui/components/audio/audio-modal/container.jsxbigbluebutton-html5/imports/ui/components/livekit/component.tsxbigbluebutton-html5/imports/ui/components/livekit/mutations.tsbigbluebutton-html5/imports/ui/core/initial-values/meetingClientSettings.tsbigbluebutton-html5/private/config/settings.yml
| // The LiveKit room connects on entry regardless of an explicit audio join, so | ||
| // akka creates the voice record deafened=false while the client defaults to | ||
| // deafened. The client owns the deafened state and must reflect it on the | ||
| // voice record whenever either changes to guarantee it is always up-to-date. | ||
| useEffect(() => { | ||
| if (!usingAudio) return; | ||
| const voiceJoined = currentUser?.voice?.joined ?? false; | ||
|
|
||
| if (!usingAudio || !voiceJoined) return; | ||
|
|
||
| setUserDeafened({ | ||
| variables: { | ||
| deafened: isDeafened, | ||
| }, | ||
| }); | ||
| }, [isDeafened]); | ||
| }, [isDeafened, currentUser?.voice?.joined]); |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
rg -n -C4 '\bLiveKitObserver\b|\busingAudio\b' bigbluebutton-html5/imports/uiRepository: bigbluebutton/bigbluebutton
Length of output: 8446
🏁 Script executed:
#!/bin/bash
set -euo pipefail
FILE="bigbluebutton-html5/imports/ui/components/livekit/component.tsx"
# Show the observer and its parent render path with line numbers.
sed -n '70,160p' "$FILE" | cat -n
printf '\n---\n'
sed -n '430,495p' "$FILE" | cat -nRepository: bigbluebutton/bigbluebutton
Length of output: 6205
Include usingAudio in the effect dependencies.
This effect reads usingAudio but omits it from the dependency array, so a bridge toggle can leave the deafened state stale while the component stays mounted.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@bigbluebutton-html5/imports/ui/components/livekit/component.tsx` around lines
115 - 129, Update the dependency array of the useEffect that calls
setUserDeafened to include usingAudio, ensuring the effect reruns when the audio
bridge setting changes while preserving the existing guards and update behavior.
Source: MCP tools
✅ Automated tests have passed! |
What does this PR do?
Summary
Adds a client setting
deafenAudioUntilExplicitJoin(defaultfalse, LiveKit only) that restores the ability to opt out of audio by closing the audio modal, like the bbb-webrtc-sfu audio bridge allows.When enabled, closing the modal without joining leaves the user with no audio (deafened) until they explicitly join; skip-check and every explicit join (microphone / listen-only / echo test) behave exactly as before: join audio (deafened=false).
Additionally, fix deafened state propagation between client and server and make the deafen mutation userId field optional as it is supposed to be.
In detail
when the user closes the audio modal without joining, the client no longer forces
a muted join, so the user stays deafened and ends up with no audio, thus
restoring the ability to opt out of audio that the bbb-webrtc-sfu bridge had.
deafened=false, regardless of whether the user has joined audio at the client
level. The client defaults to deafened and only undeafens on an explicit join,
so a not-joined user (deafenAudioUntilExplicitJoin, or autoJoin=false) displayed
as in-audio to everyone and its deafened state never reached the server.
handler treats it as optional, falling back to the caller's own userId
(routing.userId) when omitted - which is how the LiveKit self-deafen path calls
it. Declare userId: String so the contract reflects the actual behaviour.
Supersedes #25393: the original approach deafened at join time (partially correct), but reinforced it with a
requestAudioJoinstep and ahandleJoinAudioshort circuit. That flow wrongly deafened skip-check auto-joins, breaking the opt-out semantics skip-check has had since at least 2.4. This PR scopes the setting to the close-modal decline only and drops the extra code, and adds the deafen-state sync the original left as a known limitation.Closes Issue(s)
Closes #25346
Motivation
With bbb-webrtc-sfu, dismissing the initial audio modal let a user stay in the session with no audio. In 3.0+ with LiveKit the audio bridge connects on entry (the connection is not optional at the client level), so closing the modal would not prevent it.
This is by design and proven to be beneficial in the majority of use cases - but there are scenarios where the old behavior is desired.
How to test
skipCheck=trueskipCheck=trueskipCheckOnJoin=true(first join)forceListenOnly=true(viewer)autoJoin=falseautoJoin=falseMore