Подкасты в TUI на контракте FRID: подписки, воспроизведение, прогресс, синхронизация устройств v4 (MR-T2) #3

Merged
ab merged 30 commits from sanapach/furumi-tui:podcasts/tui into federation 2026-11-20 14:11:09 +00:00
30 Commits
Author SHA1 Message Date
sanapachandClaude Opus 5.5 ea7cdc4b7f Point frid deps at the fork branch
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-20 15:12:14 +02:00
sanapachandClaude Opus 5.5 c7e6a3672d Test that an older Jam guest cannot drop the host's episodes
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-20 01:51:02 +02:00
sanapachandClaude Opus 5.5 e0624ab7f4 Document what an older device's takeover does to a podcast queue
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-19 22:15:09 +02:00
sanapachandClaude Opus 5.5 2806e679ac Leave out placeholders an older device echoes back as music
A device below sync v4 mirrors the redacted queue it gets with its own
types, which drop PlaybackTrack::source, so each "Private item" becomes
a bare music item. When it takes playback over (Play on it, a
paused-startup claim, automatic failover) or sends a command, it
announces those items, and this device adopted unplayable fake tracks
and passed them on to every v4 peer. States from such devices are now
cleaned on receipt, with a status message once per change.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-19 22:15:09 +02:00
sanapachandClaude Opus 5.5 d03a3300f1 Resume dropping prototype feed validators after an interrupted start
The prototype import commits inside PodcastStore::open and the imported
validators were dropped afterwards, once. A start that stopped in
between left them for good. A marker next to the store, written before
the import and removed once every podcast was handled, makes the step
run again at the next start. The imported failure count is recorded
again as it was, so the back-off is kept.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-19 22:12:24 +02:00
sanapachandClaude Opus 5.5 42ecc310fc End a sizeless episode stream where it ends when only the feed knew its length
A stream without a file size whose decoder cannot measure its duration
only has the feed's itunes:duration, which is often longer than the
audio. Treat that duration as a hint: a clean close past 80 % of it is
the end. A duration the decoder measured keeps the strict completion
window. The interrupted message for a stream that cannot seek now says
to start over or mark the episode played instead of "press play".

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-19 22:11:33 +02:00
sanapachandClaude Opus 5.5 96e615bf1d Refuse an episode seek without leaving the effect early
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-19 21:56:12 +02:00
sanapachandClaude Opus 5.5 34c096a36b Bound a whole feed fetch and test the fetch limits
A slow server could hold one of the four refresh slots for 60 s per
redirect hop. A feed or cover fetch now has an overall deadline (120 s).
Tests cover feeds over the size cap with and without Content-Length
(error recorded with back-off, catalog kept), the redirect cap, a
redirect loop, a non-http redirect, a hanging server, and covers (not an
image, over the cap, written atomically). The test server can stall.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-19 21:53:44 +02:00
sanapachandClaude Opus 5.5 268ea915da Keep podcast store work in sync handlers off Tokio workers
The device-sync stream handlers exported and merged podcast snapshot
sections and operations synchronously on a Tokio worker. While a large
feed refresh held the store (up to about half a second), the worker's
other tasks (feed checks, streams, art) waited. Run that work in
block_in_place on the multi-thread runtime, and say so in ARCHITECTURE.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-19 21:52:05 +02:00
sanapachandClaude Opus 5.5 e0da2ddf2b Move a feed to its permanent address behind a temporary redirect
A 301 to a new host followed by a 302 (CDN, tracker) never moved the
feed, because only all-permanent chains counted; every check then went
through the old address without validators and re-applied the whole
feed. The target of the leading permanent hops is now recorded as the
new fetch URL (the old one becomes an alias); the document is still
parsed against the URL that served it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-19 21:50:44 +02:00
sanapachandClaude Opus 5.5 fe373e4169 Parse imported prototype feeds on their first check
The prototype import keeps the prototype's ETag and Last-Modified, but
the prototype stored no seasons, episode numbers or types, and GUID-less
episodes stay provisional until the feed is parsed again. The first check
was answered 304 and a feed that no longer changes was never parsed.
Drop the imported validators right after the migration so the first
check downloads and applies the feed. Contract gap for the FRID import.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-19 21:49:16 +02:00
sanapachandClaude Opus 5.5 42f22f0fea Document lost connections, cancellation and seeks of episodes
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-19 21:47:41 +02:00
sanapachandClaude Opus 5.5 2989747162 Stop broken episode streams instead of completing them
- The stream reader records whether the decoder stopped on a read error
  and whether the server announced the file size. An episode whose
  connection was lost (stall, expired URL) or whose sizeless stream
  closed early is no longer completed at its full duration: the last
  position is saved, playback stops on the episode and the queue does
  not move on (playback::played_to_the_end).
