chore: improve handling of errors on screen share negotiation - #41372
Conversation
|
Looks like this PR is not ready to merge, because of the following issues:
Please fix the issues and try again If you have any trouble, please check the PR guidelines |
|
WalkthroughScreen-share replacement now updates WebRTC before stopping the previous track. Media stream synchronization uses active transceivers, handles connection state guards, and reacts when negotiation finds only stopped transceivers. ChangesMedia signaling updates
Estimated code review effort: 3 (Moderate) | ~20 minutes Possibly related PRs
Suggested labels: Suggested reviewers: 🚥 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 #41372 +/- ##
===========================================
+ Coverage 68.52% 68.76% +0.23%
===========================================
Files 4114 4155 +41
Lines 159688 159672 -16
Branches 28938 28161 -777
===========================================
+ Hits 109432 109794 +362
+ Misses 45213 44700 -513
- Partials 5043 5178 +135
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.
Actionable comments posted: 1
🧹 Nitpick comments (1)
packages/media-signaling/src/lib/Call.ts (1)
580-580: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueRemove the implementation comment.
The ordering should be clear from the code or an extracted method name.
As per coding guidelines, “Avoid code comments in the implementation.”
🤖 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/Call.ts` at line 580, Remove the implementation comment immediately above the track-stop logic in Call, leaving the existing behavior and ordering unchanged.Source: Coding guidelines
🤖 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 `@packages/media-signaling/src/lib/Call.ts`:
- Around line 574-578: The screen-share track replacement must be atomic across
both affected sites: in packages/media-signaling/src/lib/Call.ts lines 566-583,
update the flow around screenVideoTrack and webrtcProcessor.setScreenVideoTrack
so the new track is published only after replacement succeeds, or restore
oldVideoTrack on failure; in
packages/media-signaling/src/lib/media/MediaStreamWrapper.ts lines 218-236, make
sender.replaceTrack() failures propagate or roll back the wrapper state instead
of only logging them.
---
Nitpick comments:
In `@packages/media-signaling/src/lib/Call.ts`:
- Line 580: Remove the implementation comment immediately above the track-stop
logic in Call, leaving the existing behavior and ordering unchanged.
🪄 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: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 470f484a-3e21-4134-ba5f-d621e2a5d62d
📒 Files selected for processing (3)
packages/media-signaling/src/lib/Call.tspackages/media-signaling/src/lib/media/MediaStreamWrapper.tspackages/media-signaling/src/lib/services/webrtc/Processor.ts
📜 Review details
⏰ Context from checks skipped due to timeout. (4)
- GitHub Check: 📦 Build Packages
- GitHub Check: CodeQL-Build
- GitHub Check: CodeQL-Build
- 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/Call.tspackages/media-signaling/src/lib/media/MediaStreamWrapper.tspackages/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/Call.tspackages/media-signaling/src/lib/media/MediaStreamWrapper.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/lib/Call.tspackages/media-signaling/src/lib/media/MediaStreamWrapper.tspackages/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/Call.tspackages/media-signaling/src/lib/media/MediaStreamWrapper.tspackages/media-signaling/src/lib/services/webrtc/Processor.ts
🔇 Additional comments (2)
packages/media-signaling/src/lib/media/MediaStreamWrapper.ts (1)
36-38: LGTM!Also applies to: 249-253
packages/media-signaling/src/lib/services/webrtc/Processor.ts (1)
383-391: 🎯 Functional CorrectnessNo change needed here —
currentDirectionis the signal for a stopped transceiver;directionis the requested state and should not be used to gate this fallback.> Likely an incorrect or invalid review comment.
There was a problem hiding this comment.
All reported issues were addressed
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
There was a problem hiding this comment.
All reported issues were addressed across 1 file (changes from recent commits).
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
There was a problem hiding this comment.
All reported issues were addressed across 1 file (changes from recent commits).
Tip: Review your code locally with the cubic CLI to iterate faster.
Re-trigger cubic
629f72d to
7b8d966
Compare
Proposed changes (including videos or screenshots)
Improves handling of errors when trying to share the screen with a peer that doesn't support video. This is only a refactor of the code in anticipation of this becoming a possibility, but since currently screen share is only available on internal calls, this change doesn't affect anything.
Issue(s)
Derived from DMV-44
Steps to test or reproduce
Further comments
Written on top of #41366
Summary by CodeRabbit