regression: mobile app shows incorrect "on hold" state on voice calls#40299
regression: mobile app shows incorrect "on hold" state on voice calls#40299pierre-lehnen-rc wants to merge 1 commit intorelease-8.4.0from
Conversation
|
Looks like this PR is ready to merge! 🎉 |
|
WalkthroughThe WebRTC processor adds cached remote-held state tracking by introducing a Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Suggested labels
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Warning Review ran into problems🔥 ProblemsErrors were encountered while retrieving linked issues. Errors (1)
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.
🧹 Nitpick comments (1)
packages/media-signaling/src/lib/services/webrtc/Processor.ts (1)
603-629: Consider renaminganyTransceiverNotSendingfor clarity.The loop returns
falseas soon as any audio transceiver is still sending, so the flag only ever represents "at least one non-stopped audio transceiver exists and none of them are sending" — effectively the held condition itself. A name likehasHeldAudioTransceiver(or simply computing once at the end) would read closer to intent. Non-blocking.♻️ Optional rename
- let anyTransceiverNotSending = false; + let hasHeldAudioTransceiver = false; const transceivers = this.getTransceivers('audio'); for (const transceiver of transceivers) { if (!transceiver.currentDirection || transceiver.currentDirection === 'stopped') { continue; } if (transceiver.currentDirection.includes('send')) { this.setRemoteHeld(false); return; } - anyTransceiverNotSending = true; + hasHeldAudioTransceiver = true; } - this.setRemoteHeld(anyTransceiverNotSending); + this.setRemoteHeld(hasHeldAudioTransceiver);🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@packages/media-signaling/src/lib/services/webrtc/Processor.ts` around lines 603 - 629, The variable anyTransceiverNotSending in updateRemoteHeld is misleading; change it to a clearer name like hasHeldAudioTransceiver (or compute the held condition directly) so the intent matches the logic that if any audio transceiver is sending we call setRemoteHeld(false) and otherwise we call setRemoteHeld(true); update references in updateRemoteHeld and keep the same behavior with getTransceivers('audio') and setRemoteHeld.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@packages/media-signaling/src/lib/services/webrtc/Processor.ts`:
- Around line 603-629: The variable anyTransceiverNotSending in updateRemoteHeld
is misleading; change it to a clearer name like hasHeldAudioTransceiver (or
compute the held condition directly) so the intent matches the logic that if any
audio transceiver is sending we call setRemoteHeld(false) and otherwise we call
setRemoteHeld(true); update references in updateRemoteHeld and keep the same
behavior with getTransceivers('audio') and setRemoteHeld.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 1c034ffa-6d05-4f8f-8fe3-1f5a28d8a96a
📒 Files selected for processing (2)
packages/media-signaling/src/definition/services/webrtc/IWebRTCProcessor.tspackages/media-signaling/src/lib/services/webrtc/Processor.ts
📜 Review details
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
- GitHub Check: 📦 Build Packages
- GitHub Check: CodeQL-Build
🧰 Additional context used
📓 Path-based instructions (1)
**/*.{ts,tsx,js}
📄 CodeRabbit inference engine (.cursor/rules/playwright.mdc)
**/*.{ts,tsx,js}: Write concise, technical TypeScript/JavaScript with accurate typing in Playwright tests
Avoid code comments in the implementation
Files:
packages/media-signaling/src/definition/services/webrtc/IWebRTCProcessor.tspackages/media-signaling/src/lib/services/webrtc/Processor.ts
🧠 Learnings (3)
📓 Common learnings
Learnt from: pierre-lehnen-rc
Repo: RocketChat/Rocket.Chat PR: 36718
File: packages/media-signaling/src/lib/Call.ts:633-642
Timestamp: 2025-09-23T00:27:05.438Z
Learning: In PR `#36718`, pierre-lehnen-rc prefers to maintain consistency with the old architecture patterns for DTMF handling rather than implementing immediate validation improvements, deferring enhancements to future work.
📚 Learning: 2026-02-26T19:25:44.063Z
Learnt from: gabriellsh
Repo: RocketChat/Rocket.Chat PR: 38778
File: packages/ui-voip/src/providers/useMediaSession.ts:192-192
Timestamp: 2026-02-26T19:25:44.063Z
Learning: In the Rocket.Chat repository, do not reference Biome lint rules in code review feedback. Biome is not used even if biome.json exists; only reference Biome rules if there is explicit, project-wide usage documented. For TypeScript files, review lint implications without Biome guidance unless the project enables Biome rules.
Applied to files:
packages/media-signaling/src/definition/services/webrtc/IWebRTCProcessor.tspackages/media-signaling/src/lib/services/webrtc/Processor.ts
📚 Learning: 2026-02-26T19:25:44.063Z
Learnt from: gabriellsh
Repo: RocketChat/Rocket.Chat PR: 38778
File: packages/ui-voip/src/providers/useMediaSession.ts:192-192
Timestamp: 2026-02-26T19:25:44.063Z
Learning: In this repository (RocketChat/Rocket.Chat), Biome lint rules are not used even if a biome.json exists. When reviewing TypeScript files (e.g., packages/ui-voip/src/providers/useMediaSession.ts), ensure lint suggestions do not reference Biome-specific rules. Rely on general ESLint/TypeScript lint rules and project conventions instead.
Applied to files:
packages/media-signaling/src/definition/services/webrtc/IWebRTCProcessor.tspackages/media-signaling/src/lib/services/webrtc/Processor.ts
🔇 Additional comments (5)
packages/media-signaling/src/definition/services/webrtc/IWebRTCProcessor.ts (1)
16-16: LGTM!Adding
remoteHeld: booleantoWebRTCInternalStateMapcleanly aligns the public internal-state surface with the new cached value emitted byMediaCallWebRTCProcessorthroughinternalStateChange.getInternalState('remoteHeld')inProcessor.tsand theupdateRemoteStates()consumer inCall.tsbecome properly typed.packages/media-signaling/src/lib/services/webrtc/Processor.ts (4)
49-49: Caching_remoteHeldand routing reads through it looks correct.The field is initialized to
false, exposed via bothisRemoteHeld()andgetInternalState('remoteHeld'), and only mutated throughsetRemoteHeld()which emitsinternalStateChange. This matches theCall.updateRemoteStates()consumer that readsisRemoteHeld()off the sameinternalStateChangeevent, so the cached value is guaranteed to be observed in sync.Also applies to: 234-235, 249-251
110-110: Pre/post-negotiation wiring covers both offer and answer paths.
- Outgoing:
createOffer→processPreNegotiation;setRemoteDescription(answer)→processPostNegotiation.- Incoming:
setRemoteDescription(offer)→processPreNegotiation;setLocalDescription(answer)→processPostNegotiation.Running
updateRemoteHeld()only fromprocessPostNegotiation(after theawait peer.setLocal/RemoteDescriptionresolves) rather than from arbitraryonsignalingstatechange/onconnectionstatechangecallbacks is the right fix for the mobile case wheretransceiver.currentDirectionlags the state-change event.Also applies to: 190-192, 207-214
577-585:setRemoteHeldshort-circuit and emit pattern are consistent withsetRemoteMute.Early return on no-change prevents spurious
internalStateChangeemissions (and therefore redundanttrackStateChangeemissions viaCall.updateRemoteStates()). Good symmetry withsetRemoteMuteabove.
603-610: TheconnectionStateguard is correct and will not swallow hold updates during mid-call renegotiation. During initial setup,connectionStateis'new'and nothing is held yet, so early return is safe. During mid-call renegotiation, the connection is already established, soconnectionStateremains'connected'andupdateRemoteHeld()executes normally to apply transceiver-based hold state. The guard only prevents hold updates if the connection has actually transitioned to'closed','failed', or (unlikely) back to'new'via explicit ICE restart, which is correct behavior.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## release-8.4.0 #40299 +/- ##
=================================================
+ Coverage 69.78% 69.79% +0.01%
=================================================
Files 3296 3298 +2
Lines 119186 119292 +106
Branches 21517 21489 -28
=================================================
+ Hits 83171 83258 +87
- Misses 32715 32734 +19
Partials 3300 3300
Flags with carried forward coverage won't be shown. Click here to find out more. 🚀 New features to boost your workflow:
|
Proposed changes (including videos or screenshots)
We update the "on hold" status whenever an internal webrtc state changes and we determine if the call is on hold based on the currentDirection attribute of the RTCRtpTransceiver.
This works fine on web, but on the mobile implementation of webrtc, the transceiver's currentDirection is only updated after the state change event is emitted, so we were updating the "on hold" status based on the previous direction instead of the current one.
This PR changes it so that the "on hold" status is always updated at the end of any negotiation, instead of immediately after it becomes stable.
Issue(s)
VMUX-94
Steps to test or reproduce
Further comments
Summary by CodeRabbit
Improvements
Performance