Files
buzz/mobile/lib
Wes 52aa37a929 perf(mobile): stop an open chat rebuilding on other channels' events (#8456)
## Summary

While a chat is open, a message in any other channel rebuilt every built
row of that chat. There were two causes:

- **The chat watched the whole channel list.** `channelsProvider`
republishes the list on every live event in any channel. The chat page,
its message list and the thread page watched all of it. They now watch
only their own channel's entry. The `#channel` name map comes from a new
`channelIdsByNameProvider`, which notifies only when a channel name or
id changes.
- **The root `App` rebuilt often, and each rebuild rebuilt every pushed
route.** It watched the agent observer and the user-status cache only to
keep them alive, and it watched the whole Me unread set. It now listens
to the first two and selects only whether Me has unread.

Rows still remount when a message arrives in the open channel. That
comes from `scrollable_positioned_list` keying rows by index, and it
gets its own PR.

## Before and after

Setup:
- iPhone 18 Pro simulator, debug build.
- Local relay with about 120 ms of added round-trip time.
- Seeded community: 120 channels, about 5.5k messages, a busy chat of
about 1.4k messages.
- The same scripted run on `main` at `5730c83f7` and on this branch,
counted with local probes that are not part of this PR.
- Counts are exact. Debug milliseconds are only useful for comparing the
two runs.

10 messages arrive in another channel while the busy chat is open:

| | `main` | this PR |
|---|---|---|
| Chat page rebuilds | 42 | 0 |
| Message row rebuilds | 1,218 | 0 |
| Frames with build time over 16.7 ms | 42 of 129 | 0 of 10 |
| Worst frame build time (debug) | 78 ms | 13 ms |

5 messages arrive in the open chat: 1,300 row rebuilds on `main`, 693 on
this PR. Most of the rest are the remounts from the index-keyed list.

## Test

A widget test publishes a new channel list where only another channel
changed, and fails if any `MessageContent` rebuilds. Reverting the
production change makes it fail.

## Validation

- `just mobile-check`
- Full mobile suite: 3,532 passed.
- The simulator run above.

**Human test:** Wes ran #8456, #8460 and #8462 together on the simulator
with his real account and confirmed they work.

buzz-review-completed

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Signed-off-by: Wes <wesbillman@users.noreply.github.com>
Co-authored-by: Carl <32a2e2c9d428ee08902cab75d956da2c1d235a22d4766b0dd4138bf6e2e5db1d@buzz.block.builderlab.xyz>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-19 16:09:52 -06:00
..