Skip to content

feat(audio): add deafenAudioUntilExplicitJoin setting (LiveKit) - #25491

Open
prlanzarin wants to merge 3 commits into
bigbluebutton:v3.0.x-developfrom
prlanzarin:feature/deafen-audio-until-explicit-join
Open

prlanzarin wants to merge 3 commits into
bigbluebutton:v3.0.x-developfrom
prlanzarin:feature/deafen-audio-until-explicit-join

Conversation

@prlanzarin

Copy link
Copy Markdown
Member

What does this PR do?

Summary

Adds a client setting deafenAudioUntilExplicitJoin (default false, 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

  • feat(audio): add deafenAudioUntilExplicitJoin setting
    • 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.
  • fix(audio): reflect the client deafened state on the LiveKit voice record
    • 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.
  • fix(graphql): make userSetDeafened userId optional to match the handler
    • 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.

Supersedes #25393: the original approach deafened at join time (partially correct), but reinforced it with a requestAudioJoin step and a handleJoinAudio short 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

# deafen flag Extra join flag Action Expected: hearing?
1 ON - Close the modal (X), don't join No
2 OFF - Close the modal (X) Yes (joined muted)
3 ON - Modal → Microphone → pass echo test → Join Yes
4 ON - Do step 1, then click the "Join audio" toolbar button Yes (modal → join)
5 OFF skipCheck=true (nothing — auto-joins) Yes
6 ON skipCheck=true (nothing — auto-joins) Yes
7 ON skipCheckOnJoin=true (first join) (nothing - auto-joins) Yes
8 ON forceListenOnly=true (viewer) (nothing - auto listen-only) Yes
9 ON autoJoin=false (irrelevant - audio does not join) No
9 OFF autoJoin=false (irrelevant - audio does not join) No

More

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.
@prlanzarin prlanzarin added this to the Release 3.0 milestone Jul 22, 2026
@coderabbitai

coderabbitai Bot commented Jul 22, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

Walkthrough

Adds the deafenAudioUntilExplicitJoin public setting, defaulting to false. When enabled, closing the audio modal no longer automatically joins LiveKit audio. LiveKit deafened-state synchronization now waits until the current user’s voice record is joined. The userSetDeafened GraphQL mutation accepts a nullable userId.

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
Loading

Possibly related issues

  • #25406 — Updates LiveKit deafened-state synchronization and the userSetDeafened mutation related to voice deafened-state consistency.

Suggested reviewers: gustavotrott, ramonlsouza, tainan404

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main change: adding the LiveKit deafenAudioUntilExplicitJoin setting.
Description check ✅ Passed The description is clearly about the audio-setting and related LiveKit and GraphQL changes in this PR.
Linked Issues check ✅ Passed The PR adds the requested setting and changes close-modal behavior so dismissing can skip joining audio.
Out of Scope Changes check ✅ Passed The extra state-sync and GraphQL schema updates are tied to the same audio flow and do not appear unrelated.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
bigbluebutton-html5/imports/ui/components/audio/audio-modal/container.jsx (1)

127-142: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

Add regression coverage for the modal-close behavior.

Please cover: LiveKit with the setting enabled (no joinMic call), LiveKit with it disabled (muted joinMic call 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

📥 Commits

Reviewing files that changed from the base of the PR and between c963ec3 and d82590c.

📒 Files selected for processing (7)
  • bbb-graphql-server/metadata/actions.graphql
  • bigbluebutton-html5/imports/ui/Types/meetingClientSettings.ts
  • bigbluebutton-html5/imports/ui/components/audio/audio-modal/container.jsx
  • bigbluebutton-html5/imports/ui/components/livekit/component.tsx
  • bigbluebutton-html5/imports/ui/components/livekit/mutations.ts
  • bigbluebutton-html5/imports/ui/core/initial-values/meetingClientSettings.ts
  • bigbluebutton-html5/private/config/settings.yml

Comment on lines +115 to +129
// 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]);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
rg -n -C4 '\bLiveKitObserver\b|\busingAudio\b' bigbluebutton-html5/imports/ui

Repository: 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 -n

Repository: 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

@github-actions

Copy link
Copy Markdown

✅ Automated tests have passed!

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Restore ability to close audio dialog and not join the audio

1 participant