Skip to content

feat(calendar): personalized presets (Following default) with watched overlay - #25

Merged
Quick104 merged 10 commits into
mainfrom
feat/calendar-presets
May 29, 2026
Merged

Quick104 merged 10 commits into
mainfrom
feat/calendar-presets

Conversation

@Quick104

@Quick104 Quick104 commented May 29, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Replaces the calendar's All / Favorites / Watchlist toggles with a Simkl-style preset switcher and a personalized default, powered by real watch data:

  • Following (default) — upcoming airings for shows you've watched, favorited, or watchlisted (per-profile).
  • Trending — externally-trending shows (TMDB/Trakt snapshot) that are in your library.
  • Everything — all catalog airings (the old behavior, now just one option).
  • Watched overlay — episodes you've completed render dimmed with a ✓, turning Following into a "what do I still need to catch up on this week" view.

Popular here (server-wide most-watched) is implemented but hidden in the web UI for now — it's sparse on a low-traffic server. Re-enabling is a one-line change; the backend filter still works for other clients.

Why / approach

Performance was an explicit goal (hundreds of concurrent calendar users). The design is "filter, don't compute": every preset resolves to a small id-set that the existing windowed calendar query intersects via itemIDExpr = ANY($n). Popular/Trending are read from background-refreshed caches (no per-request aggregation); Following is resolved per request from indexed per-profile lookups. No new heavy SQL is added beyond the windowed query that already ran.

Design spec and implementation plan are included under docs/superpowers/.

Backend

  • CalendarFilter gains a generic id-set restriction (RestrictByIDs / RestrictToIDs), replacing the favorites/watchlist EXISTS special-cases with one uniform mechanism.
  • New per-profile resolvers (internal/catalog/calendar_personal.go): followed / favorites / watchlist id-sets + a bounded watched lookup.
  • Handler maps preset → id-set (resolveCalendarRestriction), overlays watched status (resolveWatched), and adds an additive watched field to event responses. Popular reads recommendation_cache; Trending reads the canonical tmdb/week snapshot.

Frontend

  • Responsive selector: segmented pills on desktop, dropdown on narrow viewports; both bind to one preset state.
  • Preset persistence via the shared storage util; empty-state nudges to other presets.
  • Watched overlay on event cards.

Reviewer notes

  • API change is additive: new filter values plus a watched field; all/favorites/watchlist still work, so existing silo-android / silo-apple clients are unaffected and can adopt the presets + watched cue as follow-ups.
  • Dropped the redundant handler-level profile required 400 guard (the /calendar route already runs behind RequireProfile); per-profile presets now degrade to an empty calendar instead of erroring.
  • recommendations.go: removed now-unused Filter/UserID/ProfileID from a CalendarFilter literal that only wants an unrestricted windowed query.

Test plan

  • go build ./... and go test ./... — green locally
  • cd web && pnpm run build + vitest + eslint + prettier --check — green locally
  • Manual: /calendar defaults to Following; switch presets (pills on desktop, dropdown when narrow); reload remembers last preset; an empty Following week shows the Trending/Everything nudge; completed episodes render dimmed + ✓

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features

    • Calendar now offers preset-based filtering: Following (default), Popular here, Trending, and Everything
    • Watched events display a checkmark overlay and dimmed appearance for visual distinction
    • Preset selections persist across sessions
    • Responsive filter selector with desktop pills and mobile dropdown
  • Documentation

    • Added implementation plan and design specifications for calendar presets

Review Change Stack

Quick104 and others added 10 commits May 29, 2026 13:47
…resolvers

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Also drops the now-unused Filter/UserID/ProfileID fields from the
blendUpcomingIntoDiscoverRows CalendarFilter literal in recommendations.go,
which only wants an unrestricted windowed query.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
…mpty-state nudge

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Popular reflects server-wide watch counts, which are sparse on a
low-traffic server. Hidden from the selector, URL allowlist, and
empty-state nudge; backend filter and the CalendarFilter type are
left intact so re-enabling is a one-line change.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
- Extract hardcoded trending snapshot source/window to named constants.
- Collapse the three identical personal-preset nil-checks into one case.
- Persist the selected preset through the shared storage util (try/catch
  wrapped) instead of raw localStorage with manual SSR guards.
- Derive KNOWN_FILTERS from PRESET_OPTIONS so the lists can't drift.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@coderabbitai

coderabbitai Bot commented May 29, 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: fa6984f6-d40e-4f5e-97ac-d338e6b76a1c

📥 Commits

Reviewing files that changed from the base of the PR and between 998803c and 5d23b65.

