Skip to content

perf(web): eliminate item detail interaction jank - #540

Merged
Quick104 merged 4 commits into
Silo-Server:mainfrom
Rhainland:perf/web-performance-pass2
Aug 27, 2026
Merged

Quick104 merged 4 commits into
Silo-Server:mainfrom
Rhainland:perf/web-performance-pass2

Conversation

@Rhainland

@Rhainland Rhainland commented Aug 4, 2026 •

Copy link
Copy Markdown
Contributor

Problem

No linked issue; this was reported and reproduced locally on movie and episode detail pages.

Opening or hovering the Version, Audio, Subs, rating, watched, favorite, and overflow controls could stall the main thread. Scrolling immediately after an action or while hovering these controls visibly dropped frames, and optimistic user-state changes triggered broad synchronous cache work.

Approach

  • replace the affected Radix detail-page popovers with lightweight, accessible portals that remain immediately interactive and close cleanly on page scroll
  • remove the detail hero Ken Burns animation and avoid live backdrop-filter repainting on the action surface
  • keep star-rating previews in CSS and isolate frequently changing mutation state below the page-content boundary
  • optimistically update watched, favorite, watchlist, and rating state while coalescing derived-surface invalidations outside the interaction frame
  • preserve concurrent optimistic fields, cancel both detail-query cache shapes, and scope recommendation invalidation so metadata changes still refresh similar titles
  • add regression coverage for popover focus/scroll behavior, invalidation scheduling, optimistic cache behavior, and realtime state reconciliation

Cold browser measurements while hovering and scrolling the seeded detail page reported a maximum frame of approximately 9.4 ms for Version, Audio, and Subs, with zero frames over 20 ms. Dropdown selection, Escape behavior, page-scroll dismissal, internal popup scrolling, overflow-menu navigation, and browser console output were also verified against the local server.

Screenshots are not included because this is a performance-focused change with no intentional layout redesign.

Testing

$ cd web && pnpm run lint
✖ 157 problems (0 errors, 157 warnings)

$ cd web && pnpm run format:check
All matched files use Prettier code style!

$ cd web && pnpm run build
✓ 4113 modules transformed.
✓ built in 7.87s

$ cd web && pnpm exec vitest run --exclude src/utils/storage.test.ts --exclude src/hooks/queries/settingValuesRealtime.test.tsx --exclude src/hooks/useTheme.test.ts --exclude src/hooks/appearanceCacheOwnership.test.tsx --exclude src/pages/setup-wizard/steps/ServerStorageStep.test.tsx --exclude src/pages/ItemDetail/SeasonContent.test.tsx
Test Files  267 passed (267)
Tests       1806 passed (1806)

$ make verify-local-paths
scripts/check-local-path-leaks.sh

$ git diff --check
(no output)

The six excluded frontend files fail identically on unchanged main in this local Node/jsdom environment because of the invalid built-in localStorage, missing ResizeObserver, and an unrelated existing query invalidation assertion.

make lint was also run and reports 303 pre-existing Go lint findings; this PR changes no Go files. Relevant Go tests are therefore not applicable.

AI Disclosure

  • Tool(s): Codex, Claude Code
  • Model(s): gpt-5.6-sol (Codex); Claude model ID was not available to the PR-authoring session
  • Involvement: AI-assisted
  • Adversarial review: Repeated Codex and Claude reviews found and resolved optimistic rollback races, incomplete query cancellation, unsafe invalidation-option merging, metadata refreshes incorrectly skipping similar-title data, realtime favorite events overwriting watched state, popup accessibility/focus gaps, viewport overflow, page-scroll layout reads, and internal popup scrolling being mistaken for page scrolling. The final pass found no remaining findings.

Checklist

  • I ran an adversarial AI review of the diff and summarized findings above.
  • I ran the repo verify commands: make lint, cd web && pnpm run lint, cd web && pnpm run format:check, and relevant go test ./....

The frontend commands and local-path verifier pass as described above. The repository-wide Go lint gate remains red on unchanged baseline findings, and no Go packages were modified.

