Skip to content

Add manual watched and unwatched toggles for movies, episodes, series, and seasons - #39

Merged
vitobotta merged 17 commits into
vitobotta:mainfrom
phantomic12:watched-unplayed
Nov 15, 2026
Merged

vitobotta merged 17 commits into
vitobotta:mainfrom
phantomic12:watched-unplayed

Conversation

@phantomic12

@phantomic12 phantomic12 commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Implements backlog item 9, Mark played / unplayed, as its own PR on top of current main.

Movies and episodes can be marked watched from their detail surfaces, library
movie cards, and watch-history rows. Series and individual seasons have
dedicated actions that apply the same released-episode rules. State is stored
on playback_progresses (completed), so it works even when catalogue metadata
has no runtime.

Behaviour

  • Movies and episodes: mark watched creates or updates one progress row and shows 100%; mark unwatched removes that exact row.
  • Series: the series is watched only when every released episode is watched. Marking it watched completes each released episode from catalogue metadata, skipping specials (season 0) and episodes that have not aired. Marking it unwatched removes all episode progress for the series.
  • Seasons: marking the selected season watched completes only that season's released episodes, using the same specials/unreleased rules. Marking it unwatched removes only that season's episode progress. The action is shown beside the season heading and hidden when the selected season has no released episodes.
  • Season tabs: completed seasons carry a check mark and an accessible "Season N, watched" label. Partially watched seasons show a compact watched/total count, such as 2/8, with an accessible "2 of 8 episodes watched" label. Zero-progress seasons stay unmarked. Tabs, season action, and series action all read from one per-season progress map.
  • Series header: a compact progress bar and "N of M episodes watched" summarise every released episode in the series, excluding specials and unaired episodes.
  • Library cards: series cards read a persisted released-episode total from the collection entry and combine it with local progress, so loading the library never calls the catalogue. The total refreshes when the series page loads.
  • Continue Watching excludes manually completed movies and advances past manually completed episodes. A completed show whose next episode has not aired is also dropped, so a fully watched series does not leave a false resume row.
  • Movies get toggles on their detail page, library cards, and history rows. Episodes get toggles in the episode drawer and history rows. Series and seasons get their actions on the series page.
  • Real playback progress clears the manual flag, so resuming a marked title returns to normal progress tracking.
  • Child accounts still cannot mark titles above their age cap.

Backlog

This is item 9 in the one-feature-per-PR Jellyfin backlog carried by PR #38.
docs/jellyfin-parity.md will need its row updated to done once #38 lands.

Migration

Adds playback_progresses.completed (boolean, default false, not null), plus collection_entries.series_total_episodes and series_total_episodes_synced_at.

A one-time backfill for existing entries is available with bin/rails series:backfill_totals. It targets library shows missing a total, leaves failures untouched for retry, and reports the affected IMDb IDs.

Testing

  • Ran RAILS_ENV=test bundle exec rspec with test encryption and catalogue API variables set on a fresh SQLite test database with the migration applied.
  • Focused coverage (progress model/service, watched toggle specs including series and seasons, watched-items, content, library, and history request specs): 85 examples, 0 failures.
  • Full suite: 535 examples, 12 failures. All 12 are the existing Windows-only process tests in media_transcoder_spec.rb, hls_session_manager_spec.rb, hls_spec.rb, and production_process_spec.rb, failing on Process.spawn(pgroup:), /dev/null, and .sh entrypoints. No watched/content/library/history spec is among them.
  • RuboCop on all changed Ruby files: no offenses.

Store an explicit completion flag so a title can be marked watched even when
catalogue metadata has no runtime, and clear it again when real playback
progress resumes. Continue Watching excludes manually completed movies and
advances past manually completed episodes.

🤖 Generated with Codebuff
Co-Authored-By: Codebuff <noreply@codebuff.com>
phantomic12 and others added 2 commits October 30, 2026 19:34
Reuse the detail-page toggle on library movie cards and on every watch
history row, with the same completed state and unwatch behaviour. Series
cards stay without a single toggle because watched state is per episode.

🤖 Generated with Codebuff
Co-Authored-By: Codebuff <noreply@codebuff.com>
A series is watched only when every released episode is watched. Marking it
watched completes each released episode from catalogue metadata, skipping
specials and unaired episodes; marking it unwatched removes all episode
progress for that series. Continue Watching also drops a show whose next
episode has not aired.

🤖 Generated with Codebuff
Co-Authored-By: Codebuff <noreply@codebuff.com>
@phantomic12 phantomic12 changed the title Add manual watched and unwatched toggles for movies and episodes Add manual watched and unwatched toggles for movies, episodes, and series Oct 30, 2026
Apply the same released-episode rules as series: marking a season watched
completes only that season's aired episodes, while unwatching removes only
that season's progress. The season action appears beside the selected season
and hides when there are no released episodes to act on.

🤖 Generated with Codebuff
Co-Authored-By: Codebuff <noreply@codebuff.com>
@phantomic12 phantomic12 changed the title Add manual watched and unwatched toggles for movies, episodes, and series Add manual watched and unwatched toggles for movies, episodes, series, and seasons Oct 30, 2026
phantomic12 and others added 7 commits October 30, 2026 19:44
Derive one per-season watched map so the tabs, the season action, and the
series action share a single source of truth. Completed seasons get a check
icon and an accessible "watched" label, making progress scannable without
opening every season.

🤖 Generated with Codebuff
Co-Authored-By: Codebuff <noreply@codebuff.com>
Keep watched/total counts in the shared season progress map so partially
watched seasons show a compact count beside the tab label. Complete seasons
keep the check, and zero-progress seasons stay unmarked.

🤖 Generated with Codebuff
Co-Authored-By: Codebuff <noreply@codebuff.com>
Show a compact progress bar and released-episode count beside the series
metadata. The summary reads the same season progress map as the tabs, so
specials and unaired episodes stay excluded everywhere.

🤖 Generated with Codebuff
Co-Authored-By: Codebuff <noreply@codebuff.com>
Reuse the released-episode rules from the series page on library cards, with
a compact watched count and progress bar. Only shows with completed episodes
trigger a catalogue lookup, and metadata failures leave the card unchanged.

🤖 Generated with Codebuff
Co-Authored-By: Codebuff <noreply@codebuff.com>
Library cards read a stored released-episode total instead of calling the
catalogue on every page load. The series page refreshes the total whenever
it already has the metadata, so existing entries populate on their next
visit while the library stays database-only.

🤖 Generated with Codebuff
Co-Authored-By: Codebuff <noreply@codebuff.com>
Populate persisted released-episode totals for existing library shows that
predate the collection-entry columns. Failures leave entries untouched so a
later run can retry them, and the task reports the affected IMDb IDs.

🤖 Generated with Codebuff
Co-Authored-By: Codebuff <noreply@codebuff.com>
Upstream now resolves the continue target through PlaybackResumeService, while
this branch decides watched state per season, episode and series. The merge
keeps the resume target for the hero button and layers the watched/series
progress values it needs on the same progress rows, and keeps both the series
total backfill note and upstream's data-directory note in the README.

🤖 Generated with Codebuff
Co-Authored-By: Codebuff <noreply@codebuff.com>
@phantomic12

Copy link
Copy Markdown
Contributor Author

@vitobotta ready for a first review and mergeable against current main: manual watched and unwatched toggles for movies, episodes, series and seasons.

@vitobotta vitobotta left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

First review at 1ced8417, with main merged. The suite is green here: 537 examples, 0 failures, RuboCop clean on thirteen files, and the backfill task runs. No CI checks are reported on the head.

I exercised the paths the specs do not: the series and season actions against a real metadata shape, Continue Watching after a manual movie and episode, a child account marking a season, the library cards with and without a persisted total, and the pages at 1280 and phone width. Those all behave.

Two problems need a fix before merge: a failed metadata load zeroes a stored series total, and undated TBA episodes are counted and marked as released. Details on the lines below. The drawer toggle's history title is a smaller inconsistency.

The rest is in good shape: ownership scoping, the child policy check, the completion policy, the way real playback clears the manual flag, and the no-catalogue library render all behave.

Comment thread app/controllers/content_controller.rb Resolved
Comment thread app/services/playback/watched_toggle.rb Resolved
Comment thread app/views/content/show.html.erb Resolved
…ed episodes

A 500 from Cinemeta zeroed a library card's stored total, and a TBA episode with no air date was counted and marked watched by the season and series actions; the drawer now stores the same label as every other entry point.
@phantomic12