📒 Files selected for processing (15)
  • docs/superpowers/plans/2026-05-29-calendar-presets.md
  • docs/superpowers/specs/2026-05-29-calendar-presets-design.md
  • internal/api/handlers/calendar.go
  • internal/api/handlers/calendar_test.go
  • internal/api/handlers/recommendations.go
  • internal/api/router.go
  • internal/catalog/calendar_personal.go
  • internal/catalog/calendar_personal_test.go
  • internal/catalog/calendar_repo.go
  • internal/catalog/calendar_repo_test.go
  • web/src/components/calendar/CalendarEventCard.tsx
  • web/src/hooks/queries/calendar.ts
  • web/src/pages/Calendar.test.tsx
  • web/src/pages/Calendar.tsx
  • web/src/utils/storage.ts

📝 Walkthrough

Walkthrough

This PR implements a calendar preset switcher feature that replaces the existing All/Favorites/Watchlist toggles with four presets: Following (default), Popular here, Trending, and Everything. The implementation includes a backend query infrastructure refactor, personal calendar data methods, handler orchestration for preset resolution and watched overlay, and frontend UI updates with persistent preset storage.

Changes

Calendar Presets & Watched Overlay

Layer / File(s) Summary
Design Specification & Implementation Plan
docs/superpowers/specs/2026-05-29-calendar-presets-design.md, docs/superpowers/plans/2026-05-29-calendar-presets.md
Spec and plan define four presets backed by ID-set intersection, watched overlay mechanism, API contract updates for /calendar filter parameter, edge cases, and task-by-task implementation roadmap across backend query, data layer, handler, frontend type, and UI components.
Backend Calendar Query Infrastructure
internal/catalog/calendar_repo.go, internal/catalog/calendar_repo_test.go
CalendarFilter struct removes personal filtering inputs (Filter, UserID, ProfileID) and adds library-scoping and ID-set restriction fields (RestrictByIDs, RestrictToIDs); buildListEventsQuery and branch builders (buildMovieBranch, buildFilteredEpisodesCTE, buildFilteredSeasonsCTE) thread restriction arguments and apply new appendRestrictClause logic; tests verify ID restriction and empty-restriction short-circuit behavior.
Personal Calendar Data Layer
internal/catalog/calendar_personal.go, internal/catalog/calendar_personal_test.go
CalendarRepository methods ListFollowedItemIDs, ListFavoriteItemIDs, ListWatchlistItemIDs, and ListWatchedItemIDs fetch per-profile content ID sets via SQL queries unioning favorites, watchlist, and watch progress; unit tests validate query structure and profile scoping.
Calendar Handler & API Integration
internal/api/handlers/calendar.go, internal/api/handlers/calendar_test.go, internal/api/handlers/recommendations.go, internal/api/router.go
CalendarHandler extends with personal, popular, trending dependencies; HandleGetCalendar validates preset values, resolves each preset to an ID-set via resolveCalendarRestriction, applies RestrictByIDs/RestrictToIDs to filter, and adds watched overlay via resolveWatched; response model gains watched boolean per event; handler wiring in router supplies recommendations and trending repos; recommendations.go updated to use new CalendarFilter fields; comprehensive tests cover all preset paths, empty-followed short-circuit, and watched state propagation.
Frontend Type Model & Storage
web/src/hooks/queries/calendar.ts, web/src/utils/storage.ts
CalendarEvent type adds optional watched boolean; storage keys gain CALENDAR_PRESET entry to support persistent preset selection.
Frontend UI Components & Preset Selection
web/src/pages/Calendar.tsx, web/src/pages/Calendar.test.tsx, web/src/components/calendar/CalendarEventCard.tsx
Calendar.tsx introduces preset model (Following/Popular/Trending/Everything) with storage helpers and legacy-compatible URL parsing; responsive preset pills (desktop) and dropdown (mobile); preset setter persists selection; CalendarEmpty refactored to offer preset-switch nudges; Calendar.test.tsx updated to expect following default; CalendarEventCard applies grayscale/opacity and check-mark overlay to watched events with muted title styling.

🎯 3 (Moderate) | ⏱️ ~25 minutes

🐰 A calendar of presets now blooms,
Following hearts, trending rooms,
With watched badges shining bright,
The UI dances left and right! ✓

✨ 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/calendar-presets

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

@Quick104
Quick104 merged commit e15c07d into main May 29, 2026
1 check was pending
@Quick104
Quick104 deleted the feat/calendar-presets branch May 29, 2026 18:58
Quick104 added a commit to thezak48/silo-server that referenced this pull request Jun 7, 2026
feat(calendar): personalized presets (Following default) with watched overlay
Quick104 added a commit that referenced this pull request Jun 11, 2026
feat(calendar): personalized presets (Following default) with watched overlay
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