fix: only open screen-share picker on a user-initiated request#3360
fix: only open screen-share picker on a user-initiated request#3360Shevilll wants to merge 1 commit into
Conversation
Since server-view screen sharing support was added (4.14.0), the desktop-capturer source picker opened on every app launch. The web app calls navigator.mediaDevices.getDisplayMedia() during page load to probe capabilities; because the app runs with autoplay-policy no-user-gesture-required, that gesture-less probe reached the newly registered setDisplayMediaRequestHandler and opened the picker. Ignore display-media requests that carry no user gesture, so the picker only opens for a genuine, user-initiated screen share. Real shares (which always originate from a click) are unaffected. This complements the earlier partial fix (RocketChat#3320), which only gated the Linux/portal cache-prewarm path and left the issue open. Closes RocketChat#3308
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
📜 Recent review details🧰 Additional context used📓 Path-based instructions (5)**/*.ts📄 CodeRabbit inference engine (CLAUDE.md)
Files:
**/*.{tsx,ts}📄 CodeRabbit inference engine (CLAUDE.md)
Files:
**/*.{ts,tsx}📄 CodeRabbit inference engine (CLAUDE.md)
Files:
**/*.spec.ts📄 CodeRabbit inference engine (CLAUDE.md)
Files:
**/*.{spec.ts,main.spec.ts}📄 CodeRabbit inference engine (CLAUDE.md)
Files:
🔇 Additional comments (4)
Walkthrough
ChangesUser gesture gate for screen-share handler
Estimated code review effort🎯 2 (Simple) | ⏱️ ~5 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 There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 ESLint
ESLint install failed. For unrecoverable errors, disable the tool in CodeRabbit configuration. 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 |
|
Hi team! Gated the screen-share capturer picker with a user gesture check ( |
Closes #3308
What changed
The desktop-capturer source picker opened on every app launch (regression since 4.14.0, introduced by #3266 which added screen-sharing support for the server view).
Root cause: the web app calls
navigator.mediaDevices.getDisplayMedia()during page load to probe capabilities. Because the app runs with--autoplay-policy=no-user-gesture-required, that automatic, gesture-less probe is not rejected as it would be in a browser — it reaches thesetDisplayMediaRequestHandlerthat #3266 now registers on every server-view webview, which opens the picker.This adds a guard so the handler ignores requests that carry no user gesture (
request.userGesture === false), and only delegates to the provider for a genuine, user-initiated screen share. Real shares always originate from a click, so they are unaffected.This complements the earlier partial fix #3320, which only gated the Linux/portal cache-prewarm path — the picker still opened on every launch on all platforms via the handler itself, which is why this issue remained open.
Why this approach
request.userGestureis the documented Electron signal for whether a display-media request came from a user interaction; gating on it is the minimal change that restores the pre-4.14.0 behaviour (no picker on launch) without reverting #3266's feature. The denial uses the samecb({ video: false })shape as the other deny paths in this module for consistency.Tests
Added two cases to
src/screenSharing/main/serverViewScreenSharing.spec.ts:{ video: false }and the provider'shandleDisplayMediaRequestis not invoked;Run with
yarn test.Manual verification
Summary by CodeRabbit
Bug Fixes
Tests