Summary by CodeRabbit

  • New Features

    • Added improved detail-page menus and popovers with responsive positioning, keyboard navigation, focus restoration, Escape handling, and outside-click dismissal.
    • Added CSS-based star-rating previews with persisted selections and hover feedback.
    • Streamlined movie and episode action controls for playback, favorites, watchlist, watched status, and ratings.
  • Bug Fixes

    • Improved real-time updates while preserving existing playback and user-state information.
    • Reduced unnecessary refreshes and prevented stale detail-page data after changes.
    • Improved detail-page visual performance by removing unnecessary backdrop effects and animations.

@coderabbitai

coderabbitai Bot commented Aug 4, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: a667e9bd-fe48-46e5-b398-3a8a337ee7b2

📥 Commits

Reviewing files that changed from the base of the PR and between 3242f76 and 5023781.

📒 Files selected for processing (28)
  • web/src/app.css
  • web/src/components/CastCarousel.tsx
  • web/src/components/RealtimeEventsProvider.test.tsx
  • web/src/components/RealtimeEventsProvider.tsx
  • web/src/components/StarRating.test.tsx
  • web/src/components/StarRating.tsx
  • web/src/hooks/queries/favorites.ts
  • web/src/hooks/queries/items.test.ts
  • web/src/hooks/queries/items.ts
  • web/src/hooks/queries/mediaSurfaceRefresh.test.ts
  • web/src/hooks/queries/mediaSurfaceRefresh.ts
  • web/src/hooks/queries/ratings.test.ts
  • web/src/hooks/queries/ratings.ts
  • web/src/hooks/queries/ratingsSurfaceRefresh.test.ts
  • web/src/hooks/queries/ratingsSurfaceRefresh.ts
  • web/src/hooks/queries/watchlist.ts
  • web/src/pages/ItemDetail/DetailHero.tsx
  • web/src/pages/ItemDetail/EpisodeContent.tsx
  • web/src/pages/ItemDetail/MovieContent.tsx
  • web/src/pages/ItemDetail/components/ActionBar.test.tsx
  • web/src/pages/ItemDetail/components/ActionBar.tsx
  • web/src/pages/ItemDetail/components/AudioTracksPopover.tsx
  • web/src/pages/ItemDetail/components/DetailPopover.test.tsx
  • web/src/pages/ItemDetail/components/DetailPopover.tsx
  • web/src/pages/ItemDetail/components/MediaUserActionBar.tsx
  • web/src/pages/ItemDetail/components/SubtitlesPopover.tsx
  • web/src/pages/ItemDetail/components/VersionDropdown.tsx
  • web/src/pages/ItemDetail/components/WatchedActionBar.tsx
🚧 Files skipped from review as they are similar to previous changes (25)
  • web/src/hooks/queries/ratings.ts
  • web/src/pages/ItemDetail/components/WatchedActionBar.tsx
  • web/src/components/CastCarousel.tsx
  • web/src/hooks/queries/ratingsSurfaceRefresh.ts
  • web/src/pages/ItemDetail/DetailHero.tsx
  • web/src/hooks/queries/ratingsSurfaceRefresh.test.ts
  • web/src/pages/ItemDetail/components/DetailPopover.test.tsx
  • web/src/pages/ItemDetail/components/SubtitlesPopover.tsx
  • web/src/pages/ItemDetail/components/MediaUserActionBar.tsx
  • web/src/pages/ItemDetail/MovieContent.tsx
  • web/src/hooks/queries/ratings.test.ts
  • web/src/components/RealtimeEventsProvider.test.tsx
  • web/src/hooks/queries/mediaSurfaceRefresh.test.ts
  • web/src/hooks/queries/mediaSurfaceRefresh.ts
  • web/src/pages/ItemDetail/components/AudioTracksPopover.tsx
  • web/src/pages/ItemDetail/components/DetailPopover.tsx
  • web/src/pages/ItemDetail/EpisodeContent.tsx
  • web/src/hooks/queries/watchlist.ts
  • web/src/hooks/queries/favorites.ts
  • web/src/app.css
  • web/src/pages/ItemDetail/components/VersionDropdown.tsx
  • web/src/pages/ItemDetail/components/ActionBar.tsx
  • web/src/hooks/queries/items.ts
  • web/src/components/StarRating.tsx
  • web/src/components/RealtimeEventsProvider.tsx

Included review availability: Your plan provides up to 2 included reviews per hour; 1 remains after this review.


📝 Walkthrough

Walkthrough

