Repository navigation
[codex] fix season page loading - #178
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (4)
🚧 Files skipped from review as they are similar to previous changes (2)
📝 WalkthroughWalkthroughBackend season response construction is refactored to batch-fetch watch progress via chunked ChangesSeason Batch Fetching and Frontend Query Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: be27715896
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| payload.content_id | ||
| ? { itemId: payload.content_id, refetchActive: false } | ||
| : { refetchActive: false }, |
There was a problem hiding this comment.
Preserve active refetches for realtime user-state changes
When a user-state change originates from another tab or device, refetchType: "none" leaves every mounted catalog, progress, history, favorite, and watchlist query showing its cached data indefinitely. The direct update above only patches user_state on the changed item's detail; it does not update user_data, season aggregates, episode progress, or list membership. Consequently, an open season or Favorites page no longer reflects remote watched/progress/favorite changes until a later focus, remount, or manual refresh, whereas these active queries were refetched before this change.
Useful? React with 👍 / 👎.
| switch { | ||
| case err == nil: | ||
| episodes, _ := h.items.episodeRepo.ListBySeasonID(r.Context(), season.ContentID) | ||
| episodes, err := h.items.episodeRepo.ListBySeasonID(r.Context(), season.ContentID) |
There was a problem hiding this comment.
Fall back to the season number when episode links are absent
For catalogs containing episodes whose nullable season_id has not been populated (including imported legacy bundles, whose importer preserves a missing season ID), this lookup returns no episodes even though the same rows are available by series_id and season_number. Before this change, toSeasonResponse performed that latter lookup, so the season detail still reported the correct episode count and aggregate user data; it now returns a zero-count season with no user data. Use the series/number lookup as a fallback, or ensure all existing rows are backfilled before relying exclusively on season_id.
Useful? React with 👍 / 👎.
| CREATE INDEX CONCURRENTLY IF NOT EXISTS idx_episodes_season_id_episode_number | ||
| ON public.episodes USING btree (season_id, episode_number); |
There was a problem hiding this comment.
Recover invalid concurrent indexes before retrying
If this non-transactional CREATE INDEX CONCURRENTLY is interrupted or fails after creating its catalog entry, PostgreSQL leaves an invalid index with this name. On the next Goose retry, IF NOT EXISTS treats that invalid relation as existing, skips rebuilding it, and allows the migration to be recorded as applied even though the optimizer cannot use the index, leaving the season lookup regression unfixed. Drop an invalid same-named index before creation or otherwise validate and rebuild it during retry.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@internal/api/handlers/items.go`:
- Around line 1466-1475: The progressMapForEpisodes method currently returns
partial progress data when batch retrieval fails, which causes incorrect
aggregation results. Instead of returning the incomplete progressMap, implement
error handling similar to listLeafUserData: check for errors during the
listProgressForEpisodeIDs call within progressMapForEpisodes and return nil,
false when a batch error occurs, ensuring that partial progress maps are never
used for aggregation and preventing incorrect episode watch status from being
displayed.
In `@migrations/sql/20260618164519_add_episodes_season_id_index.sql`:
- Around line 8-9: The issue is that using IF NOT EXISTS with CREATE INDEX
CONCURRENTLY can mask invalid index states in PostgreSQL's system catalog. When
a concurrent index creation fails, the IF NOT EXISTS clause will skip recreation
on rerun even though the index is invalid, causing the migration to appear
successful while the index remains unusable. Remove the IF NOT EXISTS clause
from the CREATE INDEX CONCURRENTLY statement in the
idx_episodes_season_id_episode_number index creation so that the migration will
fail explicitly if the index already exists, forcing immediate attention to any
invalid index state rather than silently skipping the operation.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: ec703134-d28c-4d90-8ed0-e4ce07877e67
📒 Files selected for processing (6)
internal/api/handlers/catalog_resources.gointernal/api/handlers/items.gomigrations/sql/20260618164519_add_episodes_season_id_index.sqlweb/src/components/RealtimeEventsProvider.tsxweb/src/hooks/queries/catalogRead.tsweb/src/hooks/queries/mediaSurfaceRefresh.ts
Code reviewNo issues found. Checked for bugs and CLAUDE.md compliance. 🤖 Generated with Claude Code |
* fix(catalog): speed up season page loads * fix: address season loading review feedback
Summary
Fixes the season page loading regression around series season selection by addressing both the frontend refetch behavior and the backend season episode lookup path.
Root Cause
Season navigation was paying for two separate problems:
user_stateevents invalidated and actively refetched visible catalog queries.episodesbyseason_idwithout a matching index, forcing scans across a large episodes table.Changes
keepPreviousDatafrom identity-specific catalog detail, season, version, and episode queries.episodes(season_id, episode_number).Impact
Season clicks no longer appear to hang while unrelated refetches finish. The backend now serves the affected season detail and episode-list paths through indexed lookups and batched progress reads.
Validation
cd web && pnpm run lintpassed with existing warnings, no errors.cd web && pnpm run format:checkpassed.cd web && pnpm run buildpassed.make migrate-validatepassed.make dev-deploysucceeded and compiled the server in Docker.https://silo.arkyncdn.net/item/series-tvdb-81797: Loguetown click updated route in about 135 ms, content settled in about 1.2 s, console stayed clean.EXPLAIN ANALYZEafter migration usedidx_episodes_season_id_episode_number, with the season episode lookup around 0.760 ms.Local bare-host Go tests were not run successfully because
/opt/dev/github/SiloServer/go.worklists Go1.26.3while this module requires>=1.26.4; the deployed Docker build path compiled successfully.Risk And Follow-Up
Scope: bug fix only; no new v1 capability.
AI-use disclosure: Implemented with AI assistance in Codex; changes were inspected, deployed to dev, and validated with browser and server timings.
Summary by CodeRabbit
Release Notes
Performance
Bug Fixes
Updates