Skip to content

v2.4.0: a re-ordered download takes the new order on its next online start - #133

Merged
KodeStar merged 5 commits into
mainfrom
fix/v2.4.0-offline-reorder
Oct 23, 2026
Merged

KodeStar merged 5 commits into
mainfrom
fix/v2.4.0-offline-reorder

Conversation

@KodeStar

Copy link
Copy Markdown
Owner

Server v2.4.0 (server#171) plays a book's files in natural order and re-orders an existing book once. On main, a downloaded copy of a re-ordered book kept its old order while online starts used the new one, so whole-book positions were saved against two different timelines.

The fix: a downloaded copy takes the server's new order only when a start loads that order. The start's load must have landed, and the start must still own the engine. The file set must be the same paths with matching sizes. Only the copy's chapters change; its files keep their download order on disk, so nothing is downloaded again.

Background chapters answers still refuse a reorder, as on main. Until its next online start, the copy plays in its download order. That covers offline starts, Android's no-JS car start and adoptLoaded after a JS restart. A start with no chapters builds its queue from the download's own chapters and files.

Tests cover each path. They also cover an overtaken start, a size change and a different file set, and an Android adoptLoaded after a restart. The guard tests fail without their guards. The gate is green: tsc, lint, format and test (5419). /simplify and /code-review max --fix ran, then a fix-round /code-review high --fix.

Needs a device run: an online start of a re-ordered download, a JS restart mid-play on Android, an Android Auto start, offline playback afterwards, and a relaunch while casting.

Follow-ups, filed separately: an Android JS restart during the load window itself, and chapters with no file list.

Pairs with KodeStar/audiosilo-docs#163.

…rder

Server v2.4.0 plays a book's files in natural order, so a downloaded book
can come back with the same files in another order. refreshedChapters
refused that, leaving the offline copy on the old whole-book timeline
while the server and an online start used the new one. The same file set
in a new order now adopts the server's chapters and order (no download),
held while the player has the book loaded in the old order and taken from
the cached answer once the loaded book changes.
- A new file order moves only the chapters: manifest.files stays in the
  order the download wrote it, since a file's index there is its name on
  disk (relocateEntry at every launch, runOne's retry). Reordering it
  swapped audio between files after a relaunch, or dropped the book and
  deleted its folder when the extensions differed. refreshedFor now gets
  the new order from chaptersRefresh instead of the files array identity.
- The loaded-order probe also covers a playBook in flight (its queue is
  built before the place lookup, nowPlaying only after), so a new order
  landing in that window waits; the start takes a held one as it ends.
- The car sync rebuilds the snapshot when a downloaded book's chapters
  change, so Android's no-JS play spec follows a new order.
- Cleanups: one take step for startChapterRefresh and adoptCachedChapters,
  withCachedChapters takes a BookRef, selectBookKey in the subscription,
  shared cacheHolds and the real chapters key in tests; docs and comments
  (types.ts, book-queue.ts, CONVENTIONS) say what the code does now.
The hold could see only what JS loaded, so after an Android JS restart
(or a relaunch mid-Cast) a chapters answer landing before adoptLoaded
could move the order the engine's track index is mapped through. A
background answer now never changes a download's file order; playBook
hands the chapters it loaded the engine with to adoptStartedChapters once
the load landed and the start still owns the engine, saved at once. Same
order chapter refreshes are unchanged. Removes the loaded-order probe,
startingOrders and the take-on-unload path.
@KodeStar
KodeStar merged commit 43b9afd into main Oct 23, 2026
1 check passed
@KodeStar
KodeStar deleted the fix/v2.4.0-offline-reorder branch October 23, 2026 19:40
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