Skip to content

refactor: clean up the codebase against the project rules - #6

Merged
Anthonyy232 merged 201 commits into
mainfrom
cleanup/main
Dec 1, 2026
Merged

Anthonyy232 merged 201 commits into
mainfrom
cleanup/main

Conversation

@Anthonyy232

@Anthonyy232 Anthonyy232 commented Dec 1, 2026 •

Copy link
Copy Markdown
Owner

What changed

A cleanup of the whole codebase against AGENTS.md. Production code is roughly net-zero in lines (+1,280 / −1,112 over 106 files); tests grew by about 1,900 lines.

  • Persistence: the database no longer wipes itself on a schema bump. Schema 14 → 15 is a real, tested migration (drops the on-disk item cache and the unused server.version column); servers, accounts, device ids and settings survive. Settings decode leniently and an unreadable row loads defaults instead of crashing every launch. The item cache is in memory, so the domain is no longer serializable.
  • Playback: the coordinator owns speed, subtitle delay and volume; the play session is the one source for the selected tracks. Fixes: speed/delay leaking into the next unrelated playback, the player stuck on Loading after a failed next episode, remote volume lost on the next episode, a track selection reported to the server that the player never applied.
  • Security: the access token is sent only to the stream's origin (an external subtitle URL on another host used to receive it). Removing a server now revokes its accounts' tokens on the server.
  • Jellyfin adapter: a malformed payload becomes an error value instead of a crash; realtime survives a malformed id; dead parameters, audio-only device profiles and duplicate kind lists removed.
  • Scene host: talks to the player and shell directly instead of through forwarding callbacks; tuning values named; flat-screen rule defined once in the domain. Meant to be behaviour-identical.
  • UI: colours, sizes and the selected-fill modifier read from the shared tokens; rules and state-dependent text moved from composables into presentation state; the shell takes screen effects even while the window is closed.
  • Build/CI: Android lint (warnings as errors) now runs on the KMP modules; the dependency lint checks every non-test configuration and keeps :infra:testing out of the app; CI runs the same command as AGENTS.md; unused plugin aliases, dependencies and module descriptions removed.
  • Jellyfin module: infra/jellyfin is a plain JVM module on the SDK's JVM artifact (identical bytecode apart from the Context-derived default device info Hotaru never used); the expect/actual files are gone. The app's ProGuard file carries the two keep rules the SDK's Android artifact used to ship, so R8 gets the same input as the shipped build.
  • Architecture pass: presentation words every error (the application layer returns reasons, not sentences); the play session pairs the player's tracks with the server's streams and defines which can be picked (the rule used to sit untested in the Android player); codecs are typed in the domain and mapped to Jellyfin's names once; a playing stage always carries its plan; the scene host logs through the logger port; pass-through use cases removed.
  • Remote control and headset: a remote Stop now stops an episode that is still loading; a remote Next no longer closes playback when the lookup fails, and a Stop can cancel it; a sign-out during autoplay starts nothing; the headset pause is owned by the playback coordinator, so an episode that starts while the headset is off waits, and a pause by you or a remote is never undone by putting the headset on.
  • Motion: every animation takes its timing from the motion tokens.
  • Tests: application 41 → 64, presentation 45 → 61, plus mapper, migration and store tests. Fakes no longer hide behaviour (tracks listed late, pause while loading).

Why

One source of truth per rule, errors as values across layers, logic in the lowest layer that can own it, no dead code — and to remove the data-loss and crash paths found on the way.

User-visible changes

  • An upgrade keeps saved servers, sign-ins and settings (previously the next schema change would have wiped them) — except Force SDR and Autoplay next episode, which return to their defaults once (their stored names changed; no compatibility shim by choice).
  • After a cold start, the first open of an item refetches it.
  • Removing a server signs its accounts out on the server too; the confirmation and README say so.
  • Top quality option reads "200 Mbps" instead of "Original" (it always was a 200 Mbps cap).
  • Keyboard Done on a blank sign-in or server address does nothing instead of showing an error.
  • Speed and subtitle delay reset for each new playback; a remote volume/mute lasts through next episode, retry and track changes.
  • Track picker is empty until a direct-play file has listed its tracks; an unknown remote track index is ignored.
  • Ratings, subtitle delay and screen width always use a dot ("★ 7.5", "+0.25 s").
  • Too-old-server message reworded; a season without a series id now loads.
  • Connecting, then closing the window: reopening lands on sign-in.
  • Error wording: "You've been signed out. Sign in again." outside the sign-in screen, "That address isn't a Jellyfin server.", every message ends with a full stop; "The server is restarting."
  • An untitled audio/subtitle stream reads "Audio N"/"Subtitle N" on direct play.
  • A pause pressed (or sent remotely) while the next episode loads makes it start paused; something cast while the headset is off and holding playback starts paused.
  • Choice rows (settings, speed, surroundings) take input over their full 48 dp height; server tiles don't react while a connect is in flight.
  • Card lift and player/cinema controls ease on the shared durations (about 0.35 s in, 0.2 s out) instead of springs.

