# Notes for AI agents working on Spotify for Fennec OS Read first (Fennec SDK, https://gitea.bluefox.support/fennec/sdk): - `docs/store-app-guide.md`: what a Fennec OS store app must be (manifest, sandbox, remote, packaging, release). - `docs/sf-ui.md`: the UI kit. Liquid Glass model, components, focus, dev tools, pitfalls. The page engine and the controller come from Netflex TV (`fennec/netflex`); keep them close to it. ## Layout ``` app.toml store manifest (id support.bluefox.spotify; permissions network, gpu, audio) src/main.rs window, glass layer (lists every exported [GlassRect]), images, controller src/spotify.rs librespot: session, Spotify Connect (Spirc), sign-in (zeroconf + pairing code), player; Cmd in, Event out src/api.rs the objects pages use, and Api: Internal (normal) or Web (Web API, only with SPOTIFY_MOCK) src/internal.rs Spotify's internal endpoints via the session: metadata, playlists, /collection/v2, recently played, search, queue command src/app.rs Controller: screen stack, keys, input/picker/toast, backdrop, sign-in screen, engine events, avatar src/nowplaying.rs Most szól: playback state, controls, seek, lyrics, queue src/page.rs the line-based page engine: lines (L) and chips (Ch) -> layout, focus, scroll, lazy images src/screens/mod.rs sections of the top nav, cards, track rows, the track "+" menu, opening a card id src/screens/home.rs Kezdőlap: recently played, playlists (+ liked), top artists/tracks, saved albums, new releases src/screens/search.rs Keresés: embedded keyboard, songs, artists, albums, playlists, podcasts src/screens/library.rs Könyvtár: tabs, grid, paging (artists by cursor) src/screens/collection.rs playlist / album / liked songs / podcast: header, Lejátszás/Keverés/Mentés, track rows, paging src/screens/artist.rs artist: header, popular tracks, albums, singles, appearances src/screens/settings.rs Beállítások: account, Connect name, quality, normalisation, autoplay, look src/config.rs config.toml: device id/name, bitrate, normalise, autoplay, glass src/format.rs Hungarian texts: times, counts, dates src/task.rs blocking work on a thread, result on the UI thread ui/app.slint root: screen fades, one FocusScope -> Rust `key`, glass exports ui/page.slint LinePage: draws the lines Rust lays out (nav, now playing capsule, avatar, keyboard) ui/nowplaying.slint the now playing screen and its lyrics panel ui/signin.slint ConnectScreen (QR code + Spotify app), InputScreen, MessageScreen ui/icons.slint SpIcon: shuffle, repeat, heart, lyrics, queue, devices (+ sf-ui's icons) tools/mock_server.py stand-in Web API with made-up data (with SPOTIFY_MOCK=1: no librespot) ``` The public Web API is not used against Spotify: librespot's client id gets 429 (rate limit) on every call. Browsing goes through `internal.rs`. ``` ``` ## Rules of this codebase - **Rust owns state and focus.** Slint only draws. Every key goes to `Controller::key`, except while an on-screen keyboard has the focus. - **Engine thread:** librespot runs on its own tokio runtime. Talk to it with `Engine::send(Cmd)`; its `Event`s reach the UI thread through `slint::invoke_from_event_loop`. Blocking calls (`Engine::token`, `Engine::lyrics`, every `Api` method) only off the UI thread (`task::spawn`, `Cx::spawn`). - **Playback is Spirc's:** play a context (`Cmd::Context`) whenever possible, so next/previous, shuffle and the phone's view work. `Cx::play` also opens Most szól. - **Short borrows:** never hold `state.borrow_mut()` while calling `images.load*`; a cached picture calls back at once. - **Glass:** new glass elements need their `glass` listed in a root `out property <[GlassRect]>`, and that array added in `main.rs`. Nothing Slint draws may sit under a glass pane. - **Slint names:** a property may not be called `focus` (a function) or `cover` (an ImageFit value). - **Texts are Hungarian.** - **Testing on the developer's PC:** never open windows on the primary monitor. Use `SPOTIFY_WINDOW_POS` to put the window on another monitor, or run headless. ## Check your change ```sh cargo test python3 tools/mock_server.py --port 7890 & SPOTIFY_MOCK=1 SPOTIFY_API=http://127.0.0.1:7890/v1 SF_UI_SIZE=1600x900 \ SF_UI_KEYS="wait wait down enter wait wait" SF_UI_SNAPSHOT=/tmp/shot.png cargo run # then look at /tmp/shot.png ```