Skip to content

feat(watchlist): honor provider list order by default - #352

Merged
Quick104 merged 1 commit into
mainfrom
feat/watchlist-provider-list-order
Jul 9, 2026
Merged

Quick104 merged 1 commit into
mainfrom
feat/watchlist-provider-list-order

Conversation

@Quick104

@Quick104 Quick104 commented Jul 9, 2026 •

Copy link
Copy Markdown
Contributor

Problem

The watchlist catalog page (/catalog?source=watchlist) had two compounding confusions:

  1. The sort dropdown lied. The default request sends no sort param, 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.
  2. Provider order mirroring was off by default. MDBList declares ProvidesWatchlistOrder and the sync plumbing mirrors its order into user_watchlist.sort_index, but sync_watchlist_order_enabled shipped 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_at went through the query executor, which maps added_at to the library's created_at — i.e. date added to the library, not date added to the list — inconsistent with the section path, which documents added_at on personal lists as list-added date.

Changes

  • Web: the watchlist source participates in the same uses_source_order mechanism as collections. The sort dropdown shows "List Order" as the active default, and an explicit "Date Added" pick now sends sort=added_at.
  • Server (catalog_parser.go): on watchlist/favorites, an explicit added_at sort takes the source-order path where OrderPersonalListIDs applies the list added-at. History keeps the executor path since its ID loading ignores the sort.
  • watchsync: new connections are created with 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_at changes 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.
  • The migration's Down restores the column default but intentionally leaves per-row values untouched: rows enabled by the Up are indistinguishable from user-enabled rows, and disabling a user-enabled row would wipe their mirrored sort_index on the next toggle-off.
  • Mirrored order lands on the next watchlist sync after the migration runs.

Verification

  • New Go parser tests (TestParseCatalogRequest_PersonalSourceOrder) plus internal/catalog and internal/watchsync/... suites pass; go build ./... clean; no new golangci findings on changed lines.
  • New vitest cases for parse/build round-trips; full web suite green except 4 pre-existing failures (Jellyfin proxy/setup-wizard, confirmed failing on a clean tree). ESLint/Prettier clean; make verify-local-paths passes.
  • goose validate passes; migration column/table names cross-checked against 20260626185649_watchlist_sort_order.sql. Not executed against a live DB (no local Docker).
  • Verified live in the browser against the dev backend: default page requests source=watchlist with no sort and shows "List Order"; picking "Date Added" issues sort=added_at&order=desc and 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

    • Catalog filtering now better supports source-based ordering for personal lists like watchlists.
    • Watchlist links and search parameters now preserve the expected order behavior when navigating between views.
  • Bug Fixes

    • Fixed sorting behavior for “Date Added” on personal lists so the displayed order matches user expectations.
    • Watchlist sync/order settings now default to enabled for new connections and existing connections were updated accordingly.

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]>
@coderabbitai

coderabbitai Bot commented Jul 9, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

This 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.

Changes

Watchlist Source-Order Enablement

Layer / File(s) Summary
Catalog request parser source-order logic
internal/catalog/catalog_parser.go, internal/catalog/catalog_parser_test.go
ParseCatalogRequest now enables UseSourceOrder for non-history personal sources when the explicit sort field is added_at; new table-driven tests cover watchlist/favorites/history cases.
Watchlist sync connection defaults
internal/watchsync/service.go
GetConnectionStatus and persistConnection now default SyncWatchlistOrderEnabled to true instead of false.
Database migration for sync flag default
migrations/sql/20260709140902_enable_watchlist_order_mirroring.sql
Adds a goose migration setting existing rows and the column default of sync_watchlist_order_enabled to true, with a down migration reverting only the default.
catalogSourceSupportsSourceOrder helper and search params
web/src/pages/catalogSearchParams.ts, web/src/pages/catalogSearchParams.test.ts
Adds exported catalogSourceSupportsSourceOrder helper, applies it in parseCatalogSearchParams and buildPersonalCatalogHref, adds a watchlist-specific branch in buildCatalogApiSearchParams, and extends tests for parsing, href building, and personal catalog hrefs.
CatalogFiltersPanel source-order UI wiring
web/src/components/catalog/CatalogFiltersPanel.tsx
Imports and uses catalogSourceSupportsSourceOrder to compute usesSourceOrder/nextUsesSourceOrder and to label source order as “List Order” for non-collection sources that support it.

Estimated code review effort: 3 (Moderate) | ~25 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 16.67% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main change: watchlist now honors provider list order by default.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ 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 feat/watchlist-provider-list-order

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

@coderabbitai coderabbitai 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.

🧹 Nitpick comments (2)
internal/catalog/catalog_parser.go (1)

86-92: 📐 Maintainability & Code Quality | 🔵 Trivial

Consider extracting the shared "added_at → source order" rule.

The same business rule — added_at sort routes personal lists (favorites/watchlist) to the source-order path — is duplicated here and in resolveSectionSource (internal/catalog/catalog_resolver.go), which independently computes useSourceOrder = 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 win

Wiring looks correct; consider covering it with a component test.

The supportsSourceOrder gating and "List Order" label change are correctly derived from the shared helper reviewed in catalogSearchParams.ts. Since this is new user-facing behavior (watchlist now shows/toggles "List Order"), consider adding a render test asserting sourceOrderLabel and the toggle round-trip for source: "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

📥 Commits

Reviewing files that changed from the base of the PR and between 7227f5a and a6bfb04.

📒 Files selected for processing (7)
  • internal/catalog/catalog_parser.go
  • internal/catalog/catalog_parser_test.go
  • internal/watchsync/service.go
  • migrations/sql/20260709140902_enable_watchlist_order_mirroring.sql
  • web/src/components/catalog/CatalogFiltersPanel.tsx
  • web/src/pages/catalogSearchParams.test.ts
  • web/src/pages/catalogSearchParams.ts

@Quick104
Quick104 merged commit b2b95a3 into main Jul 9, 2026
2 checks passed
@Quick104
Quick104 deleted the feat/watchlist-provider-list-order branch July 9, 2026 14:28
Quick104 added a commit that referenced this pull request Jul 10, 2026
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]>
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