How it was checked

  • ./gradlew check :app:quest:assembleDebug with zero warnings on every item and on the final tree (also once uncached with --rerun-tasks).
  • Every item was reviewed twice (diff against AGENTS.md, then an independent review); three consistency sweeps, an architecture survey, and a final whole-branch review by three independent reviewers whose findings are fixed in the last two merges.
  • Regression tests were shown to fail without their fix. The migration test builds a real v14 database from 14.json.
  • :app:quest:minifyReleaseWithR8 runs clean (unsigned).
  • On a Quest 3 (debug build installed over an existing 0.1.1 debug install with a real v14 database): the app opened straight to Home still signed in; the database is at version 15 with the server, account, device id and settings row intact and the token file byte-identical; Settings shows the saved values and "200 Mbps"; a choice-row option switches when tapped just above its pill; Search, Detail (next-up label, played tick, season tabs), direct play, resume at the saved position, rewind, the track picker (titles from the server, selection marked, subtitle delay shown), Stop, Switch user, the Quick Connect code, LAN discovery and resuming the saved account all work.
  • Not checked: on the headset: the immersive cinema, hand and controller input, remote control from another client, the headset-off pause, a transcode, and a minified release build. No dedicated live-server test run. assembleRelease was not run (needs the keystore). The token-origin rule lives in Media3Player and has no unit test.

Headset steps still to do

  1. Upgrade: install over 0.1.2 without uninstalling → straight to Home, same account, all settings unchanged; saved server still listed after "Switch user".
  2. Playback: direct play, a forced transcode and a sidecar subtitle all play and seek (token still reaches the server). Set 1.5× and +0.5 s: they last through next episode, retry and an audio-track change, and reset for a new item. Fail the next episode (Wi-Fi off): player closes, no spinner.
  3. Tracks: picker empty while loading, then default audio and subtitle marked; switch audio, pick an external subtitle, pick Off; burned-in subtitle on a transcode is marked and hides subtitle delay.
  4. Remote control from Jellyfin web: volume 40 % and mute apply, survive the next episode and show in the dashboard; "set subtitle" to a stream the headset lacks changes nothing.
  5. Cinema (must be unchanged): placement and height, recenter, grab-handle resize, hold, controls show/hide with panels following, settings popover, Back, headset off/on, 180/360 content, surroundings fades, return to window.
  6. Connect: Done on a blank field does nothing; Connect then close the window → sign-in on reopen; tapping another server during a connect does nothing; removing a server removes its device session in the Jellyfin dashboard, also works with the server off; Quick Connect works.
  7. Look (must be unchanged): tab bar and user-tile selected fill, card badges, seek bar colours, settings separators, spinners, remove-server confirmation text fits on one line, "200 Mbps" option.
  8. Networking on a release (minified) build, since the SDK artifact and its R8 rules changed: LAN discovery, add by address over http and https, password and Quick Connect sign-in, images, direct play and transcode, remote control and live library/user-data updates, sign-out revoke.
  9. Motion: card lift eases in and out in about 0.2 s with no springy settle; window and cinema controls fade and slide together, about 0.35 s in and 0.2 s out; route transitions, tab bar and glass fade unchanged.
  10. Remote control from another Jellyfin client: Stop while the next episode loads → nothing starts; Next with the server unreachable → the current item keeps playing; Next then Stop → no new episode; Pause while the next episode loads → it arrives paused.
  11. Headset: off pauses, on resumes; pause yourself, then off/on → stays paused; off while the next episode loads → it waits paused and plays when the headset is back on; off, on, pause, resume, let the episode end → the next one plays; with playback held, a cast that fails → headset on resumes the old item; Retry after an error plays even if the headset reads off.
  12. Negotiation (needs a server): h264/HEVC HDR10/AV1 files direct play; a DTS-HD file transcodes audio to aac; an MPEG-4 Part 2 or VC-1 file transcodes video — the same decisions as 0.1.2.
  13. Library: Home rows, search (movie, series, episode, collection), episode backdrops/thumbs with parent fallback, a series' seasons and episodes; marking a long series played from the web updates every episode on an open detail.

Left for a later decision

  • Licence note: jellyfin-core is LGPL-3.0 and ass-kt bundles FriBidi (LGPL-2.1+). AGENTS.md forbids GPL only; worth stating whether LGPL is accepted.

A version bump dropped every saved server, sign-in and setting, and a settings row from another build crashed every launch.
The cache only serves ten-minute-fresh items, so a table that outlives the process bought nothing and forced the domain to be serializable. The stored server version was never read. Migration 14 to 15 drops both and keeps servers, sign-ins and settings.
Nothing stores domain types any more; settings keep their own serializer in the application layer.
The keyboard's Done skipped the button's rule and showed an error line
instead, so the form rule now lives in the state and guards both paths.
A new item that replaces one the headset holds starts held too while
the headset is still off. A pause from the player or a remote client
while the next episode loads now starts it paused instead of being
ignored.
forceSdr and autoplayNext become isSdrForced and isAutoplayEnabled with
no migration: existing installs fall back to the defaults for those two
settings.
@Anthonyy232
Anthonyy232 marked this pull request as ready for review December 1, 2026 20:49
@Anthonyy232
Anthonyy232 merged commit 2b26715 into main Dec 1, 2026
2 checks passed
@Anthonyy232
Anthonyy232 deleted the cleanup/main branch December 1, 2026 20:54
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