Skip to content

perf(home): make ResolvedSection Equatable so unchanged Home reloads don't re-render every row #10

Closed

Description

@Artic0din

Problem

HomeViewModel.sections holds [ResolvedSection], and ResolvedSection is not Equatable. @Observable can't skip a no-change assignment, so every loadSections() (debounced watch-state refreshes, returning from the player) re-renders Home even when the server returns the same rows. HomeFeedRow takes the whole section plus fresh closures, so every row body re-runs too.

Where

Proposed fix

Add Equatable conformance (its members SectionItem and SectionCollectionCard are already Hashable, so it can be synthesized). Optionally guard the assignment with if new != sections.

Estimated effort: S

Source

Found in a SwiftUI best-practice review of main at 71a3beb (code reading only; not built or profiled). Line numbers and confirmation are in the triage comment.

ELI5

The home screen redraws everything even when nothing changed. Letting the app compare old and new rows lets it skip that work.

Activity

  1. added
    needs-triage
    on Nov 21, 2026
  2. Artic0din commented on Nov 21, 2026

    @Artic0din
    OwnerAuthor

    Triage

    Verdict: Confirmed on main 71a3beb by reading the code (not profiled). ResolvedSection is not Equatable, so every assignment to HomeViewModel.sections notifies observers, even when the server sends the same rows. I did not measure how much rendering that costs.

    What I checked

    Duplicates

    Not a duplicate. I searched fork and upstream for "ResolvedSection", "Equatable", "Home re-render" and "Home refresh". Related: #48 (the tvOS feed deep-compares section items each body pass and proposes a revision counter instead; the two approaches should agree), #47 (per-row flag computation in HomeFeedRow), #5 (tvOS Home showing stale progress, a correctness problem, not this one). Redundancy check: no Equatable conformance or extension for ResolvedSection anywhere at head. No .out-of-scope/ directory.

    Agent Brief

    Category: enhancement

    Summary: Make ResolvedSection Equatable so reloading Home with unchanged rows doesn't notify observers.

    Current behavior: Every Home load and cache hydrate assigns a fresh array of sections. Because the section type can't be compared, observation treats each assignment as a change and Home re-renders, even when nothing changed.

    Desired behavior: Assigning a sections array equal to the current one sends no change notification. Any real difference, including a changed watch position, title, item order or collection card, still notifies and re-renders.

    Key interfaces:

    • ResolvedSection: add synthesized Equatable conformance. Don't add a custom == that compares only IDs.
    • HomeViewModel.sections: no API change. An explicit inequality guard before assignment is optional.

    Acceptance criteria:

    • ResolvedSection conforms to Equatable with field-by-field equality.
    • A unit test using observation tracking shows that assigning an equal sections array to HomeViewModel does not fire the change handler.
    • A unit test shows that a section differing only in one item's watch position does fire it.
    • Existing Home and section tests pass on iOS, tvOS and macOS.

    Out of scope:

    Triaged against main 71a3beb on 21 Nov 2026.

  3. added
    enhancement
    ready-for-agent
    and removed
    needs-triage
    on Nov 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementready-for-agent

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions