Skip to content

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

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

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

Conversation

@XiaTian-AC

@XiaTian-AC XiaTian-AC commented Nov 15, 2026 •

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.

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:

  • cargo check/build for --features ytmusic and --features spotify.
  • CLOOFY_REQUIRE_MPV=1 cargo test -p cloofy-ytmusic --lib — 89 pass, several of them spawn a real mpv over the new pipe.
  • cargo test -p cloofy-core, -p cloofy-os; cargo check --workspace --all-targets.
  • 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.

Summary by CodeRabbit

  • New Features
    • Added Windows support for YouTube Music and Spotify, including media controls, desktop notifications, sleep/wake handling, and Credential Manager sign-ins.
    • Added Windows installation, status, and removal commands, plus installer and package-manager setup options.
    • On systems without downloadable updates, the app now explains that updating requires building locally.
  • Documentation
    • Added Windows setup and platform guidance, including prerequisites, notification behavior, and uninstall details. નોંધ

@coderabbitai

coderabbitai Bot commented Nov 15, 2026 •

Copy link
Copy Markdown

Explain Change →

Caution

Review failed

The pull request is closed.

Walkthrough

This change adds Windows support for media playback, notifications, power events, settings, credentials, browser discovery, installation, and update handling. It also adds Windows CI coverage and documents Windows setup and platform behavior.

Changes: Windows platform and OS services

Layer / File(s) Summary
Platform selection and credential storage
Cargo.toml, crates/cloofy-os/Cargo.toml, crates/cloofy-os/src/fallback.rs, crates/cloofy-os/src/lib.rs, crates/cloofy-core/src/config.rs, crates/cloofy-core/src/paths.rs
Windows-specific OS dependencies and module selection are added. Keychain configuration recognizes Windows, and oversized secrets use file-backed storage when keychain writes return InvalidInput.
Windows OS services
crates/cloofy-os/src/windows/*
Windows implementations add media controls, toast notifications, sleep and wake monitoring, settings detection, and Credential Manager support.

Windows playback, commands, and packaging

Layer / File(s) Summary
Browser discovery and mpv IPC
crates/cloofy-ytmusic/src/auth.rs, crates/cloofy-ytmusic/src/player/*
YouTube Music browser discovery checks Windows profile roots. mpv uses named-pipe IPC on Windows, with shared asynchronous reader and writer interfaces.
Windows shortcut commands and packaging
crates/cloofy/Cargo.toml, crates/cloofy/src/main.rs, crates/cloofy/src/windows.rs, packaging/windows/*
The cloofy windows command manages the Start Menu shortcut. Installer and uninstaller scripts manage the binary and PATH entries, and Scoop manifests describe the Spotify and YouTube Music packages.

TUI, CI, and documentation

Layer / File(s) Summary
Update and notification handling
crates/cloofy-core/src/update.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
The updater displays local-build instructions when a release has no build for the current system. The TUI desktop notification channel now includes Windows.
CI and Windows documentation
.github/workflows/ci.yml, CHANGELOG.md, README.md, packaging/windows/README.md
CI builds both Windows service variants and runs workspace checks. The documentation describes Windows setup, installation, and platform behavior.

Estimated code review effort: 4 (Complex) | ~50 minutes

Change: Feature

Sequence Diagram(s)

sequenceDiagram
  participant Cloofy
  participant Ipc
  participant mpv
  participant NamedPipe
  Cloofy->>Ipc: Configure Windows IPC
  Ipc->>mpv: Start with named-pipe server argument
  mpv->>NamedPipe: Open IPC pipe
  Ipc->>NamedPipe: Retry connection until connected or timeout
  NamedPipe-->>Ipc: Provide asynchronous reader and writer
  Ipc-->>Cloofy: Return IPC streams
Loading

Suggested reviewers: yk-sgr

  • 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

@XiaTian-AC

Copy link
Copy Markdown
Author

Sorry — I opened #36 before running the CI steps. A clippy warning in a test (clippy::to_string_in_format_args) would have failed the new Windows job on its first run. I've now reproduced the job locally (both --locked builds, cargo clippy --workspace --all-targets --locked -- -D warnings, and cargo test --workspace --locked with CLOOFY_REQUIRE_MPV=1), fixed the warning, and opened a fresh PR so the diff starts clean rather than showing a broken first push.

Nothing about the design changed; this is the same branch, one line different.

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