chore: auto detect screen share based on video direction - #41366
Conversation
|
Looks like this PR is ready to merge! 🎉 |
|
Walkthrough
ChangesWebRTC screen-share signaling
Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant LocalScreenShare
participant MediaCallWebRTCProcessor
participant RTCPeerConnection
participant RemoteScreenShareState
LocalScreenShare->>MediaCallWebRTCProcessor: loadScreenVideoTrack()
MediaCallWebRTCProcessor->>RTCPeerConnection: updateDirectionForVideoTrackChanged()
RTCPeerConnection-->>MediaCallWebRTCProcessor: negotiated video transceiver directions
MediaCallWebRTCProcessor->>RemoteScreenShareState: updateRemoteScreenShare()
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
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 |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #41366 +/- ##
===========================================
- Coverage 69.12% 68.18% -0.95%
===========================================
Files 3762 3968 +206
Lines 147936 154740 +6804
Branches 26428 27844 +1416
===========================================
+ Hits 102261 105504 +3243
- Misses 41185 44443 +3258
- Partials 4490 4793 +303
Flags with carried forward coverage won't be shown. Click here to find out more. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
🧹 Nitpick comments (1)
packages/media-signaling/src/lib/services/webrtc/Processor.ts (1)
631-642: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueAvoid redundant state updates and logs when activating.
To make the activation logic symmetric with the deactivation logic below, consider checking
!this.streams.screenShareRemote.activebefore logging and callingsetActive(true). This prevents redundant logs and method calls during subsequent WebRTC renegotiations if the screen share is already active. Additionally, we can swap the backticks for single quotes since there's no string interpolation.♻️ Proposed refactor
if (transceiver.currentDirection.includes('recv')) { - this.config.logger?.debug(`Video Transceiver is receiving; enabling screen-share`); - this.streams.screenShareRemote.setActive(true); + if (!this.streams.screenShareRemote.active) { + this.config.logger?.debug('Video Transceiver is receiving; enabling screen-share'); + this.streams.screenShareRemote.setActive(true); + } return; } } if (this.streams.screenShareRemote.active) { - this.config.logger?.debug(`No video Transceiver is receiving, disabling screen-share`); + this.config.logger?.debug('No video Transceiver is receiving; disabling screen-share'); this.streams.screenShareRemote.setActive(false); }🤖 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 `@packages/media-signaling/src/lib/services/webrtc/Processor.ts` around lines 631 - 642, Update the activation branch in the transceiver direction handling to guard the debug log and streams.screenShareRemote.setActive(true) with !this.streams.screenShareRemote.active, mirroring the existing deactivation check. Use a single-quoted string for the non-interpolated debug message.
🤖 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.
Nitpick comments:
In `@packages/media-signaling/src/lib/services/webrtc/Processor.ts`:
- Around line 631-642: Update the activation branch in the transceiver direction
handling to guard the debug log and streams.screenShareRemote.setActive(true)
with !this.streams.screenShareRemote.active, mirroring the existing deactivation
check. Use a single-quoted string for the non-interpolated debug message.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: e480bff7-2bc1-4d0b-880c-ad61acd30143
📒 Files selected for processing (1)
packages/media-signaling/src/lib/services/webrtc/Processor.ts
📜 Review details
⏰ Context from checks skipped due to timeout. (2)
- GitHub Check: cubic · AI code reviewer
- GitHub Check: Hacktron Security Check
🧰 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/lib/services/webrtc/Processor.ts
🧠 Learnings (3)
📚 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/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/lib/services/webrtc/Processor.ts
📚 Learning: 2026-05-06T12:21:44.083Z
Learnt from: juliajforesti
Repo: RocketChat/Rocket.Chat PR: 40256
File: apps/meteor/client/components/CreateDiscussion/CreateDiscussion.tsx:121-149
Timestamp: 2026-05-06T12:21:44.083Z
Learning: Field wrappers in rocket.chat/fuselage-forms (Field, FieldLabel, FieldRow, FieldError, FieldHint) auto-create htmlFor/id associations, aria-describedby, and role="alert" for errors. Do not manually set htmlFor, id, aria-describedby, or role attributes when using these wrappers. This automatic wiring does not apply to plain rocket.chat/fuselage components, which require explicit ID wiring per the accessibility docs. In code reviews, prefer using fuselage-forms wrappers for form fields and verify there is no unnecessary manual ID/aria wiring in files that use these wrappers. If a component uses plain fuselage components, ensure proper id wiring as per docs.
Applied to files:
packages/media-signaling/src/lib/services/webrtc/Processor.ts
🔇 Additional comments (1)
packages/media-signaling/src/lib/services/webrtc/Processor.ts (1)
10-10: LGTM!Also applies to: 478-480, 529-530, 593-597, 686-689, 780-781
There was a problem hiding this comment.
All reported issues were addressed across 1 file
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
Proposed changes (including videos or screenshots)
The current screen share implementation relies on a data channel to notify the other side that the screen share has started/stopped. This PR removes that dependency on the data channel and makes both sides of the call auto detect when screen sharing is enabled or not based on the state of video exchange in the connection.
Issue(s)
Derived from DMV-44
Steps to test or reproduce
Further comments
Also solves this flaky test:
https://github.com/RocketChat/Rocket.Chat/actions/runs/29510595480/job/87668479725
Summary by CodeRabbit