Skip to content

fix: allow screen sharing without media devices - #41682

Closed
Akanshagore wants to merge 6 commits into
RocketChat:developfrom
Akanshagore:fix/screen-share-without-media
Closed

fix: allow screen sharing without media devices#41682
Akanshagore wants to merge 6 commits into
RocketChat:developfrom
Akanshagore:fix/screen-share-without-media

Conversation

@Akanshagore

@Akanshagore Akanshagore commented Aug 4, 2026

Copy link
Copy Markdown

Proposed changes (including videos or screenshots)

This PR allows users to share their screen even when a microphone or camera is not available.

Previously, screen sharing depended on having a local audio input track available. Users without media devices could receive calls and view shared screens, but they could not start their own screen sharing.

This change:

  • Allows calls to continue without an available microphone input track.
  • Allows WebRTC negotiation without requiring a local audio track.
  • Handles screen sharing as a separate media track.
  • Enables users without camera/microphone devices to start and share their screen.

Issue(s)

Fixes #1745

Steps to test or reproduce

  1. Use two clients:

    • Client A with microphone/camera available.
    • Client B without microphone/camera available.
  2. Start a media call from Client A to Client B.

  3. Accept the call from Client B.

  4. From Client B, start screen sharing.

  5. Verify that Client A can see Client B's shared screen.

  6. Stop screen sharing and verify that the call continues normally.

Further comments

This implementation keeps audio input and screen sharing as separate media concerns. Missing microphone/camera devices should no longer prevent users from participating in calls or sharing their screen.

Review in cubic

Summary by CodeRabbit

  • New Features

    • Added screen-sharing controls and status indicators for voice and video calls.
    • Added support for muting and placing calls on hold.
    • Calls can now be accepted without microphone access.
  • Bug Fixes

    • Improved call setup when no microphone or audio track is available.
    • Prevented failed microphone access from unnecessarily ending calls.
    • Improved audio handling during held and receive-only calls.
    • Added validation for call control messages to improve reliability.
    • Standardized messaging when microphone access fails.

@dionisio-bot

dionisio-bot Bot commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

Looks like this PR is not ready to merge, because of the following issues:

  • This PR is missing the 'stat: QA assured' label
  • This PR is missing the required milestone or project

Please fix the issues and try again

If you have any trouble, please check the PR guidelines

@changeset-bot

changeset-bot Bot commented Aug 4, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 993dfab

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@coderabbitai

coderabbitai Bot commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 7542b681-9b21-42a3-b3c0-e12fe0d6c8df

📥 Commits

Reviewing files that changed from the base of the PR and between f951a6e and 993dfab.

📒 Files selected for processing (1)
  • packages/media-signaling/src/lib/services/webrtc/Processor.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/media-signaling/src/lib/services/webrtc/Processor.ts
📜 Recent review details
⏰ Context from checks skipped due to timeout. (1)
  • GitHub Check: cubic · AI code reviewer

Walkthrough

The PR allows media calls to continue without an input audio track. It adds screen-sharing controls and session state for local and remote streams. The development script now builds selected packages before starting Meteor.

Changes

VoIP media flow

Layer / File(s) Summary
Input-less media negotiation
packages/media-signaling/src/definition/call/IClientMediaCall.ts, packages/media-signaling/src/lib/Session.ts, packages/media-signaling/src/lib/services/webrtc/Processor.ts
Calls no longer hang up or reject answers when no audio input track exists. Audio direction now reflects hold state and track availability. Data-channel commands require string type validation.
Screen-sharing context and provider wiring
packages/ui-voip/src/context/MediaCallViewContext.ts, packages/ui-voip/src/context/definitions.d.ts, packages/ui-voip/src/providers/MediaCallViewProvider.tsx
The context exposes screen-sharing state and a toggle callback. The provider delegates toggling to call controls and standardizes the incoming device-request error message.
Screen-sharing session state
packages/ui-voip/src/providers/useMediaSession.ts
The session derives local and remote screen-sharing flags from SIP and non-SIP media streams. Unconfirmed sessions reset flags to false.

Development setup

Layer / File(s) Summary
Development command and locale formatting
package.json, packages/i18n/src/locales/en.i18n.json
The root dev script builds @rocket.chat/core-typings and @rocket.chat/livechat before targeting @rocket.chat/meteor. The English locale file gains a trailing blank line.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Session
  participant Processor
  participant RTCPeerConnection
  Session->>Processor: createAnswer without input audio
  Processor->>RTCPeerConnection: add audio transceiver
  Processor->>RTCPeerConnection: set audio direction