Copy link
Copy Markdown
Contributor Author

@vitobotta all three are fixed on the branch.

  • Failed catalogue zeroing the total: persist_series_total now runs only when the metadata call succeeded, so a 500 leaves the stored 62 and its sync time untouched. Pinned by an example that stubs the request with a 500 and asserts the value survives.
  • Undated TBA episodes: released? in both WatchedToggle and SeriesProgress now treats a blank or unparseable air date as not released, so released: null episodes drop out of the count, the season action and the series action together. Specs cover a TBA/released: nil episode being skipped and 0 of 1 episodes watched for a show with one aired and one TBA episode.
  • Drawer label: the drawer toggle now sends Breaking Bad S01E01, the same string as the player and the season/series actions, so one episode no longer appears in history under two different titles. Asserted on the rendered page.

One consequence worth naming: a show whose episodes all lack air dates now reports 0 of N rather than treating them as released — that is the fail-closed direction you asked for, but it is a visible change for any such catalogue payload.

watched_toggle_spec, content_spec, watched_items_spec and playback_progress_spec: 58/0, RuboCop clean on the five touched files.

@vitobotta vitobotta left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-reviewed at fa9e26e9. The three findings from the first pass are fixed:

  • Blank and unparseable release dates now read as not released in both SeriesProgress and WatchedToggle; the new examples cover the TBA episode and the count, and the series action skips it.
  • The drawer toggle now stores the same Show SxxExx label as the player and the series and season actions; the new content example asserts it.
  • A failed catalogue call no longer persists the 0 total; the new example keeps the stored 62.

One data-loss edge remains and is on the line below. meta_result.success? covers the failed call, but a successful response with an empty episode list still writes 0 over a stored total. I stubbed a 200 with videos: [] on an entry with 62 and the entry went to 0.

The PR is also CONFLICTING with main; merging origin/main conflicts in app/services/playback/continue_watching_query.rb, so a merge or rebase is needed before this can land.

Gates at the head: focused 31/0, full 540/0, JS 528/0, RuboCop clean on the five touched Ruby files.

Comment thread app/controllers/content_controller.rb Resolved
A 200 with no episodes left the stored series total at 0, the same data loss as a failed call, so the guard now requires episodes to be present.
# Conflicts:
#	app/services/playback/continue_watching_query.rb
Upstream renamed the successor lookup and made it return the labelled Next struct, so the rebased examples stub next_episode_after with that shape.
@phantomic12

phantomic12 commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor Author

@vitobotta the empty-success case is covered and the branch now merges main at 72df706.

  • Empty episode list: the guard is now meta_result.success? && @metadata&.dig(:episodes).present?, so a 200 with videos: [] leaves the stored total alone. New example stubs a successful response with no episodes on an entry holding 62 and asserts it stays 62.
  • Rebase: merged origin/main; the only conflict was app/services/playback/continue_watching_query.rb, where main renamed the successor lookup to next_episode_after and made it return the labelled Next struct. I kept main's richer call and my :series_complete/:not_released early return, and updated the two query doubles in playback_progress_spec to the new name and struct — with the old ContentRef payload the query returned a failure and the card vanished.

watched_toggle_spec, content_spec, watched_items_spec, playback_progress_spec, streaming_spec: 87/0. RuboCop clean on the touched Ruby files.

@vitobotta vitobotta left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The empty-success guard is fixed at 72df706. The controller now requires both a successful metadata call and a present episode list before persisting the total, and the new request example keeps an entry at 62 when a successful response returns no episodes.

The branch still conflicts with current main in db/schema.rb. Main bumps the schema version to 2026_10_30_130000 for the playlists migration, so rebase onto main and keep 2026_10_30_160000 while retaining the playlists tables that main adds.

Gates after a test merge with that resolution: 601 RSpec examples, 0 failures; 578 JavaScript tests, 0 failures; RuboCop 195 files, no offenses; Brakeman clean. The focused watched, content, history and progress specs are 87 examples, 0 failures.

No other findings.

Comment thread db/schema.rb Resolved
Keep this branch's 2026_10_30_160000 schema version and its completed and
series_total_episodes columns, while retaining the playlists tables main
adds. The merged schema was checked by migrating an empty database from
scratch and comparing the dump, which matches byte for byte.
@phantomic12

