mirror of
https://github.com/block/buzz.git
synced 2026-11-14 13:21:02 +00:00
Every channel view read the channel's member roster (kind 39002) twice: once for the member list (`channelMembersProvider`) and once for bot roles (`channelBotPubkeysProvider`, which feeds agent mention styling). Both sent the same `kinds:[39002] #d:[channel] limit:1` query, and both re-ran it on every roster update. Screens that show messages from several channels did this per channel: opening Activity read 10 rosters twice each. Bot roles now come from `channelMembersProvider`, so each channel's roster is fetched once. While the relay is disconnected, bot roles now come from the member list's last loaded roster instead of going empty, so agent mentions keep their styling offline. ### Validation New test: watching both the member list and bot roles for a channel fetches the roster once and both report the bot. It fails without this change (two fetches). The existing bot-role tests (live updates, subscription cleanup, working bots) pass unchanged. The channel page test for a bot-role replay used a fixed member list alongside live bot roles, which can no longer differ; it now reads both from its fake relay. Full mobile test suite and `flutter analyze` pass. On an iPhone 12 mini signed in to Block's Builderlab (instrumented profile build), opening Activity right after launch read 10 channel rosters once each (25.7 KB) instead of twice (51.5 KB), and opening a channel read its roster once instead of twice. Agent messages kept their agent styling. The same automated run covered cold start, opening and scrolling Activity, scrolling the home list, opening buzz-mobile-tomb-review (a channel with agent members) and returning home. ### Regressions None expected. Bot roles now refresh when the member list does (on roster updates and after a reconnect) rather than on every relay session state change, which only drops redundant refetches. Signed-off-by: Tom Brow <tomb@squareup.com> Co-authored-by: Tom Brow <tomb@squareup.com> Co-authored-by: studio <dc2fc481343672df31a689840c09299972e704dac592e0da6f18486646a7ee3e@buzz.block.builderlab.xyz>