Search and invite recovery read a community's open-channel directory (every open, listed channel's kind 39000 metadata) from the relay, and match names on the device. Until now the app kept that directory in memory for 30 seconds only, so every search session after that, and the first search after every launch, downloaded the whole directory again. This follows [#9466 directory-only search load](https://github.com/block/buzz/pull/9466) and [#9457 directory keeps message times](https://github.com/block/buzz/pull/9457), which made each of those downloads cheaper; this one makes most of them unnecessary. Now the directory is saved in a file per community and account, next to the image cache, and search reads it from there: - **What's saved.** Only the latest revision of each open, listed, non-DM channel. The relay's directory read also returns the user's own private, unlisted and DM channels; those are never held or saved as the directory, and a channel whose latest revision is no longer discoverable drops out. - **First read.** The first time search opens, the app downloads the whole directory, as before, and saves it. - **Catch-up.** When search opens later, it shows the saved copy at once. At most once a minute, it asks the relay in the background only for directory changes since the newest saved one, or since the last read started by the device clock if that is earlier (less a minute of overlap), and merges them in. The relay can stamp a busy channel's metadata minutes ahead of wall time, so the newest saved stamp alone could skip channels created meanwhile. A catch-up that brings back nothing new saves nothing and leaves the list alone, and a search opened while a background read is still running shares it rather than starting another. - **Offline open.** A search opened before the session connects shows the saved copy and runs its check on the next connect. - **Daily full read.** Once the last full read is a day old (or dated in the future, by a clock since set back), the next check downloads the whole directory in the background and replaces the saved copy, which drops channels that became private or unlisted or were deleted. A catch-up can't see those: the relay never serves them to a non-member. - **Gone on open.** Opening a saved result that the relay no longer serves (private or deleted) drops it from the directory at once, and no directory read already in flight (background check, list refresh or Retry) brings it back. A restore from disk never overrides a full read already running, and a background read never displaces one. - **Invite recovery** still downloads the whole directory, as on main: it needs fresh memberships, and its read also refreshes the saved copy. - **Cleanup.** Signing out of a community, replacing its account, or leaving it deletes the file. The saved events omit signatures (the relay signed them; the copy is a cache of what it served). The file's JSON is encoded and decoded off the UI isolate, and an unavailable caches directory (or one that takes over 3 seconds) just means no saved copy. A file that is unreadable, from another version, or over 20,000 channels or 16 MiB is discarded and read again from the relay. There is no relay change. `CONTEXT.md` gains an "Open-channel directory" entry. ### Validation | Workflow (small community, 63 open channels) | Directory bytes before | Directory bytes after | | --- | --- | --- | | First search after install | 39.5 KB (2 requests) | 39.5 KB (2 requests) | | Search again 2 minutes later | 39.5 KB (2 requests) | 0.6 KB (2 requests) | | Relaunch, then search | 39.5 KB (2 requests) | 0.6 KB (2 requests) | Measured on an iOS simulator signed in to a test community, with a temporary local counter on each relay query response (not part of this PR), main at [6974237](69742376a9) vs this branch. The full read grows with the number of open channels (about 600 bytes each); the catch-up grows only with what changed. Search results were identical on both builds, and opening an unjoined result from the saved directory still showed its preview with Join. Tests: - A journey test drives the real channel list against a fake relay that honors `since`, with a real file and a fake clock: the first reader saves the directory without signatures; more readers within a minute ask nothing; a minute later a reader asks only for changes since the newest saved one less a minute; after a relaunch the saved copy serves at once and the catch-up starts from it; a channel that turned private stays until the daily full read replaces the copy; the search status never shows loading for the background reads; a catch-up of only held events leaves the list identical and the file unwritten; a second search a minute into a slow full read shares it; and opening a channel the relay no longer serves drops it, even with a read in flight. Each guard was checked by breaking it: removing the once-a-minute limit, dropping `since`, never doing the full read, merging the full read instead of replacing, removing the drop-on-open, the no-change check, the shared in-flight read, or the in-flight drop fence each fail the test. - Focused cases against the same fake relay and real file, each checked by breaking its guard: member-only private, unlisted and DM metadata is never saved, and a saved channel that turns private drops out on catch-up; a catch-up starts no later than the last read's start, across a relaunch, so a channel created after a burst-stamped one is found; a full read or check dated in the future by a clock set back is due; a search opened before the session connects checks on connect; a restore leaves a running full read's status alone and is not displaced by a catch-up; a list or Retry full read in flight does not bring back a channel dropped on open. - Storage tests: the round trip omits signatures; unusable data is discarded; a directory over the bounds leaves no stale copy; a closed store neither reads nor writes; cleanup keeps only each community's current account and its save in progress. - The community test now also checks that replacing an account deletes the old account's saved directory (fails without the cleanup call). - Full mobile test suite and `flutter analyze` pass. No visible change, so no screenshots: the same results appear, just without a download on later searches. ### Regressions - A channel that turns private or is deleted can still appear in search for up to a day, until the daily full read, unless you open it (the first open in a session asks the relay, drops it at once, and the relay withholds its content). A channel already previewed earlier in the same session reopens from its cached details without asking the relay, so it stays until the daily read or a relaunch. Before, it disappeared from the next search at least 30 seconds later. - A channel that turns unlisted can also appear in search for up to a day. Opening it does not drop it, and its content stays readable, because the relay serves an unlisted open channel to anyone who names it. - A channel created while search is open appears the next time search opens, not while it stays open. That was already the case within the 30-second window. - The saved file costs some disk per community (about 30 KB for 63 channels, roughly 0.5 KB per channel), deleted on sign-out or leaving. --------- 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>
5.0 KiB
Buzz domain language
Shared terminology for Buzz product behavior. This glossary currently covers mobile push suppression, the notification body, mobile builds, sharing, quick send and the open-channel directory; it is not a complete model of Buzz.
Notifications
Mobile push notification
A notification directed to a user's mobile installation through the platform's push service.
Notification body
The text a mobile push notification shows for a message: the message's text with its Markdown syntax removed, cut only where the platform would cut it. See ADR 0002.
Push suppression
Withholding an otherwise eligible mobile push notification based on desktop activity and a working connection to the relevant community. It does not depend on whether desktop alerts can be shown.
Avoid: Read receipt, mark as read, mute
Desktop activity
User interaction with the computer running Buzz, including interaction with another application. It is the interaction itself, not a state that lasts afterward, and does not imply that a particular Buzz message was displayed or read.
Avoid: Message visibility, read activity
In-app activity
User interaction inside Buzz. Recent in-app activity remains evidence of desktop activity after Buzz loses focus; current window focus is a separate condition.
Desktop inactivity
The state reached when the duration specified in the spec has elapsed since the last observed desktop activity.
Additional notification delay
A waiting period after desktop inactivity begins before mobile push notifications resume. This is distinct from the inactivity threshold itself.
Suppressed message
A message whose otherwise eligible mobile push notification was withheld. The term refers to its notification, not withholding the message itself, and says nothing about whether the message has been read.
Suppression activity signal
Information communicated for deciding whether desktop activity warrants push suppression. It is distinct from visible presence and is not a read receipt.
Visible presence
The availability status shown to other members, such as online, away, or offline. A chosen visible presence status does not necessarily reflect actual desktop activity.
Suppression renewal
A suppression activity signal that extends how long push suppression applies based on activity on one desktop.
Inactivity cutoff
The time of the last observed desktop activity plus the duration specified in the spec, when desktop inactivity begins. New desktop activity moves this cutoff forward.
Mobile builds
Internal build
A mobile app an organization distributes only to its own members, for example through device management. It uses only that organization's Builderlab and reaches only that organization's community.
Avoid: Dogfood build, enterprise build, org build
Public build
The mobile app distributed through the App Store and TestFlight. It uses only the public Builderlab and cannot reach any organization's community.
Avoid: App Store build, external build
Sharing
Share
Bringing content such as a screenshot, screen recording, URL or text from another app into a Buzz conversation through the system share sheet. A share ends in that conversation's composer, where the person adds their own text and sends it.
Avoid: Forward, post
Share target
A conversation offered among the share sheet's suggested destinations: an existing channel or DM, or a new Solo chat. Share targets are learned from top-level messages a person sends in a conversation; thread replies and incoming messages never count.
Avoid: Recipient, contact, suggestion
Agents and conversations
Bestie
The one agent a person has chosen as their default in a community. A community has at most one Bestie per person.
Avoid: Default agent, main agent, assistant
Quick send
Sending a message to Buzz from outside the app (Siri, Shortcuts, the Action button) without opening Buzz. A quick send to the Bestie posts the message in the person's DM with the Bestie.
Avoid: Siri message, dictation, background send
Channels
Open-channel directory
The open, listed channels of a community that a person can find and preview without being a member. Private channels, DMs and unlisted channels are never in it. A client's saved copy is the set it last saw, so a channel that has since turned private, unlisted or deleted can linger in it until the next full read.
Avoid: Channel list, public channels, discovery