Copy link
Copy Markdown
Contributor Author

Merged today's main (d0f8cb9) into the branch at 7828189; the PR is now MERGEABLE/CLEAN, with lint, scan_js and scan_ruby passing.

Schema resolution — db/schema.rb keeps this branch's version 2026_10_30_160000 along with its completed column on playback_progresses and series_total_episodes on collection_entries, and retains main's playlists and playlist_items tables. To check the resolution rather than hand-trust it, I migrated an empty throwaway SQLite database through every migration and compared the dump with the merged file: identical.

Gates at 7828189 (Windows dev box): full RSpec 601 examples, 12 failures — your test merge also reports 601, and all 12 failures here are the platform-only set (9 Process.spawn(..., pgroup: true), 2 SIGCONT, 1 bin/docker-entrypoint exec), with no assertion failures. Coverage 87.9% line / 71.1% branch. JS 578/578. RuboCop 196 files, no offenses.

A rebase was not the right tool for these branches: #43 carried earlier merges of main, so replaying its seven commits re-conflicted each one. A merge produces the same tree your test merge validated, and this branch is the same shape — one conflict, in the schema version line only.

@vitobotta vitobotta left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The four earlier findings are fixed at 7828189. The head is a merge of d0f8cb9 and carries no branch-owned code changes after 72df706, so the verified behavior is unchanged.

Current main has moved past d0f8cb9: #43 is merged, and db/schema.rb is now 2026_11_05_090000 with the app_settings, playlists, and playlist_items tables. The PR is CONFLICTING in db/schema.rb. Merge current main and keep that version, main's three tables, and this branch's completed and series_total_episodes columns.

Gates on a test merge with current main: 670 RSpec examples, 0 failures; 580 JavaScript tests, 0 failures; RuboCop inspected 208 files, no offenses; Brakeman clean. CI passes lint, scan_js, and scan_ruby.

No other findings.

Resolve the schema dump against the merged 2026_11_05_090000 version: keep
main's app_settings, playlists and playlist_items tables together with this
branch's completed and series_total_episodes columns. Checking the merged
file against a migration of an empty database gives an identical dump.
@phantomic12

Copy link
Copy Markdown
Contributor Author

Merged current main (6f92786, which includes #43) at 608ddf7. The PR is MERGEABLE/CLEAN again and lint, scan_js, scan_ruby pass on the new head.

db/schema.rb now takes main's 2026_11_05_090000 version with its app_settings, playlists and playlist_items tables, and keeps this branch's completed column on playback_progresses plus series_total_episodes and series_total_episodes_synced_at on collection_entries. I migrated an empty database through every migration and compared the dump with the merged file: identical.

Gates at 608ddf7 (Windows dev box): 670 RSpec examples — your count — with 12 failures, all from the same platform gaps as before (9 Process.spawn(..., pgroup: true), 2 SIGCONT, 1 bin/docker-entrypoint exec) and nothing else. JS 580/580, RuboCop 208 files with no offenses, coverage 88.6% line / 72.0% branch.

@vitobotta vitobotta left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved at 608ddf7.

The schema conflict is resolved correctly. The branch keeps 2026_11_05_090000, retains app_settings, playlists, and playlist_items from main, and adds completed plus the two series_total_episodes columns from this branch. I dropped the test database, migrated an empty one through every migration, and the generated schema matched the committed file.

Gates at this head: 670 RSpec examples, 0 failures; 580 JavaScript tests, 0 failures; RuboCop inspected 208 files with no offenses; Brakeman found no warnings. CI passes lint, scan_js, and scan_ruby.

The four earlier findings remain fixed: the total write requires a successful metadata call with a present episode list, blank and unparseable release dates count as not released, the episode drawer uses the shared Show SxxExx title, and the series progress count excludes specials and unaired episodes.

No remaining findings.

@vitobotta
vitobotta merged commit 2fef898 into vitobotta:main Nov 15, 2026
3 checks passed
@vitobotta

Copy link
Copy Markdown
Owner

Thanks @phantomic12 for the watched toggles work. It covers detail pages, library cards, history rows, season tabs, series progress, and the catalogue backfill, with the empty and failed catalogue cases pinned. A new release is coming shortly.

@phantomic12
phantomic12 deleted the watched-unplayed branch November 15, 2026 22:34
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.

2 participants