Repository navigation
feat(watchlist): honor provider list order by default - #352
Conversation
The watchlist catalog page silently returned the stored list order while its sort dropdown claimed "Date Added", and mirroring a provider's list order (e.g. MDBList) was off by default, so synced watchlists appeared in first-sync-time order with no way to tell what was happening. - Web: the watchlist source now uses the same source-order sentinel as collections — the dropdown shows "List Order" as the default, and an explicit "Date Added" pick sends sort=added_at instead of being stripped (previously indistinguishable from the default). - Server: on personal lists (watchlist/favorites) an explicit added_at sort now takes the source-order path, where added_at means "date added to the list"; the query executor path sorted by the library's created_at instead. History keeps the executor path since its ID loading ignores the sort. - watchsync: new connections default sync_watchlist_order_enabled to true, with a migration flipping existing rows to match. Providers without the provides_watchlist_order capability ignore the flag at sync time. Co-Authored-By: Claude Fable 5 <[email protected]>
📝 WalkthroughWalkthroughThis PR enables watchlist source-order (list order) behavior by default across backend request parsing, watchlist sync connection defaults, a database migration, and frontend catalog search/filter logic, along with corresponding test coverage. ChangesWatchlist Source-Order Enablement
Estimated code review effort: 3 (Moderate) | ~25 minutes 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (2)
internal/catalog/catalog_parser.go (1)
86-92: 📐 Maintainability & Code Quality | 🔵 TrivialConsider extracting the shared "added_at → source order" rule.
The same business rule —
added_atsort routes personal lists (favorites/watchlist) to the source-order path — is duplicated here and inresolveSectionSource(internal/catalog/catalog_resolver.go), which independently computesuseSourceOrder = qs.Field == "added_at". Keeping this logic in one place would prevent the two paths from silently diverging later.🤖 Prompt for 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. In `@internal/catalog/catalog_parser.go` around lines 86 - 92, The added_at-to-source-order rule is duplicated between catalog_parser.go and resolveSectionSource in catalog_resolver.go, so consolidate it into one shared helper or decision function and have both req.UseSourceOrder and useSourceOrder call that single source. Keep the personal-list logic (favorites/watchlist) and the history exception in the shared symbol so both paths stay aligned if the rule changes.web/src/components/catalog/CatalogFiltersPanel.tsx (1)
11-14: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winWiring looks correct; consider covering it with a component test.
The
supportsSourceOrdergating and"List Order"label change are correctly derived from the shared helper reviewed incatalogSearchParams.ts. Since this is new user-facing behavior (watchlist now shows/toggles "List Order"), consider adding a render test assertingsourceOrderLabeland the toggle round-trip forsource: "watchlist", similar to existing collection-source coverage if present.Also applies to: 54-55, 88-88, 112-114
🤖 Prompt for 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. In `@web/src/components/catalog/CatalogFiltersPanel.tsx` around lines 11 - 14, Add a component render test for CatalogFiltersPanel covering the new watchlist behavior. Verify that sourceOrderLabel resolves to "List Order" when CatalogSearchState.source is "watchlist", and that the supportsSourceOrder gating enables the toggle and preserves the round-trip interaction. Reuse the same test patterns used for existing collection-source coverage if available, and target the CatalogFiltersPanel component plus the shared helper-derived behavior from catalogSourceSupportsSourceOrder.
🤖 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.
Nitpick comments:
In `@internal/catalog/catalog_parser.go`:
- Around line 86-92: The added_at-to-source-order rule is duplicated between
catalog_parser.go and resolveSectionSource in catalog_resolver.go, so
consolidate it into one shared helper or decision function and have both
req.UseSourceOrder and useSourceOrder call that single source. Keep the
personal-list logic (favorites/watchlist) and the history exception in the
shared symbol so both paths stay aligned if the rule changes.
In `@web/src/components/catalog/CatalogFiltersPanel.tsx`:
- Around line 11-14: Add a component render test for CatalogFiltersPanel
covering the new watchlist behavior. Verify that sourceOrderLabel resolves to
"List Order" when CatalogSearchState.source is "watchlist", and that the
supportsSourceOrder gating enables the toggle and preserves the round-trip
interaction. Reuse the same test patterns used for existing collection-source
coverage if available, and target the CatalogFiltersPanel component plus the
shared helper-derived behavior from catalogSourceSupportsSourceOrder.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 6f5e030e-eb49-4a1f-980c-eec0c6e802f1
📒 Files selected for processing (7)
internal/catalog/catalog_parser.gointernal/catalog/catalog_parser_test.gointernal/watchsync/service.gomigrations/sql/20260709140902_enable_watchlist_order_mirroring.sqlweb/src/components/catalog/CatalogFiltersPanel.tsxweb/src/pages/catalogSearchParams.test.tsweb/src/pages/catalogSearchParams.ts
The watchlist catalog page silently returned the stored list order while its sort dropdown claimed "Date Added", and mirroring a provider's list order (e.g. MDBList) was off by default, so synced watchlists appeared in first-sync-time order with no way to tell what was happening. - Web: the watchlist source now uses the same source-order sentinel as collections — the dropdown shows "List Order" as the default, and an explicit "Date Added" pick sends sort=added_at instead of being stripped (previously indistinguishable from the default). - Server: on personal lists (watchlist/favorites) an explicit added_at sort now takes the source-order path, where added_at means "date added to the list"; the query executor path sorted by the library's created_at instead. History keeps the executor path since its ID loading ignores the sort. - watchsync: new connections default sync_watchlist_order_enabled to true, with a migration flipping existing rows to match. Providers without the provides_watchlist_order capability ignore the flag at sync time. Co-authored-by: Claude Fable 5 <[email protected]>
Problem
The watchlist catalog page (
/catalog?source=watchlist) had two compounding confusions:sortparam, so the server returns the stored list order — but the UI displayed the default as "Date Added". Collections already solve this honestly with a "Collection Order" sentinel; the watchlist never got the same treatment. A side effect: explicitly picking "Date Added" was indistinguishable from the default (the param was stripped either way), so a true date-added sort was unreachable from the UI.ProvidesWatchlistOrderand the sync plumbing mirrors its order intouser_watchlist.sort_index, butsync_watchlist_order_enabledshipped default-off — so synced watchlists appeared in first-sync-time order (every item from the initial sync shares one timestamp) unless the user found the toggle.There was also a latent semantics bug:
source=watchlist&sort=added_atwent through the query executor, which mapsadded_atto the library'screated_at— i.e. date added to the library, not date added to the list — inconsistent with the section path, which documentsadded_aton personal lists as list-added date.Changes
uses_source_ordermechanism as collections. The sort dropdown shows "List Order" as the active default, and an explicit "Date Added" pick now sendssort=added_at.catalog_parser.go): on watchlist/favorites, an explicitadded_atsort takes the source-order path whereOrderPersonalListIDsapplies the list added-at. History keeps the executor path since its ID loading ignores the sort.sync_watchlist_order_enabled = true; a migration flips existing rows and the column default to match. Order application still requires the provider capability, so this is a no-op for Trakt/Simkl.Behavior notes / risks
GET /api/v1/catalog?source=watchlist&sort=added_atchanges meaning from library-added to list-added ordering. No fields or status codes change (additive-only rules respected); this is a semantics fix aligning with the section path. Clients that send this param (Android/Apple) should be checked — if they expose a watchlist "Date Added" sort they now get the more intuitive list-date ordering with no code change.sort_indexon the next toggle-off.Verification
TestParseCatalogRequest_PersonalSourceOrder) plusinternal/catalogandinternal/watchsync/...suites pass;go build ./...clean; no new golangci findings on changed lines.make verify-local-pathspasses.goose validatepasses; migration column/table names cross-checked against20260626185649_watchlist_sort_order.sql. Not executed against a live DB (no local Docker).source=watchlistwith no sort and shows "List Order"; picking "Date Added" issuessort=added_at&order=descand updates the URL; switching back strips it. No console errors.Related: #214 (closed epic for external list-backed collections; no open scope issue covers this — it comes from a direct UX report that "Recently Added" on a synced MDBList watchlist was ambiguous and didn't honor MDBList's order).
AI-use disclosure
Implemented with Claude Code (Claude Fable 5), human-directed and reviewed.
🤖 Generated with Claude Code
Summary by CodeRabbit
New Features
Bug Fixes