Skip to content

feat(sections): show episode context in cards - #18

Merged
Quick104 merged 1 commit into
mainfrom
codex/episode-section-labels
May 27, 2026
Merged

Quick104 merged 1 commit into
mainfrom
codex/episode-section-labels

Conversation

@Quick104

@Quick104 Quick104 commented May 27, 2026 •

Copy link
Copy Markdown
Contributor

Note

Low Risk
Mostly presentation and default-section seeding; section API adds an extra fetch for episodes missing meta, which is a small performance/behavior change on list endpoints.

Overview
This PR improves how episode items appear in section/browse cards and tightens default sections for TV libraries.

Section API: When building home/library section responses, episode rows that lack per-item metadata now get a batched lookup (FetchEpisodesByContentIDs) so responses include series_title, season_number, and episode_number without overwriting metadata already on the section.

Defaults & generated home rows: New and restored defaults are library-type aware. Series libraries use a “Recently Released Episodes” custom-filter query (episodes by release_date) on the home page and in library defaults, instead of a generic “recently released” row and the old “Recently Released TV Shows” library section (series default count goes from 7 → 6). Generated home sections are keyed by kind (added / released / released episodes), with episode-specific config and title sync when a library is renamed; library creation passes folder.Type when seeding generated home sections.

Web UI: ItemCard and SectionItemCard use shared buildEpisodeCardLabels so episodes show the series as the primary title, the episode title as a subtitle when distinct, and a zero-padded code (S01E01 instead of S1 E1).

Reviewed by Cursor Bugbot for commit b880c7d. Bugbot is set up for automated code reviews on this repo. Configure here.

Summary by CodeRabbit

Release Notes

  • New Features

    • Added "recently released episodes" section to library home pages
    • Episodes now display with series title and episode code in S##E## format on cards
  • Improvements

    • Enhanced episode metadata display, including episode title information
    • Improved default section organization for series libraries

Review Change Stack

@Quick104
Quick104 merged commit 985b296 into main May 27, 2026
1 check was pending
@Quick104
Quick104 deleted the codex/episode-section-labels branch May 27, 2026 19:49
@coderabbitai

coderabbitai Bot commented May 27, 2026 •

Copy link
Copy Markdown
Contributor

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: b340e464-ff86-482c-9ad4-0bec0f216f98

📥 Commits

Reviewing files that changed from the base of the PR and between c066d75 and b880c7d.

📒 Files selected for processing (13)
  • internal/api/handlers/libraries.go
  • internal/api/handlers/sections.go
  • internal/api/handlers/sections_test.go
  • internal/sections/defaults.go
  • internal/sections/defaults_test.go
  • internal/sections/generated.go
  • internal/sections/generated_test.go
  • internal/sections/repo.go
  • web/src/components/ItemCard.test.tsx
  • web/src/components/ItemCard.tsx
  • web/src/components/SectionItemCard.test.tsx
  • web/src/components/SectionItemCard.tsx
  • web/src/lib/episodeCardLabels.ts

📝 Walkthrough

Walkthrough

This PR extends home section generation to support episode-scoped sections with a kind-based abstraction, enriches section responses with fetched episode metadata, and adds frontend episode card labeling for series title and formatted episode codes.

Changes

Backend: Generated Sections and Episode Enrichment

Layer / File(s) Summary
Generated section kind system and episode config
internal/sections/generated.go, internal/sections/generated_test.go
Introduces kind constants for generated home sections (released, added, episodes), adds GeneratedHomeLibraryRecentEpisodesConfig for episodes-scoped queries, refactors config parsing and title generation to be kind-aware, and adds title syncing helpers.
Default sections generation with library type
internal/sections/defaults.go, internal/sections/defaults_test.go
Refactors DefaultHomeSections to dynamically generate per-library recent sections using helper functions; removes "recently released TV shows" for series, shifting subsequent section positions; updates test expectations accordingly.
Section repository layer with library type integration
internal/sections/repo.go
Updates CreateGeneratedHomeLibraryRecentSections to accept libraryType, builds sections using kind-keyed map to avoid duplicates, and uses kind-aware title syncing in SyncGeneratedHomeLibraryRecentTitles.
API handlers: library creation and episode enrichment
internal/api/handlers/libraries.go, internal/api/handlers/sections.go, internal/api/handlers/sections_test.go
Library handler passes folder type to section creation; section handler wires episode fetcher, preloads episode metadata across sections, and falls back to fetched metadata when per-section metadata is unavailable; includes tests validating enrichment and preservation of existing metadata.

Frontend: Episode Card Labeling and Component Updates

Layer / File(s) Summary
Episode card labeling utility
web/src/lib/episodeCardLabels.ts
New module providing buildEpisodeCardLabels function that formats season/episode numbers into SxxExx codes, derives series and episode titles from item metadata, and validates required fields.
ItemCard and SectionItemCard updates
web/src/components/ItemCard.tsx, web/src/components/ItemCard.test.tsx, web/src/components/SectionItemCard.tsx, web/src/components/SectionItemCard.test.tsx
Components use buildEpisodeCardLabels to display series title, optional episode title, and formatted episode code; test assertions updated to expect SxxExx format; SectionItemCard now renders episode-specific metadata instead of year/type fallback.

🎯 3 (Moderate) | ⏱️ ~25 minutes

🐰 A section kind blooms in spring,
Episodes and titles now take wing,
Metadata fetched with gentle care,
Episode labels float through the air! ✨

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/episode-section-labels

Comment @coderabbitai help to get the list of available commands and usage tips.

@cursor cursor Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit b880c7d. Configure here.

const displayTitle =
item.type === "episode" && item.series_title ? item.series_title : item.title;
const episodeLabels = buildEpisodeCardLabels(item);
const displayTitle = episodeLabels ? episodeLabels.seriesTitle : item.title;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Episode display title regresses when season/episode numbers missing

Low Severity

The old displayTitle logic showed item.series_title for any episode that had one, regardless of whether season_number/episode_number were present. The new logic delegates to buildEpisodeCardLabels, which returns null when season_number or episode_number is missing, causing displayTitle to fall back to item.title. Episodes with a series_title but incomplete season/episode metadata will now display the episode title instead of the series title in the browse grid.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit b880c7d. Configure here.

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