Skip to content

Windows support: mpv over a named pipe, media keys, notifications and a Start Menu entry - #37

Open
XiaTian-AC wants to merge 4 commits into
parda21:mainfrom
XiaTian-AC:windows
Open

XiaTian-AC wants to merge 4 commits into
parda21:mainfrom
XiaTian-AC:windows

Conversation

@XiaTian-AC

Copy link
Copy Markdown

What

Makes cloofy build and run on Windows, with the same two services and the OS integration the platform has equivalents for: YouTube Music over mpv, Spotify over librespot/WASAPI, media keys and Now Playing (SMTC), desktop notifications, sleep/wake, reduced motion and power saving, Credential Manager, and a Start Menu entry.

Supersedes #36, which I opened before running the CI steps and which carried a clippy failure. Same branch, one line different.

The Spotify build already compiled on Windows untouched; the work below is mostly about the parts that were Unix-only by construction.

How

mpv IPC (crates/cloofy-ytmusic/src/player/mpv.rs). The Unix path uses a socketpair and --input-ipc-client=fd://N. Windows has no socketpair, and mpv's documented Windows side is --input-ipc-server=\\.\pipe\…, where mpv is the server. So the Windows build spawns mpv with a per-instance pipe name (\\.\pipe\cloofy-<pid>-<n>), connects as a client with a short retry while mpv creates it, and adds CREATE_NO_WINDOW so no console flashes. Mpv keeps one reader/writer abstraction; everything above it is unchanged.

crates/cloofy-os/src/windows/ — a third platform next to macos/ and linux/, using the existing traits:

  • media.rs — MediaPlayer + SystemMediaTransportControls with automatic integration disabled, so the buttons go through Command like everywhere else. WinRT objects are not Send, so they live on one thread and update() posts to it.
  • notifications.rs — toast through ToastNotificationManager, replacing the previous one by tag/group, cover as a file:/// image. None when the shortcut is missing, because a toast without an AUMID fails silently.
  • power.rs — RegisterSuspendResumeNotification → Event::Sleep/Wake.
  • settings.rs — SPI_GETCLIENTAREAANIMATION for reduced motion, GetSystemPowerStatus for battery saver.
  • secrets.rs — Credential Manager. Its 2560-byte blob limit matters: the YouTube cookies exceed it, so Secret grows a real fallback chain in cloofy-core/src/paths.rs (write falls back to the file, and reading a file that is too large no longer fails while migrating).

cloofy windows install|status|remove — the same shape as cloofy omarchy install|status|remove: it creates the Start Menu shortcut with System.AppUserModel.ID = dev.cloofy.cloofy, which is what Windows needs before it will show a toast. packaging/windows/ has install.ps1 / uninstall.ps1 (PATH is untouched unless asked for) and scoop manifests for later.

Smaller things: cloofy login ytmusic learns the Windows browser locations (the known() table was XDG/.app only); update::supported() lets the UI say "build it yourself" instead of offering an update that cannot be installed; config.rs's keychain check now accepts Windows; .github/workflows/ci.yml gets a windows-latest job that installs NASM/mpv and runs the same checks as Linux.

Verification

On Windows 11, Rust 1.98:

  • The Windows job's own commands, run locally: cargo build --locked -p cloofy --no-default-features --features ytmusic, the same for spotify, cargo clippy --workspace --all-targets --locked -- -D warnings, and cargo test --workspace --locked with CLOOFY_REQUIRE_MPV=1. All pass.
  • CLOOFY_REQUIRE_MPV=1 cargo test -p cloofy-ytmusic --lib — 90 pass, several of them spawn a real mpv over the new pipe.
  • cargo check for x86_64-unknown-linux-gnu and aarch64-apple-darwin, so the other platforms are untouched.
  • The app runs: YouTube Music plays, covers draw, the media session appears to GlobalSystemMediaTransportControlsSessionManager, cloofy windows install/remove and uninstall.ps1 work.

Not in this PR

  • Pausing when the default output device changes (needs an IMMNotificationClient; sleep/wake is separate).
  • crates/cloofy/tests/smoke.rs uses openpty; a Windows version needs CreatePseudoConsole.
  • Windows release artifacts. update() therefore reports "no prebuilt cloofy for this system" rather than downloading something.

For the reviewer

cargo test --workspace fails 8 cloofy-tui snapshot tests on a machine with core.autocrlf=true (the fixtures come out CRLF, the harness renders LF); the content is identical, and CI's actions/checkout doesn't set that. The new Windows CI job has not run yet — this is the first push that will exercise it.

@coderabbitai

coderabbitai Bot commented Nov 15, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 52 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: cc6cc1a8-cad2-4691-b746-07bd30ae1063
Commits

Reviewing files that changed from the base of the PR and between 4b86401 and af64aff.

Files ignored due to path filters: 1

  • Cargo.lock is excluded by !**/*.lock
Files selected for processing: 31

  • .github/workflows/ci.yml
  • CHANGELOG.md
  • Cargo.toml
  • README.md
  • crates/cloofy-core/src/config.rs
  • crates/cloofy-core/src/paths.rs
  • crates/cloofy-core/src/update.rs
  • crates/cloofy-os/Cargo.toml
  • crates/cloofy-os/src/fallback.rs
  • crates/cloofy-os/src/lib.rs
  • crates/cloofy-os/src/windows/media.rs
  • crates/cloofy-os/src/windows/mod.rs
  • crates/cloofy-os/src/windows/notifications.rs
  • crates/cloofy-os/src/windows/power.rs
  • crates/cloofy-os/src/windows/secrets.rs
  • crates/cloofy-os/src/windows/settings.rs
  • crates/cloofy-tui/src/app/mod.rs
  • crates/cloofy-tui/src/notify.rs
  • crates/cloofy-tui/src/scenarios.rs
  • crates/cloofy-tui/src/ui/topbar.rs
  • crates/cloofy-ytmusic/src/auth.rs
  • crates/cloofy-ytmusic/src/player/mod.rs
  • crates/cloofy-ytmusic/src/player/mpv.rs
  • crates/cloofy/Cargo.toml
  • crates/cloofy/src/main.rs
  • crates/cloofy/src/windows.rs
  • packaging/windows/README.md
  • packaging/windows/cloofy-spotify.json
  • packaging/windows/cloofy-ytmusic.json
  • packaging/windows/install.ps1
  • packaging/windows/uninstall.ps1
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

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.

1 participant