Files
spotify/AGENTS.md
Tamas Csikel 3a66e0c7c7
All checks were successful
release / release (push) Successful in 12m14s
Spotify for Fennec OS: native TV client
Rust + Slint on sf-ui's Liquid Glass, with the page engine of Netflex TV.
librespot plays (GStreamer on the TV) and makes the TV a Spotify Connect
device; the Web API (token from the session) feeds the pages.

- Sign-in with the phone: a pairing code / QR code (spotify.com/pair,
  OAuth device flow) or picking the TV in the Spotify app (zeroconf).
- Home, search, library, playlist / album / liked songs / podcast pages,
  artist pages, settings; the user's picture top right.
- Now playing: seek, shuffle, repeat, like, synced lyrics, queue.
- package.sh builds x86-64 and aarch64 (Raspberry Pi); the Gitea CI
  releases both on a tag.
- tools/mock_server.py and SPOTIFY_MOCK for work without an account.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-03 17:23:34 +01:00

56 lines
4.1 KiB
Markdown

# 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 Spotify Web API (browsing, library, search, queue), token from the session; short GET cache, 429 retry
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 panel (lyrics / queue)
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)
```
## 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
```