- Streams are cancelled by the player's source generation: a superseded
  start stops connecting or reading up to its resume offset, and a read
  blocked inside the audio callback returns within 100 ms instead of up
  to 30 s. The player no longer reports the end of a superseded source.
- A pause or resume pressed while an episode connects is applied when
  its source arrives (Controller::expect_source).
- Seeks report their result (PlayerEvent::Seeked); an episode's seek is
  saved only when the audio moved, and seeks while connecting or in a
  stream without Range support are refused with a message.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-19 21:47:41 +02:00
sanapachandClaude Opus 5.5 8d87fe3959 Keep older devices hearing from a podcast queue owner
A device below sync v4 got no playback snapshot while the queue held an
episode, so its engine never heard the owner's heartbeat and took
playback over by automatic failover after two minutes; this device then
adopted its queue and the episodes were gone. Send such peers the
coordination envelope with the queue redacted like for Jam: every
episode becomes an opaque "Private item", nothing is stripped, and their
commands stay refused while the queue has episodes.

This departs from FRID PLAYBACK_PROTOCOL.md rule 1 ("send None") and is
reported as a contract gap.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-19 21:40:07 +02:00
sanapachandClaude Opus 5.5 70df945ada Keep podcast URLs out of the personal-sync debug log
Podcast operations and playback commands with episodes carry feed and
audio URLs that may hold private tokens; the Logs tab shows this crate's
debug output. Log only their kind.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-19 21:39:19 +02:00
sanapachandClaude Opus 5.5 a79f0a0e95 Save a seek from a controlling device as an explicit episode action
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-19 21:03:55 +02:00
sanapachandClaude Opus 5.5 c6d7848ba4 Document podcast sync between devices and release 0.4.0
README explains that podcast state is private by default, syncs only
between trusted devices and streams audio from the publisher, plus
handoff, Jam and older devices. ARCHITECTURE, AGENTS and the changelog
describe protocol v4, version gating, the podcast store bridge and the
invariants (no numeric ids for episodes, versions only from the device
itself).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-19 21:02:45 +02:00
sanapachandClaude Opus 5.5 a92e12f322 Hand off podcast queues to v4 devices and keep episodes private in Jam
Queue items now cross the wire with their explicit source: episodes as
PlaybackSource::PodcastEpisode, received ones as TrackItem episodes, and
the source mode filter never drops them. A handoff carries the episode,
position and pause; an episode that becomes current at position 0
resumes from its saved position. A podcast queue is not handed to a
device below v4 (it needs an update), and playback commands from such a
device are ignored while the queue has episodes. Controlling a v4 device
may queue episodes.

Jam hosts publish redacted snapshots, so guests see numbered private
placeholders. Guest commands that add episodes are dropped; their
placeholders are mapped back to the host's episodes, and changes that
drop or duplicate them, or seek in them, are refused. A guest leaving a
Jam drops the placeholders.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-19 21:00:39 +02:00
sanapachandClaude Opus 5.5 79372e00fc Sync podcast state with devices on protocol v4
This client now announces device-sync protocol 4. Podcast operations
are applied to the podcast store, kept in the log and relayed; those
that arrive before the store opens wait in sync_podcast_pending.
Snapshots carry the podcast sections, bounded by the shared limits and
by the line budget of each message, and are merged after the operations.
Operations, snapshot sections and playback state that need v4 are only
sent to peers that reported v4. Periodic progress checkpoints are
coalesced in the log, and the Podcasts tab reloads after changes from
other devices.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-19 20:54:16 +02:00
sanapachandClaude Opus 5.5 4c3edbcd12 Store peer protocol versions as the peers report them
A device_profile_set and the pending pairing row used to store this
build's own protocol constant for another device, which would defeat
version gating. Self-reports (hello, pairing, the sender's own entry of a
devices list, its own profile announcement) now replace the stored
version and relayed profiles only raise it. Invites and profile
announcements carry the version, and the first start of a new version
announces it in the log.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-19 20:44:14 +02:00
sanapachandClaude Opus 5.5 e7713269f2 Use the shared device-sync wire types
The private copies of the device-sync wire types are replaced by
music_dht::device_sync. Golden tests keep the furumi-tui 0.3.x types
verbatim and check that v3 messages serialize byte for byte the same.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-19 20:41:11 +02:00
sanapachandClaude Opus 5.5 253583b139 Complete episodes after a seek into their last seconds
The progress tracker's observation step is now a pure method with tests
for listening time (jumps and pauses do not count), pause saves, the
checkpoint interval and one-time completion. A seek no longer marks the
playback completed by itself, so seeking into the last seconds still
sends complete_session on the next tick. The episode list render test
covers the live position of the playing episode.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-19 20:30:11 +02:00
sanapachandClaude Opus 5.5 54db2978e0 Document episode playback, queue identity and progress saving
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-19 20:28:36 +02:00
sanapachandClaude Opus 5.5 9321e82335 Play podcast episodes from the queue and save their progress
Episodes stream from the publisher through the prototype's bounded HTTP
Range reader (ported, URL queries redacted from errors). The audio URL and
resume position come from the store at play time; a 4xx on the audio URL
refreshes the feed once and retries with the address it now lists, and a
stream that cannot seek refuses to start at a saved position instead of
playing from the wrong place. Prepared sources reach the audio thread
with the player's source generation, so a slow stream never replaces a
newer start or stop, and with their start offset for position reporting.

Progress follows the FRID contract through one ordered writer thread:
start_session or restart on start, checkpoints every 20 s and on pause,
explicit seeks, complete_session near the end or at end of stream, and a
final save with the last seen position on stop, track change, handoff
and exit. A superseded session stops checkpointing until the next
explicit action; listening sessions are recorded at pause, completion
and end. Enter on an episode plays it after the current item, b starts
it over, a/A queue it, and mark played goes through the same writer.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-19 20:28:36 +02:00
sanapachandClaude Opus 5.5 3567f5f395 Key queue items by source and keep episodes out of music-only paths
Podcast episodes share the sentinel id -1, so the queue key now checks
the episode id first (ep:...) and falls back to TrackItem::key instead of
local:{id}. Likes, playlists, metadata edits, music history, content-id
lookups, share links, similarity and artist/release jumps skip episodes;
Shift-J and the info popup open the podcast instead. Sync protocol 3
cannot carry episodes, so peers and Jam guests get the private-item
placeholder, handoff of a queue with episodes is refused and remote
SetState commands do not replace such a queue.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-19 20:12:01 +02:00
sanapachandClaude Opus 5.5 7583afaeba Box large AppEvent payloads after TrackItem grew
furumi-library 0.3.0 adds TrackItem.podcast, which makes TrackItem a few
hundred bytes larger. Box the track-info result and the federation status
in AppEvent so the event enum stays small (and clippy's
large_enum_variant does not fire on it).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-19 20:00:36 +02:00
sanapachandClaude Opus 5.5 043caf1aaf Document podcast subscriptions and their runtime boundaries
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-19 19:58:37 +02:00
sanapachandClaude Opus 5.5 99c4d05dec Replace the Podcasts placeholder with subscriptions, seasons and episodes
The tab opens the FRID podcast store (podcasts.sqlite3, migrating a
prototype database in place; newer or foreign files are reported and left
unchanged) off the UI thread and shows subscriptions with unplayed counts
and check status, podcast -> seasons -> episodes navigation, and episodes
with saved position, played state, duration and date. Episode search,
played filter and order run as paged store queries with request sequence
numbers. Adding a feed, checking one or all feeds, marking played and
unsubscribing (with a confirmation that progress is kept) go through
Effect/AppEvent; a scheduler refreshes due feeds in the background.

New actions are bound in the podcasts keymap context and listed in a
Podcasts help section.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-19 19:58:37 +02:00
sanapachandClaude Opus 5.5 07dcd0587c Fetch podcast feeds and stamp store actions from the sync log
Add src/podcasts: an HTTP client with conditional requests, hand-followed
redirects (permanent ones become feed aliases via PodcastStore::apply_feed),
size and time limits and a furumi user agent; subscribe and refresh flows
that parse feeds with the shared music-dht parser and keep the store's
local fetch state with exponential back-off and Retry-After.

DeviceSync::run_podcast_action hands PodcastStore actions stamps reserved
in the device-sync log and appends the operations they return with exactly
those stamps. Podcast operations stay out of outgoing sync batches until
this client speaks sync protocol v4.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-19 19:54:48 +02:00
sanapachandClaude Opus 5.5 bc04587252 Bump music-dht to 0.6.0 and furumi-library to 0.3.0
TrackItem gained a podcast field; music literals set it to None. The
music-dht podcast-feed feature provides the shared RSS/Atom parser.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-19 19:37:28 +02:00