This PR adds targeted media-surface refresh scheduling, optimistic cache updates, shared detail popovers, a portal-based overflow menu, action-bar wrappers, CSS star-rating states, and memoized detail components.

Changes

Media refresh and cache updates

Layer / File(s) Summary
Targeted media refresh and mutation handling
web/src/hooks/queries/*, web/src/components/RealtimeEventsProvider.tsx, web/src/components/RealtimeEventsProvider.test.tsx
Mutations and realtime events now patch cached item state, cancel detail queries, and schedule coalesced media-surface invalidation. Tests cover filtering, timing, deduplication, and cache preservation.

Detail interaction components

Layer / File(s) Summary
Shared popovers and overflow actions
web/src/pages/ItemDetail/components/DetailPopover.tsx, web/src/pages/ItemDetail/components/ActionBar.tsx, web/src/pages/ItemDetail/components/AudioTracksPopover.tsx, web/src/pages/ItemDetail/components/SubtitlesPopover.tsx, web/src/pages/ItemDetail/components/VersionDropdown.tsx, web/src/pages/ItemDetail/components/DetailPopover.test.tsx
Detail menus now use shared portal-based positioning, focus handling, dismissal, keyboard navigation, and accessibility behavior.
Action-bar state wiring
web/src/pages/ItemDetail/components/MediaUserActionBar.tsx, web/src/pages/ItemDetail/components/WatchedActionBar.tsx, web/src/pages/ItemDetail/MovieContent.tsx, web/src/pages/ItemDetail/EpisodeContent.tsx
Favorite, watchlist, rating, and watched-state mutations move into dedicated action-bar wrappers.

Detail presentation updates

Layer / File(s) Summary
Rating, rendering, and action styling
web/src/app.css, web/src/components/StarRating.tsx, web/src/components/StarRating.test.tsx, web/src/components/CastCarousel.tsx, web/src/pages/ItemDetail/DetailHero.tsx
Star hover states move to CSS, star and cast rendering gain memoization, and detail action and backdrop styling removes selected transitions and compositing hints.

Estimated code review effort: 4 (Complex) | ~60 minutes

Merge Risk: ⚪ Minimal · up to 50237

This change improves detail-page interaction performance while preserving the documented popover, optimistic-state, invalidation, and realtime behavior; no actionable merge-blocking risk remains beyond normal checks and review.

Suggested reviewers: blurbery, quick104

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 8.11% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 37 functions across 27 files. (1 skipped: … 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 summarizes the main change: improving web item-detail interaction performance by eliminating jank.
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.
Full details: Docstring Coverage

Explanation

Docstring coverage is 8.11% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 37 functions across 27 files. (1 skipped: 1 unsupported.)

  • Fix all pre-merge checks with AI
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

@Rhainland
Rhainland marked this pull request as ready for review August 4, 2026 19:29
@coderabbitai coderabbitai Bot added the v1.0 Silo v1 scope - auto-adds to the Silo v1 project label Aug 4, 2026

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

Actionable comments posted: 6

🧹 Nitpick comments (8)
web/src/components/StarRating.tsx (1)

33-35: 🎯 Functional Correctness | 🔵 Trivial | 💤 Low value

Keep this concern scoped to button radiogroups.

StarRating now has roving focus, but StarRating is the only button radiogroup in the changed code flow. Generalize this when multiple radiogroups need arrow-key focus rotation, rather than introducing the issue here.

🤖 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/StarRating.tsx` around lines 33 - 35, Keep the
roving-focus change scoped to the StarRating button radiogroup: retain the focus
lookup and preventScroll behavior within StarRating, and do not generalize
arrow-key focus rotation into shared radiogroup logic or other components unless
multiple radiogroups require it.

Source: Learnings

web/src/pages/ItemDetail/components/DetailPopover.test.tsx (1)

23-83: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Add coverage for the controlled open path.

The tests exercise only the uncontrolled mode. VersionDropdown and SubtitlesPopover both pass open and onOpenChange, so the controlled branch in setOpen (which must not update internal state) is untested. Add one test that renders with open and asserts onOpenChange receives false on Escape while the dialog stays mounted until the owner flips the prop.

🤖 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/pages/ItemDetail/components/DetailPopover.test.tsx` around lines 23 -
83, The DetailPopover tests cover only uncontrolled behavior; add a
controlled-open test around renderPopover that supplies open and onOpenChange,
dispatches Escape, and verifies onOpenChange is called with false while the
dialog remains mounted because the owner has not changed open. Anchor the test
to the existing Escape handling and controlled setOpen path, preserving the
current focus and close assertions for uncontrolled mode.
web/src/pages/ItemDetail/components/MediaUserActionBar.tsx (1)

33-50: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Both action-bar wrappers depend on mutation result objects instead of mutate. useMutation returns a new result object on every state transition, so the useCallback wrappers in both wrappers gain a new identity whenever isPending changes. Destructure the stable mutate function, and read isPending separately, as handleRatingChange already does with useSetRating.

  • web/src/pages/ItemDetail/components/MediaUserActionBar.tsx#L33-L50: destructure mutate from useWatchedStateMutation, useToggleFavorite, and useToggleWatchlist, and keep isPending from the watched mutation for isUpdatingWatched.
  • web/src/pages/ItemDetail/components/WatchedActionBar.tsx#L15-L19: destructure mutate from useWatchedStateMutation and depend on it in handleToggleWatched, keeping isPending for isUpdatingWatched.
🤖 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/pages/ItemDetail/components/MediaUserActionBar.tsx` around lines 33 -
50, Both action-bar components should depend on stable mutation functions rather
than changing mutation result objects. In
web/src/pages/ItemDetail/components/MediaUserActionBar.tsx lines 33-50,
destructure mutate from useWatchedStateMutation, useToggleFavorite, and
useToggleWatchlist, retain isPending separately for isUpdatingWatched, and
update the callbacks to depend on the destructured functions. In
web/src/pages/ItemDetail/components/WatchedActionBar.tsx lines 15-19,
destructure mutate and isPending from useWatchedStateMutation, use mutate in
handleToggleWatched dependencies, and retain isPending for isUpdatingWatched.
web/src/pages/ItemDetail/components/ActionBar.tsx (1)

282-377: 📐 Maintainability & Code Quality | 🔵 Trivial | 🏗️ Heavy lift

Extract the shared portal positioning and dismissal logic.

Lines 282-377 duplicate DetailPopover.tsx lines 63-158 almost exactly: the same viewportPadding/gap constants, the same flip-above math, the same pointerdown/keydown/focusin/scroll listener set, the same requestAnimationFrame coalescing, and the same focus-restore cleanup. Two copies will drift when positioning or dismissal is later adjusted.

Extract a hook, for example useAnchoredPortal({ open, triggerRef, contentRef, onClose, align }), and consume it from both DetailPopover and this menu. The only real difference is horizontal alignment: DetailPopover aligns to triggerRect.left, and this menu aligns to triggerRect.right - menuRect.width.

🤖 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/pages/ItemDetail/components/ActionBar.tsx` around lines 282 - 377,
Extract the shared anchored-portal positioning, dismissal listeners,
scroll-frame handling, and focus restoration from
positionOverflowMenu/useLayoutEffect and DetailPopover into a reusable hook such
as useAnchoredPortal. Support the existing open state, trigger/content refs,
close callback, and horizontal alignment so DetailPopover preserves left
alignment while the overflow menu preserves right-edge alignment, then replace
both duplicated implementations with the hook.
web/src/hooks/queries/items.test.ts (1)

147-171: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Add coverage for the field-level revert.

This test covers the optimistic write. The new onError handler restores only played and keeps is_favorite and in_watchlist. That branch has no test. Add a case that runs the onError updater against a detail with is_favorite: true and asserts the favorite value survives the revert.

🤖 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/hooks/queries/items.test.ts` around lines 147 - 171, Extend the
watched-state mutation test around useWatchedStateMutation to invoke its onError
handler and apply the item-detail updater to a detail with is_favorite: true.
Assert that the revert restores played while preserving is_favorite (and the
existing in_watchlist field), covering the field-level revert behavior.
web/src/hooks/queries/mediaSurfaceRefresh.test.ts (1)

169-191: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Restore real timers in afterEach.

Four tests call vi.useFakeTimers() and then vi.useRealTimers() as the last statement. If an assertion fails before that last line, fake timers stay installed and every later test in the file inherits them. The original failure is then hidden behind cascading timeouts. Move the restore into an afterEach hook and delete the trailing calls.

♻️ Proposed fix
-import { describe, expect, it, vi } from "vitest";
+import { afterEach, describe, expect, it, vi } from "vitest";
 describe("invalidateMediaSurfaceQueries", () => {
+  afterEach(() => {
+    vi.useRealTimers();
+  });
+
🤖 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/hooks/queries/mediaSurfaceRefresh.test.ts` around lines 169 - 191,
Update the media surface refresh test suite to restore real timers in an
afterEach hook, and remove the trailing vi.useRealTimers calls from the
individual tests that use fake timers. Ensure cleanup runs even when assertions
fail.
web/src/hooks/queries/mediaSurfaceRefresh.ts (1)

157-165: 🚀 Performance & Scalability | 🔵 Trivial | ⚡ Quick win

Hoist surfacePrefixes out of the predicate.

shouldInvalidateMediaSurfaceQuery runs once per cached query on every invalidation pass. This block rebuilds the array and calls adminKeys.playbackHistory({}).slice(0, 2) on each of those calls. Move the list to module scope so it is built once.

The JSON.stringify fallback in queryKeyStartsWith (Lines 131-135) also runs on this hot path. Restrict it to non-primitive key parts.

♻️ Proposed fix
+const MEDIA_SURFACE_PREFIXES = [
+  itemKeys.all,
+  progressKeys.all,
+  historyKeys.all,
+  favoriteKeys.all,
+  watchlistKeys.all,
+  personKeys.all,
+  adminKeys.playbackHistory({}).slice(0, 2),
+];
+
 function shouldInvalidateMediaSurfaceQuery(
-  const surfacePrefixes = [
-    itemKeys.all,
-    progressKeys.all,
-    historyKeys.all,
-    favoriteKeys.all,
-    watchlistKeys.all,
-    personKeys.all,
-    adminKeys.playbackHistory({}).slice(0, 2),
-  ];
-  if (surfacePrefixes.some((prefix) => queryKeyStartsWith(queryKey, prefix))) {
+  if (MEDIA_SURFACE_PREFIXES.some((prefix) => queryKeyStartsWith(queryKey, prefix))) {
     return true;
   }
🤖 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/hooks/queries/mediaSurfaceRefresh.ts` around lines 157 - 165, Hoist
the surfacePrefixes list out of shouldInvalidateMediaSurfaceQuery to module
scope so it is constructed once, preserving all existing key entries including
the sliced adminKeys.playbackHistory value. In queryKeyStartsWith, only use the
JSON.stringify fallback for non-primitive key parts, while retaining direct
comparisons for primitive values.
web/src/hooks/queries/ratingsSurfaceRefresh.ts (1)

27-31: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Consolidate the two prefix-matching helpers.

This startsWith duplicates queryKeyStartsWith in web/src/hooks/queries/mediaSurfaceRefresh.ts (Lines 128-137), but the two use different comparison rules: this one compares with === only, while the other adds a JSON.stringify fallback for non-primitive key parts. If a key prefix later contains an object or array part, the two helpers will disagree.

Export one shared helper and use it in both files.

🤖 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/hooks/queries/ratingsSurfaceRefresh.ts` around lines 27 - 31,
Consolidate the duplicate prefix-matching logic by exporting one shared helper,
preserving the comparison behavior of queryKeyStartsWith including its
JSON.stringify fallback for non-primitive parts. Remove the local startsWith
implementation in ratingsSurfaceRefresh.ts and update both
ratingsSurfaceRefresh.ts and mediaSurfaceRefresh.ts to import and use the shared
helper consistently.
🤖 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 `@web/src/app.css`:
- Around line 1060-1061: Update the fill declarations in both
.star-rating-star[data-filled="true"] svg and the corresponding second location
to use the configured lowercase CSS keyword currentcolor instead of
currentColor, resolving the value-keyword-case violations.

In `@web/src/hooks/queries/mediaSurfaceRefresh.test.ts`:
- Around line 38-40: Update the cancel assertion in the media surface refresh
test to inspect the captured filters argument directly, verifying the predicate
and that revert is not false. Replace the broad expect.any(Object) check while
preserving the existing cancellation behavior.

In `@web/src/hooks/queries/mediaSurfaceRefresh.ts`:
- Around line 221-223: Update the promise chain around
invalidateMediaSurfaceQueries to invoke bumpHomeRefreshSignal in a finally
handler rather than then. Preserve the existing queryClient and mergedOptions
arguments so the Home refresh signal is bumped whether invalidation succeeds or
rejects.

In `@web/src/hooks/queries/ratings.ts`:
- Line 16: Update the snapshots in useSetRating and useDeleteRating to use the
shared item-detail predicate, covering both ["items","detail",itemId] and
["catalog","items",itemId,"detail"] cache shapes. Keep rollback scoped
consistently with cancelItemDetailQueries and updateCatalogItemDetail.

In `@web/src/pages/ItemDetail/components/ActionBar.tsx`:
- Around line 547-560: Gate the overflow trigger Button around
toggleOverflowMenu so it renders only when hasOverflowActions || hasAdminActions
|| hasMetadataActions || Boolean(contentId) is true. Reuse this existing guard
from the portal content and keep the button’s current props and behavior
unchanged when actions are available.

In `@web/src/pages/ItemDetail/DetailHero.tsx`:
- Around line 121-124: Remove the remaining Ken Burns animation assignment from
the backdrop image in DetailHero, including the animation style or class that
applies var(--animate-ken-burns-a). Keep the existing opacity transition and
image layout styling unchanged.

---

Nitpick comments:
In `@web/src/components/StarRating.tsx`:
- Around line 33-35: Keep the roving-focus change scoped to the StarRating
button radiogroup: retain the focus lookup and preventScroll behavior within
StarRating, and do not generalize arrow-key focus rotation into shared
radiogroup logic or other components unless multiple radiogroups require it.

In `@web/src/hooks/queries/items.test.ts`:
- Around line 147-171: Extend the watched-state mutation test around
useWatchedStateMutation to invoke its onError handler and apply the item-detail
updater to a detail with is_favorite: true. Assert that the revert restores
played while preserving is_favorite (and the existing in_watchlist field),
covering the field-level revert behavior.

In `@web/src/hooks/queries/mediaSurfaceRefresh.test.ts`:
- Around line 169-191: Update the media surface refresh test suite to restore
real timers in an afterEach hook, and remove the trailing vi.useRealTimers calls
from the individual tests that use fake timers. Ensure cleanup runs even when
assertions fail.

In `@web/src/hooks/queries/mediaSurfaceRefresh.ts`:
- Around line 157-165: Hoist the surfacePrefixes list out of
shouldInvalidateMediaSurfaceQuery to module scope so it is constructed once,
preserving all existing key entries including the sliced
adminKeys.playbackHistory value. In queryKeyStartsWith, only use the
JSON.stringify fallback for non-primitive key parts, while retaining direct
comparisons for primitive values.

In `@web/src/hooks/queries/ratingsSurfaceRefresh.ts`:
- Around line 27-31: Consolidate the duplicate prefix-matching logic by
exporting one shared helper, preserving the comparison behavior of
queryKeyStartsWith including its JSON.stringify fallback for non-primitive
parts. Remove the local startsWith implementation in ratingsSurfaceRefresh.ts
and update both ratingsSurfaceRefresh.ts and mediaSurfaceRefresh.ts to import
and use the shared helper consistently.

In `@web/src/pages/ItemDetail/components/ActionBar.tsx`:
- Around line 282-377: Extract the shared anchored-portal positioning, dismissal
listeners, scroll-frame handling, and focus restoration from
positionOverflowMenu/useLayoutEffect and DetailPopover into a reusable hook such
as useAnchoredPortal. Support the existing open state, trigger/content refs,
close callback, and horizontal alignment so DetailPopover preserves left
alignment while the overflow menu preserves right-edge alignment, then replace
both duplicated implementations with the hook.

In `@web/src/pages/ItemDetail/components/DetailPopover.test.tsx`:
- Around line 23-83: The DetailPopover tests cover only uncontrolled behavior;
add a controlled-open test around renderPopover that supplies open and
onOpenChange, dispatches Escape, and verifies onOpenChange is called with false
while the dialog remains mounted because the owner has not changed open. Anchor
the test to the existing Escape handling and controlled setOpen path, preserving
the current focus and close assertions for uncontrolled mode.

In `@web/src/pages/ItemDetail/components/MediaUserActionBar.tsx`:
- Around line 33-50: Both action-bar components should depend on stable mutation
functions rather than changing mutation result objects. In
web/src/pages/ItemDetail/components/MediaUserActionBar.tsx lines 33-50,
destructure mutate from useWatchedStateMutation, useToggleFavorite, and
useToggleWatchlist, retain isPending separately for isUpdatingWatched, and
update the callbacks to depend on the destructured functions. In
web/src/pages/ItemDetail/components/WatchedActionBar.tsx lines 15-19,
destructure mutate and isPending from useWatchedStateMutation, use mutate in
handleToggleWatched dependencies, and retain isPending for isUpdatingWatched.
🪄 Autofix

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: ab527966-9e79-495a-afae-aaa529a488b2

📥 Commits

Reviewing files that changed from the base of the PR and between 8bde6f1 and 27f28e6.

📒 Files selected for processing (25)
  • web/src/app.css
  • web/src/components/CastCarousel.tsx
  • web/src/components/RealtimeEventsProvider.test.tsx
  • web/src/components/RealtimeEventsProvider.tsx
  • web/src/components/StarRating.tsx
  • web/src/hooks/queries/favorites.ts
  • web/src/hooks/queries/items.test.ts
  • web/src/hooks/queries/items.ts
  • web/src/hooks/queries/mediaSurfaceRefresh.test.ts
  • web/src/hooks/queries/mediaSurfaceRefresh.ts
  • web/src/hooks/queries/ratings.ts
  • web/src/hooks/queries/ratingsSurfaceRefresh.test.ts
  • web/src/hooks/queries/ratingsSurfaceRefresh.ts
  • web/src/hooks/queries/watchlist.ts
  • web/src/pages/ItemDetail/DetailHero.tsx
  • web/src/pages/ItemDetail/EpisodeContent.tsx
  • web/src/pages/ItemDetail/MovieContent.tsx
  • web/src/pages/ItemDetail/components/ActionBar.tsx
  • web/src/pages/ItemDetail/components/AudioTracksPopover.tsx
  • web/src/pages/ItemDetail/components/DetailPopover.test.tsx
  • web/src/pages/ItemDetail/components/DetailPopover.tsx
  • web/src/pages/ItemDetail/components/MediaUserActionBar.tsx
  • web/src/pages/ItemDetail/components/SubtitlesPopover.tsx
  • web/src/pages/ItemDetail/components/VersionDropdown.tsx
  • web/src/pages/ItemDetail/components/WatchedActionBar.tsx

Comment thread web/src/app.css Resolved
Comment thread web/src/hooks/queries/ratings.ts Resolved
Comment thread web/src/pages/ItemDetail/DetailHero.tsx Resolved
@Rhainland

Copy link
Copy Markdown
Contributor Author

Review-body follow-up for commit 2bc0aa2:

  • StarRating focus scope: already satisfied; the roving-focus behavior remains local to StarRating.
  • Controlled DetailPopover coverage: added an Escape test proving onOpenChange(false) is requested without mutating owner-controlled open state.
  • Stable mutation callbacks: addressed in MediaUserActionBar and WatchedActionBar by depending on destructured mutate functions and retaining isPending separately.
  • Watched rollback coverage: added coverage proving played is reverted while favorite and watchlist state survive.
  • Fake timer cleanup: moved real-timer restoration into afterEach.
  • Media-surface hot predicate: hoisted the static prefix list and limited structural serialization to non-primitive key parts.
  • Shared anchored-portal hook: intentionally deferred. The duplication is real, but refactoring the newly verified positioning, dismissal, focus, and scroll paths here would add regression risk unrelated to the requested fixes.
  • Shared prefix helper: intentionally deferred. ratingsSurfaceRefresh currently uses primitive-only prefixes, so the simpler identity comparison is correct and exporting the heavier structural matcher would add coupling without changing behavior.
  • Generic docstring coverage warning: no change; mass documentation additions would not improve this focused frontend performance patch.

Validation: 30 focused tests pass, production build passes, Prettier passes, ESLint reports 0 errors and 157 pre-existing warnings. Local browser smoke testing confirmed no hero animation, a working overflow menu and Escape dismissal, and no console errors.

@coderabbitai coderabbitai Bot removed the v1.0 Silo v1 scope - auto-adds to the Silo v1 project label Aug 4, 2026

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

Actionable comments posted: 1

🤖 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 `@web/src/pages/ItemDetail/components/DetailPopover.test.tsx`:
- Around line 89-90: Update the DetailPopover controlled-close test to assert
that the dialog remains visible, not merely present in the document, after
onOpenChange(false). Also preserve the popover position while controlledOpen
remains true, clearing it only when the controlling owner actually closes the
popover.
🪄 Autofix

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: c22da8af-0e99-456b-9a65-aa11919c9263

📥 Commits

Reviewing files that changed from the base of the PR and between 27f28e6 and 2bc0aa2.

📒 Files selected for processing (11)
  • web/src/app.css
  • web/src/hooks/queries/items.test.ts
  • web/src/hooks/queries/mediaSurfaceRefresh.test.ts
  • web/src/hooks/queries/mediaSurfaceRefresh.ts
  • web/src/hooks/queries/ratings.test.ts
  • web/src/hooks/queries/ratings.ts
  • web/src/pages/ItemDetail/DetailHero.tsx
  • web/src/pages/ItemDetail/components/ActionBar.tsx
  • web/src/pages/ItemDetail/components/DetailPopover.test.tsx
  • web/src/pages/ItemDetail/components/MediaUserActionBar.tsx
  • web/src/pages/ItemDetail/components/WatchedActionBar.tsx
💤 Files with no reviewable changes (1)
  • web/src/pages/ItemDetail/DetailHero.tsx
🚧 Files skipped from review as they are similar to previous changes (8)
  • web/src/hooks/queries/ratings.ts
  • web/src/hooks/queries/mediaSurfaceRefresh.test.ts
  • web/src/pages/ItemDetail/components/WatchedActionBar.tsx
  • web/src/pages/ItemDetail/components/MediaUserActionBar.tsx
  • web/src/hooks/queries/items.test.ts
  • web/src/hooks/queries/mediaSurfaceRefresh.ts
  • web/src/pages/ItemDetail/components/ActionBar.tsx
  • web/src/app.css

Rhainland and others added 4 commits August 27, 2026 18:34
- keep main's library-collection invalidation scope in the surface-refresh predicate
- keep main's compositor-only hover classes and MediaActionIcon menu icons
- adopt main's longest-entry overflow menu sizing
- retarget the home refresh signal test at mediaSurfaceKeys.refreshSignal
- align StarRating and ActionBar tests with the CSS-driven hover design
@Quick104
Quick104 force-pushed the perf/web-performance-pass2 branch from 6ad4504 to 5023781 Compare August 27, 2026 22:42
@coderabbitai

coderabbitai Bot commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

Note

GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer.

@Quick104

Copy link
Copy Markdown
Contributor

Rebased onto current main (3242f768) and pushed. Main had moved ~150 web commits since this branch was cut, so beyond mechanical conflict resolution there is one reconciliation commit (5023781) with these calls:

  • Surface refresh: kept this PR's single-predicate invalidateMediaSurfaceQueries + coalescing scheduler, and folded main's newer library-collection invalidation scope (libraryCollectionKeys, library-scoped) into the predicate. The home refresh signal now uses main's mediaSurfaceKeys.refreshSignal() key.
  • Watched mutation: kept this PR's field-only optimistic revert (preserves concurrent favorite/watchlist optimistic state) over main's later whole-snapshot rollback; adapted main's test accordingly.
  • ActionBar: kept this PR's portal overflow menu (gated behind hasOverflowMenuItems), grafted in main's MediaActionIcon menu icons and longest-entry (w-max) menu sizing, and kept main's compositor-only hover classes (transform-gpu scale) on the play/watched buttons. Dropped this PR's blanket transition: none CSS on detail action-bar buttons since it would have killed main's compositor hover; the opaque .glass-subtle override (no live backdrop-filter) stays.
  • StarRating: kept this PR's CSS-only hover preview; rewrote main's later JS-hover test against the data-filled/CSS contract.

Validation: pnpm run build clean, full make test-web suite passes (298 files / 2218 tests), pnpm run lint 0 errors (warnings pre-existing), Prettier clean.

Rebase and reconciliation performed with Claude Code at the maintainer's request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants