Skip to content

fix(linux): use a real screen source on X11 instead of the portal sen…#768

Open
maxmedina05 wants to merge 1 commit into
webadderallorg:mainfrom
maxmedina05:fix/linux-x11-capture-source
Open

fix(linux): use a real screen source on X11 instead of the portal sen…#768
maxmedina05 wants to merge 1 commit into
webadderallorg:mainfrom
maxmedina05:fix/linux-x11-capture-source

Conversation

@maxmedina05

@maxmedina05 maxmedina05 commented Jul 19, 2026

Copy link
Copy Markdown

Description

The Linux HUD renders no source picker, so getSelectedSource() is always null when recording starts. startRecording then substitutes the screen:linux-portal sentinel for every Linux session, forcing capture through getDisplayMedia and the xdg-desktop-portal ScreenCast dialog. On X11 that dialog never opens, so recording fails with Could not start video source.

Main already resolves screens correctly per session type via getScreenSourceIdForDisplay() — the portal sentinel on Wayland, a real desktop-capturer id on X11. The renderer just never asked for it. This adds resolveDefaultLinuxSource(), which prefers a real screen id when available and keeps the sentinel as fallback.

Part of a series of Linux fixes for Ubuntu 24.04; each PR is standalone and touches disjoint files.

Motivation

X11 users cannot record at all — capture fails immediately with Could not start video source, confirmed by #137. Wayland is unaffected today and stays unaffected here: it still resolves to the portal sentinel and the single-dialog flow. Only X11 changes, moving to direct capture with a real source id. Fallback ids (screen:fallback:*) are skipped so the existing "Selected display is not available" guard still applies.

Type of Change

  • Bug Fix
  • New Feature
  • Refactor / Code Cleanup
  • Documentation Update
  • Other (please specify)

Related Issue(s)

Refs #137, #364, #441

Screenshots / Video

Not a UI change — the observable difference is that recording starts instead of throwing. On X11, source resolution now yields a real id (e.g. screen:661:0) and capture begins; before, it threw Could not start video source before any frame.

Testing Guide

npx vitest --run
npm run dev   # on a Linux X11 session, press record without picking a source — it should record

Verified on Ubuntu 24.04 (GNOME, X11): resolves a real source id and captures at 3840x2160@60 from a fresh profile with no source selected. Wayland unchanged — still resolves to the portal sentinel.

Note: resolveDefaultLinuxSource is module-private and depends on window.electronAPI, so a unit test means exporting it and mocking that. Happy to add if wanted.

Checklist

  • I have performed a self-review of my code.
  • I have added any necessary screenshots or videos.
  • I have linked related issue(s) and updated the changelog if applicable.

Notes

Investigated and drafted with Claude Code. The error message and the X11/Wayland behaviour described are from real runs on the hardware listed, not generated — I can re-run either on request.


Thank you for contributing!

Summary by CodeRabbit

  • New Features

    • Linux screen recording now automatically selects the first available captureable screen source.
    • If no suitable source is found, recording continues using the standard fallback option.
  • Bug Fixes

    • Improved Linux recording startup by avoiding unavailable or non-captureable screen sources.

…tinel

The Linux HUD does not render a source picker, so `getSelectedSource()`
is always null when recording starts. startRecording then substituted
the `screen:linux-portal` sentinel for every Linux session, forcing
capture through getDisplayMedia and the xdg-desktop-portal ScreenCast
dialog.

On X11 that dialog never opens, so capture failed with:

  Failed to start recording: Could not start video source

Main already resolves screens per session type via
getScreenSourceIdForDisplay(): the portal sentinel on Wayland, a real
desktop-capturer id on X11. The renderer just never asked for it.

Prefer a real screen id when one is available and keep the sentinel as
the fallback, so Wayland behaviour is unchanged and X11 uses direct
capture. Fallback ids (screen:fallback:*) are skipped so the existing
"Selected display is not available" guard still applies.

Verified on Ubuntu 24.04 (GNOME, X11): resolution now yields a real
source id and captures at 3840x2160@60.

Refs webadderallorg#137, webadderallorg#364, webadderallorg#441

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Jul 19, 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: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 4e5a9ec1-9ddb-4b9a-9f24-5ea4acfcf442

📥 Commits

Reviewing files that changed from the base of the PR and between 360b160 and ce00de7.

📒 Files selected for processing (1)
  • src/hooks/useScreenRecorder.ts

📝 Walkthrough

Walkthrough

Linux recording now queries available screen sources, selects the first captureable real source, and falls back to the portal sentinel when resolution fails or no suitable source exists.

Changes

Linux source selection

Layer / File(s) Summary
Source resolution and recording startup
src/hooks/useScreenRecorder.ts
Adds asynchronous Linux source discovery that excludes portal and fallback entries, warns on lookup errors, and updates startRecording to await the resolved source when none is selected.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related PRs

Suggested reviewers: webadderall

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main Linux X11 screen-source fix and is concise.
Description check ✅ Passed The description follows the template closely and includes the required sections with concrete testing and issue references.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant