Skip to content

Clarify screen capture availability probing#15

Open
ashish200729 wants to merge 1 commit into
TechyCSR:mainfrom
ashish200729:screen-capture-availability-probe
Open

Clarify screen capture availability probing#15
ashish200729 wants to merge 1 commit into
TechyCSR:mainfrom
ashish200729:screen-capture-availability-probe

Conversation

@ashish200729
Copy link
Copy Markdown

Summary

Clarifies the screen capture watcher so it no longer treats Electron's source enumeration as active screen sharing detection.

Electron's desktopCapturer.getSources() can confirm whether screen/window capture sources can be enumerated, but it does not reliably indicate whether another app is currently sharing the screen. This change makes that distinction explicit by tracking capture availability separately from screen sharing mode.

What Changed

  • Adds explicit screenCaptureStatus state with available, lastError, and lastCheckedAt
  • Prevents overlapping capture availability checks
  • Keeps isScreenBeingShared unchanged when capture enumeration fails
  • Exposes capture availability through getWindowStats()
  • Updates logs to distinguish capture availability from screen sharing mode

Why

The previous implementation implied that desktopCapturer.getSources() detected active screen sharing. In practice, it only verifies that Electron can enumerate capture sources. Treating that probe as screen sharing detection could produce misleading state and confusing logs.

This keeps the existing screen sharing mode behavior intact while making the periodic probe accurate and observable.

Validation

  • Ran node -c src/managers/window.manager.js
  • Ran git diff --check
  • Confirmed only src/managers/window.manager.js is included in the commit

@ashish200729 ashish200729 marked this pull request as ready for review May 26, 2026 09:53
Copilot AI review requested due to automatic review settings May 26, 2026 09:53
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

This PR replaces the periodic “screen sharing detection” logic with a safer “screen capture availability” probe (to avoid Linux/Wayland portal issues), and exposes the probe status via debug info.

Changes:

  • Replaced setupScreenSharingDetection() with setupScreenCaptureAvailabilityWatcher() and a new checkScreenCaptureAvailability() flow.
  • Added screenCaptureStatus + overlap-guard state (isCheckingScreenCaptureStatus) to track probe results and timing.
  • Updated logs and cleanup logic to reflect the new watcher.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

try {
const sources = await desktopCapturer.getSources({
await desktopCapturer.getSources({
types: ['screen', 'window'],
if (previousAvailability === false) {
logger.debug('Screen capture enumeration still unavailable', logContext);
} else {
logger.warn('Screen capture enumeration unavailable; leaving screen sharing mode unchanged', logContext);
Comment on lines +867 to +871
this.screenCaptureStatus = {
available: false,
lastError: error.message,
lastCheckedAt: checkedAt
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants