Skip to content

perf(mobile): memoize worktree list rows - #9889

Merged
nwparker merged 1 commit into
mainfrom
nwparker/perf-mobile-row-memo
Jul 22, 2026
Merged

nwparker merged 1 commit into
mainfrom
nwparker/perf-mobile-row-memo

Conversation

@nwparker

@nwparker nwparker commented Jul 22, 2026 •

Copy link
Copy Markdown
Contributor

What

The mobile host worktree list rows (WorktreeListRow, WorktreeAgentRow) were not memoized, so any unrelated parent re-render reconciled every visible row — noticeable on large lists / the tablet sidebar. #9857 already preserves the worktree-array identity on equal snapshots, but the rows still re-rendered because the parent did.

Fix: wrap both rows in React.memo (default shallow comparison) and stabilize the one prop that defeated it — onToggleLineage is now a useCallback that reads the worktree id from the row's item, instead of an inline per-row closure. The now prop stays a real prop so relative timestamps / status aging still update.

ELI5

Your worktree list re-drew every single row whenever anything on the screen changed. Now each row only re-draws when its own data (status, preview, unread, agents…) actually changes.

Proof of zero regression

  • Default shallow memo comparison — no custom comparator — so every live field (preview, unread, lastOutputAt, agents, status, now) still invalidates the row. perf(mobile): gate host polling on foreground/background #9857's snapshot equality keeps the item reference stable only when nothing changed, so the memo bailout is safe and effective.
  • Prop-stability audited: item (snapshot-stable), primitives (now/status/repoColor/hideRepo/isReadOnly), repoIcon (state-owned map), onPress/onLongPress (stable), and the new useCallback onToggleLineage.
  • Tests: a new render-count test (converted to the mobile .ts + createElement convention) proves an unrelated sibling render does not re-render the row, while preview/unread/lastOutputAt/agents/status/now changes do — and agent rows skip unchanged props but render for a changed agent. Full mobile suite 307 files / 2229 pass; typecheck / oxlint (index.tsx stays within its max-lines budget) / oxfmt --check clean.

Proof of perf improvement

Cuts row reconciliation on unrelated parent renders (which fire frequently on a live dashboard) — low-medium JS-thread savings that scale with list length, most visible on the tablet sidebar. The test directly asserts the row render count stays flat across an unrelated sibling update.

Made with Orca 🐋

@coderabbitai

coderabbitai Bot commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

@nwparker, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 4 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: ebd95538-dfc2-4b31-a1ab-b89d452880dd

📥 Commits

Reviewing files that changed from the base of the PR and between e600600 and ddff189.

📒 Files selected for processing (4)
  • mobile/app/h/[hostId]/index.tsx
  • mobile/src/components/WorktreeAgentRow.tsx
  • mobile/src/components/WorktreeListRow.test.ts
  • mobile/src/components/WorktreeListRow.tsx

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.

@nwparker
nwparker merged commit c6d2803 into main Jul 22, 2026
3 checks passed
@nwparker
nwparker deleted the nwparker/perf-mobile-row-memo branch July 22, 2026 21:13
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
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