You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
feat(downloads): download audiobooks and play them offline - #1192
Other clients: Android Silo-Server/silo-android#957; Roku N/A (downloads and offline playback are deferred in docs/spec.md); Web N/A (the web client has no offline downloads)
The Apple apps can't download audiobooks. Android can, so iPhone, iPad and Mac listeners lose their books the moment they go offline. This adds audiobook downloads and offline playback, and sends listening done offline back to the server, which Android doesn't do yet.
Approach
Detail page (iPhone, iPad, Mac): Download sits in the action row for a book stored as one file, always as the original file. The server keeps one download per book on a device (downloads_device_entry_uidx is keyed on content), so a book split into several files can't be saved whole and isn't offered. Android saves one part of such a book; that can be one chapter of a long book, so this leaves them out until the server supports whole-book downloads. Speed leaves the action row so the row fits on one line; it stays in the player.
Downloads tab: books list as their own rows with a square cover and the author, and the storage bar gets an Audiobooks bucket. The offline page plays a book in the audio player. A manifest's series id no longer groups a book under a TV series.
Player: a downloaded part loads from disk with no server playback session, and streams instead if the file won't open. When the server can't be reached, the book opens from its download and stored manifest.
Progress: while the server can't be reached, whole-book positions go into the existing offline queue with the time they were sampled (the server merges queued items newest-first). The queue is sent when the server becomes reachable, not only on foreground. At start, unsent local listening is sent first (waiting up to 3 seconds for the server's answer) and the server's reconciled resume point is used; only when the server didn't apply it (refused, deferred, or not answered in time) does the local position win. Starting a download seeds the offline resume point from the server's. Online playback of a downloaded book still uploads directly and keeps the local resume point current.
Validation
Unit tests (SiloTests, iOS 27.2 simulator): download grouping, audiobook progress, offline playback mapping, download pipeline and watch-state suites, 84 tests, 0 failures. Three new tests cover book classification and the offline book timeline.
Builds: iOS, macOS and tvOS compile.
Simulator end to end against a real server: download, local playback while online with no playback session started, offline playback with the server unreachable, offline seek and pause, and the queued position reaching the server when it came back (server row matched the paused position).
Installed and launched on a physical iPhone.
Not run: progress routing has no unit test (it would need a test-only seam in the player or download store); the simulator run covers it. Not re-run on the simulator after the last review fixes and the Speed removal.
Surface and build: iPhone simulator (iOS 27.2), Debug build of this branch. Before captures weren't possible: a main build couldn't sign in to the test server after it started answering 410 on /api/v1/auth/setup (see Risks). Before this change the audiobook action row had no Download and Downloads listed no audiobooks. iPad, Mac and iPhone Duo use the same views and weren't captured; Apple TV has no downloads.
Risks
Downloaded playback skips the server playback session, so admin activity doesn't show offline or local listening; whole-book progress still syncs.
Books split into several files have no Download until the server can hold a whole book per device.
Unrelated, found while testing: servers on current main answer 410 on GET /api/v1/auth/setup (feat(api)!: retire /api/v1 behind a 410 tombstone silo-server#3200 retired /api/v1), and this app's server check still calls it, so signing in to such a server fails. Needs its own fix.
Checklist
I read and can explain the complete diff.
This pull request addresses one concern.
The Evidence section shows every change a user can see, or how I checked a change nobody sees.
AI Disclosure
Harness: Claude Code
Tool(s): Claude Code (T3 Code); a second Claude Code run as advisor; XcodeBuild via MacDev's build service
Model(s): claude-opus-5-5 (implementation); claude-fable-5-2 (design and code review)
Involvement: Fully AI-generated, human verified
Adversarial review: claude-fable-5-2 reviewed the design, the diff, and the fixes, read-only. It cut multi-part support and author grouping, and found progress bugs: Resume used the detail page's stale position, unsent and in-flight queue entries were ignored at start, a late failed upload could re-queue an old position, and sessions opened offline never uploaded once back online. All were fixed; a re-check found three smaller issues, also fixed. Skipped: flushing right after a failed final save (an unanswered flush holds the entry for good).
Add offline audiobook download and playback support in iOS app
Adds a single-file audiobook download path in DownloadManager.downloadAudiobook that seeds a local resume point from the server position. Audiobook records get their own list items, storage category, and square cover rows.
AudioPlayerViewModel can now build a playback context from the offline manifest, play downloaded files without a server session, and fall back to the download when the online request fails. Progress is uploaded when online, recorded locally for downloaded books, or queued offline when the server is unreachable.
Audiobook downloads only appear for books with exactly one audio part; the detail page's speed menu is replaced by this download control.
mergeProgress preserves a local seed written during an in-flight server read; online context loading reconciles unsent local progress with the server before choosing a resume position.
Behavioral Change: AudioPlaybackTrack.version is now optional (nil for downloaded files), audiobook records are excluded from movie records and series groups, and the detail Resume action no longer forwards a position to startPlayback.
A book stored as one file gets Download on its detail page (iPhone, iPad,
Mac). The downloaded file plays from the device online and offline, and
listening done offline reaches the server once it is reachable again.
- Detail page: Download in the action row for single-file books, always
the original file. The server keeps one download per book per device, so
books split into several files aren't offered. Speed moves out of the
row; it stays in the player.
- Downloads: books list as their own rows with an Audiobooks storage
bucket; the offline page plays them in the audio player.
- Player: a downloaded part loads from disk with no server session and
streams instead if the file won't open. With the server unreachable the
book opens from its download.
- Progress: offline positions are queued with their sample time and sent
when the server is reachable again; unsent local listening wins over the
server's older resume point at start.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).
Limit details: You’ve used the included review currently available. Your 98 included PR review attempts over the past 7 days set your current allowance at 1 review per hour.
The iOS app adds audiobook downloads, includes downloaded audiobooks in the library, and supports offline playback from local files. It also records audiobook progress locally and synchronizes it with the server.
Download records identify audiobooks. Detail pages offer downloads for single-file books, and the download manager creates audiobook records with author and resume metadata.
Offline audiobook details start playback through the audio player. The player builds context from a download manifest and can load the local audio file without creating a server playback session.
Offline progress recording and synchronization iosApp/iosApp/Downloads/DownloadManager.swift, iosApp/iosApp/Screens/Audio/AudioPlayerViewModel.swift
Progress updates include owner and sample-time checks. The player records local progress and queues or synchronizes updates based on network availability and upload results.
sequenceDiagram
participant OfflineBrowse
participant AudioPlaybackStore
participant AudioPlayerViewModel
participant DownloadManager
participant AudioEngine
OfflineBrowse->>AudioPlaybackStore: Start audiobook with content ID and preview
AudioPlaybackStore->>AudioPlayerViewModel: Start playback
AudioPlayerViewModel->>DownloadManager: Find playable download and read manifest
DownloadManager-->>AudioPlayerViewModel: Provide download record and manifest
AudioPlayerViewModel->>AudioEngine: Load downloaded audio file
Loading
Possibly related issues
Silo-Server/silo-apple issue 339: The issue covers audiobook progress, resume, chapters, and playback speed. This change adds progress reconciliation, offline playback context with chapter ordering, and replaces the detail-page speed menu with download controls.
Silo-Server/silo-apple issue 319: The issue covers downloads and offline use. This change adds audiobook downloads and playback from downloaded files.
Suggested reviewers:rhainland, zzebrahz
Merge Risk: Moderate · previous review 49991
Downloaded audiobooks can occasionally resume from a stale position, or a periodic progress save can attach the wrong book's position when the user switches books quickly. These issues are bounded but should be fixed before merge.
Security architecture risk: Moderate · up to 49991
A playback start racing a profile, account, or server switch may open a book cached for the previous identity. Download creation and queued progress have ownership checks, but the new local audio opening path does not enforce the same boundary. Whether navigation always prevents this race remains unresolved.
Retained concerns
Medium · security · inferred: The new offline audiobook opener is not bound to the download scope. During a profile, account, or server switch, the previous store can remain installed while loadedScope is nil. playableDownload still returns its records, and localFileURL opens files from that installed store without validating a playback owner. The detail-error fallback also accepts authorization-related failures unless they are cancellations. A start that reaches this window may therefore play the previous identity’s downloaded book instead of respecting the new identity’s access decision. The previous audio path required online detail and server playback negotiation; local opening is new. End-to-end navigation gating remains unresolved, so the exposure is inferred rather than reproduced.
Security review details
Security Blast Radius
inferred — The retained concern is limited to previously downloaded audiobook content on a shared installation during an identity transition. It does not establish arbitrary filesystem access, remote code execution, or increased server privileges.
Security Findings and Attack Paths
inferred — A possible path is an audiobook start during replacement of the download scope: the prior scope’s record remains selectable, an online detail failure takes the local fallback, and the file opens without a current playback-owner check. Confirming that starts cannot reach this interval would materially change the assessment.
Trust Boundaries and Controls
observed — Progress-owner checks reject local and queued writes after their download scope changes. The progress transport also validates captured profile identity and applies an owner fence. These controls protect progress dispatch but do not validate the new local media opening path.
Resilience and Maintainability Implications
observed — The reused queue durably claims batches before sending. Definitely unsent or deferred batches return to pending; uncertain dispatches remain held rather than automatically replayed. Replacement events retain separate identities, and stale-scope responses cannot resolve a newer scope’s queue.
Pre-merge checks: 4
Check name
Status
Explanation
Title check
The title "feat(downloads): download audiobooks and play them offline" matches the main change. The changeset adds audiobook downloads, offline progress queuing, and offline playback from local manife…
Linked Issues check
Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check
Check skipped because no linked issues were found for this pull request.
Description check
The description is clearly related to the changeset. It explains that the Apple apps gain audiobook downloads and offline playback, and it describes the detail page, Downloads tab, player, and progres…
Full details: Title check
Explanation
The title "feat(downloads): download audiobooks and play them offline" matches the main change. The changeset adds audiobook downloads, offline progress queuing, and offline playback from local manifests in the Apple apps.
Full details: Description check
Explanation
The description is clearly related to the changeset. It explains that the Apple apps gain audiobook downloads and offline playback, and it describes the detail page, Downloads tab, player, and progress queueing changes. It also lists validation steps and known risks. The description is not off-topic and is specific enough to pass this lenient check.
Finishing Touches
Generate unit tests (beta)
Commit to this branch
Create a new PR
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
- A start sends unsent offline listening first (up to 3 s) and then reads
the server's reconciled resume point; only when the send doesn't land
does the local position win.
- The shared progress flush belongs to the scope it started in, so a
flush after a profile or server switch drains that scope's queue.
- Downloading a book seeds its offline resume point from the server's.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Evidence is incomplete. The private evidence link and PR description identify an iPhone simulator build, but the changed views are shared by iOS and macOS targets (#if !os(tvOS)). They reach iPhone, iPhone Duo folded and open, iPad, and Mac; Apple TV is correctly excluded.
Audiobook detail action row (AudiobookDetailContent.swift, DownloadActionButton.swift): the new Download control and removed speed action need captures on iPhone Duo folded and open, iPad, and Mac. The PR explains why before captures were unavailable; that limitation is noted.
Downloads list and storage UI (DownloadGrouping.swift, DownloadManager.swift, DownloadsView.swift, DownloadManagerRows.swift, DownloadsManagerComponents.swift): audiobook rows, cover/subtitle presentation, and the Audiobooks storage category need captures on iPhone Duo folded and open, iPad, and Mac.
Offline book detail and playback (OfflineBrowse.swift, AudioPlayerViewModel.swift, AudiobookPlaybackContext.swift): the offline detail and downloaded-book playback/resume flow need evidence on iPhone Duo folded and open, iPad, and Mac, including a recording of the multi-step download-to-offline-playback flow.
Automated check: Macroscope check run agent (gpt-6-luna). Evidence was not reviewed for correctness.
Visible UI and playback changes are not fully evidenced across the affected devices.
AudiobookDetailContent.swift, DownloadsView.swift, DownloadManagerRows.swift, DownloadsManagerComponents.swift, and OfflineBrowse.swift: the Evidence section identifies an iPhone simulator capture, but says iPhone Duo (folded and open), iPad, and Mac were not captured. The shared views use different width- and platform-specific layouts, so the linked page should show the new detail action row and audiobook/download screens on those devices. The reason the before-capture was unavailable is documented; it remains unavailable rather than passing.
AudioPlayerViewModel.swift: offline audiobook playback and progress sync are a multi-step, user-noticeable flow. The linked page should show a recording of download, offline playback/resume, and reconnect progress sync on iPhone, iPhone Duo (folded and open), iPad, and Mac. Apple TV need not be included because the app has no audiobook download path there.
Suggested fix: No diff — add the missing device captures and flow recording to the linked evidence page.
Automated check: Macroscope check run agent (gpt-6-luna). Evidence was not reviewed for correctness.
…ress
The start-time send now reports whether the server applied the book's
queued position, instead of inferring it from an empty queue:
- a rejected, refused or deferred send leaves the local position winning,
and the start stops waiting as soon as the flush ends;
- a send that lands after the 3 s wait, while the detail is on its way,
reads the detail again so newer progress from elsewhere wins.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
On the evidence comments: the published page covers the iPhone flow end to end against a real server (download, playback from the device while online, offline playback, and the offline position reaching the server on reconnect, checked against the server's progress row). The detail page, Downloads list and offline page are the same SwiftUI views on iPad, iPhone Duo and Mac (#if !os(tvOS), no size-class branches added). Those devices weren't captured because the test server started answering 410 on GET /api/v1/auth/setup partway through (Silo-Server/silo-server#3200), and the app's sign-in still calls it, so no fresh build could sign in. The PR body's Evidence and Risks sections say so. Apple TV has no downloads.
The latest progress-reconciliation change in AudioPlayerViewModel.swift can change where and when downloaded audiobook playback resumes after reconnect. The Evidence section describes an iPhone simulator test, but no recording of this updated multi-step flow; add one showing offline playback, reconnect, and the resulting resume position on iPhone, iPhone Duo folded and open, iPad, and Mac. The section says the Duo, iPad, and Mac were not captured.
Suggested fix: No diff — add the recording to the linked evidence page.
Automated check: Macroscope check run agent (gpt-6-luna). Evidence was not reviewed for correctness.
…lts by scope
- The player captures the download scope at every start and decides at
each save whether the book is downloaded, so a download that finishes
while listening keeps the offline resume point current from then on.
- syncUnsentProgress reports nothing applied when the scope changed while
it waited, so another profile's answer can't stand in for this one.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Exercise grouping with a retained audiobook series ID.
The factory initializes book.seriesId to nil, and the preceding assertions confirm that it stays nil. Thus, this grouping assertion still passes if the audiobook exclusion is removed from seriesGroups.
Keep the manifest assertions. Add a separate grouping case that explicitly sets an audiobook's seriesId before grouping. This protects the new filter independently of manifest hydration.
As per coding guidelines, “Add focused regression tests when they meaningfully protect changed behavior.”
Source: Coding guidelines
Review info
Run configuration
Source mode: Auto
Repository: Unavailable
Branch: Unavailable
File: No configuration file from this repository applied
Commit: Unavailable
Layers: Organization UI
Review profile: CHILL
Plan: Advanced
Run ID: 0793dfdb-e2f1-4996-b01b-45c4dab72294
Commits
Reviewing files that changed from the base of the PR and between 484d823 and 4999189.
Included review availability: This review used your included allowance. 0 included reviews remain after this review. Your included PR review attempts over the past 7 days set your current allowance at 1 review per hour.
…ore the store loads
A book started while the download store was still loading had no scope
owner for the whole session. The player now takes the scope at the first
save after the store has loaded; a profile or server switch closes the
player, so it is still the scope playback started in.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
…iting
- syncNow captures the book, position, duration, sample time, download
scope and request identity before the session-progress request, and the
whole-book upload uses that identity (syncProgress(_:auth:)), so a newer
start or a profile switch can't mix into the sample.
- syncUnsentProgress reports a book applied only when no newer position
for it is still unsent.
- A download's seeded resume point is dated as old as possible, so the
next progress read replaces it with the server's.
- The grouping test gives the book a series id, so it fails without the
audiobook exclusion.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
…date seeds at detail load
- The audio player captures the request identity when a book starts and
uploads whole-book progress only under it. An explicit profile switch
doesn't close the player, so a book left playing is now refused instead
of writing into the newly selected profile.
- A download's seeded resume point is dated when the detail reporting it
arrived: a newer save elsewhere still replaces it, and an older progress
read that was already in flight doesn't.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
silo-triageBot
added
size/XXL
1000–2999 added + deleted lines (all files); change volume, not priority.
and removed
size/XL
500–999 added + deleted lines (all files); change volume, not priority.
labels
Nov 16, 2026
A downloaded book's seeded resume point no longer carries a client-made
date. It is dated distantPast and marked with the device time it was
written (LocalProgressEntry.seededAt): a progress read already in flight
leaves it, and the next read that starts after it replaces it with the
server's row. No device time is compared with a server time, and a cached
or delayed detail can't make a stale position look fresh.
The audio player takes a late download scope only for the profile it
started under, since an explicit profile switch keeps the player going.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
enhancementNew feature or requestpriority: P2Limited scope, workaround exists, or polishsize/XXL1000–2999 added + deleted lines (all files); change volume, not priority.
1 participant
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Related issue: N/A
Validation tasks: changes #339 C4, C9, C10; changes #319 C1
Other clients: Android Silo-Server/silo-android#957; Roku N/A (downloads and offline playback are deferred in
docs/spec.md); Web N/A (the web client has no offline downloads)The Apple apps can't download audiobooks. Android can, so iPhone, iPad and Mac listeners lose their books the moment they go offline. This adds audiobook downloads and offline playback, and sends listening done offline back to the server, which Android doesn't do yet.
Approach
downloads_device_entry_uidxis keyed on content), so a book split into several files can't be saved whole and isn't offered. Android saves one part of such a book; that can be one chapter of a long book, so this leaves them out until the server supports whole-book downloads. Speed leaves the action row so the row fits on one line; it stays in the player.Validation
SiloTests, iOS 27.2 simulator): download grouping, audiobook progress, offline playback mapping, download pipeline and watch-state suites, 84 tests, 0 failures. Three new tests cover book classification and the offline book timeline.Evidence
Evidence: https://evidence.siloserver.org/r/silo-apple/audiobook-offline-downloads/
Surface and build: iPhone simulator (iOS 27.2), Debug build of this branch. Before captures weren't possible: a
mainbuild couldn't sign in to the test server after it started answering 410 on/api/v1/auth/setup(see Risks). Before this change the audiobook action row had no Download and Downloads listed no audiobooks. iPad, Mac and iPhone Duo use the same views and weren't captured; Apple TV has no downloads.Risks
mainanswer 410 onGET /api/v1/auth/setup(feat(api)!: retire /api/v1 behind a 410 tombstone silo-server#3200 retired/api/v1), and this app's server check still calls it, so signing in to such a server fails. Needs its own fix.Checklist
AI Disclosure
🤖 Generated with Claude Code
Note
Add offline audiobook download and playback support in iOS app
DownloadManager.downloadAudiobookthat seeds a local resume point from the server position. Audiobook records get their own list items, storage category, and square cover rows.AudioPlayerViewModelcan now build a playback context from the offline manifest, play downloaded files without a server session, and fall back to the download when the online request fails. Progress is uploaded when online, recorded locally for downloaded books, or queued offline when the server is unreachable.mergeProgresspreserves a local seed written during an in-flight server read; online context loading reconciles unsent local progress with the server before choosing a resume position.AudioPlaybackTrack.versionis now optional (nil for downloaded files), audiobook records are excluded from movie records and series groups, and the detail Resume action no longer forwards a position tostartPlayback.Macroscope summarized 4acc583.