Commit Graph

469 Commits

Author SHA1 Message Date
Matt Toohey
2cbdabdae5 fix(mobile): bind picked mentions by position and never show a key in the composer
A picked chip is now bound to its recipient by its place in the draft, not
by its label. The editor carries each binding across every edit with a
selection-aware diff, so deleting the first of two identical chips removes
that recipient, text typed before a chip moves it, and a chip stays bound
until an edit reaches into it or a letter or digit is typed directly against
it. Punctuation, straight and curly apostrophes, a hyphen or a slash after a
chip keep it and its recipient (`@Bob's idea`, `@Bob-bot`, `@Bob/Alice`),
the same boundary rule buzz-app uses (recommendation 3).

Namesakes no longer put a public key in the composer. A picked chip whose
name another candidate shares reads the chooser's short label, `@Sam · a1b2`,
while the draft text stays `@Sam`; both Sams can be picked and each chip
keeps its own key. The sent content qualifies namesakes of different keys
as `@Sam (<key>)` so bubbles still tell them apart, except inside code,
and each picked Sam gets its own p tag (recommendation 4). The ambiguity
refusal for a typed, unpicked `@sam` is unchanged.

Drafts persist their bindings as positions (`mentions`), with the saved
label-keyed `mention_keys` still read and an unreadable record kept as a
tombstone that refuses to send while an `@` remains. The agent prefill and
failed-send recovery restore text and bindings in one update.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Signed-off-by: Matt Toohey <contact@matttoohey.com>
2026-11-19 15:06:59 +11:00
Matt Toohey
9152e91fe3 fix(mobile): make picked mentions atomic chips bound to their recipient
Picked people (channel members and directory results) now render as
atomic composer chips like agents already did, and the recipient a send
notifies comes from the same occurrence scan that draws the chips.

- Backspace right after a chip removes the trailing space first and the
  whole chip second, for people and agents alike; Left and Right step
  over a chip as one unit. The agent chip previously broke into plain
  `@Scou` on the second Backspace because an undo heuristic mistook any
  Backspace landing on earlier typed text for Undo. Undo and Redo are
  now detected explicitly through an `Actions` override of
  `UndoTextIntent`/`RedoTextIntent` around the field, so the editing
  formatter leaves restored values exact and widens real deletions.
- `mentionOccurrences` opens a mention after `(`, `[` and `{` as the
  query trigger already did, so `see (@Bob` picked after a bracket
  notifies Bob, and the typed exact-member fallback accepts the same
  brackets. Draft pruning, rendering and send resolution share it.
- Deleting or editing a chip removes its recipient; text left behind
  notifies nobody. Typed, unpicked names keep their existing behaviour,
  visible draft text stays `@Label`, and qualified namesake labels still
  render as coloured text.
- Person chips use key `composer-person-mention-chip` with semantics
  `Mention: <name>` and an `@` prefix; agent chips keep their key, bot
  icon and `Agent mention:` semantics. Chip widgets, the editing
  formatter and the history action move to `composer_chips.dart`.