Loading
sequenceDiagram
  participant MediaCallViewContext
  participant MediaCallViewProvider
  participant CallControls
  MediaCallViewContext->>MediaCallViewProvider: onToggleScreenShare()
  MediaCallViewProvider->>CallControls: toggleScreenSharing()
  CallControls-->>MediaCallViewProvider: Promise<void>
Loading

Possibly related PRs

  • RocketChat/Rocket.Chat#41200: Modifies packages/ui-voip media-call provider and session infrastructure for screen-sharing and media handling.
  • RocketChat/Rocket.Chat#41416: Continues micless-call changes in Session.ts and MediaCallViewProvider.tsx with related WebRTC behavior.
  • RocketChat/Rocket.Chat#41616: Updates ui-voip context, provider, and useMediaSession contracts for session state and screen-sharing behavior.

Suggested labels: type: bug

Suggested reviewers: tassoevan

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Out of Scope Changes check ⚠️ Warning The trailing blank line in the English locale file is unrelated to the screen-sharing objective. Remove the unrelated whitespace-only change from packages/i18n/src/locales/en.i18n.json.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly describes enabling screen sharing without available media devices.
Linked Issues check ✅ Passed The changes support screen sharing and WebRTC calls without requiring a local microphone or camera, addressing issue #1745.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

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

🤖 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/services/webrtc/Processor.ts`:
- Around line 489-495: The issue is that getDesiredAudioDirection() returns
recvonly when this.inputTrack is null, and then updateRemoteHeld() incorrectly
infers a remote hold condition from the absence of send capability in the
direction, marking the call as remotely held even when the peer is actively
sending audio. Fix this by updating the remote hold inference logic in
updateRemoteHeld() to skip the direction-based inference when this.inputTrack is
null, or by introducing an independent remote hold signal that does not rely on
the presence or absence of local send capability. The outcome must preserve the
distinction between a mic-less local state and an actual remote hold condition.

In `@packages/ui-voip/src/providers/MediaCallViewProvider.tsx`:
- Around line 114-117: Update the device-acquisition catch block in
MediaCallViewProvider to invoke startCall(true) after logging the error, using
the micless fallback so calls can proceed when microphone access fails.
🪄 Autofix

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 Plus

Run ID: eee7ac96-36d7-45c1-9a95-97aefefd5f74

📥 Commits

Reviewing files that changed from the base of the PR and between d18228d and 062416d.

⛔ Files ignored due to path filters (1)
  • packages/ui-voip/src/views/MediaCallWidget/__snapshots__/MediaCallWidget.spec.tsx.snap is excluded by !**/*.snap
📒 Files selected for processing (9)
  • package.json
  • packages/i18n/src/locales/en.i18n.json
  • packages/media-signaling/src/definition/call/IClientMediaCall.ts
  • packages/media-signaling/src/lib/Session.ts
  • packages/media-signaling/src/lib/services/webrtc/Processor.ts
  • packages/ui-voip/src/context/MediaCallViewContext.ts
  • packages/ui-voip/src/context/definitions.d.ts
  • packages/ui-voip/src/providers/MediaCallViewProvider.tsx
  • packages/ui-voip/src/providers/useMediaSession.ts
📜 Review details
⏰ Context from checks skipped due to timeout. (1)
  • GitHub Check: cubic · AI code reviewer
🧰 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/ui-voip/src/context/definitions.d.ts
  • packages/ui-voip/src/context/MediaCallViewContext.ts
  • packages/media-signaling/src/lib/Session.ts
  • packages/ui-voip/src/providers/useMediaSession.ts
  • packages/media-signaling/src/definition/call/IClientMediaCall.ts
  • packages/media-signaling/src/lib/services/webrtc/Processor.ts
  • packages/ui-voip/src/providers/MediaCallViewProvider.tsx
🧠 Learnings (6)
📚 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/ui-voip/src/context/definitions.d.ts
  • packages/ui-voip/src/context/MediaCallViewContext.ts
  • packages/media-signaling/src/lib/Session.ts
  • packages/ui-voip/src/providers/useMediaSession.ts
  • packages/media-signaling/src/definition/call/IClientMediaCall.ts
  • 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/ui-voip/src/context/definitions.d.ts
  • packages/ui-voip/src/context/MediaCallViewContext.ts
  • packages/media-signaling/src/lib/Session.ts
  • packages/ui-voip/src/providers/useMediaSession.ts
  • packages/media-signaling/src/definition/call/IClientMediaCall.ts
  • 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/ui-voip/src/context/definitions.d.ts
  • packages/ui-voip/src/context/MediaCallViewContext.ts
  • packages/media-signaling/src/lib/Session.ts
  • packages/ui-voip/src/providers/useMediaSession.ts
  • packages/media-signaling/src/definition/call/IClientMediaCall.ts
  • packages/media-signaling/src/lib/services/webrtc/Processor.ts
  • packages/ui-voip/src/providers/MediaCallViewProvider.tsx
📚 Learning: 2026-02-26T19:22:29.385Z
Learnt from: gabriellsh
Repo: RocketChat/Rocket.Chat PR: 38778
File: packages/ui-voip/src/views/CallHistoryContextualbar/CallHistoryActions.tsx:40-40
Timestamp: 2026-02-26T19:22:29.385Z
Learning: For TSX files in the UI VOIP package, ensure that when a media session state is 'unavailable', the voiceCall action is excluded from the actions object passed to CallHistoryActions so it does not render in the menu. This filtering should occur upstream (before getItems is called) to avoid tooltips or UI hints for unavailable actions. If there are multiple actions with availability states, implement a centralized helper to filter actions based on session state.

Applied to files:

  • packages/ui-voip/src/providers/MediaCallViewProvider.tsx
📚 Learning: 2026-05-05T12:34:29.042Z
Learnt from: gabriellsh
Repo: RocketChat/Rocket.Chat PR: 40331
File: packages/ui-voip/src/views/MediaCallWidget/OngoingCallWithScreen.tsx:69-69
Timestamp: 2026-05-05T12:34:29.042Z
Learning: In Rocket.Chat’s `packages/ui-voip` UI (e.g., media/call widgets), voice/media calls are only supported in Direct Message (DM) rooms. Rocket.Chat models a DM as a “room” with exactly two participants, so handlers like `onClickDirectMessage` are the correct destination—even when the UI text/element says “Open in room” (e.g., on the shared screen card/`StreamCard`). During review, don’t flag a “DM vs room” mismatch for these cases; they intentionally map to the same destination.

Applied to files:

  • packages/ui-voip/src/providers/MediaCallViewProvider.tsx
📚 Learning: 2026-03-27T14:52:56.865Z
Learnt from: dougfabris
Repo: RocketChat/Rocket.Chat PR: 39892
File: apps/meteor/client/views/room/contextualBar/Threads/Thread.tsx:150-155
Timestamp: 2026-03-27T14:52:56.865Z
Learning: In Rocket.Chat, there are two different `ModalBackdrop` components with different prop APIs. During review, confirm the import source: (1) `rocket.chat/fuselage` `ModalBackdrop` uses `ModalBackdropProps` based on `BoxProps` (so it supports `onClick` and other Box/DOM props) and does not have an `onDismiss` prop; (2) `rocket.chat/ui-client` `ModalBackdrop` uses a narrower props interface like `{ children?: ReactNode; onDismiss?: () => void }` and handles Escape keypress and outside mouse-up, and it does not forward arbitrary DOM props such as `onClick`. Flag mismatched props (e.g., `onDismiss` passed to the fuselage component or `onClick` passed to the ui-client component) and ensure the usage matches the correct component being imported.

Applied to files:

  • packages/ui-voip/src/providers/MediaCallViewProvider.tsx
🔇 Additional comments (11)
package.json (1)

27-27: LGTM!

packages/i18n/src/locales/en.i18n.json (1)

7451-7452: LGTM!

packages/media-signaling/src/definition/call/IClientMediaCall.ts (1)

110-111: LGTM!

packages/media-signaling/src/lib/Session.ts (1)

564-565: LGTM!

Also applies to: 567-569

packages/media-signaling/src/lib/services/webrtc/Processor.ts (2)

339-343: LGTM!

Also applies to: 354-355, 576-577


473-474: 🎯 Functional Correctness

No change needed for late microphone attachment.

MediaStreamWrapper.setTrack() calls syncTrackChange(), which uses RTCRtpSender.replaceTrack() or RTCPeerConnection.addTrack() and registers the transceiver; this path renegotiates direction changes without calling updateAudioDirectionWithoutNegotiation() directly.

			> Likely an incorrect or invalid review comment.
packages/ui-voip/src/context/definitions.d.ts (1)

32-33: LGTM!

packages/ui-voip/src/context/MediaCallViewContext.ts (1)

22-22: LGTM!

Also applies to: 46-47, 60-60

packages/ui-voip/src/providers/MediaCallViewProvider.tsx (1)

131-132: LGTM!

Also applies to: 204-206, 253-253

packages/ui-voip/src/providers/useMediaSession.ts (2)

20-21: LGTM!

Also applies to: 160-161


176-180: 🎯 Functional Correctness

No change needed for inactive screen-share streams.

After stop, screenShareRemote.stop() removes and clears the video track wrapper, so getMediaStream('screen-share')?.hasVideo() returns false for stopped streams.

			> Likely an incorrect or invalid review comment.

Comment thread packages/media-signaling/src/lib/services/webrtc/Processor.ts
Comment thread packages/ui-voip/src/providers/MediaCallViewProvider.tsx

@cubic-dev-ai cubic-dev-ai 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.

No issues found across 10 files

Re-trigger cubic

@cubic-dev-ai cubic-dev-ai 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.

1 issue found across 1 file (changes from recent commits).

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="packages/media-signaling/src/lib/services/webrtc/Processor.ts">

<violation number="1" location="packages/media-signaling/src/lib/services/webrtc/Processor.ts:643">
P3: This guard correctly prevents micless calls from being falsely inferred as remote-held, but it also disables remote-held detection entirely once the local input track is absent. Because inputTrack can be cleared mid-call via setInputTrack(null), a call that was correctly marked as remote-held while the mic was present will keep _remoteHeld (exposed as remoteHeld in Call.ts) frozen at true even after the remote resumes, since updateRemoteHeld now returns before re-evaluating the audio transceivers. If stale held state is a concern, consider only skipping when there is genuinely nothing to infer, or explicitly resetting held state when the track is removed.</violation>
</file>

Tip: Review your code locally with the cubic CLI to iterate faster.

Re-trigger cubic

return;
}

if (!this.inputTrack) {

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.

P3: This guard correctly prevents micless calls from being falsely inferred as remote-held, but it also disables remote-held detection entirely once the local input track is absent. Because inputTrack can be cleared mid-call via setInputTrack(null), a call that was correctly marked as remote-held while the mic was present will keep _remoteHeld (exposed as remoteHeld in Call.ts) frozen at true even after the remote resumes, since updateRemoteHeld now returns before re-evaluating the audio transceivers. If stale held state is a concern, consider only skipping when there is genuinely nothing to infer, or explicitly resetting held state when the track is removed.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At packages/media-signaling/src/lib/services/webrtc/Processor.ts, line 643:

<comment>This guard correctly prevents micless calls from being falsely inferred as remote-held, but it also disables remote-held detection entirely once the local input track is absent. Because inputTrack can be cleared mid-call via setInputTrack(null), a call that was correctly marked as remote-held while the mic was present will keep _remoteHeld (exposed as remoteHeld in Call.ts) frozen at true even after the remote resumes, since updateRemoteHeld now returns before re-evaluating the audio transceivers. If stale held state is a concern, consider only skipping when there is genuinely nothing to infer, or explicitly resetting held state when the track is removed.</comment>

<file context>
@@ -640,6 +640,10 @@ export class MediaCallWebRTCProcessor implements IWebRTCProcessor {
 			return;
 		}
 
+		if (!this.inputTrack) {
+			return;
+		}
</file context>

@gabriellsh

Copy link
Copy Markdown
Member

Hello @Akanshagore! I'm sorry to inform you, this issue was already fixed here #41416, so I'll be closing this PR.

But, I have a few tips for next time, if you're intersted:

  • make sure you open PR's as drafts if they're not ready yet
  • be careful not to include unrelated or unneeded file changes (in your pr specifically, package.json, eol on i18n file, and some snapshots which I think may be broken?).
  • Run local test suite's before marking the PR as ready to merge and make sure they pass (or before opening the PR if not opening as draft).
  • Test manually too. For example, there are some hard stops on the UI too which would prevent a call from being answered.

This is just an overview, the last 3 items I included just FYI. That's why it's important to open PR's as draft first, and only converting them to ready for review when they're actually ready. Those items would make you PR invalid for merge.

I greatly appreciate the effort though, thanks for contributing and making the platform better! 🚀

@gabriellsh gabriellsh closed this Aug 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Suggestion: Allow screen sharing, even when camera/mic not available

3 participants