Skip to content

perf(web): render home rows without mounting every card up front - #2288

Merged
Quick104 merged 2 commits into
mainfrom
perf/web-home-row-rendering
Oct 11, 2026
Merged

Quick104 merged 2 commits into
mainfrom
perf/web-home-row-rendering

Conversation

@Quick104

@Quick104 Quick104 commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor

Problem

Related issue: N/A
Validation tasks: changes #1142 C1, C3 (rows render the same items; not yet run)

The web Home page mounts every card in every row as soon as the row's data arrives, and each card mounts its full menu machinery: six mutation hooks, a Radix menu, profile queries, and two to four links with router hooks. With rows of 40–100 items this is thousands of DOM nodes and hundreds of milliseconds of main-thread work before the first row appears. Rows also re-render whenever another row's data arrives. This change makes a row cost roughly what is on screen.

Approach

  • Card windowing. Rows built by SectionRow mount the cards that fit the viewport plus two. The others render as empty slides with the card's exact width, so the carousel's snaps and scroll width don't change. They fill in eight at a time while the browser is idle (a timer on Safari), immediately when they scroll within half a row of view, and all at once when focus enters the row. After about a second every card exists, so browser Find and screen readers still reach the whole row.
  • Menus mount on first use. The menu trigger and quick-action buttons render as before. The Radix menu, mutations, and dialogs mount on the card's first hover, focus, context menu, or long-press; a press before that is queued and runs once they mount. The trigger keeps Radix's aria attributes and focus return.
  • Fewer re-renders. DeferredHomeSection, SectionRow, and both card types are memoized; the scroll arrows appearing no longer re-renders every slide; spoiler preferences are read once per row.
  • First paint. The two eager rows are chosen by layout position rather than load order and render in the same commit their data arrives. The first row's visible posters load eagerly at high priority with no fade, unless a hero banner is present.

Validation

  • tsc -b, pnpm run lint (0 errors), pnpm run format:check, pnpm run build, pnpm run budget:check: pass.
  • make test-web: 849 files, 7,425 tests pass. New tests cover windowing (placeholders, idle fill, scroll and focus fill, no re-render of unchanged slides), the lazy menu (opens on the first click, keyboard open focuses the first item, quick action before mount), and Home's eager rows.
  • In headless Chromium against a test server: the card menu opens with all actions, Escape returns focus to the trigger, rows fill in completely after scrolling, and the page logs no errors.

Evidence

Measured together with the companion loading PR (#2289) in headless Chromium, fresh tab, medians of 5 runs; this PR's share was not measured on its own:

Rows of 100, local network Before After
LCP 720 ms 308 ms
Long tasks during load 263 ms 0

The page looks the same once loaded; cards beyond the viewport fill in within about a second. Surface and build: web app, desktop, this branch with the loading PR.

Risks

  • Cards still filling in are missing from Find and the accessibility tree for about the first second.
  • If a row refreshes with the same length but a different item, the swapped-in empty slide fills on idle or focus rather than on scroll.
  • The menu trigger copies Radix's trigger and focus rules; a Radix upgrade that changes them could drift. Touch long-press was checked by reading Radix's code, not on a device.
  • View transitions were not checked in a real browser; the links themselves are unchanged.

Checklist

  • I read and can explain the complete diff.
  • This pull request addresses one concern.
  • The Evidence section shows every change a user can see, or says there is none.

AI Disclosure

  • Harness: Claude Code (Claude Agent SDK), running in T3 Code
  • Tool(s): Claude Code, including Claude Code subagents
  • Model(s): claude-opus-5-5
  • Involvement: Fully AI-generated, at a maintainer's direction; maintainer review pending
  • Adversarial review: a separate Claude Code subagent reviewed windowing (keys, carousel re-init, keyboard and TV navigation, Find, idle callbacks on unmount), the lazy menu (first open by click, key, long-press, and context menu; aria; focus return), and memo correctness. It found no bugs in this PR's files; its notes are under Risks.

🤖 Generated with Claude Code

Each home row now mounts the cards that fit the viewport and fills in the
rest while the browser is idle, when they scroll into view, or when focus
enters the row; placeholders keep the carousel's geometry. A card's menu
mounts on first hover, focus, long-press, or context menu. Rows and cards
are memoized, eager rows render in the commit their data arrives, and the
first row's visible posters load eagerly at high priority.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@silo-kody

silo-kody Bot commented Oct 11, 2026 •

Copy link
Copy Markdown

Silo Kody — review complete

Review finished. Check the inline comments for findings and verify each suggestion against the code and tests.

Reviewing changes in Silo
  • Include the related issue, expected behavior, and validation steps in the PR description.
  • For API changes, describe the effect on Apple and Android clients and Jellyfin compatibility.
  • For plugin changes, identify the affected SDK contract, plugin, and catalog entry.
  • Follow this repository's AGENTS.md and CONTRIBUTING.md.
  • Request another review with @kody start-review in a PR comment.
  • React with 👍 or 👎 to give feedback on individual suggestions.
Review settings
Review Options

The following review options are enabled or disabled:

Options Enabled
Bug ✅
Performance ✅
Security ✅
Business Logic ❌

@coderabbitai

coderabbitai Bot commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: b69f4320-5da7-4f68-8c30-4fe10c171680

📥 Commits

Reviewing files that changed from the base of the PR and between b78c1ff and 178b172.


📒 Files selected for processing (14)
  • web/src/components/ContinueWatchingCard.tsx
  • web/src/components/MediaCardArtwork.tsx
  • web/src/components/MediaCarousel.test.tsx
  • web/src/components/MediaCarousel.tsx
  • web/src/components/MediaItemMenu.test.tsx
  • web/src/components/MediaItemMenu.tsx
  • web/src/components/SectionItemCard.tsx
  • web/src/components/SectionRow.tsx
  • web/src/components/overlays/CardOverlays.tsx
  • web/src/hooks/useEpisodeSpoilerPrefs.ts
  • web/src/lib/carouselWindow.ts
  • web/src/lib/uiCustomization.ts
  • web/src/pages/Home.test.tsx
  • web/src/pages/Home.tsx

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 2 remain after this review.



📝 Walkthrough

Walkthrough

This pull request adds windowed rendering for carousels, priority loading for selected card artwork, and layout-based Home row rendering. It also defers media-menu action machinery until interaction and adds tests for carousel windowing, Home row placement, and menu activation.

Changes

Home Carousel and Card Loading

Layer / File(s) Summary
Carousel sizing and windowed slide rendering
web/src/lib/carouselWindow.ts, web/src/lib/uiCustomization.ts, web/src/components/MediaCarousel.tsx, web/src/components/MediaCarousel.test.tsx
Sizing helpers calculate visible slide counts and idle tasks. The carousel initially renders a configured window, then mounts more slides through idle work, viewport intersection, or focus. Tests cover mounting behavior and slide identity.
Card and row priority wiring
web/src/components/ContinueWatchingCard.tsx, web/src/components/MediaCardArtwork.tsx, web/src/components/SectionItemCard.tsx, web/src/components/SectionRow.tsx, web/src/hooks/useEpisodeSpoilerPrefs.ts, web/src/components/overlays/CardOverlays.tsx
Rows pass priority to visible cards and share spoiler preferences across Continue Watching cards. Prioritized artwork loads eagerly with high fetch priority. The container-query support check caches its result for the current CSS object.
Home row placement and priority
web/src/pages/Home.tsx, web/src/pages/Home.test.tsx
Home assigns eager priority using row layout position and passes it to SectionRow. Tests cover row placeholders and priority values.

Media Menu Activation and Actions

Layer / File(s) Summary
Dropdown and action engine
web/src/components/MediaItemMenu.tsx
The dropdown controls focus behavior, while a separate engine hosts actions and overlays. The engine reports pending states and drains queued requests after mounting.
Lazy mounting and interaction routing
web/src/components/MediaItemMenu.tsx, web/src/components/MediaItemMenu.test.tsx
Interactions mount the menu machinery and route quick actions through the engine. Tests cover trigger activation, focus, ARIA state, and deferred mounting.

Priority: ➖ Normal

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

Change: Refactor

Sequence Diagram(s)

sequenceDiagram
  participant Home
  participant SectionRow
  participant MediaCarousel
  participant CardArtwork
  Home->>SectionRow: Pass row priority
  SectionRow->>MediaCarousel: Pass windowing settings and card slides
  MediaCarousel->>CardArtwork: Render initially mounted slides
  MediaCarousel->>CardArtwork: Render slides as the window expands
Loading

Suggested reviewers: blurbery, rhainland


Merge Risk: 🔵 Low · up to 178b1

This change makes Home rows faster by rendering only the cards near the viewport at first and loading card menus on demand. No concrete defect has been confirmed. However, cards that have not yet filled in are briefly missing from Find and from screen readers, and touch long-press has not been tested on a real device. These are acceptable to merge as long as the owner is aware of them.

Pre-merge checks | Passed 4 | Failed 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 28.57% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 35 functions across 14 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description check Passed The description directly explains the Home row windowing, lazy menu mounting, memoization, eager loading, validation, evidence, and risks described in the changeset.
Title check Passed The title clearly and concisely describes the main performance change: Home rows no longer mount every card up front.
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.

  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR


🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 11, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-11T21:32:52.920700Z 178b172 New commits
🔒 Security Review ✅ Completed 2026-10-11T21:32:01.499303Z 178b172 New commits
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@silo-triage silo-triage Bot added enhancement New feature or request evidence-required Needs before-and-after evidence before the Evidence check passes impact: polish Annoyance, cosmetic, or nice-to-have javascript Pull requests that update javascript code priority: P2 Limited scope, workaround exists, or polish labels Oct 11, 2026
@silo-triage

silo-triage Bot commented Oct 11, 2026

Copy link
Copy Markdown

The timing table measures both PRs together, but does not show progressive card filling or the lazy menu's first-open and focus behavior. Please add before/after Home captures with the same data at desktop and phone widths (or show mobile is unaffected), plus a short recording of row filling and menu opening/focus return. Name the builds, including whether #2289 is applied.

Comment thread web/src/components/MediaItemMenu.tsx Resolved
Screen readers and element.click() send only a click event, which the
replacement menu trigger ignored. A click not preceded by a pointer press
now toggles the menu, without toggling twice for mouse, Enter, or Space.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@silo-kody

silo-kody Bot commented Oct 11, 2026 •

Copy link
Copy Markdown

Silo Kody — review complete

Review finished. Check the inline comments for findings and verify each suggestion against the code and tests.

Reviewing changes in Silo
  • Include the related issue, expected behavior, and validation steps in the PR description.
  • For API changes, describe the effect on Apple and Android clients and Jellyfin compatibility.
  • For plugin changes, identify the affected SDK contract, plugin, and catalog entry.
  • Follow this repository's AGENTS.md and CONTRIBUTING.md.
  • Request another review with @kody start-review in a PR comment.
  • React with 👍 or 👎 to give feedback on individual suggestions.
Review settings
Review Options

The following review options are enabled or disabled:

Options Enabled
Bug ✅
Performance ✅
Security ✅
Business Logic ❌

@Quick104
Quick104 merged commit fee2f04 into main Oct 11, 2026
23 of 24 checks passed
@Quick104
Quick104 deleted the perf/web-home-row-rendering branch October 11, 2026 22:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request evidence-required Needs before-and-after evidence before the Evidence check passes impact: polish Annoyance, cosmetic, or nice-to-have javascript Pull requests that update javascript code priority: P2 Limited scope, workaround exists, or polish

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant