Skip to content

Conversation

@RobbieTheWagner
Copy link
Member

@RobbieTheWagner RobbieTheWagner commented Dec 11, 2025

Summary by CodeRabbit

  • Chores

    • Updated PipeWire integration to a newer Linux binding and enabled Wayland support in the Rust build.
    • CI now installs additional system packages (PipeWire dev libraries and OpenSSL) to support headless/media tests.
    • Added an automated build-time patching mechanism to apply dependency fixes during builds.
  • Documentation

    • Added guidance on managing and troubleshooting dependency patches.

✏️ Tip: You can customize this high-level summary in your review settings.

@RobbieTheWagner RobbieTheWagner added the bug Something isn't working label Dec 11, 2025
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 11, 2025

Warning

Rate limit exceeded

@RobbieTheWagner has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 15 minutes and 12 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between 0dfae12 and 9f3c947.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (8)
  • .github/workflows/electron.yml (1 hunks)
  • .github/workflows/ember.yml (1 hunks)
  • .github/workflows/lint.yml (1 hunks)
  • .github/workflows/release.yml (2 hunks)
  • .github/workflows/rust-tests.yml (1 hunks)
  • .tool-versions (1 hunks)
  • electron-app/magnifier/rust-sampler/src/sampler/wayland_portal.rs (1 hunks)
  • package.json (6 hunks)

Walkthrough

Switched the Rust magnifier to a git-pinned pipewire-rs binding, migrated code to the PipeWire 0.9 API, added a build-time cargo-patch flow and libspa patch, enabled Wayland in CI Rust builds, and installed PipeWire system packages in the GitHub Actions workflow.

Changes

Cohort / File(s) Summary
CI Environment
/.github/workflows/electron.yml
Added installation of libpipewire-0.3-dev and libssl-dev to the system dependencies step; other workflow steps unchanged.
Cargo metadata & dependency changes
electron-app/magnifier/rust-sampler/Cargo.toml
Replaced Linux PipeWire dependency with a git-pinned pipewire-rs (specific rev); added [build-dependencies] cargo-patch = "0.3" and [package.metadata.patch.libspa] specifying version 0.9 and patches = ["patches/libspa-modifier-i64.patch"].
Build-time patching & docs
electron-app/magnifier/rust-sampler/build.rs, electron-app/magnifier/rust-sampler/PATCHES.md, electron-app/magnifier/rust-sampler/patches/libspa-modifier-i64.patch
Added build.rs to apply dependency patches via cargo_patch::patch() and set rerun triggers; documented patch workflow in PATCHES.md; added a patch that adjusts libspa modifier storage casts (i64 ↔ u64).
PipeWire API migration
electron-app/magnifier/rust-sampler/src/sampler/wayland_portal.rs
Updated code to PipeWire 0.9 API variants (e.g., MainLoopRc::new(None), ContextRc::new(..., None), context.connect_rc, StreamBox::new, VideoInfoRaw::default(), and pw::loop_::Timeout::Finite(...)) and updated comments.
CI build feature flags
package.json
build:rust:ci script updated to build with both x11 and wayland features: cargo build --release --features x11,wayland (was only x11).

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20–30 minutes

  • Pay attention to src/sampler/wayland_portal.rs for correct 0.9 API usage, lifetimes, and error handling around mainloop/context/stream.
  • Review Cargo.toml git dependency and the correctness/implications of pinning to a specific rev.
  • Verify build.rs cargo-patch invocation and that patches/libspa-modifier-i64.patch safely preserves semantics.
  • Confirm PATCHES.md instructions align with build.rs behavior.
  • Validate CI changes: package names (libpipewire-0.3-dev, libssl-dev) and the added wayland feature build in CI.

Poem

🐰
I nibbled loops and threaded light,
Switched pipes to git in moonlit night,
Casts whisper safe where types once sighed,
Wayland joins X — side by side,
Hop—build passes! 🥕

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Update pipewire to 0.9' accurately summarizes the main change in the pull request—upgrading the PipeWire dependency from version 0.8 to 0.9 across multiple files and adapting the code accordingly.

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 and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
electron-app/magnifier/rust-sampler/src/sampler/wayland_portal.rs (1)

186-195: Stream::new() does not exist in PipeWire 0.9; use StreamBox::new() instead.

The PipeWire 0.9 API requires creating a stream with StreamBox::new(), not Stream::new(). After creating the stream, you must call .connect() separately with the appropriate direction, ID, flags, and parameters.

Change to:

let stream = pw::stream::StreamBox::new(
    &core,
    "swach-screenshot",
    pw::properties::properties! {
        *pw::keys::MEDIA_TYPE => "Video",
        *pw::keys::MEDIA_CATEGORY => "Capture",
        *pw::keys::MEDIA_ROLE => "Screen",
    },
).map_err(|_| "Failed to create PipeWire stream".to_string())?;

stream.connect(spa::Direction::Output, None, pw::stream::StreamFlags::empty(), &mut [])?;
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c9cea43 and d64deaa.

📒 Files selected for processing (4)
  • .github/workflows/electron.yml (1 hunks)
  • electron-app/magnifier/rust-sampler/Cargo.toml (1 hunks)
  • electron-app/magnifier/rust-sampler/src/sampler/wayland_portal.rs (3 hunks)
  • package.json (1 hunks)
🧰 Additional context used
🪛 GitHub Actions: Rust Tests
electron-app/magnifier/rust-sampler/src/sampler/wayland_portal.rs

[error] 309-309: failed to resolve: could not find Timeout in loop_


[error] 175-175: function or associated item not found in MainLoop: expected new


[error] 179-179: function or associated item not found in pipewire::context::Context: expected new


[error] 187-187: function or associated item not found in pw::stream::Stream: expected new


[error] 309-309: E0433: could not find Timeout in loop_


[error] 175-175: E0599: no function or associated item named new found for struct MainLoop in the current scope


[error] 179-179: E0599: no function or associated item named new found for struct pipewire::context::Context in the current scope


[error] 187-187: E0599: no function or associated item named new found for struct pipewire::stream::Stream in the current scope


[error] cargo test failed for feature set x11,wayland (process completed with exit code 101)

electron-app/magnifier/rust-sampler/Cargo.toml

[error] cargo test failed for feature set x11,wayland (process completed with exit code 101)

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Tests
🔇 Additional comments (3)
electron-app/magnifier/rust-sampler/src/sampler/wayland_portal.rs (1)

221-221: LGTM: VideoInfoRaw construction updated.

The change from VideoInfoRaw::new() to VideoInfoRaw::default() appears correct as there's no compilation error for this line.

.github/workflows/electron.yml (1)

25-25: LGTM: PipeWire development headers added to CI.

Adding libpipewire-0.3-dev correctly provides the necessary system libraries for building the Rust sampler with Wayland/PipeWire support.

package.json (1)

24-24: LGTM: Build script correctly enables wayland feature.

The addition of the wayland feature to the cargo build is correct. However, the build will fail until the PipeWire 0.9 API issues in wayland_portal.rs are resolved.

Note: This change depends on fixing the compilation errors in the Rust code that uses the PipeWire API.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (2)
electron-app/magnifier/rust-sampler/PATCHES.md (1)

30-30: Optional: Consider "resolves" for a more formal tone.

The word "fixes" is perfectly acceptable here. If you prefer a more formal style, you could use "resolves" instead, but this is purely a stylistic preference.

electron-app/magnifier/rust-sampler/build.rs (1)

1-10: Consider watching the patch file explicitly.

The build script correctly applies patches and fails fast on errors. However, line 4 watches the patches/ directory, which may not trigger rebuilds when patch file content changes—only when files are added or removed. Consider adding an explicit watch for the patch file itself to ensure rebuilds when patches are modified.

Apply this diff to watch the patch file explicitly:

 fn main() {
     // Ensure build script re-runs if Cargo.toml or patches change
     println!("cargo:rerun-if-changed=Cargo.toml");
     println!("cargo:rerun-if-changed=patches/");
+    println!("cargo:rerun-if-changed=patches/libspa-modifier-i64.patch");
     
     // Apply patches to dependencies
     // This patches the libspa crate to fix the modifier type mismatch
     // where newer PipeWire versions use i64 instead of u64
     cargo_patch::patch().expect("Failed to apply patches to dependencies");
 }
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between eb74c89 and 89c3772.

📒 Files selected for processing (5)
  • electron-app/magnifier/rust-sampler/Cargo.toml (1 hunks)
  • electron-app/magnifier/rust-sampler/PATCHES.md (1 hunks)
  • electron-app/magnifier/rust-sampler/build.rs (1 hunks)
  • electron-app/magnifier/rust-sampler/patches/libspa-modifier-i64.patch (1 hunks)
  • electron-app/magnifier/rust-sampler/src/sampler/wayland_portal.rs (3 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
electron-app/magnifier/rust-sampler/src/sampler/wayland_portal.rs (7)
electron-app/magnifier/rust-sampler/src/sampler/macos.rs (1)
  • new (29-46)
electron-app/magnifier/rust-sampler/src/sampler/linux.rs (1)
  • new (36-63)
electron-app/magnifier/rust-sampler/src/sampler/windows.rs (1)
  • new (11-23)
electron-app/magnifier/rust-sampler/src/types.rs (1)
  • new (12-18)
electron-app/magnifier/rust-sampler/tests/linux_sampler_tests.rs (1)
  • new (16-22)
electron-app/magnifier/rust-sampler/tests/macos_sampler_tests.rs (1)
  • new (19-25)
electron-app/magnifier/rust-sampler/tests/windows_sampler_tests.rs (1)
  • new (15-20)
🪛 LanguageTool
electron-app/magnifier/rust-sampler/PATCHES.md

[style] ~30-~30: Consider using a different verb for a more formal wording.
Context: ... on the PipeWire version. Once upstream fixes this issue, we can remove this patch. ...

(FIX_RESOLVE)

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Tests
🔇 Additional comments (7)
electron-app/magnifier/rust-sampler/PATCHES.md (1)

1-71: Excellent documentation for patch management.

The documentation is comprehensive, well-structured, and provides clear guidance for understanding and maintaining the patch system. It covers the rationale, implementation details, troubleshooting, and future maintenance considerations.

electron-app/magnifier/rust-sampler/patches/libspa-modifier-i64.patch (1)

1-18: Patch correctly handles modifier type compatibility.

The bidirectional casting approach (u64 ↔ i64) maintains API compatibility while adapting to PipeWire's underlying type change. This is a reasonable workaround. Note that casting between signed and unsigned types could theoretically cause issues if negative values are ever used, but in practice video/DRM modifiers are positive values, making this safe for the current use case.

electron-app/magnifier/rust-sampler/Cargo.toml (2)

44-47: The git commit is legitimate and verified to exist.

The pinned commit b23847892822352f4a98b1cbc61746e9160ad010 has been confirmed in the pipewire-rs repository. It was authored by dimtpap on 2025-04-14 and includes FFI-related changes ("spa: Add newtype for node commands") with libspa-sys present in the commit, confirming it contains the necessary FFI bindings.


54-58: Patch remains necessary.

The patch configuration is correct and aligns with the build script. No upstream fixes for this libspa Modifier type issue were found in recent releases or commits, so the patch should be retained.

electron-app/magnifier/rust-sampler/src/sampler/wayland_portal.rs (3)

174-195: PipeWire 0.9 Rc/Box setup matches the documented patterns

The switch to MainLoopRc::new(None), ContextRc::new(&mainloop, None), connect_rc(None), and StreamBox::new(&core, "swach-screenshot", properties! { ... }) lines up with the 0.9.x crate examples for Rc-based main loop/context/core wiring and stream creation, so this migration looks correct. (pipewire.pages.freedesktop.org)

If you haven’t already, please confirm CI/cargo check passes against the exact git-pinned pipewire commit used here, since those APIs are version-sensitive.


221-222: VideoInfoRaw::default() is fine and equivalent here

VideoInfoRaw implements both new() and Default, and you immediately call parse(param) before reading width/height/stride, so using VideoInfoRaw::default() is behaviorally equivalent and consistent with the libspa bindings. (pipewire.pages.freedesktop.org)

Please just double-check that the pinned libspa/pipewire-rs version still exposes Default for VideoInfoRaw (it does in 0.9.2).


309-310: Loop::iterate timeout wrapper matches the 0.9 Timeout API

In 0.9.x, Loop::iterate takes a pw::loop_::Timeout, so calling mainloop.loop_().iterate(pw::loop_::Timeout::Finite(Duration::from_millis(10))) is the correct, typed way to provide a finite timeout. (pipewire.pages.freedesktop.org)
This contradicts an earlier (outdated) review that assumed a plain Duration parameter; no change is needed here with the current crate.

Verify that your Cargo.toml/patch is actually pulling in pipewire ≥ 0.9 so this signature matches what’s built.

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

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants