# Development ## Setup (Windows) 1. Node 22+, Rust stable (MSVC), Visual Studio C++ build tools, 7-Zip. 2. `npm ci` 3. `.\scripts\fetch-libmpv.ps1` downloads the shinchiro `mpv-dev-x86_64` build (the Windows libmpv builds linked from mpv.io) into `vendor/mpv/windows`. 4. Put a `.env` in the repository root for the development sign-in: `PLEX_SERVER_URL=...` and `PLEX_TOKEN=...`. It is ignored by git and only read by debug builds and the Vite dev server. Never commit or print it. 5. `npm run tauri dev` ## Setup (macOS) 1. Node 22+, Rust stable (`brew install rustup && rustup default stable`), the Xcode command line tools and Homebrew. 2. `npm ci` 3. `sh scripts/fetch-libmpv.sh` installs Homebrew's `mpv` and copies libmpv with every library it links into `vendor/mpv/macos`, rewritten to find each other there (`@loader_path`) and signed, so the bundle doesn't depend on Homebrew. Homebrew builds for the macOS it runs on, so the app's minimum macOS is that of the build machine (`scripts/build.sh` sets it from the libraries). 4. `.env` as on Windows, then `npm run tauri dev`. Debug builds on macOS keep the Plex token in `dev-secrets.json` in the app data folder rather than the Keychain: every rebuild is a new unsigned binary, which the Keychain would ask about again. Release builds always use the Keychain. The interface alone runs in a browser with `npm run dev` (port 1420), which is handy for layout work; playback, downloads and native dialogs need the desktop app. In development builds the stores are available as `window.__kaleido` for debugging. To drive the desktop app from scripts, start it with `WEBVIEW2_ADDITIONAL_BROWSER_ARGUMENTS=--remote-debugging-port=9333` and attach over the Chrome DevTools Protocol. ## Checks ```powershell npm run typecheck npm test cargo check --manifest-path src-tauri/Cargo.toml ``` Playback tests change real Plex progress; resume an in-progress title near its saved position, or restore it afterwards. Selecting audio or subtitle tracks is saved to Plex for that file. Up Next (`player/PostPlay.tsx`) opens at an episode's first credits marker, or at the end without markers. The video is drawn into its top-left frame (`player_rect`) behind a matching hole in the page; check that the two line up after resizing, changing display scale and returning to the video. In the browser, open it from the console by setting `postPlay: true` (with `item`, `nextUp`, `episodeContextReady`) on `__kaleido.usePlayer`. ## Diagnostics `src-tauri/src/diagnostics.rs` writes to the app's log folder (`%LOCALAPPDATA%\tv.kaleido.desktop\logs` on Windows); nothing is uploaded. - **Hangs**: a watchdog asks the UI thread to answer every second. After 5 seconds of silence it writes `kaleido-hang-