Tests: a compose bar journey covers person chip insertion, two-Backspace
removal of person and agent chips, arrow stepping, chip deletion sending
no recipient, bracket-prefixed picks and space-selected names notifying,
and the typed fallback after a bracket; `mention_bindings_test` gains
bracket rows. `flutter analyze`, `dart format` and the full mobile
`flutter test` suite pass.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Signed-off-by: Matt Toohey <contact@matttoohey.com>
2026-11-19 15:02:27 +11:00
Taylor Ho
fd436af846 feat(mobile): add saved channel section filters (#8479)
**Category:** new-feature
**User Impact:** Mobile users can filter each channel section by unread
or recent activity and save their choices to their account.

**Problem:** Mobile sections do not expose the account's saved All,
Unreads and Active filters, making long channel lists harder to navigate
on mobile.

**Solution:** Add per-section view settings with shared sheet chrome,
checked choices, inline Active duration and Apply/Cancel. Preserve
access to filtered channels through inline recovery and confirm
encrypted filter writes on relay readback.

**Known desktop and web sync limitation:** Mobile uses the encrypted
`channel-filter` record. The separate current desktop and web build
reads and writes `channel-workspace-filter` and falls back to the legacy
record only before a workspace filter exists. Once the workspace record
exists, filter changes are independent across the builds. The
interoperability tests below cover the older companion format from
[block/buzz-app #1297](https://github.com/block/buzz-app/pull/1297).
Current desktop and web interoperability is follow-up work.

<details>
<summary>File changes</summary>

**mobile/README.md**
Document section controls, recovery and preference behavior.


**mobile/lib/features/channels/channel_filter/channel_filter_activity.dart**
Read verified message activity with bounded concurrency and
lifecycle/live invalidation.


**mobile/lib/features/channels/channel_filter/channel_filter_manager.dart**
Preflight, publish and confirm encrypted preference changes, retaining
rollback and errors. Skip no-op deletion cleanup and allow best-effort
cleanup after local section removal.


**mobile/lib/features/channels/channel_filter/channel_filter_provider.dart**
Scope preference ownership and cache to the current account and relay.


**mobile/lib/features/channels/channel_filter/channel_filter_store.dart**
Preserve companion-compatible registers, durations, reset tombstones and
unknown fields; define filter predicates and salvage malformed
supported-v1 siblings from authenticated relay records.

**mobile/lib/features/channels/channels_page.dart**
Connect the filter owners and shared sheet header to channel navigation.

**mobile/lib/features/channels/channels_page/body.dart**
Apply filters using the same readiness predicate as unread highlights,
retain the selected channel and expose activity retry. Delete sections
locally before best-effort filter cleanup.

**mobile/lib/features/channels/channels_page/filters.dart**
Provide one draft settings sheet with checked rows, duration, pending
guards and retry. Announce retained-draft failures in a visible live
region beside the footer.

**mobile/lib/features/channels/channels_page/sections.dart**
Open section options directly and reveal hidden channels in the existing
roster.

**mobile/lib/features/channels/channels_provider.dart**
Invalidate activity for self-authored and muted messages independently
of unread state.


**mobile/test/features/channels/channel_filter/channel_filter_test.dart**
Cover record preservation, confirmed writes, malformed sibling repair
and the actual activity-provider/predicate composition, including
future-dated history.

**mobile/test/features/channels/channels_page_test.dart**
Cover staged saves, cancellation, failed drafts, saved duration and
read-only recovery at enlarged text.

**mobile/test/features/channels/channels_provider_test.dart**
Verify self-authored activity invalidates filters without changing
unread timestamps.


**mobile/lib/features/channels/channel_sections/channel_sections_provider.dart**
Emit local deletion immediately so offline removal updates the list
without waiting for a relay event.


**mobile/test/features/channels/channels_page_test/filter_feedback_tests.dart**
Verify pre-seed unread consistency and offline section deletion through
the real section provider and persistent storage, without filter
publication.


**mobile/test/features/channels/channel_filter/channel_filter_interop_test.dart**
Exercise encrypted desktop/mobile golden payloads and crossed writes
that converge on one complete winning record.

**mobile/test/fixtures/channel_filter_desktop.json**
Retain signed, encrypted synthetic-key payloads from the companion
desktop implementation and mobile manager for protocol regression
coverage.

</details>

### Reproduction

1. Open a channel section's options. Select Active and 7 days, then
Apply; reopen to see the saved choices checked.
2. Confirm older channels are hidden. Expand Show hidden channels to
navigate without clearing the filter.
3. Change a draft and Cancel. Confirm the saved filter remains
unchanged.
4. With preferences unavailable, delete an unfiltered custom section. It
should disappear and remain deleted locally without publishing a filter
reset.
5. Make a filter save fail. The draft should remain selected and the
error should be visible beside Retry and exposed as a live region.

### Validation and limits

- Follow-up fixes at `f38bf9b273402dd86e93476dde02f468747fa65a`, with
main `a93f3282c` integrated. Required pre-push checks passed on that
head: 3,742 Flutter tests passed, 16 skipped; four unconfigured-push
tests passed. Analyzer, formatting, file-size and branch-skew checks
passed.
- Repaired v1 metadata now contains exactly `v` and `g`, preserving
unknown top-level extensions. The pinned companion at `475e2afef`
verified, decrypted and adopted the repaired mobile head without
rewriting it. Sort-only Apply preserves late-loaded filters and
publishes no filter write; the existing signed-read sheet journey covers
this race.
- Affected pre-integration journeys/protocol tests: 97 passed. Removing
the production fixes produces six failures across unread readiness,
offline deletion, malformed siblings, activity classification and
accessible failed-save status; sources restored afterward.
- Protocol exercise: actual `block/buzz-app` browser-host filter code at
`475e2afef` produced the signed NIP-44 desktop golden head; the mobile
manager adopted it and published a sibling choice; desktop
decrypted/adopted that mobile write and preserved both durations on its
next edit. These are production-code exercises with synthetic keys and a
fake relay boundary, not two packaged clients exchanging against a live
relay.
- Whole-record last-write-wins applies to both mode and duration.
Preflight preserves observed sibling choices; crossed writes can
overwrite an unseen edit, even in another section. Readback checks the
requested pair, and refresh adopts the retained winner. Per-section
conflict-free merging is not promised.
- Supported-v1 malformed siblings are salvaged from the authenticated
relay head, with canonical repair published only by an explicit
confirmed save. Oversized records and unsupported schema versions remain
read-only; display cache never grants repair authority.
- Section deletion is local first. Unfiltered sections skip publication;
failed cleanup can leave unreachable settings for a never-reused section
ID. No offline filter-save queue or automatic cleanup retry is
introduced.
- Earlier iPhone 17 / iOS 26.5 testing exercised section options,
Cancel/reopen and Active/7-day filtering. The normal-flow screenshot
below predates these review fixes. Failure-path runtime/screen-reader
checks, Android, dark mode, packaged cross-device workflow and human
acceptance remain unverified.
- Preferences refresh on load/resume/pull-to-refresh; no instant
cross-device sync promise. Sort retains its existing asynchronous
persistence and is not atomic with the separate filter record.
- On `85949bcde`, 5,095 Flutter tests passed with 71 skipped, plus 27
secp256k1 tests. GitHub's required checks cleared. The duration
animation was tested on the iPhone 17 simulator against a local relay,
and the same animation is included in this head. The separate
non-required Codex Security Review run was canceled before publishing a
review.

### Screenshots

Actual iOS simulator capture, cropped to the section settings surface.

| Section view settings |
| --- |
| ![Section options with Active and seven days
selected](https://github.com/user-attachments/assets/3145394a-0efe-4177-9388-67cbdf62d48b)
|

---------

Signed-off-by: Taylor Ho <taylorkmho@gmail.com>
Signed-off-by: Tom Brow <tomb@block.xyz>
Co-authored-by: Carl <acda9e433d19dcd0e6b6840f7f4b98f3a56f1fab98049d444c087019e6d36560@buzz.block.builderlab.xyz>
Co-authored-by: Tom Brow <tomb@block.xyz>
Co-authored-by: studio <dc2fc481343672df31a689840c09299972e704dac592e0da6f18486646a7ee3e@buzz.block.builderlab.xyz>
2026-11-18 16:26:10 -08:00
Tom Brow
b544fcea4a feat(mobile): add a diagnostics test report and test crash to Settings (#9676)
A way to check that a build's diagnostic reporting works end to end, per
[mobile diagnostic
reporting](https://github.com/block/buzz/blob/main/docs/mobile-diagnostic-reporting.md).
A build with a reporting destination shows a Diagnostics card in
Settings with **Send test report** and **Test crash**. A build without
one, which includes every build from this repository alone, never shows
it and still reports nothing.

| Before | After |
| --- | --- |
| ![Settings bottom,
before](https://github.com/user-attachments/assets/92fdef05-8d63-43db-8df1-32ccb92105c8)
| ![Settings bottom with the Diagnostics
card](https://github.com/user-attachments/assets/a205ab18-ed1e-49d5-8e34-88e29e4c91fa)
|

![Test crash
confirmation](https://github.com/user-attachments/assets/335eb362-3a61-4c8c-8b32-44de548cf788)

### What's in it

- The reporter gains `reporting` (whether the build has a destination),
`sendTestReport()` and `crashForTest()`. The do-nothing reporter returns
false and does nothing.
- **Send test report** sends a fixed `DiagnosticTestError` tagged with a
new `testReport` operation. It passes through the same filter as every
report.
- **Test crash** asks for confirmation, then crashes in native code
through the SDK, so native crash reports can be checked too. The report
goes out the next time the app opens.
- The spec gains a "A way to check a build" decision.

### Regressions

None expected: builds without a destination render Settings exactly as
before.

### Validation

Added widget tests for the card being absent without reporting, sending
a test report, and the crash happening only once confirmed, plus a test
of what a sent test report contains and one that a second tap sends a
second report. The screenshots come from simulator builds of main and
this branch, both with the same placeholder destination.

A full-app simulator run at dec267f (placeholder destination) passed:
channel list, opening and scrolling a channel, search, the other
Settings sections, two test reports (a toast each time), cancelling Test
crash, confirming it (a native crash in the Sentry SDK) and relaunching
signed in.

---------

Signed-off-by: Tom Brow <tomb@block.xyz>
Co-authored-by: studio <dc2fc481343672df31a689840c09299972e704dac592e0da6f18486646a7ee3e@localhost>
2026-11-18 14:48:25 -08:00
Will Pfleger
b624eb0f20 fix(mobile): recover stuck read-state updates and stale Mark Read (#9492)
## Summary

Mobile read-state fixes within the current NIP-RS text.

- **Stuck pending update.** When the relay refuses a pending update with
`invalid: event timestamp too far from server time` and the update is
older than the relay's 15-minute window by the device clock, the update
is retired. The next pass reads a fresh snapshot and sends a strictly
newer successor, journaled before it is sent, unless the relay already
holds that update or an own-slot update covering every key in it. The
marks come from the journaled local state, so nothing is lost. A refusal
of an update that is not old by the device clock reports
`ReadStateClockSkewError` and keeps the exact signed bytes. Unknown
outcomes (timeouts, lost acknowledgements) still retry the exact bytes.
- **Mark Read from the channel actions sheet.** The sheet is the only
owner of the action, for custom-section channels too. It marks through
the newest message known at the tap (the listed `lastMessageAt` or a
newer observed unread event), not the `Channel` captured when the menu
opened, so messages arriving after the tap stay unread. With no known
message time it only releases forced-unread flags.
- **Failed snapshot.** A failed snapshot, during startup or inside a
publish, retries with backoff (5 s doubling to 5 min) while connected
and on app resume; the retry re-syncs and sends journaled marks. When a
publish's own snapshot read succeeds first, the pending retry is
cancelled, the backoff resets to 5 s and the superseded snapshot error
is cleared. A reconnect still re-syncs as before. The channels list
shows a tappable "Unread status isn't syncing" notice while sync is
failing.
- **Marks in the manager gap.** A mark, seed or forced unread made after
a dependency change retired the manager, but before the rebuild, now
runs the pending rebuild and reaches the current manager instead of
being dropped.

The session-wide publishing switch-off after an unsupported-kind or
missing-scope refusal is unchanged: marks stay journaled and the next
manager (restart, re-authentication or community switch) publishes them.
In that state the notice offers no retry and says to sign in again or
restart Buzz.

## Tests

- `read_state_manager_test.dart`: expired update with only partial
coverage is renewed with a newer successor carrying every mark; expired
update the relay already holds is retired with no new send; clock-skew
refusal keeps the exact update and reports the skew error; failed
snapshot retries on the backoff timer and stops after recovery; a
snapshot failure inside a publish retries on its own and sends the
marks; after an explicit flush whose snapshot read succeeds, no extra
snapshot is read and the next failure retries after 5 s, whether the
write succeeds or fails.
- `channel_actions_sheet_test.dart`: Mark Read covers a message that
arrived while the sheet was open; with no known message time it only
releases forced unread.
- `read_state_provider_test.dart`: a mark made between a community
switch and the next manager's build is kept.

Each new test fails without its fix.

---------

Signed-off-by: Will Pfleger <wpfleger@block.xyz>
Signed-off-by: Tom Brow <tomb@block.xyz>
Co-authored-by: Hayt <211b96e6a2b7f45fd4047988976c7bbbeeda0c15f3ae7b32eec20834b5a55118@buzz.block.builderlab.xyz>
Co-authored-by: Tom Brow <tomb@block.xyz>
2026-11-18 15:32:15 -05:00
Tom Brow
3689241672 feat(mobile): reply to a message from its iOS notification (#9439)
On iOS, a notification that shows a channel or DM message now offers
**Reply**. The user types a reply in the notification and sends it
without opening the app.

- The reply goes in a subthread under the notified message (its thread
root is the message's own root, or the message itself when top-level). A
Solo chat takes no thread replies, so there it goes at the chat's top
level.
- It always mentions the notified message's sender, so the person or
agent being answered is notified. Typed `@name` text stays plain, since
a notification has no mention autocomplete.
- It is sent by the app's own send path. iOS starts the Flutter engine
when it wakes the app in the background, and the reply reopens the relay
connection (closed after the background grace period), waiting a bounded
time for it before sending.
- A sent reply marks the conversation read **up to the notified
message** (newer messages stay unread) and clears that notification and
earlier ones from the same conversation.
- An unsent reply (offline, relay error, timeout, a channel the user
isn't in) keeps the typed text as a draft, after any draft already
there, and shows a "Reply not sent" notification that opens the
conversation.

For now only notifications from the community selected in the app offer
Reply: replying must not switch communities, and the app can only reach
the selected one. Forum posts and fallback notifications that show no
message offer none. The design and the options considered are in
`docs/adr/0004-notification-reply.md`.

### Before / after

Long-pressing a message notification (synthetic names and text). Before
has no reply field (captured by sending the notification without its new
reply category, which is how main presents it); after shows one with
Send.

| Before | After |
| --- | --- |
|
![before](https://raw.githubusercontent.com/block/buzz/df800599173cf3436af4d2c738447396a632fac7/pr-9439--before.png)
|
![after](https://raw.githubusercontent.com/block/buzz/df800599173cf3436af4d2c738447396a632fac7/pr-9439--after.png)
|

### Demo

With the app backgrounded past the relay grace period, replying from the
notification lands the reply in a subthread under the message:


https://github.com/user-attachments/assets/37df7e28-aa46-4521-938e-8af5faa77b83

### Regressions

Nothing existing changes unless the user taps Reply. Notifications gain
a category and a small reply context in `userInfo`; tapping a
notification still opens the conversation as before. The relay reconnect
only happens for a pending reply and then falls back to the normal
background disconnect, so idle background behavior and network use are
unchanged. Reply failures end in a draft and a "Reply not sent"
notification rather than touching other state.

### Validation

- End to end on an iOS 27 simulator against a real community: with the
app backgrounded past the relay grace period, replied from the
notification; the reply appeared in a subthread under the message,
mentioning its sender. The demo above was recorded before the review
fixes (session hold, community fence, origin-community drafts, composer
draft sync); the same run was repeated on the current head, 9b9c8b0, and
the reply again appeared in the subthread with no "Reply not sent"
notification.
- Human testing is waived for this repo's mobile client; the simulator
run above replaces it. Not yet exercised on a physical device or on a
cold launch (app not running).
- Added tests: a Dart journey covering top-level, in-thread and Solo
replies, another community (draft kept in that community), a failed
send, a channel the user isn't in (draft appended), a reply arriving
while running, an unreachable relay, and a community switch while
connecting (not sent, draft kept in the reply's community); a
relay-session test that a background-work hold keeps the grace
disconnect off, including one already waiting on cleanup, until released
or its limit; a composer step showing a draft appended elsewhere appears
in the mounted composer and survives its next edit; a relay-session test
for reconnecting a paused session and timing out (fails without the
fix); Swift tests for reply context encoding, NIP-10 root parsing
aligned with the app, and request validation.
- `relay_session.dart` was at its 1200-line cap, so the background
connect lives in a new part file and three existing test hooks moved
unchanged into another.
- Full `mobile-test`, `mobile-check` and BuzzPushKit `swift test` pass.

---------

Signed-off-by: Tom Brow <tomb@squareup.com>
Signed-off-by: Tom Brow <tomb@block.xyz>
Co-authored-by: studio <dc2fc481343672df31a689840c09299972e704dac592e0da6f18486646a7ee3e@buzz.block.builderlab.xyz>
2026-11-18 16:15:28 +00:00
Tom Brow
a5b3dbc00d fix(mobile): stop reporting saved images as failed on iOS (#9599)
On iOS, **Save image** in the image viewer reported a failure for a save
that worked. It asks only for permission to add photos. With that
permission the image landed in Photos, but the app showed "Could not
save image" and iOS then asked for full library access. After choosing
**Keep Add Only**, every later save did the same: saved, and reported as
failed.

Now the save reports what actually happened, and add-only permission is
all it needs, so iOS never asks for full access.

| Before | After |
| --- | --- |
| <img
src="https://github.com/user-attachments/assets/5926b595-6a2d-4382-83e5-89329c009159"
alt="Before: full access prompt over a &quot;Could not save image&quot;
message" width="300"> | <img
src="https://github.com/user-attachments/assets/3b797c3e-43c4-4766-950b-8bef415ae2e0"
alt="After: &quot;Saved to Photos&quot; message" width="300"> |

Before:


https://github.com/user-attachments/assets/e4f88b29-cabc-4c43-9967-d8481e434551

After:


https://github.com/user-attachments/assets/ca3631a5-c988-4082-898a-426867788051

### Cause

`photo_manager`'s `saveImage` returns the saved asset, so its iOS code
fetches the new asset back after writing it. PhotoKit does not let an
add-only app fetch assets: the fetch makes iOS show the full-access
prompt and comes back empty, and the plugin reports an error for a write
that succeeded. The latest release (3.12.0) has the same code.

On iOS the image is now written by a small native saver
(`PhotoLibrarySaver`) that creates the asset and reports the result of
that write, without reading the library. Android keeps using
`photo_manager`, and the permission request is unchanged on both
platforms.

### Regressions

None expected.

- The write is the same PhotoKit creation request the plugin made, with
the same original filename, so saved images are unchanged.
- Real failures still show "Could not save image": a denied permission,
a failed download and a failed write all still surface.
- Android and the rest of the app's photo library use (the composer's
photo picker) are untouched.

### Validation

- Added test: the image actions journey saves on iOS with a photo
library that grants add-only access and rejects every read, and expects
"Saved to Photos", one write with the downloaded bytes and filename, and
an add-only permission request. A failed write then shows "Could not
save image". It fails without the fix.
- Full mobile suite and the iOS Runner unit tests pass.
- Full-app run on an iOS 27 simulator, on a fresh install with no photo
permission, comparing this branch with unmodified `main`:
- `main`: first save adds the image, shows "Could not save image" and
the full-access prompt; a second save after **Keep Add Only** adds
another copy and shows the error again.
- This branch: first and second saves each add one image and show "Saved
to Photos", with no full-access prompt, and only add permission is
granted afterwards.
- This branch, other paths: **Don't Allow** shows "Could not save image"
and saves nothing; saving with full access already granted works;
**Share image** still opens the share sheet.
- Not covered: a physical device, and Android (its code path is
unchanged).

---------

Signed-off-by: Tom Brow <tomb@squareup.com>
Co-authored-by: judge <7615ec4b7ddf99f0bb48e913297f99f8f772d289a1c9ef54e1d906dd55a93ba8@buzz.block.builderlab.xyz>
2026-11-18 07:17:27 -08:00
Tom Brow
a26eacde49 perf(mobile): save own thread interest once per unread catch-up (#9614)
iOS was killing the app with watchdog terminations (`0x8BADF00D`,
"scene-update watchdog transgression" and "Failed to terminate
gracefully") because the main thread spent 5 to 10 seconds in unread
catch-up.

Symbolicated reports from a 1.4.0-rc.1 user all point at the same stack:
`UnreadCatchUp._catchUpUnreadEvents` →
`ChannelsNotifier._writeThreadInterestStores` → `jsonEncode` /
`SharedPreferences.setString`. For every self-authored event in a
catch-up batch whose thread was new to the interest sets, the notifier
re-encoded **both** whole root-id sets and wrote both to
SharedPreferences. That is quadratic in the batch: a fresh sign-in,
whose catch-up returns many of the user's own messages, ran thousands of
growing encodes and platform-channel writes on the main thread.

Now the catch-up adds the whole batch to the in-memory sets and saves
once if anything changed. The live single-event path is unchanged (one
write per new thread).

### Regressions

None expected. The persisted keys, format and contents are identical;
only the number of intermediate writes changes. The storage contract is
unchanged: saves were and still are fire-and-forget `setString` calls,
so neither version guarantees durability before a process kill. A kill
before the save lands now loses the whole batch rather than a prefix of
it; a later catch-up can re-add those threads only while they are still
after the channel's read timestamp and within the catch-up window.

### Validation

- **Writes per catch-up**, 50 own messages across 50 threads: 50 writes
per key before, 1 after (new test).
- Added test: `unread catch-up saves own thread interest once per batch`
(channels_provider_thread_interest_cases.dart). It checks the saved sets
and the write count; it fails on the old code.
- Full mobile check and test suite pass.

- Automated full-app run on an iOS simulator (PR head build, signed in
to a real community): cold launch and unread catch-up saved both
thread-interest sets; background and foreground; Activity rows and
unread dots render; opened a thread and sent a reply, and the
participation set grew by one (live path still saves). No errors in the
app log.

Signed-off-by: Tom Brow <tomb@squareup.com>
Co-authored-by: Tom Brow <tomb@squareup.com>
2026-11-17 15:01:13 -05:00
John Matthew Tennant
21802f019e Keep transparency in mobile avatar photo crops (#9319)
## Summary

Choosing a transparent PNG as a profile photo on mobile produced an
avatar with a solid background on every client. The crop step always
re-encoded to JPEG
([`profile_avatar_crop_page.dart#L507`](44b3c4823f/mobile/lib/shared/widgets/profile_avatar_crop_page.dart (L507))),
and `ProfileImageAvatarDraft` always uploaded with `mimeType:
'image/jpeg'`
([`profile_avatar_draft.dart#L51`](44b3c4823f/mobile/lib/features/profile/profile_avatar_draft.dart (L51))).

- The crop encodes PNG when the 512px result has an alpha channel and
any pixel is transparent, and JPEG otherwise. Opaque photos, including
16-bit and low-bit-depth PNGs whose decoder reports zero alpha, keep the
smaller JPEG output.
- The draft labels its upload from the bytes' signature, using the
existing detector in `media_upload.dart`, now public as
`detectImageMimeType`.

### Related issue

None found.

### Testing

- `uploads a transparent photo crop as PNG` picks a transparent PNG,
crops and saves it, and checks the upload is `image/png` with a
transparent corner pixel. It fails on `main` with `Expected: 'image/png'
Actual: 'image/jpeg'`.
- `uploads an opaque 16-bit photo crop as JPEG` fails without the
alpha-channel guard, and the existing opaque-photo test now checks the
upload stays `image/jpeg`.
- On an iOS simulator against a local relay, I picked a transparent PNG
with an opaque red disc through the native photo picker, cropped it and
saved it. On `main` the stored avatar is a 512x512 JPEG with white
corners. With this change it is a 512x512 RGBA PNG with transparent
corners and the same red center.

| Before (`main`) | After |
| --- | --- |
| ![Settings avatar: red disc on a white
square](https://github.com/user-attachments/assets/6dc7470e-d677-4357-a74b-1c9d686cc2ee)
| ![Settings avatar: red disc on the avatar
background](https://github.com/user-attachments/assets/5e4f37bc-5afc-42dd-8532-d04a77db8959)
|

buzz-review-completed

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

---------

Signed-off-by: John Tennant <jtennant@squareup.com>
Signed-off-by: Tom Brow <tomb@squareup.com>
Co-authored-by: Maeve <be734facf808af9bc7720a1cb69aeb2a3d136149938eedf4d0667a70ef433961@buzz.block.builderlab.xyz>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: Tom Brow <tomb@squareup.com>
Co-authored-by: studio <dc2fc481343672df31a689840c09299972e704dac592e0da6f18486646a7ee3e@buzz.block.builderlab.xyz>
2026-11-17 06:58:36 -05:00
Tom Brow
6f1eabe4e8 fix(mobile): read presence for a person shown again while still covered (#9595)
## Context

Follow-up to [#9480 stop following off-screen
presence](https://github.com/block/buzz/pull/9480), from [Wes's review
comment](https://github.com/block/buzz/pull/9480#discussion_r4591994023).

When a person is retired, presence narrows the live subscription to the
people still shown. If that narrowing fails, the old wide stream stays
live and still covers the retired person. If that person is then shown
again, the tracked set matches the live stream's keys, so `_subscribe`
returned early without reading their snapshot. Their dot stayed empty
until a live event or the next 60 second poll. The same gap happened
when a person was shown again before the retirement's resubscribe ran.

`_subscribe` now schedules the pending snapshot read before returning in
that case, so a person shown again gets their current presence right
away.

## Validation

- New test: `a key shown again while a failed narrowing left it covered
is read`. It failed before the fix (no snapshot read for the re-shown
key) and passes after it.
- `flutter analyze` clean; full mobile `flutter test` suite passes.
- Automated app test (iOS 27 simulator, signed-in debug build): Home
Team filter DM rows show presence dots, and they are still correct after
switching to Solo for 70 s and back. The Team list stays mounted
offstage while hidden, so that run is a smoke check of the presence
flows; the retire and re-show path itself is covered by the new unit
test.

## Regressions

None expected. The extra read happens only when a newly tracked key is
already covered by the live stream. `_schedule` already dedupes and
skips while a retry is pending, so it adds at most one small snapshot
query per re-shown key.

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>
2026-11-16 21:12:22 -08:00
Tom Brow
b0e55606f2 perf(mobile): stop following presence for people no longer shown (#9480)
[#9444](https://github.com/block/buzz/pull/9444) narrows the live
presence subscription (kind 20001) to the people the app has shown this
session. That set only grows, so scrolling through a long DM list or
opening many profiles keeps receiving presence for people who are no
longer on screen, and each new person reopens the subscription with
everyone seen so far. This was raised in [Jude's
review](https://github.com/block/buzz/pull/9444#pullrequestreview-5896221680).

With this change, presence follows only who is on screen now:

- `track` returns a release callback. DM rows and profile sheets release
when they unmount. Counts are per person, so someone shown in a DM row
and an open profile sheet stays followed until both are gone.
- A person nobody has shown for at least 30 seconds is retired: dropped
from the tracked set and the cache, and the live subscription is
replaced with one for the people still shown. A sweep every 30 seconds
retires everyone whose own 30 seconds are up, so each person stays
followed for 30 to 60 seconds after their release and the subscription
narrows at most once per 30 seconds. Scrolling back within 30 seconds
keeps the current subscription.
- A read that started before someone was retired doesn't fill in their
presence if they are shown again; they wait for a read of their own.
- When nobody is shown, the stream closes, and the next person shown
opens a new one immediately.
- Switching communities keeps following people still on screen, instead
of dropping everyone.

### Regressions

- **Mention picker ranking.** The picker reads the presence cache
without tracking anyone itself, so it ranks by presence only for people
currently on screen (before, also for anyone shown earlier in the
session). Keeping a retired person's last value would show stale
presence, which is worse.
- **Dot pop-in.** A retired person's dot is missing when they come back
(scrolling back after 30 seconds, or switching the Home filter to Solo
and back after 30 seconds) until the replacement subscription is ready
and their snapshot read returns. On a slow link that can take seconds.
Before, the dot stayed for the whole session.
- **Network.** A retirement costs one replacement REQ and a CLOSE, at
most once per 30 seconds of scrolling. A person shown again after being
retired costs one snapshot read, the same as the first time they were
shown.
- **Reliability.** Narrowing uses #9444's replacement path (the old
stream stays until the new one is ready), so a failed narrowing keeps
the wider stream and the poll retries it.

### Validation

iPhone 12 mini on Builderlab (measured on
[bda9e214f](https://github.com/block/buzz/commit/bda9e214f), before the
sweep change), cold launch, scroll the Home list to the bottom and back
to the top, then 60 s idle:

| | #9444 head | This PR |
| --- | --- | --- |
| Live presence authors at the end | 37 (only grows) | 1 (37 at the
bottom, then 11, then 1) |
| Presence events while idle (60 s) | 29 (10.7 KB) | 0 |
| Presence REQs during the run | 36 | 37 |

Presence dots still show on the DM rows visible at the bottom of the
list. Both heads still reopen the subscription once per newly shown
person while scrolling (36 swaps for 37 people); batching those during a
fling would be the next bound, and is not part of this PR.

Added tests:
- A person shown in two places stays followed until both release.
Released people leave the subscription only after the delay, and their
late live events are ignored.
- Showing someone again within the delay keeps the same subscription and
their cached presence.
- Releasing everyone closes the stream, and the next person shown gets a
new subscription and a snapshot read right away.
- Scrolling 500 rows past a window of 10 leaves a subscription for
exactly the last 10, with exactly two replacement opens after scrolling
stops (the sweeps 30 s apart).
- A person released 29 seconds after another keeps their subscription
and cached presence when the first one is retired, and is retired at a
later sweep.
- A person retired while their snapshot is in flight stays absent.
- A read started a second before someone is retired doesn't fill them in
once they're shown again; the other people in that read keep their
results, and the person's own read does.
- Production seam: removing a DM row from the Home list stops following
that person after the delay (the stream closes and the cache empties).

Each guard was mutation-checked: removing it fails at least one of these
tests.

Changed test: the community-switch snapshot test now expects people
still on screen to be read in the new community.

Full mobile suite: 4857 passed, 71 skipped (on ca0066de3, after rebasing
onto main).

---------

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>
2026-11-16 15:13:36 -08:00
Tom Brow
d39545ebd4 fix(mobile): name the failing step in sign-in errors (#9263)
Organization sign-in shows the same "Couldn't sign in. Try again."
(landing page) or "Sign in failed. Try again." (in-app banner) for every
failure after the browser hands control back: a rejected or stale
callback, a keychain write that doesn't stick, a code exchange the
server refuses, a session for a different account, or a malformed
response. Server logs can't tell these apart either, because the
exchange can succeed on the server and still fail on the device. So a
user's screenshot of the error tells us nothing about which step broke.

This appends a short code naming the failure, for example "Couldn't sign
in (account-storage). Try again." or "Sign in failed
(browser-restartLogin). Try again." The code is the failure's enum name,
prefixed by where it came from (`browser-` for the callback, `account-`
for the exchange and session). An unexpected failure type throws instead
of showing a made-up code.

### Validation

- Focused test changes: the sign-in banner's recovery test now checks
the code in the message for two account failures and one browser
failure, at each text scale.
- Full mobile suite (`flutter test`) and `flutter analyze` pass.
- Not yet: an automated app run reproducing a failed sign-in to capture
the new message on screen.

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

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>
2026-11-16 13:21:57 -08:00
Wes
aec5710453 fix(mobile): order same-second messages by millisecond offsets (#9541)
## Summary

Messages sharing a Nostr second can appear in hash order on mobile even
when
their signed `ms` tags establish a send order. Channel timelines and
thread
replies now compare `created_at * 1000 + ms`, using the same first-tag
and
canonical 0–999 validation as desktop. Each comparator retains its
existing
event-ID tie-break. Effective times are computed once per event and
memoized.

Relay paging still uses whole seconds and IDs. Legacy history now
chooses and
filters its cursor with the existing relay-order helpers, independently
of
display order. The channel-window relay comparator is unchanged.

The review fixes from #9550 preserve the original event's millisecond
time
through edits and provisional thread rendering, so cached replies keep
their
order when the query lands. Effective edits use the relay's greatest
`(created_at, id)` rule, independently of display order.

### Related issue

Related desktop symptom: #8192. Desktop implementation:
block/buzz-app#249.
No matching open mobile PR found in the original searches for
same-second/millisecond titles. Review fixes: #9550, merged without
rewriting
its commit.

### Testing

- Original regression run against unchanged production source: four
failures
covering channel/thread millisecond order, window flattening, and legacy
  pagination; all 218 focused tests passed after the initial fix.
- Review regressions cover `007`/`12a` rejection, same-second edit
selection in
both input orders, and provisional replies before/after query
completion.
- Final head, including current main:
  `f3fdf3fa0fae6e495e6fc1b7b38f4834a1751d56`.
- `just mobile-install` passed. The required push hook then passed
  `just mobile-check && just mobile-test` on that clean head, including
formatting, analysis, the full Flutter suite, gateway recipe checks and
  the crypto-package suite. File-size and diff-whitespace checks passed.

Draft pending simulator revalidation and human testing of the merged
head.
Re-run numbered 60-message channel and thread sequences, then a
200-message
burst. Verify send order, the newest message at the end, same-second
edits,
and cached thread ordering as the query completes. Page backward and
confirm
the fully loaded history has no missing or duplicate messages.

Scope note: during backward paging, the oldest loaded second can
temporarily
show gaps because relay pages select an ID-ordered subset of that second
while rendering uses milliseconds. The next page fills those gaps; fully
loaded history is complete. Boundary continuity needs a separate loading
contract and remains deferred.

---------

Signed-off-by: Rocket <0c41329ade659e01801116549bc617351689892a382bc864a1186dc9191293a7@buzz.block.builderlab.xyz>
Signed-off-by: Tom Brow <tomb@squareup.com>
Co-authored-by: Rocket <0c41329ade659e01801116549bc617351689892a382bc864a1186dc9191293a7@buzz.block.builderlab.xyz>
Co-authored-by: Tom Brow <tomb@squareup.com>
Co-authored-by: studio <dc2fc481343672df31a689840c09299972e704dac592e0da6f18486646a7ee3e@localhost>
2026-11-16 13:24:20 -07:00
John Matthew Tennant
9ccad95344 feat(mobile): accept mentions with Tab and send with Enter on hardware keyboards (#8733)
## Summary

The mobile composer ignored Tab and Enter from hardware keyboards. Tab
and Enter now accept the first selectable mention or channel suggestion
while its picker is visible. Otherwise Enter or numpad Enter sends the
message when attachment controls are closed. Enter leaves the draft
untouched while an attachment surface is open. Tab leaves the draft
unchanged while the picker is hidden or the field is read-only. A
visible picker with no selectable row consumes Tab and Enter without
sending. Only unmodified Tab accepts suggestions. Native attachment and
emoji pickers own keyboard input until dismissal. Keyboard suggestion
acceptance and sending use the same selection haptic as touch. Modified
Enter and active IME composition retain normal text-field handling.

Android IMEs can emit Enter as a key event too. Sending requires a
mapped physical Enter key on Android, so scan-code-free IME Enter keeps
newline handling.

### Related issue

None found.

### Testing

The composer widget regressions reproduce ignored Tab/Enter before the
feature and an unintended send from Android IME Enter before its guard.
The picker regressions cover Enter accepting a visible suggestion, Enter
and numpad Enter retaining an Android draft while the attachment menu is
open, and Tab leaving hidden or read-only suggestions untouched. They
verify suggestion acceptance, error-only picker handling, native
attachment popover ownership, modified Tab, sending, software Return and
Android physical-key handling. Rapid Enter while member scanning is
pending sends only once through the existing draft revision guard.

Native validation and screenshots use an isolated Android API 28
ComposeBar harness at `09fb673f9`, with an observed send callback and a
test-only native key injector. Physical Enter sends once and clears the
draft; IME Enter inserts a newline without sending. Native validation of
picker acceptance, visibility and read-only handling remains
outstanding.

### Screenshots

| Physical Enter sends and clears the draft | IME Enter keeps a newline
without sending |
| --- | --- |
| ![Physical Enter
sends](https://github.com/user-attachments/assets/bf1b33ca-2f07-475a-b762-38c05e693163)
| ![IME Enter keeps a
newline](https://github.com/user-attachments/assets/6be835ad-a81a-4c6d-84c7-46549b858aee)
|

| Mention suggestions | Tab accepts the suggestion |
| --- | --- |
| ![Mention
suggestions](https://github.com/user-attachments/assets/7a5f0365-955c-4f98-9090-dd5d9ee919d3)
| ![Tab accepts a
mention](https://github.com/user-attachments/assets/cf947194-f2ad-4aae-9a47-4c465ca25444)
|

---------

Signed-off-by: John Tennant <jtennant@squareup.com>
Signed-off-by: Tom Brow <tomb@squareup.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: Oliver <e78152627ea32fbacb070e5047afcfb8e409fa3343d9e618227baacca5b5e607@buzz.block.builderlab.xyz>
Co-authored-by: Tom Brow <tomb@squareup.com>
Co-authored-by: studio <dc2fc481343672df31a689840c09299972e704dac592e0da6f18486646a7ee3e@buzz.block.builderlab.xyz>
2026-11-16 15:01:21 -05:00
klopez4212
921a05a379 fix(mobile): host Duo long-press menus in native sheets (#9536)
## Summary

On unfolded Duo landscape, channel/DM actions and Solo details now open
in a UIKit sheet above the app’s native controls, while retaining Buzz’s
Flutter tiles, member rows, and grouped cards. Content drags take
priority over sheet dragging; the native top bar still supports
dismissal.

The presentation-only engine starts only when an eligible sheet is
presented, without account, camera, audio, or storage plugins. It is
destroyed on dismissal; other iPhones pay no second-engine launch cost.
The main app retains live permissions and actions, and the native sheet
dismisses before opening follow-up screens. Cover-display and portrait
postures retain the existing bottom sheet. Pending avatar requests are
abandoned on dismissal, including after the display wait expires; the
display timeout alone lets the download finish and cache. Confirmed
lifecycle actions retire the invisible owner route before waiting for
the relay.

### Related issue

Follow-up to #8568. No duplicate sheet PR found.

### Testing

- `just mobile-install mobile-check mobile-test`: clean analysis; 4,900
Flutter tests passed (71 skipped), plus gateway/package checks.
- Mobile file-size and diff checks passed.
- Earlier signed device preview built, installed, and launched; owner
confirmed its scrolling. The later lazy-start and lifecycle fixes have
not been rechecked on the device.
- Unsigned iOS release build passed for `4ed94c6eb4` (Xcode 116.7s).
- Journeys cover bridge permissions, copy/close callbacks, the content
renderer, full profile-to-DM return, and reopening the list during a
held archive. Avatar tests cover immediate cancellation, display timeout
followed by cancellation, and timeout followed by completion and cache
reuse; regression probes fail with the fixes disabled. UIKit drag
handling still lacks automated interaction coverage.

### Snapshots

Actual Flutter sheet contents at 540×580 points with sample data. These
show the content layout; they do not show UIKit’s surrounding sheet or
its animation.

| Surface | Light | Dark |
| --- | --- | --- |
| Solo details | ![Solo details,
light](https://github.com/user-attachments/assets/43251c76-11c6-48d0-9be5-b242329234e6)
| ![Solo details,
dark](https://github.com/user-attachments/assets/ba03cac5-e890-4036-a4fd-337ed1a78a85)
|
| Channel actions | ![Channel actions,
light](https://github.com/user-attachments/assets/88c37da0-53cb-48d9-9c07-8c547e1502d9)
| ![Channel actions,
dark](https://github.com/user-attachments/assets/4bd9956d-9a65-498e-81c5-6da74939ffc9)
|

---------

Signed-off-by: kenny lopez <klopez4212@gmail.com>
Co-authored-by: Terp <5856f6900e8e0a4e0ea1f4f8d2ee33e4753d2119bc122f94ecafc660b46c0511@buzz.block.builderlab.xyz>
2026-11-16 19:14:38 +00:00
Will Pfleger
df21064800 feat(auth): tolerate client clocks up to 120 s off (#9485)
Lets clients whose clocks are up to 120 s off sign in to NIP-FI
communities and stay connected.

**Relay**
- NIP-42 AUTH and NIP-98 HTTP Auth accept `created_at` within ±120 s,
using a shared `buzz_auth::TIMESTAMP_TOLERANCE_SECS`. This covers relay
login, audio admission, bridge, admin, invites, NIP-FI policy and Git.
- `DEFAULT_REPLAY_TTL_SECS` goes from 120 to 250 s: a 2 × 120 s window,
plus 1 s for the inclusive whole-second bounds, plus a 9 s budget for
the clock difference between relay pods. A compile-time assert checks
the arithmetic. The 9 s is an operational assumption about NTP-synced
pods, and the doc comment says so. No `deploy/` override exists.
- Media (kind 24242):
- Both modes accept `created_at` up to 120 s in the future and an
`expiration` greater than `now − 120`.
  - Strict: the 120 s age limit and the 60 s lifetime cap.
  - Permissive: keeps its 3600 s age allowance and has no lifetime cap.
- `buzz-auth` and `buzz-media` read the time through a `wall_now()` that
tests can pin (a `#[cfg(test)]` thread-local), so boundary tests are
exact.
- Git transport: comments only. It still reuses one proof per session,
so the reuse window now matches ±120 s.

**CLI**
- The desktop-provider lane asks the desktop app for the assertion every
time and keeps no copy, so the desktop's cache owns each token's
deadline. It looks the token up again after signing and sends that one,
so a provider may hand out a new token on every call.
- The direct-mint cache sets its deadline to `min(request_start + (exp −
iat), receipt + (exp − local_now))`, on a monotonic clock.
`request_start` is when the attempt that got the reply was sent, not the
start of the retry loop.
- An assertion with no local lifetime left is never returned or sent.
The cache asks again, up to 3 times, then fails with an auth error that
points at the computer's clock. An assertion without a readable `iat` is
refused. `iat` may be fractional (a NumericDate); the lifetime is
`max(0, floor(exp − iat))` whole seconds.

**Cache reuse (CLI, Flutter, iOS):** each cached token records when it
arrived on both the monotonic and the wall clock. It is reused only
while `max(monotonic elapsed, wall elapsed)` since arrival is under its
budget (`refresh point − receipt`, on the monotonic clock). A negative
wall elapsed counts as 0. The monotonic clocks used here stop while the
device sleeps, so the wall clock ends reuse after a sleep; setting the
wall clock back can't stretch a token, because the monotonic bound still
applies.

**Mobile**
- Flutter `HostedRelayAuth`: the same lifetime rule, on a monotonic
clock, for async acquisition and for the synchronous `cachedHeaders`
media path. A token with no local lifetime left is never sent: issuance
is retried up to 3 times, then fails as `unavailable`. A token without a
readable `iat` fails as `invalidResponse`.
- Flutter refusal hint: the account client reads `Date` when a 403's
headers arrive, before the body (`boundedHttpResponse` gains an
`onHeaders` callback). The 403 stays `AccountFailure.denied` even if its
body is then lost, late or too large. The hint is stored with the
refusal it explains (`HostedRelayAuth.failureClockHint`), cleared when
that community next gets a token or the account session changes, and
left alone by other communities' issuance. The account client records a
403's hint only for the acquisition whose own request was refused
(`BuilderlabAccountClient.observingRefusals`), so an unrelated account
call, such as the organization key backup, never supplies a sign-in's
hint. When the offset is over 115 s, the reconnect and organization
banners add "Your device's clock looks about N minutes off, which can
cause this. Check your date and time settings."
- iOS `BuzzRelayAssertionIssuer`: the same lifetime rule, on
`systemUptime`. An assertion without a readable `iat` is refused.
- iOS push enrollment: a new grant's window starts 120 s in the past, so
`not_before = now − 120` and `expires_at = now − 120 + lifetime`. A fast
phone then neither signs a `not_before` the gateway hasn't reached nor
goes over its 30-day maximum. A resumed journal resubmits the
installation expiry it already attested, byte for byte. The delegation,
which is signed fresh each time, expires at the earlier of that expiry
and `not_before + lifetime`, so a journal written by an older client on
a fast phone still gets a grant the gateway accepts. The saved grant
records the delegation's expiry.
- Flutter and iOS already sign a fresh proof with a `nonce` on every
issuer attempt, so their retries needed no change.

**Specs:** NIP-FA proof bounds (120 s old / 120 s future), plus NIP-FI
Git (`±120s`), media freshness, the media read residual and the media
trace row.

`desktop/` is untouched.

Not exercised live: Git clone/push, audio join and push delivery with a
skewed client clock.

---------

Signed-off-by: Will Pfleger <wpfleger@block.xyz>
Signed-off-by: Tom Brow <tomb@squareup.com>
Co-authored-by: Hayt <211b96e6a2b7f45fd4047988976c7bbbeeda0c15f3ae7b32eec20834b5a55118@buzz.block.builderlab.xyz>
Co-authored-by: Tom Brow <tomb@block.xyz>
Co-authored-by: Tom Brow <tomb@squareup.com>
2026-11-16 12:17:14 -05:00
Tom Brow
4ec5efa936 fix(mobile): read a Solo chat through its newest message on open (#9515)
Opening a Solo chat now reads it through its newest message, the way
opening a DM already does.

Before, a Solo chat (a `stream` placed under Solo) was read row by row:
holding still at the bottom wrote only the channel catch-up mark, and
that mark skips messages addressed to the reader (p-tags, broadcasts)
and replies. Each such message needed its own row to be fully on screen.
Agent messages in Solo chats tag the reader all the time, so the Solo
row stayed bold after the reader opened the chat, jumped to the oldest
unread and scrolled around.

A Solo chat is all for the reader, like a DM, so it now takes the same
open read. The jump to the oldest unread still works: its target is
captured before the open read is written.

### Regressions

- Opening a Solo chat with a long unread backlog marks it all read even
if the reader doesn't scroll through it, as DMs already do. The
jump-to-oldest-unread button still appears on that open, so the backlog
stays reachable.
- No extra relay traffic: it reuses the read mark path DMs use (local
first, synced behind the existing debounce), so newer messages loaded
while the chat is open advance the mark the same way they do in a DM,
and only while the page is in front and the app is in use.

### Validation

Added tests:
- `opening a Solo chat reads the whole chat`: an agent message that tags
the reader sits above the viewport; opening the chat reads through the
newest message and the addressed message is no longer unread. Fails on
main (no channel mark is written).
- `opening an archived Solo chat reads a tall newest mention` (was
`reading the bottom of an archived Solo chat ...`): now expects the open
read.
- Removed `reading the bottom of a Solo chat reads a tall newest inline
reply mention`; the open-read test covers it. The tall-newest-mention
rule for ordinary channels keeps its own tests.

Full mobile check and test suite pass.

### In the app

Simulator (iPhone 17 Pro, iOS 27) against a local relay with two
synthetic identities: a Solo chat (`buzz.solo`) where a second member
posted 17 messages, two of them @mentioning the reader, one tall and
above the fold.

Before (main): open the Solo chat, tap the up arrow, scroll, go back.
The row stays bold.


https://github.com/user-attachments/assets/8adf8131-ca0e-499c-ad7c-b45c0f903360

After: the same steps clear the row. The up arrow still appears and
jumps to the oldest unread. A DM still reads on open, and an ordinary
channel with an unread @mention above the fold stays unread after
opening it and going back.


https://github.com/user-attachments/assets/ec88914a-a757-47cc-901b-d7cc6a658448

Limitations: run on a local relay, not a hosted community; the Solo chat
was created by publishing the same kind:9007 tags the app sends, not
through the new-chat flow (which needs an owned agent).



buzz-review-completed

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>
2026-11-16 07:57:30 -07:00
Tom Brow
c16dac2324 fix(mobile): keep the Solo header's agent portrait while its roster reloads (#9512)
Opening a Solo chat made the header's agent portrait flash away and come
back.

The header draws its portraits from the chat's member list. That list
(`channelMembersProvider`) is auto-disposed when the page closes, so
every open refetched it from the relay. Until the fetch landed, the Solo
header fell back to the viewer alone, then swapped to the agent once the
roster arrived.

The header now watches `latestChannelMembersProvider`: the last roster
loaded in this relay, account and channel scope (the existing
`watchLatestChannelMembers` snapshot), or before any load, the channel
list's member snapshot. The fresh fetch still runs and replaces it when
it lands.

### Before / after

Opening a Solo chat, slowed 4x and cropped to the header.


https://github.com/user-attachments/assets/f42e500e-8b0c-446d-b47c-68b58e98d5d5


https://github.com/user-attachments/assets/b8e63e39-c6ee-4fd6-b195-6327b709b316

### Validation

- Added a step to `Solo and channel headers show bounded roster
portraits`: with the roster fetch held pending, the first frame of a
Solo chat shows the agent portrait. It fails on main (the header shows
the viewer) and passes with the fix.
- Full mobile suite and `flutter analyze` pass. One unrelated test
(`message_skeleton_geometry_test.dart: image null matches preview at
320.0`) failed once in the full run and passes on its own.
- iOS simulator (iPhone 17 Pro, debug build, internal community): opened
and closed a Solo chat repeatedly from Messages, before and after.
Before, the first frame shows the viewer's avatar; after, the agent's
portrait from the first frame, with the rest of the open and back flow
unchanged.

### Regressions

None expected. The header shows a roster from the last load (or the
channel list) for the moment before the fresh fetch lands, the same
staleness the page's names and author visibility already accept through
`watchLatestChannelMembers`. No extra relay reads; the snapshot is
scoped to the relay, account and channel, so another community or
account never sees it.



buzz-review-completed

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>
2026-11-16 07:55:46 -07:00
Tom Brow
75d78eab68 perf(mobile): pulse the Solo working dots at 12 fps on a shared clock (#9554)
Each working row on Home (the three pulsing dots next to a Solo chat
whose agent is working) ran its own 60 fps animation. So an idle Home
with any working agent produced a frame on every vsync. Painting the
dots is cheap. The frame itself is not: each one costs the app,
backboardd and the kernel together, and on the iPhone SE that adds 8.6%
of battery per hour over static dots.

The rows now step from one shared clock: 17 steps per 1400 ms cycle
(about 12 fps), with the same cosine wave. All rows read the same step,
so they stay in phase and repaint in the same frame. The clock runs only
while a row is visible with `TickerMode` on and the app is in the
foreground, so a Home with no working rows, a covered or off-screen
Home, or a backgrounded app has no timer.

### Validation

Idle Home with working agents, 30 s Time Profiler, % of one core, iPhone
12 mini (release builds of main and this branch; real working agents, 3
rows in the before run and 2 in the after run, which doesn't matter
because the cost is per frame, not per row):

| | Buzz | backboardd | kernel | Total |
|---|---|---|---|---|
| Before (60 fps) | 43.3 | 42.0 | 18.9 | 104.2 |
| After (12 fps) | 14.9 | 15.7 | 14.8 | 45.4 |

Earlier battery runs on the iPhone SE (2nd gen), whole-device gauge, 8
min per variant, same setup: 60 fps +600 mW (+8.6%/h) over static dots;
12 fps +109 mW (+1.6%/h).

Two working rows on a simulator:

Before (60 fps):

<video
src="https://github.com/user-attachments/assets/539ce17d-7df4-4508-a981-4d6b31f8f805"
width="400"></video>

After (12 fps):

<video
src="https://github.com/user-attachments/assets/18513348-6f24-48c5-bb3b-4ac328d0c983"
width="400"></video>

- Added tests: `solo_working_dots_test.dart` checks that rows step
together at about 12 fps with no frames scheduled between steps, and
that the shared timer is gone when the last row is removed, when
`TickerMode` is off, and while the app is hidden.
- Full mobile suite passes (4912 tests). The one failure is
`search_channels_journey_test.dart`, which doesn't compile on main;
[#9545](https://github.com/block/buzz/pull/9545) fixes it.
- Automated app run (signed-in simulator, every Solo row forced to
working with a local-only patch): the rows pulse in phase on Home, keep
pulsing after opening a chat and going back, and after backgrounding and
resuming the app.

### Regressions

- The pulse steps at 12 fps instead of animating smoothly. Side by side
in the recordings it reads the same; you notice the steps only if you
look for them.
- Rows are now in phase with each other instead of each starting its
wave when it mounted.
- Reduced motion still shows static dots at full opacity, as before.

---------

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>
2026-11-15 17:05:02 -08:00
klopez4212
a82d596fc2 mobile: show account communities in the switcher and sync saved destinations (#9262)
## Summary

Switch Community currently shows only device-saved communities, leaving
account destinations behind a separate Find step. It now merges saved
communities with supported account destinations directly, keeps Add
Community, and removes the redundant Find action from that Add route.
Initial onboarding and identity recovery keep their discovery entry.
Find lists supported account addresses before hosted identity setup;
hosted selection still performs binding, backup, and admission, while
external selection opens the existing identity flow.

Mobile also saves QR/address additions and explicit removals through
Builder Lab's existing known-communities account APIs. A per-account
local journal retries transient failures, survives restarts, pauses in
the background, and fences requests against account changes. External
secure addresses use the existing self-hosted entry flow; account
destinations never imply membership or bypass admission. Remote list
omissions do not delete local identities.

Explicit additions store an account owner and revision atomically with
local credentials. Legacy/unclaimed destinations remain local-only until
explicitly added while signed in; signing into another account never
claims retained destinations. Restart reconciliation lets a committed
re-add supersede an older removal even if the retry-journal write
failed. Local deletion and its credential-free account-removal intent
commit in one storage write, independent of the account-only retry
journal. Removing one of several local identities owned by the same
account at an address retains its account destination until that
account’s last identity is removed. Another account’s saved identity
does not block removal or lose its credentials during recovery. Offline
edits retain the stored account subject without treating it as network
authorization. Discovery-only intent survives browser callbacks, app
restart, and retry. Onboarding recovery controls have a Material
ancestor in the actual route. Pending status is fenced to the current
subject; interrupted older removals offer explicit local completion, and
denied requests offer browser reauthentication. Same-host ports have
distinct labels and confirmations, and unsupported hosted ports are
excluded.

This changes the mobile client and its public-build CI test list only:
no relay endpoints, events, migrations, or backend deployment.

### Related issue

No duplicate found among open known-communities/switcher issues and PRs.
Related picker editing work: #6632 (renaming communities).

### Testing

Validated after merging main (`02535e1b53`) at
`c4ee037f7e710962f176540abf88d26e98c2823c`. Wes’s follow-up fixes cover
push-revocation commit ordering, same-account removal confirmation, and
recovery after completed hosted admission. The merge also preserves
main’s toolbar and session protections; a test override now accepts the
updated relay subscription parameter.

- Formatting, static analysis, and differential file-size checks pass.
- Prior full CI and security review passed on `3adb117aae`; security
checks also passed on `cf3836ecb`. Fresh CI and security review are
required for this head.
- Mutation checks fail when either the initiating-account removal guard
or the rendered-status subject fence is removed; both guards were
restored before final validation.
- CI explicitly runs the public-only account discovery and
synchronization journeys.
- Added journeys cover paused removal across A→B, offline restart,
journal read/write failures, duplicate local identities in either
removal order, delayed status reads across accounts, real browser
handoff after denial, unbound external discovery, and local same-host
port removal.
- Earlier journeys cover pairing acknowledgement and restart after
journal-write failure, same-subject setup completion, offline/rejected
removal with reopen/retry, and fresh external-only/mixed account entry.
- Regression coverage includes discovery deduplication and retry, hosted
and external selection, Add without Find, account-only removal, shared
authentication/removal persistence, restart recovery, latest-intent
ordering, account changes, and retry pause/resume.
- `just mobile-check`, `just file-size-check`, and `just mobile-test`:
4,954 default-build tests passed (71 skipped), plus 27 crypto-package
tests.
- Full public-account suite: 5,012 passed, 12 skipped, one pre-existing
failure in `fullscreen_onboarding_test.dart` ("Home stays hidden until
community choice and admission"). The same assertion was reproduced on
clean base `8cce12f591`: expected both communities imported, actual only
the selected community.
- Follow-up regression journeys cover both A/B same-address removal
orderings, recovery preserving B’s saved key, the production onboarding
widget composition, and retained discovery intent with callback/retry
plus normal-sign-in controls.
- Native/live-account and human testing remain outstanding. The tests
use fake network/storage boundaries; live account API behavior,
cross-device synchronization, native accessibility, and
timeout/late-server-commit ordering still require integration
verification.

- The three expanded recovery/removal journeys pass and each fails when
the corresponding fix is removed. A durably journaled revocation now
finishes the confirmed removal even if the account changes during
journaling; pre-journal account mismatches still abort. Confirmation
copy counts only same-account identities. Explicit account recovery
retires a completed join target while preserving in-progress targets.

### Preview

Sample-data Flutter widget renders: saved-only and combined lists. These
illustrate the picker layout, not a device session or live account sync.

| Saved-only | Combined |
| --- | --- |
| ![Saved-only
picker](https://github.com/user-attachments/assets/eeadbd28-5ef0-4bc1-a381-8fdf71563144)
| ![Combined
picker](https://github.com/user-attachments/assets/58080884-82c2-4538-8d9d-54eb95218d81)
|

### Manual verification

1. Sign into a public account with a community saved on another device.
Open Switch Community; verify it appears alongside local choices and
Add.
2. Select a hosted and an external community; verify the existing
identity/admission flow opens. Add should not offer Find again.
3. Add a community by QR/address, then check the account list on
desktop. Remove it on mobile and verify the account entry disappears
while other devices retain their local credentials.
4. Repeat removal offline, restart, then reconnect/resume. Verify the
queued removal reaches the account service without switching identities.
5. On a fresh device, verify external-only and mixed account lists offer
external entry. Check two ports on the same host remain distinguishable.
6. Sign out of account A and into B; retained A destinations must not
upload to B. Explicitly add a B destination and verify it syncs.
7. Reject or interrupt account removal; verify visible pending/failure
status. A denied session must open browser sign-in through “Sign in
again” and retry after exchange; setup-required accounts retain their
setup action.
8. Keep two local identities owned by the same account at one address;
removing the first must keep the account entry, and removing the last
must queue account removal. Repeat with A and B at that address;
removing A must preserve B’s saved credentials and still sync A’s
removal.
9. Restart offline with a stored account, add/remove an external
community, then reconnect as the same account and verify convergence.
Explicit sign-out must not claim new local-only entries.


10. Start Find my communities, restart during browser authentication,
then return or retry. External destinations must appear before hosted
identity setup; normal sign-in must retain its identity checks.

---------

Signed-off-by: kenny lopez <klopez4212@gmail.com>
Signed-off-by: Tom Brow <tomb@squareup.com>
Co-authored-by: Terp <5856f6900e8e0a4e0ea1f4f8d2ee33e4753d2119bc122f94ecafc660b46c0511@buzz.block.builderlab.xyz>
Co-authored-by: Tom Brow <tomb@block.xyz>
Co-authored-by: Tom Brow <tomb@squareup.com>
Co-authored-by: studio <dc2fc481343672df31a689840c09299972e704dac592e0da6f18486646a7ee3e@localhost>
2026-11-15 15:07:56 -08:00
Tom Brow
1a5c6939c5 perf(mobile): save the open-channel directory and catch it up (#9513)
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>
2026-11-15 12:31:58 -07:00
Tom Brow
5b92e02e2a fix(mobile): sign out from Settings in every build, keeping keys on the device (#9421)
Public and Nostr-only builds had no way to sign out. The only route was
Switch community → Edit, remove every community, then tap Back to get a
"Sign out of BuilderLab?" prompt. Removing a community that way also
deletes its key from the phone, even when the user never exported or
backed it up.

Settings now ends with **Sign out** in every build (internal builds
already had it). After confirming:

- Each community's key is first copied into this device's saved
identities, the same thing internal Sign out already did. Sign-in offers
them again, so signing out never destroys a key that may exist nowhere
else. If saving fails, nothing is removed.
- In a public build, the Builderlab session ends next, before anything
is removed. The Sign in landing that follows never shows the old
session, and nothing started there can be cancelled by it. If the
session or a pending browser sign-in can't be cleared, including a saved
session not yet restored after launch, Sign out stops with an error and
keeps every community. Ending the session never waits behind a pending
account request, such as a stalled session check at launch, and no such
request can restore the session once it finishes later. This path never
shows the hosted setup page over Settings. The removed communities'
push-lease tombstones still publish afterwards: the outbox authenticates
them with the push-stop credential the session leaves behind for 10
minutes, including a saved session that was never restored (an offline
launch), even when a first cleanup attempt failed partway.
- Every community is removed, the active one last, so removing the
others never switches to (and connects) another community on the way
out.
- A Sign out failure now shows its error in Settings. The row used
Settings' outer context, so the snackbar went to the page underneath.

Nothing else changes: the switcher, per-community Remove and the
onboarding landing's Back → "Sign out of BuilderLab?" path behave as
before. Internal Sign out keeps its behavior (one community, key kept,
the landing then ends the organization session). The only new UI is one
row at the bottom of Settings.

| Before | After |
| --- | --- |
| <img width="300" alt="before"
src="https://github.com/user-attachments/assets/f49f7869-3401-4e05-aa7b-debe7a7d425c">
| <img width="300" alt="after"
src="https://github.com/user-attachments/assets/99731c6a-035e-447b-987a-7fa0d8e767cc">
|

Demo (public build, simulator): Sign out → confirm → back at the Buzz
landing, signed out of Builderlab.


https://github.com/user-attachments/assets/da64082b-3b73-46d0-8578-771fca7dec22

### Validation

- Added tests: `settings_sign_out_test.dart`, a Settings journey with
two communities whose keys aren't backed up. Cancelling keeps
everything. Confirming removes both (active last) and both keys end up
in saved identities. The root swaps Settings for the real
`OnboardingAppEntry` as the app does. The authenticated root is wrapped
in the real `HostedAppGate`, and no route may be pushed while Sign out
runs. In a public build it fails three ways, each showing the error in
Settings and removing nothing: a saved session that isn't restored yet
can't be deleted, a restored one can't be deleted, and a pending browser
sign-in can't be cleared. Then, with revocations held pending, the
landing appears with the session already gone and no "Signed in as", and
releasing the revocations changes nothing. It runs in the default lane
and in the CI public-build lane (added to `_ci-clients.yml`). Confirmed
it fails when the key save is removed, when the session ends after the
landing appears, when sign-out goes through the flow's published stages,
when a failed clear is detected only by a missing in-memory session,
when a browser cleanup failure is swallowed, and when the error goes to
the page underneath.
- `organization_relay_auth_test.dart`: a push stop still gets an
assertion after signing out a saved session that was never restored,
including a failed cleanup followed by a successful retry (fails without
the fix).
- Sign-out never waits on a pending account request: the Settings
journey holds `/v1/auth/me` during the final sign-out and checks that
its later completion restores nothing (without the fix, Sign out stalls
and both communities stay). `builderlab_account_test.dart` covers a
session check already pending, one that starts while the session is
being deleted, an exchange queued before the sign-out, and an account
request during the removal that must not share the credential with the
notification extension again.
- Focused existing validation: `internal_build_entry_test.dart` with the
internal-build defines passes.
- Full `just mobile-test` (4,848 passed, 74 skipped) and `just
mobile-check` are clean.
- Automated app run at
([d36150c](d36150ccaf)):
fresh iPhone 17 Pro simulator, public-build Debug signed in to a
Builderlab community. Opened Settings from the community menu (Sign out
is the last row), confirmed Sign out, and landed on the Buzz landing
(Scan a QR code / sign in with email) with no community and no
Builderlab session, and no hosted setup page in between. The screens
match the demo above, which was recorded at an earlier head. Re-signing
in through Builderlab wasn't exercised in the simulator; the journey
test covers the saved identities that sign-in offers. Later commits
change only session-clearing internals, and the tests above cover them.

---------

Signed-off-by: Tom Brow <tomb@squareup.com>
Co-authored-by: Tom Brow <tomb@squareup.com>
Co-authored-by: studio <dc2fc481343672df31a689840c09299972e704dac592e0da6f18486646a7ee3e@localhost>
2026-11-15 19:31:04 +00:00
Tom Brow
44c8206bea fix(mobile): wrap inline Markdown links with their sentence (#9462)
A link inside a sentence used to be drawn as its own little widget, so a
long label jumped to a line of its own and the words after it started
yet another line. Plain links are now text in the sentence: a long label
breaks mid-label, and the words after it continue on the same line.

Tap still opens the link, a finger on it still tints it, and a hold
still opens the link sheet (Open, Copy, Share) instead of the message
menu. Buzz chips (channel and message links), audio attachments and
repository links keep their current widget look.

| Before | After |
| --- | --- |
| <img alt="before"
src="https://github.com/user-attachments/assets/e77aa97a-6ac5-43b9-bc44-cc43fb169c8f"
width="300"> | <img alt="after"
src="https://github.com/user-attachments/assets/4c76bb23-e6df-4244-bf7e-e1753b727d7b"
width="300"> |

A finger on a text link tints it, across every line of a wrapped label:

<img alt="Pressed tint on a wrapped link"
src="https://github.com/user-attachments/assets/1cde5a1a-39aa-4bc7-90f8-8d95b15ee852"
width="400">


https://github.com/user-attachments/assets/021dd099-d24b-4370-bf75-e60f273e2a92

### Regressions

One tradeoff, accepted so links can wrap:

- **VoiceOver users lose Copy and Share on text links.** VoiceOver still
opens the link, but a text span can only expose a tap to accessibility,
so the link sheet (Copy, Share) can't be reached on text links with
VoiceOver. Chips and repository links keep it. A link nothing can open
(such as mailto) shows its sheet on a tap, so it isn't dead for
VoiceOver users.

Nothing else gets worse. The pressed tint is a translucent paint-only
layer drawn on top of the message's Markdown over the link's text boxes,
so inline code and table header backgrounds can't hide it, so a press
repaints that message and rebuilds nothing; a tint that spans a wrapped
label covers both lines, and it stays inside what's visible (a long link
in a scrolled table cell tints only inside the table). Each message
reuses one recognizer per link across rebuilds and disposes them when
its text changes or the message goes away, and a scroll that starts on a
link cancels the hold, so it never opens the sheet. Only plain links
change shape (including any inline code inside a link label, which now
taps and holds as part of the link); chips, media and code outside links
are untouched.

### Validation

Added tests:
- A long link label in a narrow message breaks across lines, and the
following words continue on the line where it ends.
- Holding a link and then sliding off it before the hold delay opens
nothing (no sheet, no message menu, no open).
- Pressing a text link tints it, and lifting or sliding off clears the
tint; lifting a second finger keeps the tint.
- A pressed link in a horizontally scrolled table cell is tinted inside
the table and nothing past its edge.
- Tapping a link nothing can open (mailto), by finger or screen reader
activate, shows Copy and Share.
- A pressed link in inline code (plain and in a bubble) or in a table
header shows its tint (these fail with the tint drawn underneath).
- Code inside a link label taps and holds as part of the link; a hold
across an edit that removes the link does nothing; a second finger
mid-hold doesn't restart it.

Existing link tests (tap, hold sheet, copy and open from the sheet,
message menu beside a link, swipe to reply from a link, attachment
links) now find links inside their paragraph. They all pass, along with
the full mobile suite and analyze.

Automated simulator run (iPhone 17 Pro, internal community, synthetic
message): pressing a wrapped link tinted all three of its lines; holding
a text link opened its sheet; holding the text right after it opened the
message menu; tapping the second line of a wrapped link opened it in
Safari; a scroll starting on a link scrolled the list and opened
nothing.

---------

Signed-off-by: Tom Brow <tomb@squareup.com>
Co-authored-by: Tom Brow <tomb@squareup.com>
Co-authored-by: studio <dc2fc481343672df31a689840c09299972e704dac592e0da6f18486646a7ee3e@localhost>
2026-11-15 09:06:30 -08:00
Tom Brow
934a16f2ff feat(mobile): message the Bestie from Siri and Shortcuts (#9517)
Adds a **Message my Bestie** action for Siri and Shortcuts. Siri asks
what to say, confirms with the Bestie's name ("Send “…” to Astra?"), and
posts the message in your DM with the Bestie, without opening Buzz. The
Bestie's reply arrives as a normal notification, in the same DM the Home
star opens.

This is the iOS 16+ App Shortcut from [ADR
0005](https://github.com/block/buzz/blob/mobile-siri-bestie-dm/docs/adr/0005-quick-send-uses-the-system-send-message-action.md).
Follow-ups, not in this PR: the iOS 27 `messages.sendMessage` schema
intent, naming other recipients, a separate "Start a chat with my
Bestie" intent for a new Solo chat, and opening Buzz with a draft when a
send fails.

### How it works

- The App Intent runs without opening the app and hands the text to Dart
over a method channel. It waits up to 20 s for Home to say it is ready,
and runs one send at a time.
- A background launch already starts the Flutter engine and builds Home
([ADR
0004](https://github.com/block/buzz/blob/mobile-siri-bestie-dm/docs/adr/0004-background-work-runs-in-the-app-engine.md)
records the measurement). So a small `QuickSendHost`, which the app
hands Home as an invisible background widget, takes the send. Nothing is
reimplemented natively.
- Before confirming, Swift asks Dart for the saved Bestie's pubkey and
name; the send then goes to exactly that agent, so a choice this phone
hasn't synced yet is caught at the confirmation.
- The send reuses the Home star's lookup for the Bestie DM (opening it
with the relay's find-or-create DM command when it isn't loaded) and
posts with the same `SendMessage` the composer uses.
- If Buzz has been in the background past its 5 s grace period, the
relay session has closed its socket. The send reopens it, then lets the
normal background pause start over.
- A message the relay rate-limits is retried (up to 3 tries); the relay
turned it away, so a retry can't duplicate it. Any other failure isn't
retried, since the message might have landed.
- The confirmation is pinned to the community and account it was shown
in: if Buzz switches either before the message goes out, the send is
refused.
- If the send fails, or Buzz can't tell whether it landed (no answer
from the relay), the message is saved as the Bestie DM's composer draft,
after any draft already there, and Siri says so ("Buzz isn't sure that
sent. Check your Bestie DM before trying again." when the outcome is
unknown). A successful send leaves the draft alone. Limits: if the DM
can't be found or opened, there is nowhere to save it and Siri says the
message wasn't saved, and the app being killed mid-send isn't covered.
- Refusals (no Bestie, offline, empty or too long, switched community)
come back as a short message Siri reads.

### Regressions

- Nothing existing changes behavior: the host only answers this method
channel, and the action does nothing until someone runs it. Its bugs
stay inside the quick send path.
- The Home star's DM lookup moved into `cachedBestieConversation`
unchanged, so the star behaves as before.
- A composer that is open on screen now shows a draft another writer
saved for it (here, a failed quick send) instead of overwriting it with
the next keystroke. It listens without rebuilding, and its own saves are
ignored.
- A background wake pays the cost of starting the app's Dart code, which
iOS already does for this launch.

### Before / after

| Before: no Buzz actions in Shortcuts | After |
| --- | --- |
| <img width="300" alt="Shortcuts Library before"
src="https://github.com/user-attachments/assets/b0870e3d-2823-4c7d-be0e-a242a3fdafd7">
| <img width="300" alt="Shortcuts Library after, listing Buzz Dev under
Apps"
src="https://github.com/user-attachments/assets/8c092006-76b9-4313-a401-68189f5674cf">
|

| Asks what to say | Confirms (names the Bestie) | Sent |
| --- | --- | --- |
| <img width="250" alt="Prompt"
src="https://github.com/user-attachments/assets/a2eaf44a-5287-48b6-9c5a-2aaefc90c0a8">
| Shows "Send “…” to *Bestie's name*?" (capture omitted: it shows an
internal agent name) | <img width="250" alt="Sent"
src="https://github.com/user-attachments/assets/07fe66e3-4480-4d06-be52-623416e567b8">
|

The DM result and a demo video show internal names, so they're shared
internally rather than here.

### Testing

- Added test, `quick_send_test.dart` journey: Home reports ready; Siri's
Bestie lookup is refused with no Bestie, then returns the chosen
Bestie's pubkey and name; a send confirmed for another community is
refused; an empty send is refused without publishing; a send while Buzz
is backgrounded and its socket closed reconnects, opens the DM with the
Bestie, survives a rate-limited first try, posts the message in that DM
tagged to the Bestie, and hands the session back to its background
pause; a second send goes to the same DM and leaves the person's draft
there as it was; a send whose answer is lost is reported as unsure and
kept in that draft after the person's own text, with its mentions; a
socket that drops just before the message goes out keeps it too; leaving
Home reports unready. Removing the rate-limit retry, the community check
or the draft save fails it.
- Extended the composer's share-delivery journey: a draft saved by
another writer while the composer is open shows in the composer and
survives the next keystroke, and survives an ordinary send that was
pending when it arrived and then fails. Removing the composer's listener
or its revision bump fails it.
- iPhone 17 Pro simulator (iOS 27), Builderlab community with a Bestie,
automated with AXe:
- Cold: Buzz terminated, ran the action from Shortcuts, the confirmation
named the Bestie, "Sent.", and the message was in the Bestie DM with its
reply. No Solo chat was created.
- Warm: Buzz in the background for 10 s, ran it again, "Sent.", same DM.
- At-risk flows: sent a typed message from the DM composer, went back to
Home, and the Home star reopened the same DM.
- `just mobile-check mobile-test` passes.






buzz-review-completed

---------

Signed-off-by: Tom Brow <tomb@squareup.com>
Co-authored-by: Tom Brow <tomb@squareup.com>
2026-11-15 09:06:25 -08:00
Tom Brow
bf422ac8e1 perf(mobile): parse each event's thread reference once (#9460)
Every time code asked an event for its parent or thread root
(`threadReference`, `parentEventId`), `parseThreadReference` walked its
tags again and ran a 64-character hex regex over each `e` tag. The
channel store asks that many times per event:

- `_trimReplyOverlay` runs on every live event merged into the window
and re-parsed every overlay event, twice.
- `_reconcilePageSummaries` called `cachedThreadReplyIds(root)` once per
row of a fetched page, and each call re-parsed every cached reply (twice
per reply) to find that root's replies. A 200-row page did 200 full
passes.

Now:

- `parseThreadReference` keeps its result per tag list in an `Expando`.
Event tags are never changed after an event is built (nothing in `lib`
mutates a `NostrEvent`'s tags), so the cached value always matches.
- `_reconcilePageSummaries` indexes cached replies by root once, then
reads each row's count from that map. `cachedThreadReplyIds` keeps its
signature and result and shares the same code.

### Validation

Full mobile test suite and `flutter analyze` pass. Existing
thread-summary, reply-overlay and thread-reference tests cover the
unchanged results.

On the iPhone 12 mini (profile build, Builderlab), same scripted run on
`main` and on this branch: open three threads from Activity, back out
after each.

| Dart CPU in thread-reference code | main | this branch |
| --- | --- | --- |
| First thread (not cached yet) | 5 ms | 2 ms |
| Second thread (loads the channel window) | 27 ms, plus 18 ms trimming
the reply overlay | 3 ms, plus 2 ms |
| Third thread | 10 ms | 0 ms |

The threads opened and showed the same replies in both runs, and the run
covered a channel window load, live events arriving while a thread was
open, and backing out to Home.

### Regressions

None expected. Results are identical; the cache holds one small record
per live tag list and is released with the event.

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>
2026-11-13 14:57:26 -08:00
Tom Brow
c97c85d8fa perf(mobile): load only the directory when search opens (#9466)
Opening search on a list that is already loaded refreshed the whole
channel list to get the open-channel directory: the membership rosters
(kind 39002), member channel metadata, hidden DMs, Huddle starts, DM
names and the latest messages of every joined channel, then the
directory pages. Only the directory was what search needed; everything
else was already in the list and kept current by live updates.

Search now reads only the directory pages and merges them into the
current list: every channel you are not a member of is rebuilt from the
fresh directory (latest revision per channel, open and non-DM only, the
same rules as a full refresh), and joined channels keep their entries
untouched. When the list has not loaded yet, the full refresh runs as
before.

Races:
- A directory-only load is fenced by scope alone (community, identity,
disposal), not by the list-refresh generation, so it neither retires an
in-flight membership refresh nor is retired by one. A community or
identity switch retires it: its response is discarded and it no longer
owns its loading status, so returning to the first community (before or
after the old request ends) lets search load the directory again.
- Directory loads are ordered among themselves: only the newest one
writes the directory and its load status, so an older full refresh
cannot overwrite a newer search load and vice versa.
- A list refresh that merged an older directory and then installs after
a search load landed re-merges the newer directory, so the open channel
search just found does not disappear.
- A list refresh no longer resets a live directory-only load's status to
idle (that reset existed because a refresh used to discard the in-flight
directory, which it no longer does for this kind of load). A load
retired by a scope switch is not live, so the reset still applies to the
status it left behind.

## Results

iPhone 12 mini, profile build, Builderlab account. Typing a query into
search on a loaded list, more than 30 seconds after the last directory
load (two runs each, same numbers both times):

| | HTTP per search | What it read |
| --- | --- | --- |
| main | 3.59 MB | rosters 1.53 MB, channel metadata and directory 1.26
MB, latest messages 0.80 MB |
| This change | 1.26 MB | directory pages only |

Unjoined open channels still appear in results with their Open badge.

## Regressions

The tradeoff we accept: on a search open, joined channels' member
counts, unread badges and latest-message times are not re-read; they
show what the last full refresh found, as updated by live events since.
Live join and leave notices, metadata changes and new messages still
apply as they arrive, and the next ordinary refresh (launch, reconnect,
resume, pull to refresh) re-reads everything. The case that differs is a
change that live delivery missed on a healthy connection (for example a
roster change made while a live chunk was briefly refused): before,
opening search happened to repair it; now the next ordinary refresh
does.

Nothing else changes: open channels are listed under the same visibility
rules, a failed directory load still reports its error to search and
keeps the cached discovery, and the first load is unchanged.

## Testing

- Full mobile suite passes; `flutter analyze` clean.
- New tests: a search load on a loaded list issues only directory
queries (no roster, member metadata, hidden-DM, Huddle or message
reads), lists the new open channel, drops one that became private and
keeps the joined channel object unchanged; a membership refresh during
the load is kept and does not reset its status; a list refresh that
merged the directory before a search load landed keeps the newer
directory; a community switch discards the response; returning to the
first community, both while the old request is in flight and after it
ended, loads the directory again.
- Automated device run on the iPhone 12 mini: launch, two search
sessions typing a query, results list joined and unjoined open channels,
close and reopen search. Rerun on f216dd6afc (after the scope-switch
fix) with the same results: 1.26 MB HTTP per query, unjoined open
channels marked Open.

---------

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>
2026-11-13 14:40:27 -08:00
Tom Brow
5f1cd67985 perf(mobile): stop rebuilding Home's channel list when a route covers it (#9459)
Opening any route or sheet above Home (search, a message's action menu,
a profile sheet, Activity, Settings) rebuilt Home's whole channel list
twice: once when the route started covering Home and once when it
finished. On a phone the open channel sits inside Home's conversation
pane, so a sheet over a channel (long-press menu, profile) did the same.
`HomePage` and `ChannelsPage` read `ModalRoute.of(context)` in their own
builds, which depends on every part of the route's state (whether it's
current, whether it's offstage, and so on). `ChannelsPage` also depended
on the whole `DuoToolbarScope`, whose `active` flag flips whenever a
route covers the pane, through `frostedAppBarHeight`. Every channel row
and the Solo section depended on `ConversationPaneScope` for the
selected channel, and that scope notified all of them when its
route-dependent `active` flag flipped. Each of those rebuilt a fresh
channel inventory, including Solo rows that had scrolled away, which
resubscribed their typing feeds for 30 seconds.

Now:

- Home's native controls (Activity bell, tab bar, Duo rail) read the
route in a small `_NativeControlsGate` leaf, so only they rebuild when
Home is covered.
- `ChannelsPage` mirrors route currency into its header suppression
notifier from a `_RouteCurrencySync` leaf above the header, so the
header still switches in the same frame. The two "wait until this route
is current again" loops read the same notifier.
- `DuoToolbarScope` is an `InheritedModel` with a strip-only lookup,
`maybeStripOf`. The frosted header's height and `ChannelsPage` use it,
so `active` changes no longer reach them. Every other reader keeps
`maybeOf` and its current behavior.
- `ConversationPaneScope`'s `active` flag lives in its own private
inherited widget, read only by `isActiveOf`. Rows that only need the
controller no longer rebuild when it flips.
- Opening a channel looks up the conversation pane instead of depending
on it.

### Validation

New test: opening and closing a sheet above Home rebuilds neither
`HomePage`, `ChannelsPage` nor any channel row. It fails without this
change.

Full mobile test suite, `flutter analyze` and the file-size check pass.

On the iPhone 12 mini (profile build, Builderlab):

Same scripted run on `main` and on this branch (search opened and closed
3 times, then a message's long-press menu and a profile sheet over an
open channel):

| | main | this branch |
| --- | --- | --- |
| Widget builds per search open | 126 to 350 | 56 to 60 |
| Build time per search open | 79 to 90 ms | 29 to 41 ms |
| Build time, long-press menu open | 64 ms | 17 ms |
| Typing subscriptions reopened by the sheets | 9 (about 80 KB of
messages downloaded) | 0 |

The menu, profile sheet, channel header and Home's tab bar and Activity
button behaved the same in both runs.

### Regressions

None expected. The native controls and header switch from the same route
state as before, in the same frame. A `DuoToolbarScope` strip change
still reaches the header and the channel list.

---------

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>
Co-authored-by: studio <dc2fc481343672df31a689840c09299972e704dac592e0da6f18486646a7ee3e@localhost>
2026-11-13 14:40:22 -08:00
Tom Brow
3764a2e4d5 perf(mobile): ask typing subscriptions only for the typing window (#9454)
Every channel that shows a typing indicator (the open channel, and each
Solo row on the home list) subscribes for typing and message events with
`limit: 10` and no `since`, so each subscribe replays that channel's
last 10 stored messages. The handler then ignores every one of them that
is older than the 8 second typing window, so the replay only costs
bytes. On an iPhone 12 mini signed in to Builderlab, seven Solo rows
made this about 66 KB of kind 9 messages on each cold start, and again
on each resubscribe.

The subscription now asks only for events inside the typing window
(`since` = now minus 8 s), which are the only ones the handler can act
on.

### Validation

New test: the typing subscription asks for history starting 8 s before
it subscribes. It fails without this change.

Full mobile test suite and `flutter analyze` pass.

On the iPhone 12 mini (profile build with this change, signed in to
Builderlab), stored and live events on the typing subscriptions in the
first minute or more after a cold start:

| | Subscriptions | Kind 9 messages | Typing events |
| --- | --- | --- | --- |
| Before (60 s) | 7 | 74 (66.6 KB) | 26 (15.6 KB) |
| After (80 s) | 8 | 2 (1.5 KB) | 29 (17.8 KB) |

Typing events are mostly live ones from agents working in Solo chats, so
they stay about the same. The automated run covered a cold start to the
home list and its Solo rows.

### Regressions

- A device clock running more than 8 s fast can make the relay skip a
message that would have ended an indicator. That indicator still clears
when its 8 s window ends, and the handler already drops events it
considers older than the window, so the same skew loses the same events
today.

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>
2026-11-13 14:40:17 -08:00
Tom Brow
9e40bf5d79 perf(mobile): don't treat a Control Center pull as a resume (#9443)
Pulling down Control Center or Notification Center, answering a system
alert, or glancing at the app switcher moves the app to `inactive` and
straight back to `resumed`. The app never leaves the foreground and the
socket stays connected, but every resume listener treated it as a return
from the background. Each glance re-read the channel list (memberships,
metadata, unread catch-up), the four settings documents (mutes, stars,
sections, sort) and the Me groups, and tore down and rebuilt the
community presence subscription. On a heavy Builderlab account that is
about 2.6 MB per glance.

This adds `appForegroundProvider`, which follows the app lifecycle but
ignores `inactive`. The resume refreshes and both presence providers
watch it instead of the raw lifecycle, so they run only when the app
actually comes back from the background. Camera capture keeps watching
the raw lifecycle, since it has to release the camera while the app is
inactive.

### Validation

Added tests: the channel sync journey test now pulls the app through
`inactive` and back without leaving the foreground and expects no
membership read; it fails without this change (2 reads instead of 1).
The existing resume and background cases in that test still pass
unchanged. A second step lets a failed list read's retry come due while
the app is `inactive`; it is read then, not left for a resume that no
longer comes (it fails without the read gate change, 8 reads instead of
9). Full mobile test suite passes.

On an iPhone 12 mini signed in to Block's Builderlab (instrumented
profile build), pulling Control Center down and dismissing it:

| | Downloaded after dismissing it |
| --- | --- |
| Before | 2.6 MB (rosters 1.5 MB, latest messages 0.7 MB, channel
metadata 183 KB, settings, presence resubscribe) |
| After | 6.5 KB (live typing and presence only) |

The same run covered cold start, 5 minutes idle on Messages, and a
resume after 60 s in the background; the resume still refreshed the
channel list, read state and settings documents as before (2.8 MB HTTP,
2.1 MB WebSocket).

### Regressions

None expected. A real return from the background still goes through
`hidden`/`paused` first, so it triggers every refresh it did before. The
only behavior change is for `inactive` alone: no refetch, and the user's
presence no longer flips through a republish of `online`. A channel-list
read that comes due during `inactive` (a membership notice or a retry)
now runs then instead of waiting for a resume, since the socket is still
connected. A missed live event during a Control Center glance is still
caught by the next real resume or reconnect, as before for any time in
the foreground.

---------

Signed-off-by: Tom Brow <tomb@squareup.com>
Co-authored-by: Tom Brow <tomb@squareup.com>
Co-authored-by: studio <dc2fc481343672df31a689840c09299972e704dac592e0da6f18486646a7ee3e@localhost>
2026-11-13 14:40:00 -08:00
Tom Brow
15c65c76d9 fix(mobile): keep a superseded roster read out of the offline snapshot (#9452)
The channel member list keeps a snapshot of the last roster it read,
which it shows while the relay is disconnected. When two roster updates
arrive close together, the member list starts a read for each. If the
first read answered after the second, it still wrote its older roster
over the snapshot. The live list stayed correct, but once the app went
offline it showed the older roster: for example, a member just removed,
or a bot role just changed, came back.

A read that a later read has replaced no longer writes the snapshot. The
snapshot cache numbers each read of a channel's roster, and only the
latest read for that channel may write. A read that ends because nothing
is watching the list any more (the user leaves the screen mid-read, or a
one-off lookup such as sending a message) still writes, since its roster
is the newest one.

### Validation

New tests, which fail without this change:

- Two roster updates arrive, the second read answers first and the first
answers after it, with a roster, with no roster event, or with an empty
roster. Once disconnected, the member list still shows the newer roster.
- A roster update arrives and the user leaves before its read answers.
Once disconnected, the member list shows that newer roster. (This passes
on main and guards against fencing on disposal, which an earlier version
of this PR did.)

The rest of the channel management tests pass unchanged. Full mobile
test suite and `flutter analyze` pass.

The race itself needs two roster reads to answer out of order and then a
disconnect, which a device run can't reliably produce. An automated run
on an iPhone 12 mini signed in to Block's Builderlab (profile build of
this head) covered the roster paths it touches: cold start, searching
for and opening buzz-mobile, its details (86 members) and its member
list (49 people, roles shown), scrolling it, backgrounding the app for
60 seconds, resuming, and reopening the member list, which loaded the
same roster.

### Regressions

None. A replaced read's result was already discarded for the live list;
now it is also kept out of the offline snapshot. Reads that nothing
replaced write the snapshot as before.

---------

Signed-off-by: Tom Brow <tomb@squareup.com>
Co-authored-by: Tom Brow <tomb@squareup.com>
Co-authored-by: corey <2dafccf60ea6d431a568f6d67fc60016c1b2a51e415e09dc8b213b8e3606cf54@buzz.block.builderlab.xyz>
Co-authored-by: studio <dc2fc481343672df31a689840c09299972e704dac592e0da6f18486646a7ee3e@buzz.block.builderlab.xyz>
Co-authored-by: perfie <1fc92b08616bef6025a30fa24528ba2417d2a0c82f2c67b62e7f912089235028@buzz.block.builderlab.xyz>
2026-11-13 14:37:45 -08:00
Tom Brow
3dcdf1c056 perf(mobile): read Activity once per reconnect (#9455)
Activity watched the whole relay session state, so it rebuilt, and
downloaded its whole feed again, for every socket state on the way back
from a reconnect: disconnected, reconnecting (once per attempt) and
connected. Only the last of those reads could subscribe live; the others
were thrown away. On an iPhone 12 mini signed in to Builderlab, every
resume after the background grace period read the 25 KB feed three
times.

Activity now reads again once per new connection, the way the profile
provider already does: it listens for the session becoming connected and
rebuilds then. Losing the connection no longer rebuilds it, so the feed
it already shows stays until the reconnect read replaces it.

### Validation

New test: a disconnected, two reconnecting and a connected state read
the feed once. It fails without this change (four reads).

Full mobile test suite and `flutter analyze` pass.

On the iPhone 12 mini (profile build with this change, signed in to
Builderlab), 60 s in the background, then the first 20 s after resuming:

| | Activity feed reads | Bytes |
| --- | --- | --- |
| Before | 3 | 74.8 KB |
| After | 1 | 25.0 KB |

After the resume, Activity's live subscriptions opened again, and
opening Activity showed the mention posted just before the resume. The
automated run covered a cold start, the home list, a 60 s background,
the resume and opening Activity.

### Regressions

- While the relay is unreachable, Activity keeps showing the feed it
last read instead of reading over HTTP on each socket state. Once the
socket connects again it reads and subscribes as before.

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>
2026-11-13 14:28:49 -08:00
Tom Brow
04af7081c8 fix(mobile): offer role controls for agents (#9475)
Mobile hides every role control for a channel member whose role is
`bot`. On relays running [#8494 bot role from
owner](https://github.com/block/buzz/pull/8494), any agent with a
recorded owner is reported as `bot` whenever it holds an ordinary role.
So if an admin demotes an owned agent from admin to member, the
refreshed roster says `bot` and mobile no longer offers "Make channel
admin": the demotion can't be undone from mobile.

This change gives agents the same role controls as people, matching
desktop:

- The member profile actions offer "Make channel admin" for `bot`
members. "Change to member" still appears only for admins and guests, so
an agent that is already ordinary isn't offered it.
- The members sheet shows the Role selector for agents, with Member
selected for `bot` (the two are permission-equivalent). The row label
still reads "Agent".

**Rollout:** ship this in a mobile release before relays with #8494
deploy.

Review discussion: [buzz-mobile-tomb-review-work
thread](buzz://message?channel=95213a25-483a-458b-9bc3-71891fa5aef6&id=4714950ee67bf04464a59c1deb3470972c0809c7be780183da6b4a2e77243714).

### Regressions

None expected. The relay already accepts admin, member and guest for
agents (owned agents can hold admin today), so the newly shown actions
submit role changes it accepts. On current relays an agent added as
`bot` now also shows these controls; tapping Member on its selector is a
no-op because Member is already selected.

### Validation

Changed tests: the profile-actions role table now expects "Make channel
admin" for `bot`; the promote, demote journey continues with the
refreshed role coming back as `bot` and expects promotion to be offered
again; the members-sheet agent row expects the Role selector with Member
selected.

Full mobile suite: 4,828 passed, 70 skipped, 1 failed. The failure,
`video_controls_test.dart` "iOS timeline requests native Liquid Glass
and fades with the toolbar", is unrelated media-viewer code; it passed
when rerun on its own, and the pre-push hook's full mobile run passed.

Simulator check against a live relay: an agent added with the `bot`
role, viewed by the channel owner in its member profile.

| Before | After |
| --- | --- |
| <img alt="before"
src="https://github.com/user-attachments/assets/2503ae98-b198-46c3-85c9-0b85dae2c4ae"
width="300"> | <img alt="after"
src="https://github.com/user-attachments/assets/82abf55a-de56-45aa-86c5-7917877e388e"
width="300"> |

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>
2026-11-13 14:05:48 -08:00
Tom Brow
237a39fe76 perf(mobile): keep latest-message times on a directory load (#9457)
Opening search loads the channel directory when it is older than 30
seconds. That load reruns the whole channel list read, including each
channel's latest messages (up to 20 per channel, 1 per DM), even though
the list is already showing and its live subscriptions keep those times
current. On an iPhone 12 mini signed in to Block's Builderlab, the
latest-message part was about 700 KB of every search open.

A directory load now skips the latest-message read when a channel list
is already loaded and keeps the loaded times, the same as the background
list reads already do. The first load, when no list is showing yet,
still reads them. Both reads still fetch latest messages for member
channels the list did not already show (for example a DM opened on
another device), so those get a time instead of sorting last in Recent;
before, background list reads left them without one. If that read hits
the relay deadline, the list is marked for a full read and retried with
backoff, as a timed-out full read was before.

### Validation

New test: with a loaded list, a directory load sends no latest-message
requests, adds the directory channel and keeps the member channel's
latest-message time. It fails without this change. A second test: a DM
first listed by a directory load, holding only our own message (which
unread catch-up skips), gets its latest-message time. It fails without
the newly-listed read. Its deadline row (the read that first lists the
DM times out) checks that the backoff retry dates the DM; it fails if
either the revalidation flag or the retry is removed.

Full mobile test suite, `flutter analyze` and the file-size check pass.
To stay under the 1200-line limit, `_advanceLastMessageAt` moved
unchanged into `channel_unread_catch_up.dart`.

On the iPhone 12 mini (profile build, signed in to Builderlab), opening
search 90 seconds after a cold start and typing "buzz":

| | Latest messages | All relay HTTP |
| --- | --- | --- |
| Before | 704 KB | 3.56 MB |
| After | 0 | 2.86 MB |

The automated run covered a cold start, the home list, opening search,
channel results for the query, and closing search back to the home list
with the same order.

### Regressions

- A directory load with a loaded list no longer refreshes cached DM
display names; the next full list read (pull to refresh, cold start, or
a channel action) still does, as for background list reads.
- A latest-message time the live subscriptions missed (for example while
the socket was down) is not corrected by opening search; the next full
list read corrects it.

---------

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>
2026-11-13 13:39:55 -08:00
Tom Brow
d1a8c3607d perf(mobile): use HTTP/2 on Android through app-wide Cronet engines (#9435)
Follows #8897 (iOS HTTP/2), now on main.

## What

Android gets the same app-wide shared sessions as iOS, backed by Cronet
(`cronet_http`) instead of `NSURLSession`:

- One Cronet engine per traffic class (API, media), so requests to a
host multiplex over one HTTP/2 connection and gzip is inflated natively,
off the Dart isolate.
- HTTP/2 on, HTTP cache off, QUIC off. QUIC would be a separate behavior
change, and `cronet_http`'s changelog lists DNS failures with QUIC on
cellular.
- Streamed uploads (media and voice notes) stay on `dart:io` on Android:
`CronetClient` reads a request body into memory before sending it, which
would break upload progress and copy large attachments in full.
- If no Cronet provider is available (no Google Play services), the
engine fails to build and the app keeps `dart:io`, as today.
- Transport error classification covers Cronet failures alongside
`NSURLSession` ones, so invite and pairing errors keep their friendly
messages.

## Measurements

Android emulator (API 36, arm64), profile builds of this branch and
main, signed in to the Feedback community. 8 cold starts per build,
alternating builds in blocks of 4. Times are for relay `/query` requests
started in the first 8 s.

| | main (`dart:io`) | this branch (Cronet) |
|---|---|---|
| First query response | 6.99 s | 1.99 s |
| Startup burst settled | 8.36 s | 2.78 s |
| Burst after the first connection | 1.44 s | 0.77 s |
| Query latency after the first connection, median / p90 | 165 / 1567 ms
| 106 / 158 ms |

**Unexplained stall:** most of main's startup gap is a ~5 s stall before
its first response on every cold start. Its cause is unconfirmed; my
guess is `dart:io` loading its CA store on the emulator, which HTTP/2
itself wouldn't fix, so the first two rows likely overstate the win on
real devices. The rows after the first connection exclude the stall and
are the fairer comparison. I also tried emulated EDGE throttling, but
the emulator's throttle did not slow its traffic, so there are no
slow-link numbers yet.

## Regressions

None found. Devices without Play services keep `dart:io`. Cleartext
`http://` requests keep the handle's own `dart:io` client, as on iOS.

## Testing

- Full mobile suite passes (`flutter test`, 4784 tests).
- Automated app run on the emulator: onboarding, Feedback nsec import,
channel and DM list load, and 16 cold starts with request timing. Media
loading wasn't separately exercised.
- No visible UI change, so no screenshots.

---------

Signed-off-by: Tom Brow <tomb@squareup.com>
Co-authored-by: Tom Brow <tomb@squareup.com>
2026-11-13 13:33:58 -08:00
Tom Brow
36fa0fe318 perf(mobile): subscribe to presence only for people on screen (#9444)
The mobile app subscribed to every presence event in the community,
though it only shows presence for people on screen. It now subscribes
only to the people it tracks.

### Validation

**Impact:** on an iPhone 12 mini signed in to Block's Builderlab, 5
minutes idle on Messages:

| | Presence downloaded | All WebSocket traffic |
| --- | --- | --- |
| Before | 2.9 MB (8153 events) | 3.1 MB |
| After | 3.6 KB (10 events) | 66 KB |

That's about 35 MB per hour saved at Builderlab's presence rate (about
27 events per second). Measured on an instrumented profile build of the
first revision,
[3f789d1](3f789d16b8).
The later swap fix doesn't change what is subscribed.

**Device runs (automated, profile builds on the 12 mini):**
- First revision: cold start, opening and leaving the home list, a
Control Center pull, and a resume after 60 s in the background. Presence
dots kept updating for people on screen.
- Final head [9844c43](https://github.com/block/buzz/commit/9844c438dd):
cold start, opening two channels, a 60 s background resume, and
scrolling the home list through the DM section. Every DM row showed its
presence dot (online and away), including rows newly scrolled into view.
Opening a DM and its details sheet worked as before.

**Added tests:**
- Swapping subscriptions: a late replacement is promoted without
clearing anyone's dot and re-reads the newly covered people; a retryable
close or an outright failure keeps the current stream; a second track
while one is opening doesn't open a third subscription. Each guard was
removed in turn and the test failed each time.
- A widening that keeps failing is retried each poll, and expired leases
are still corrected.
- Replacements the relay never answers are dropped and retried, and
after the current stream also closes, the next poll covers and reads
everyone.
- A first subscription still retrying when it opens waits for its ready,
then reads everyone and widens.

**Updated test:** the filter test now expects no subscription while
nobody is tracked, then `authors: [alice]`, then `[alice, bob]`. The
full mobile test suite passes.

### How it works

- The live subscription filters by `authors`: everyone shown with
presence this session. The cache never untracks; it resets on community
or account change. Nothing is subscribed while nobody is tracked.
- When someone new is tracked, a replacement subscription opens for the
wider set. The current one keeps delivering until the replacement's
first EOSE, then it's swapped in and the old one closed. Newly covered
people get a fresh snapshot at that point.
- If the replacement fails or closes first, it's dropped and nothing on
screen changes. The 60-second poll retries the widening and keeps
reading the people already covered.
- One replacement opens at a time; people tracked meanwhile join the
next round.

### Regressions

- A person tracked mid-session gets live presence after one extra
subscription round trip (up to about a second on a slow link). People
already on screen keep live presence throughout the swap.
- Each widening resends the full tracked list (about 67 bytes per
person), so a few hundred people cost tens of KB per widening, against
35 MB per hour saved. The relay indexes `authors` filters up to 4096
authors, so this is cheap for it.

---------

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>
2026-11-13 13:32:53 -08:00
Wes
59ae028a36 fix(mobile): require Builderlab consent for existing identities (#8823)
Existing mobile identities entering the Builderlab hosted flow now
require confirmation before the app reserves the account’s identity
slot, binds the identity, or uploads its secret key. Cancelling leaves
saved community keys usable and allows another identity to be selected,
including after restart. Imported keys remain tentative until approval;
paired keys remain safely retained outside the account slot.

The confirmation shows the receiving account’s verified email and public
key, explains that Builderlab can decrypt the backup and signed-in
account users can recover it, and discloses that the app cannot change
the linked identity later. **Cancel setup** stops future work without
claiming to undo earlier binding or an upload whose acknowledgement was
lost. The user can sign out; missing account identification blocks
confirmation. Browser-initiated binding uses **Link and continue**, with
explicit bind-only wording and no upload.

Fresh keys generated in the current hosted attempt use ordinary
onboarding without an extra backup prompt. Interrupted attempts without
a confirmed backup ask again; approval is deliberately not persisted or
carried across retries, cancellation, restart, account changes, or a
replaced flow. Confirmed matching backup receipts skip the backup
prompt. Cloud recovery and organization-managed backup are separate
flows and are not changed here; this PR does not resolve server-side
consent or recovery-authorization policy.

Updated against main through `ce42853982` (#9418). Integration commit
`dfb29fe5e7` includes the landed Hickory security fix and the shared
workflow-test/runner repair. The consent implementation is unchanged
from Carl’s reviewed `e11025ebed`; the CI merge preserves its configured
public consent journeys.

Validation at `e11025ebed`: 96 focused tests across eight files passed
with public hosted domains configured; Flutter analysis passed. In an
isolated source/Git/build copy, removing pre-adoption consent, bypassing
the upload gate, and removing stale-confirmation checks each failed the
consent journeys; restoring the code passed. Carl’s independent source
review found no blockers. Mandatory hooks and hosted mobile CI passed,
including both consent journeys in the configured public lane.

Integration validation at `dfb29fe5e7`: 99 focused tests passed; one
additional fullscreen-onboarding test failed its background
community-admission assertion. An isolated clean-main control at
`ce42853982` reproduces the same failure with the same expected/actual
values. All consent journeys passed. Required commit and push hooks
passed, including mobile analysis and the broader default mobile suite.
Hosted CI is green at `dfb29fe5e7` ([run
43320753801](https://github.com/block/buzz/actions/runs/43320753801)).
Security and the previously failing Rust/workflow gates now pass. The
Mobile Checks log confirms both consent journeys executed successfully;
that run has no pending checks.

Review follow-up `ac9ac9be35`, integrated with main `279a31daac` at
current head `1acfd2dff6`, is test-only: the browser journey now
restores a saved account key without a receipt, cancels without binding,
restarts and requires explicit approval before `/verify`. Both consent
journeys passed again after integration using the updated CI settings.
Disabling only the production bind gate in an isolated source/Git/build
copy now fails the added step; restoring it passes. Mandatory
commit/push hooks passed. Hosted CI is green at `1acfd2dff6` ([run
43343333843](https://github.com/block/buzz/actions/runs/43343333843));
no failing or pending checks remain. The Mobile Checks log confirms both
consent journeys executed successfully, including the extended
browser-binding journey. Carl’s latest review on `dfb29fe5e7` found no
production blockers; its recommended test gap is addressed by this
follow-up.

Native-device and human acceptance have not been recorded here; the
author’s ready-for-review setting is preserved.

Try it: with two saved self-hosted keys, connect to Builderlab, select
A, cancel, restart, then select B. Check the receiving account and key
before approval. Repeat with an imported/paired key and a browser bind
link; cancel must not reserve or bind the new selection. After an
interrupted upload, cancellation must describe that earlier effects may
remain. Confirm that ordinary brand-new onboarding has no extra backup
step.

---------

Signed-off-by: Wes <wesbillman@users.noreply.github.com>
Co-authored-by: Brain <1a02c72794dcd0f07058a353bc3a81f4028b8c77c92c87fce6d5c8b85970a20b@buzz.block.builderlab.xyz>
2026-11-13 11:55:32 -07:00
Tom Brow
a2d4ba0267 feat(mobile): use HTTP/2 on iOS through app-wide URLSessions (#8897)
On iOS, Buzz's HTTP traffic now uses HTTP/2. Dart's `dart:io` client
speaks only HTTP/1.1, so every feature's client opened its own
connections to the relay, which sits behind Cloudflare and offers
HTTP/2. On a slow link those extra handshakes, and the HTTP/1.1
head-of-line queueing, are a large share of cold-start time.

### What changes

- iOS HTTP goes through two app-wide `NSURLSession`s via
[cupertino_http](https://pub.dev/packages/cupertino_http)
(`lib/shared/http/app_http_client.dart`): one for API traffic (relay
queries, NIP-11, account, admission, pairing) and one for media
(image/video/voice downloads and uploads). Requests to a host multiplex
over one connection per session. Media has its own session so image
bytes can't starve queries on a shared HTTP/2 connection: in prototype
measurements with a single shared session, the channel-list batch query
finished *later* than on HTTP/1.1.
- Callers keep owning and closing their clients; on iOS `close()` leaves
the shared session open. Both sessions are ephemeral with no URL cache
and no cookies, so apart from the protocol (and native gzip, inflated
off the Dart isolate) behavior matches `dart:io`.
- Android, and tests, keep `http.Client()` unchanged, including
`http.runWithClient` overrides.
- Because closing a client no longer cancels a request on a shared
session, the relay query client (both `/query` posts and bounded
snapshot reads) and the dev push-lease fetch abort their request on
timeout instead.
- Non-`https` requests (`http://` media and community icons from other
clients, local dev relays) stay on the handle's own `dart:io` client,
because App Transport Security would block cleartext loads through
URLSession. An HTTPS URL that redirects to `http://` is the one case
that newly fails on iOS (URLSession follows the redirect and ATS blocks
the downgrade); we accept that rather than follow redirects in Dart.
- URLSession failures arrive as `NSErrorClientException`, not
`SocketException`, so pairing and invite-join error messages now also
recognize `NSURLErrorDomain` offline, TLS and timeout codes.
- cupertino_http 3.0.1+ requires native_toolchain_c 0.19 and hooks 2.x,
so `buzz_secp256k1` moves to those. Its build hook compiles unchanged.

### What gets better, and what doesn't get worse

- **Better:** on a slow link, requests reuse one warm connection per
session instead of paying TCP+TLS setup each time, so they complete
where `main` times out (see the table). On Wi-Fi, small queries are
slightly faster.
- **Not worse:** request semantics, caching (none) and cookies (none)
match `dart:io`; Android and tests are untouched; timed-out requests are
aborted so they can't keep using bandwidth on the shared connection;
offline errors keep their friendly messages. The accepted regression is
HTTPS-to-HTTP redirects on iOS, above.

WebSockets stay on `dart:io`. Android (Cronet) is a possible follow-up
using the same seam.

### Validation

Added tests: shared-session handles don't close the session; off iOS the
transport honors `http.runWithClient`; NSURLError code classification;
timed-out relay queries and bounded snapshot reads abort their request;
cleartext requests stay off the shared session.

Focused existing validation: full mobile suite (the only failures are 11
push/notification tests that fail identically on `main` on the same
machine), `flutter analyze`, `buzz_secp256k1` package tests (27/27), and
an iOS release build.

On-device A/B on an iPhone 12 mini against the internal prod relay over
WARP, comparing cold starts of `main` and this branch (profile builds
with local-only request timing, 3 cold starts each):

| | `main` | this branch |
|---|---|---|
| Wi-Fi: first query done (median) | 0.31s | 0.25s |
| Wi-Fi: small-query latency (median) | 0.22s | 0.18s |
| NLC Edge: requests completed in 90s | 0, 0, 0 (29–30 failed) | 12, 14,
16 (5–7 failed) |
| NLC Edge: first request done | never | 6.3–7.0s |

On Wi-Fi the two are about even. Under Edge, every HTTP/1.1 request on
`main` hit its timeout while still opening a connection, and each retry
started a fresh TCP+TLS handshake. The branch reuses one connection, so
queries complete. Connection counts weren't measured on the device,
since no proxy was in the path.

Cold-cache demo on an iOS simulator (this branch, app caches and cached
prefs wiped before launch): avatars, community icons, channel lists,
public channel images, a DM image and custom emoji, video playback,
reactions, and an image and video upload with progress all load. The DM
image and clip are synthetic test media.


https://github.com/user-attachments/assets/039d1a25-46f2-4e0e-b147-f96d0cfabd40

buzz-review-completed (agent review and device validation done; the
human-test step is not applicable under Tom's standing exception for
mobile changes)

---------

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>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-13 10:48:58 -08:00
Evan Broderick
642ce4165c fix(mobile): show shared chats under Solo (#9348)
## Summary

Mobile puts agent-created and shared Solo chats under Team because it
checks who created the chat. Show unarchived Solo chats the viewer
belongs to under Solo and exclude them from Team. Preserve membership
checks, guest read-only access, legacy chats, and owner-only composing.
This changes mobile classification; it needs no relay changes or data
migration.

**Desktop:**
<img width="557" height="695" alt="Screenshot 2026-11-11 at 10 00 07 AM"
src="https://github.com/user-attachments/assets/d338fa19-7b6f-4b52-a3a6-061025216ed3"
/>

**Mobile (missing solo chats created by agents):**

<img width="423" height="754" alt="Screenshot 2026-11-12 at 11 19 47 AM"
src="https://github.com/user-attachments/assets/18b5da75-38e9-4cca-906c-d0a949cc8cbb"
/>

### Code Changes

Separate Solo list and unread classification from owner-only composing.
Add regression coverage for shared and agent-created chats, Team
exclusion, membership/archive filters, legacy chats, and ordinary
sending from Solo.

### Related issue

Related: #8963 adds mobile access controls and Solo sharing. This PR
fixes the separate Solo/Team placement mismatch. No duplicate found in
searches for mobile Solo issues and PRs.

### Testing

Independent agent review found no blockers.

Device testing could not be completed. Android emulators stalled at
launch, iOS Simulator sign-in was blocked, and iPhone installation
required capabilities unavailable to the Personal Team. Shared Solo
placement and sending remain unverified in an authenticated app;
before/after screenshots remain pending.

Remaining manual checks:

- Have an agent create a Solo chat and include the viewer as a member.
- Confirm it appears once under Solo and is absent from Team.
- Open it, send a message, and confirm owner-only Solo settings are
absent.

Generated with Codex

---------

Signed-off-by: Evan Broderick <ebroderick@squareup.com>
Signed-off-by: Tom Brow <tomb@squareup.com>
Co-authored-by: coder <e509b66797ba43fd355dc12801a0c1ba376b06924147c65abdafa7ababcf8e2e@buzz.block.builderlab.xyz>
Co-authored-by: Tom Brow <tomb@block.xyz>
Co-authored-by: Tom Brow <tomb@squareup.com>
Co-authored-by: studio <dc2fc481343672df31a689840c09299972e704dac592e0da6f18486646a7ee3e@buzz.block.builderlab.xyz>
2026-11-13 09:11:02 -08:00
Tom Brow
41587e0284 feat(mobile): render messages with gpt_markdown 1.3.4 plusparse (#8945)
Message Markdown on mobile moves from gpt_markdown 1.2.1's legacy regex
pipeline to the CommonMark parser that 1.3 added ("plusparse"). Before
this, passing `inlineComponents` (now deprecated, removed in 2.0.0) kept
every message on the legacy pipeline.

### What changes for users

Rendering moves closer to desktop (react-markdown + remark-gfm):

- `_italic_` and `__bold__` work, backslash escapes and HTML entities
decode, and `[a [b] c](url)` labels are correct.
- Inline code follows CommonMark pairing: `"```npm install```"` in a
sentence is inline code, and four-backtick fences work.
- Setext headings, reference links, footnotes, `~~~` fences, `1)` lists
and CommonMark list/quote continuation render.
- HTML comments are hidden, as on desktop.
- `\[`, `\]`, `\(` and `\)` stay literal, as on desktop. Plusparse
hard-codes them as LaTeX delimiters, so they're written as entities
before rendering.
- Side effect: an unfenced `__init__` now renders as bold "init", and a
line over `---` becomes a heading, same as desktop.

Device benchmark (iPhone SE, profile build, 600 synthetic messages, 3
launches per build): scrolling spends 9% less time building, and frames
with more than 8 ms of build drop from 63 to 22. Jumping onto unbuilt
messages is 11% cheaper, and raster time is unchanged.

App size: the release app grows about 4.6 MB uncompressed (80.6 to 85.2
MB), mostly Dart code from the new math and highlighting packages.

### Before and after

Synthetic messages that reproduce differences found in real channel
history, rendered through `MessageContent` on main and on this branch:


![01-escaped-brackets-in-code](https://raw.githubusercontent.com/block/buzz/49600d2f9b87c2c41fd1bcac450efd345de0d0db/pr-8945--01-escaped-brackets-in-code.png)


![02-inline-triple-backticks](https://raw.githubusercontent.com/block/buzz/49600d2f9b87c2c41fd1bcac450efd345de0d0db/pr-8945--02-inline-triple-backticks.png)


![03-four-backtick-fence](https://raw.githubusercontent.com/block/buzz/49600d2f9b87c2c41fd1bcac450efd345de0d0db/pr-8945--03-four-backtick-fence.png)


![04-entities](https://raw.githubusercontent.com/block/buzz/49600d2f9b87c2c41fd1bcac450efd345de0d0db/pr-8945--04-entities.png)


![05-stars-and-underscores](https://raw.githubusercontent.com/block/buzz/49600d2f9b87c2c41fd1bcac450efd345de0d0db/pr-8945--05-stars-and-underscores.png)


![06-ordered-list-paren](https://raw.githubusercontent.com/block/buzz/49600d2f9b87c2c41fd1bcac450efd345de0d0db/pr-8945--06-ordered-list-paren.png)


![07-setext-heading](https://raw.githubusercontent.com/block/buzz/49600d2f9b87c2c41fd1bcac450efd345de0d0db/pr-8945--07-setext-heading.png)


![08-dunder](https://raw.githubusercontent.com/block/buzz/49600d2f9b87c2c41fd1bcac450efd345de0d0db/pr-8945--08-dunder.png)

### Demo

A scroll through synthetic messages covering common formatting
(headings, lists, quotes, links, highlighted code, a table, a task list,
escapes), recorded on an iPhone 17 Pro simulator running this branch:


https://github.com/user-attachments/assets/bdc9680c-d20b-41ec-8e1a-a5b51c602f9d

### How

- Mentions, custom emoji and `#channel` tokens are `InlinePattern`s.
Links go through `inlineLinkBuilder` into the existing `_buildLink`, so
chips, media links and taps are unchanged.
- Removed workarounds the parser makes unnecessary:
  - the render-path escape shielding from #8925
- the `_MarkdownEscapeMd`, `_MarkdownLabelEntityMd` and `_MessageLinkMd`
components
  - the zero-width prefix before a leading `#channel`

Plain-text previews and gallery helpers keep their own escape handling.
`normalizeBareLinks` stays because attachment and gallery detection
depend on its output. Bubble segmentation unescapes a link destination
itself before its imeta lookup, since content no longer arrives
shielded.
- Kept desktop parity where plusparse differs from GFM:
- a table typed directly under a caption line gets a blank line inserted
before it, since plusparse can't start a table mid-paragraph
- `> [!NOTE]` quotes render as quotes (`alertBuilder` returns
`asBlockQuote()`), since desktop has no alerts
- `mapMarkdownProse` now ends an unclosed backtick run at its paragraph.
Before, it could pair with a run in a later block and flip code and
prose for the rest of the message.
- Synthesized autolink labels escape backslashes instead of using
`&#92;`, which the parser leaves undecoded in a URL-shaped label.
- Repo/PR/issue chips keep their own semantics node.
- Forum card previews clip at their 120 px cap instead of overflowing:
blocks now lay out as a column.
- Pinned to exactly 1.3.4. 1.4.0 renders HTML by default and themes
through the separate `material_ui` package, which would need a theme
bridge.

### Validation

- Full mobile suite passes and analyze is clean at 78b9c1a6d0.
- All of #8925's and #8940's backslash-escape cases pass on the new
parser, including the strike-across-lines case that used to be a known
limitation.
- Real-message diff: 2,259 recent messages from 13 busy channels,
rendered through `MessageContent` on main and on this branch. 29
differed in text or styling. On inline and fenced code, the branch
matched desktop's parser (remark-gfm) in 23 of them and main in 7. The
review found the three parity gaps above, now fixed. The rest are
CommonMark behavior that desktop shares.
- Added tests, each confirmed to fail without its fix:
  - a leading `#channel` renders as a link, not a heading
  - a table under its caption renders as a table
  - an alert-marker quote stays a quote
  - an unclosed backtick run doesn't flip later code
- the transcript tests detect a rendered link by its style; the old
`LinkButton` check passed even with autolink on
- Automated simulator run (iPhone 17 Pro, iOS 27, debug build, signed in
to a Builderlab community): channel list, two channels with history
scrolled back several pages (mentions, link previews, thread summaries,
images), an agent Solo chat with long agent messages, and the inbox. No
rendering errors or layout breaks; the Solo chat screen also matched
main's build side by side.

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

---------

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>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-13 08:06:50 -07:00
Tom Brow
2b428f56b8 feat(mobile): share into Buzz from the iOS share sheet (#9433)
Lets people share screenshots, screen recordings, photos, URLs and text
from any iOS app into Buzz. Today Buzz doesn't appear in the share sheet
at all.

- **Plain Buzz icon:** opens a new Solo chat with the items in its
composer.
- **Suggested conversation:** iOS offers channels and DMs the person
recently sent top-level messages in. Choosing one opens that
conversation with the items in its composer. When the conversation is
already open, the share goes to that page's composer instead of opening
a second one; if another page covers it, Buzz stays where it is and
shows "Go back to that conversation to finish sharing", and the items
join the draft when the person goes back.
- The share extension has no UI and sends nothing. It copies the items
into the app group and opens Buzz, which prefills the normal composer,
so drafts, attachments, mentions and failed-send handling all stay the
app's (see [the
ADR](https://github.com/block/buzz/blob/mobile-share-extension-design/docs/adr/0003-share-hands-off-to-the-conversation.md)).
- If the conversation already has a draft, Buzz asks whether to add the
shared items to it or replace it.
- A share to a conversation that's no longer available (a removed
community or channel, or an unreadable share) shows "That conversation
isn't available". A share while signed out shows "Sign in to share".

Suggestions come from an outgoing `INSendMessageIntent` the app donates
after a top-level send or a new Solo chat. The notification extension no
longer donates incoming messages, so receiving a message never makes a
conversation a suggestion; it still turns the push into a communication
notification with the sender's avatar. Both use the same conversation
identifier, now the plain community and channel IDs instead of a hash,
because the extension needs to hand the identifier back to the app.

| Before | After |
| --- | --- |
| <img alt="Share sheet without Buzz"
src="https://github.com/user-attachments/assets/452fac1b-7e87-44c3-a442-099f78d0e07b"
width="300"> | <img alt="Share sheet with Buzz"
src="https://github.com/user-attachments/assets/54b9775d-29b4-49a5-8ab9-5fda8718a02f"
width="300"> |

| Buzz icon: new Solo chat | Suggested DM with a draft | After Add |
| --- | --- | --- |
| <img alt="New Solo chat with the shared photo"
src="https://github.com/user-attachments/assets/c5da4d8b-1dd8-4e30-9e92-9dba515b3623"
width="250"> | <img alt="Add to your draft prompt"
src="https://github.com/user-attachments/assets/2f879f8a-3b9f-48e0-b963-2828e90dc9fe"
width="250"> | <img alt="Draft with the shared link and photo added"
src="https://github.com/user-attachments/assets/12832006-85c5-4447-98b5-62932552c931"
width="250"> |


https://github.com/user-attachments/assets/b9d380fa-e802-4ed7-89a8-592a03784c8f

### Regressions

- Nothing changes for people who never use the share sheet, except that
sending a top-level message or starting a Solo chat now makes one local
`INInteraction.donate` call (skipped while the age restriction is on,
which still purges every interaction).
- Communication notifications look the same. Dropping the incoming
donation removes work (and a deletion fence) from the notification
extension's time budget.
- The share hand-off reuses the existing deep link dispatcher. A share
link is a new link type; notification and message links take the same
paths as before.

### Validation

- Added tests:
- Dispatcher hand-off: a share to a suggested channel opens it with the
shared text and files; shares to a removed community, an unlisted
channel, an unknown manifest version or a missing manifest show the
error and delete the pending share; share links accept only the
extension's UUID ids.
- Composer delivery: with an existing draft, Add appends the shared text
on a new line and attaches the file, Replace clears the draft first, and
the app group copy is deleted either way.
- Notification presenter: specializes the notification from the intent,
or falls back to the ordinary content when that throws (replaces the
donation and deletion-fence tests).
- Full mobile Flutter suite and BuzzPushKit Swift tests pass.
- Automated app run on an iPhone 17 Pro simulator (iOS 27, dev relay
test community), recorded above: sent a DM, shared a photo from Photos
with the Buzz icon from a cold start (new Solo chat with the photo
attached), then handed a link and photo to a DM that had a draft and
chose Add. Also checked that a share's pending files are deleted after
delivery.
- Limitation: the iOS simulator never shows share-sheet conversation
suggestions (it has no `coreduetd`), so the suggested-DM step in the
video is staged by writing the same pending share and link the extension
writes. Choosing a real suggestion still needs a check on a device.
- Known gaps, all confined to sharing: suggestions have no avatar image
yet; a suggestion for a conversation left after signing out shows "isn't
available"; choosing Later in the unfinished-chat dialog keeps the share
until the next new chat; and a pending share the app never receives (for
example when Buzz doesn't open) stays in the app group.

### Before merge

- [x] On a real iPhone, choose a suggested conversation in the share
sheet and confirm the shared items open in that conversation's composer
(the simulator can't show suggestions). Waived before merge: the managed
test iPhone shows no share-sheet suggestions for any app, so this will
be checked on a personal phone after landing.

---------

Signed-off-by: Tom Brow <tomb@squareup.com>
Co-authored-by: Tom Brow <tomb@squareup.com>
2026-11-12 22:57:21 -08:00
Kalvin C
3c0adc1882 fix(mobile): qualify every namesake mention and keep authored mention casing (#9325)
## problem

When a message mentions two different identities that share a display
name, the mobile composer qualified only the later selection as `@Name
(<64-hex>)` and left the first one bare. A qualified occurrence denies
the plain name on render, so the first mention rendered as plain text on
mobile and desktop. `MessageContent` also displayed every mention in the
lowercased binding key rather than its authored spelling.

## change

- `mention_bindings.dart`:
- `selectedMentionLabel` qualifies a selection whenever another selected
identity shares its name, without regard to case.
- `namesakeRequalifications` and `renameMentions` qualify earlier plain
selections. Each occurrence keeps its authored spelling, and occurrences
in code stay as typed.
- `compose_bar/helpers.dart` and `compose_bar_widget.dart`:
- Selecting a namesake qualifies earlier same-name mentions before the
new label is inserted, keeping the caret in place.
- Occurrences inside code that the composer styles are skipped:
single-backtick spans and closed triple-backtick fences, found by the
same walk the editor uses to draw them. A key whose occurrence stays in
code remains bound beside its qualified label, so its recipient still
sends.
- `agent_mention_prefill.dart`: automatic addressing qualifies every
same-name agent it inserts.
- `message_content.dart`: mentions render in their authored spelling,
and bindings still resolve case-insensitively.
- `docs/mention-editor.md`: describes the behavior, including that
Markdown code forms the composer does not style (tilde fences, indented
code) are qualified like prose.

## tests

- `mention_bindings_test.dart`: requalification, spelling preservation
and code exclusion.
- Composer journeys:
  - picker selections qualify both namesakes and send both keys;
- styled code (fences, list fences, spans, spans after bold or italics)
stays as typed while surrounding prose is qualified;
  - a selection left only in code keeps its recipient;
  - automatic prefill of two same-name agents qualifies both.
- `message_content_exact_mentions_test.dart`: authored casing with
case-insensitive resolution.
- `just mobile-check mobile-test` passes.
- Real relay: composed bodies exchanged through a local relay render as
correctly targeted chips in desktop and in Flutter `MessageContent`.

---------

Signed-off-by: Kalvin Chau <kalvin@block.xyz>
Signed-off-by: Tom Brow <tomb@squareup.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: goose-wayne <ae6b377e5b6d090ee22558d19246413a5731628a127e25371111badfd4861535@buzz.block.builderlab.xyz>
Co-authored-by: Tom Brow <tomb@squareup.com>
Co-authored-by: peon <9ac6794b000690b7e814eb1805ad32405d0bec7d52838de3a86cf967565dacc0@buzz.block.builderlab.xyz>
2026-11-12 19:11:37 -08:00
Tom Brow
5bfbda4c33 fix(mobile): never pop Home when archiving from channel settings (#9387)
Archive, Leave, Unarchive and Delete in channel settings wait for the
relay, then close the settings sheet by popping whatever route is on top
of the root navigator. If the user closes the sheet themselves during
that wait (for example: long-press a chat on Home, Archive, confirm,
then tap the close button), that pop lands on Home instead. The
navigator ends up empty: a blank white or black screen with no controls
and no way back short of killing the app.

### Change

- **Close only the route that offered the action.** (Main has since
gained the same guard; after merging main, this part of the diff is a
comment plus the tests below.) After the action completes, the settings
sheet or page closes itself only if it is still on top, with its "close
the conversation too" result, as before. If the user opened something
over it meanwhile (for example a member's profile), it stays open under
that route, which keeps working. If the user already dismissed it,
nothing is popped. The sheet still closes on its own after a successful
archive.
- **Home can no longer be popped.** The app's root route refuses pops. A
stray pop that reaches it is reported through `FlutterError.reportError`
(which fails widget tests) and ignored, so no other caller can leave an
empty navigator either. Local-history pops on the root route (a drawer
or persistent bottom sheet) still close normally. The root route still
rebuilds from the current auth state, so sign-in and sign-out
transitions are unchanged.

### What changes for the user

Only the case where a settings action finishes after the user moved on:

- Settings dismissed mid-flight: before, the completion popped whatever
was on top (Home, the conversation, a thread or a profile). Now nothing
is popped.
- Something opened over settings mid-flight: before, the completion
popped that new route and left settings open. Now that route stays, and
settings stays open under it, as on main. That settings page shows the
channel as it was before the action (for example still offering Archive
after an archive, or a channel that is gone after Delete or Leave), as
on main. Settings following lifecycle changes is part of the follow-up
below.
- Delete or Leave from the pushed settings page, then back out before
the relay answers: before, the stray pop happened to close the
conversation. Now the conversation stays open until the user leaves it
(Leave and Archive show the read-only notice; a deleted conversation
keeps showing its last state). Closing it reliably needs the
conversation to notice its channel is gone, which is a follow-up.

Pops that reach Home were always a bug and are now refused. Every other
pop (sheets, pushed pages, system back above Home) takes the same path
as before.

### Validation

Added tests:
- Channel actions sheet journey: confirm Archive with the relay call
still pending, close the sheet, then let the archive finish. Home stays.
A second pass leaves the sheet open and checks it closes by itself once
the archive completes. Fails on the old code with Home popped.
- Conversation journey: open settings from a conversation, confirm
Archive with the relay call pending, open a member's profile, then let
the archive finish. The profile stays open and current, and its Message
action still opens the DM. Fails if the completion pops the top route,
and fails if it removes the covered settings page (the profile loses the
context it navigates from).
- Root route: normal push and pop still work, a drawer on Home closes on
back, and popping Home is refused, reported, and Home stays on screen.

Full mobile test suite and `mobile-check` pass, including after merging
main.

Automated app run at
[c158c17](c158c1793d)
on an iOS 27 simulator (iPhone 17 Pro, debug build, public Builderlab
community): long-press a solo chat on Home, archive it from the settings
sheet, and confirm the sheet closes by itself with the channel list
intact. Then the race: confirm Archive and immediately drag the sheet
closed while the archive is in flight. Home stays intact with the chat
archived, and no refused-pop error is logged. Limitation: AXe taps don't
reach the native glass close button on the simulator, so the run
dismissed the sheet with the drag gesture, which takes the same route
pop.

buzz-review-completed

---------

Signed-off-by: Tom Brow <tomb@squareup.com>
Co-authored-by: Tom Brow <tomb@squareup.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-12 16:06:45 -08:00
Tom Brow
60b7fb8178 fix(mobile): keep shortcut taps and the member picker from wedging (#9388)
Follow-up to review notes on [#9360 Home Screen
shortcuts](https://github.com/block/buzz/pull/9360). These are fixes for
rare races, with no visible change.

- **The member picker can't wedge.** UIKit ignores a dismiss that
arrives mid-transition (the sheet still animating in, or during an
interactive swipe-down) and never runs its completion. The picker
coordinator queues every later present behind that completion, so New DM
and Add members then opened nothing for the rest of the session. Dismiss
now waits for the transition to finish, then dismisses whatever is still
presented.
- **A shortcut tap reaches Dart once.** The native bridge both buffered
a tap and sent it, so a tap during cold launch could arrive twice and
run again after Home had already handled it. Now a tap is buffered only
until Dart first takes the pending one, and after that it is sent
directly.
- **Signing out drops a waiting tap.** Removing Home clears a tap that
is still waiting (for example on a Bestie that is still loading), so it
can't run in the next account's Home.

Not included: carrying the Bestie's pubkey in the shortcut item, so a
stale "Message Alice" falls back to Agents rather than opening the
current Bestie. It's optional, and it would change the bridge's payload
shared with the lock screen widgets in [#9373 lock screen
widgets](https://github.com/block/buzz/pull/9373).

### Validation

- The Home shortcut journey gains a step: a tap waiting while the app is
inactive is cleared when Home goes away. The step fails with the
teardown guard removed.
- Automated simulator run (iPhone 17 Pro, iOS 27, signed in to a
Builderlab test community), driving the app icon's quick actions on the
Home Screen:
- New DM from a conversation opens the picker. New DM again, with the
picker already open, replaces it. New chat over the picker closes it and
opens a draft, and New DM after that opens the picker again (it doesn't
get stuck).
  - Message (Bestie) opens the Bestie conversation.
- Cold launch through New chat opens exactly one New chat screen. Back
returns to Messages.

buzz-review-completed

Signed-off-by: Tom Brow <tomb@squareup.com>
Co-authored-by: Tom Brow <tomb@squareup.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-12 14:09:31 -08:00
Tom Brow
4a101752fb fix(mobile): never show emoji shortcodes in reaction pills (#9411)
## Context

A reaction slot should never show an emoji shortcode as text. Today it
does in two cases:

- An agent's reaction is a kind 7 event with content `:shortcode:` and
no NIP-30 `emoji` tag, so the pill printed `:approve:` in tiny text
instead of the community emoji.
- A custom emoji whose image fails to load fell back to the shortcode
text.

## Behavior

- A tagless `:shortcode:` reaction resolves against the community
custom-emoji palette and renders that image. An `emoji` tag on the event
still wins.
- A shortcode with no palette entry, or whose image fails to load, shows
a neutral placeholder glyph (the muted sparkles icon) instead of text.
The shortcode survives only as the semantics label.
- This applies to every reaction slot: the timeline pills, the combined
reaction tray, the Flutter reaction detail sheet, and the native iOS
reactions sheet (which is told which shortcodes have no image, so
`NativeMessageGlyph` draws the placeholder). System-message rows reuse
the same reaction row.
- Unicode emoji are unchanged.

The icon is the existing `BuzzIcons.sparkles`. Pareto note: the palette
lookup is the shared `reactionEmojiUrl` helper, so there is no new
resolver, and the pill only watches the palette when the reaction has no
tag.

### Validation

- `just mobile-check mobile-test`: format and analyze clean; full suite
passes (4773 passed, 74 skipped).
- New widget tests (journeys, in
`reaction_row_test/shortcode_tests.dart`): a tagless known shortcode
renders its image; an unknown shortcode and a failed image render the
placeholder and never the text; unicode is unchanged; the native sheet
payload marks image-less shortcodes. Reverting the fix makes both new
journeys fail.
- iOS: added a Swift unit test for the native glyph placeholder
(`NativeMessageImageLoaderTests`); not run locally, the app run below
exercises the same code.
- Automated app run on a cloned iOS simulator with a fixture entry point
(mocked media, synthetic palette): confirmed the pills before and after,
and opened the reaction sheet from a long-press to confirm the
placeholder renders there too. The clone was deleted afterwards.

## Before / after

Captures use synthetic shortcodes and a synthetic palette.

<img width="300" alt="reaction-pills-before"
src="https://raw.githubusercontent.com/block/buzz/75b22a00d92df2db389ef90d35d476b285b60374/pr-9411--reaction-pills-before.png">

<img width="300" alt="reaction-pills-after"
src="https://raw.githubusercontent.com/block/buzz/75b22a00d92df2db389ef90d35d476b285b60374/pr-9411--reaction-pills-after.png">

Reaction sheet after:

<img width="300" alt="reaction-sheet-after"
src="https://raw.githubusercontent.com/block/buzz/75b22a00d92df2db389ef90d35d476b285b60374/pr-9411--reaction-sheet-after.png">

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

Signed-off-by: Tom Brow <tomb@squareup.com>
Co-authored-by: Tom Brow <tomb@squareup.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: studio <dc2fc481343672df31a689840c09299972e704dac592e0da6f18486646a7ee3e@buzz.block.builderlab.xyz>
2026-11-12 13:38:37 -08:00
Michael Fransen
2f792c2f6b fix(mobile): isolate channel header scroll rebuilds (#9400)
## Summary

Improve scrolling performance in the Messages channel list by avoiding
unnecessary inventory rebuilds as the header moves. Keep scroll-driven
header state in a notifier and retain the inventory while the header
animates. Provider and parent updates still rebuild the inventory with
current channel data.

This complements the lazy-row optimization in #9401. In manual iPhone
runs with 500 channels, adding lazy rows on top of header isolation
reduced maximum observed Flutter UI work from **65.5 ms to 4.2 ms**.
That measurement reflects the added lazy-row change; no standalone
performance gain was established for header isolation.

This is an independent production-only change. Test fixtures and
diagnostic instrumentation are excluded; regression checks were run
locally and are not included in this PR.

### Related issue

Related: #5911 addresses scrolling behavior inside conversations. This
change addresses header-triggered rebuilds in the Messages channel
inventory. No matching open PR or issue was identified in the focused
duplicate search.

### Testing

Exercised Messages on a physical iPhone with 500 channels against an
isolated local relay. Header collapse and channel updates worked. This
change alone did not remove the large scroll stalls; lazy section rows
are a separate change. The device run preceded the refresh onto current
main.

Local-only regression checks passed 10 tests on this independent branch.
They verify stable inventory identity during header movement and visible
channel updates. These checks are excluded from the commit.

Remaining visible jumps are under investigation; this PR does not claim
to resolve them.

Generated with Codex

Signed-off-by: Michael Fransen <mfransen@squareup.com>
Co-authored-by: Karl <9e8471f7b792e46c9c100840959dc71c660786c79c2a3165dbcaf58f52c4266e@buzz.block.builderlab.xyz>
2026-11-12 13:11:49 -08:00
Michael Fransen
2636e986a0 fix(mobile): build channel section rows lazily (#9401)
## Summary

Improve scrolling performance in the Messages channel list by building
Solo and Team rows only as needed. Sections currently mount all their
rows as one scroll item, which causes long UI stalls with large channel
lists.

In manual iPhone runs with 500 channels, maximum observed Flutter UI
work fell from **65.5 ms to 4.2 ms** after adding lazy rows to a build
with header isolation (#9400). The tester reported much smoother
scrolling. This was an exploratory comparison with different gestures,
not a controlled benchmark of this independent branch.

Use stable channel keys and retain section controls, sorting, and
collapse animations. Clip the sliver extent during collapse so the
animation does not mount the entire section. The shared transition
supports downward vertical lists.

This is an independent production-only change. Test fixtures and
diagnostic instrumentation are excluded; regression checks were run
locally and are not included in this PR.

### Related issue

Related: #5911 addresses scrolling behavior inside conversations. This
change addresses eager row mounting in the Messages channel inventory.
No matching open PR or issue was identified in the focused duplicate
search.

### Testing

On a physical iPhone with 500 channels against an isolated local relay,
maximum Flutter UI work fell from 65.5 ms to 4.2 ms after adding lazy
rows to a build that already isolated header rebuilds. The tester
reported much smoother scrolling. Gestures differed between runs, so
this is not a controlled benchmark or an isolated measurement of this
branch on its own. The device run preceded the refresh onto current
main.

Local-only regression journeys passed 12 tests on this independent
branch. They cover page laziness and updates, variable-height rows,
large text, the last row, collapse reversal, reduced motion, and
semantics. These checks are excluded from the commit.

Smaller visible jumps remain under investigation; this PR does not claim
to resolve them.

Generated with Codex

---------

Signed-off-by: Michael Fransen <mfransen@squareup.com>
Signed-off-by: Tom Brow <tomb@squareup.com>
Co-authored-by: Karl <9e8471f7b792e46c9c100840959dc71c660786c79c2a3165dbcaf58f52c4266e@buzz.block.builderlab.xyz>
Co-authored-by: Tom Brow <tomb@block.xyz>
Co-authored-by: Tom Brow <tomb@squareup.com>
Co-authored-by: studio <dc2fc481343672df31a689840c09299972e704dac592e0da6f18486646a7ee3e@buzz.block.builderlab.xyz>
2026-11-12 12:56:43 -08:00
klopez4212
cb69ad9e4f Adapt iPhone Duo layouts, rail navigation, and native sheets (#8568)
Duo keeps conversations and Settings details open across closed, book
and flat postures. Book mode splits at the fold; flattening restores the
sidebar. Native rail controls, full-width navigation backdrops and
sheet-local safe areas keep content aligned. Ordinary iPhones remain
single-pane in portrait and landscape; tablet and Duo split layouts
remain enabled.

Includes the recovered preview's matching pane widths, Buzz empty-pane
mark, stable Settings chevrons, Bestie pane routing and Duo-only upward
New menu attachment. Current main's Activity redesign, Search content
fade and unread-navigation button are retained. Menu selection checks
sit beside their labels.

Shared mobile changes remain in scope: the native iOS status editor,
Appearance preview layout, avatar crop preservation, onboarding footer
layout, profile/invite sheet geometry and nested conversation
navigation. This PR is not exclusively Duo-gated. Nested navigator
observers preserve recording cancellation and navigation callbacks; crop
resizing preserves the selected image region. iOS 27.1 APIs remain
compile-time and runtime gated.

Validation on the reconciled source: Flutter analysis, Activity/Home
journeys, the full mobile test suite, file-size checks and Swift package
tests. The iPhone single-pane fix was also exercised on an iPhone 18 Pro
simulator before reconciliation. Fresh hosted CI and physical-device
confirmation of the reconciled build are separate and remain pending.

---------

Signed-off-by: kenny lopez <klopez4212@gmail.com>
Signed-off-by: Tom Brow <tomb@squareup.com>
Co-authored-by: Terp <5856f6900e8e0a4e0ea1f4f8d2ee33e4753d2119bc122f94ecafc660b46c0511@buzz.block.builderlab.xyz>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: Tom Brow <tomb@block.xyz>
Co-authored-by: Tom Brow <tomb@squareup.com>
2026-11-12 19:00:58 +00:00
klopez4212
5f81803cb1 End last-human agent Huddles and preserve mobile transcript access (#9375)
## Summary

Leaving an agent DM Huddle previously skipped client lifecycle cleanup,
allowing Join to remain visible while the relay waited for the agent.
Apply the existing last-human rule to DMs: release audio first, then
publish the ending and archive when the human count is at most one.
Preserve the existing additional-device and same-Huddle rejoin guards.
Retain DM membership when other humans remain so hanging up does not
revoke transcript access.

Offer **View** only when cached backing-room membership confirms
transcript access, opening the original Huddle transcript and reply
threads without joining audio. Non-members retain disabled Ended.
Preserve Open for an active local session even when an ended event
arrives.

For admitted or just-left Huddles, switching/removing a community
retires pending remote finalization and waits for local audio teardown.
Generation guards prevent retired count/end results from launching
follow-up writes or interfering with a later call. Existing in-flight
Huddle-start rollback behavior is unchanged.

Client only; remote relay finalization is separate in #9376. Human
counts use backing-channel membership; known duplicate owner admissions
prevent client cleanup. Concurrent device arrivals are not made atomic
by this client-only change, and human-to-human DMs with retained
memberships still rely on relay finalization.

### Related issue

Split from the combined Huddle repair at the author's request. Searched
open Huddle issues/PRs; no exact duplicate found for this mobile
behavior.

### Testing

Follow-up fixes are in `7f28dc486`; merged current main in `7a592f19d`.
Required push checks pass on the merged head.

- Mobile formatting, analysis, and full suite passed (4,705 tests, 71
skipped; supplementary suites: 4 and 27).
- DM hangup journey covers sole-human ending, preservation of another
owner device, and preservation of membership when another human remains.
Existing rejoin/lifecycle regressions remain in the full suite.
- View journey reads the original transcript and opens a server-only
reply-thread summary without joining audio.
- Mutation checks: restoring the DM cleanup exemption fails the
last-human journey; removing thread summaries fails View navigation.
Restored production code passes.
- Independent review completed; follow-up review of the three blocking
fixes found no remaining blockers.
- Follow-up regressions cover live-call Open after an ended event,
reactive history membership revocation, stalled count/end requests
during community transition, and background teardown of a later call
while retired cleanup is unresolved.

Phone/human validation remains pending. Start an agent DM Huddle and
leave from the last human device: its card should stop offering Join.
Tap View to read the transcript and replies. Repeat with another device
still in the Huddle and verify it stays open. Not deployed.

---------

Signed-off-by: kenny lopez <klopez4212@gmail.com>
Co-authored-by: Terp <5856f6900e8e0a4e0ea1f4f8d2ee33e4753d2119bc122f94ecafc660b46c0511@buzz.block.builderlab.xyz>
2026-11-12 10:45:10 -08:00
Tom Brow
473d592602 fix(mobile): keep a thread tail behind the keyboard unread (#9295)
Follow-up to [#9243 read tall
mentions](https://github.com/block/buzz/pull/9243).

**Problem.** Since #9243, the newest reply in a thread is read once its
end shows at the live bottom, even when it is taller than the screen.
The thread view decides "at the tail" from scroll geometry that ignores
the keyboard. On Android, with the keyboard open and tail-follow
detached, the last reply can sit at the scroll end but entirely behind
the keyboard, and it gets marked read. The mark stays after the keyboard
closes, so a mention there can be cleared without ever being seen.

**Fix.** The thread's live bottom now also requires the tail row's end
to be inside the reading area, above the keyboard and composer. This
matches how the channel timeline already checks its bottom row.

### Validation

- Added test: a thread whose last reply sits behind the Android keyboard
leaves it unread, including after the keyboard closes. It fails without
the guard.
- Full mobile suite and `flutter analyze` pass.

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

Signed-off-by: Tom Brow <tomb@squareup.com>
Co-authored-by: Tom Brow <tomb@squareup.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-12 06:28:36 -08:00
Tom Brow
c0e30110dd fix(mobile): restore header cues and per-channel identity check for #9369 (#9370)
Follow-up to #9369 (conversation header avatars). Fixes two regressions
found in its review. The intended behavior of #9369 stays the same.

1. **Message rows no longer each scan the roster.**
`showMessageAuthorName` ran at the top of every message and thread row,
in every channel. Each run watched a whole `Channel` object (which has
no value equality) and built sets from the full roster, plus two more
sets for the stale-DM check in DMs. A new
`confirmedConversationPairProvider` works out the two-person pair once
per channel, including the rule that a DM keeps attribution while its
metadata disagrees with the roster. It returns a record that compares by
value, so rows rebuild only when the pair itself changes. It reads
`watchLatestChannelMembers`, so a revisit uses the cached roster and
rows no longer re-wrap 48 dp wider once the roster fetch returns. The
visible rule is the same as before.
2. **Android private channels show the lock again.** Every Android
conversation header now uses the compact title pill, which had no lock.
The pill now shows the existing lock icon (and its "Private channel"
label) before the name.

### Validation

- Added tests, all extending existing journeys:
- The author-visibility journey checks that replacing the channel object
(as live activity does) doesn't notify rows when the pair is unchanged.
Its existing `stale-dm` case covers the metadata rule now inside the
provider.
  - The private-lock header test expects the lock again.
- Each new or restored Dart assertion fails with its fix reverted, and
so does the `stale-dm` case with the provider's metadata rule removed.
- Full mobile suite (`just mobile-test`) and `flutter analyze` pass.
- Not run: an automated full-app session on a simulator or device.

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

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>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-12 06:21:39 -08:00