Commit Graph

478 Commits

Author SHA1 Message Date
klopez4212
9c0bcd6239 Align Duo chat headers, inset Home selections, and fix received photo-stack swipes (#9795)
- In unfolded Duo portrait, place the live chat avatar and name together
beside Back. Align the Messages and Activity headers with the status
controls and keep the filters full width.
- Center the stacked avatar and chat title over the sticky date with the
Duo rail on either side.
- Give Home selections rounder corners and a shared 12-point outer
gutter for channels, DMs, and Solo chats. Preserve icon and label
alignment.
- Mirror drag distance and flick velocity for received photo stacks so a
rightward swipe advances the stack.

The combined release preview was installed and checked on a physical
Duo. Widget tests cover the portrait header geometry, filter width, and
return to landscape.

### Portrait layout references

Cropped headers from the earlier Duo preview used as the design
reference.

![Messages header in unfolded
portrait](https://github.com/user-attachments/assets/93fa0134-81c8-406e-90a9-9d3711b0bdc0)

![Left-aligned chat chip in unfolded
portrait](https://github.com/user-attachments/assets/e79a9337-7d31-4871-96c3-9cb0300437cf)

### Simulator snapshots

The fixtures use sample content and a 76-point right rail inset.

![Stacked avatar and title aligned with the sticky
date](https://github.com/user-attachments/assets/1b9b409d-5fa6-4f79-8444-9927e2bee59e)

![Received photo stack during a rightward
swipe](https://github.com/user-attachments/assets/383be530-31df-4238-b6e4-62ecc2f299e0)

---------

Signed-off-by: Terp <5856f6900e8e0a4e0ea1f4f8d2ee33e4753d2119bc122f94ecafc660b46c0511@buzz.block.builderlab.xyz>
Signed-off-by: Tom Brow <tomb@block.xyz>
Co-authored-by: Terp <5856f6900e8e0a4e0ea1f4f8d2ee33e4753d2119bc122f94ecafc660b46c0511@buzz.block.builderlab.xyz>
Co-authored-by: Tom Brow <tomb@block.xyz>
Co-authored-by: studio <dc2fc481343672df31a689840c09299972e704dac592e0da6f18486646a7ee3e@buzz>
2026-11-20 18:09:43 +00:00
morgmart
97bec174a4 fix(mobile): only dot channel-sent replies in the reader's threads (#9696)
## What changed

Mobile matches block/buzz-app#3938. A reply someone sends with **Also
send to channel** used to light the channel's attention dot and count
toward the app icon badge for everyone in the channel, even people who
never joined that thread.

Now it follows the same rule as any other reply:

- **Dot** if it mentions you, or it's in a thread you're part of (you
started it, replied in it, or follow it).
- **Bold only** otherwise, like a new top-level post. It no longer
counts toward the app icon badge.

Reading is unchanged. These replies are still marked read individually,
as desktop reads them, so reaching the bottom of the channel doesn't
silently mark them read on one device but not the other.

## How

- The "is this one of my threads" check that already decides which
ordinary replies count is now shared, and channel-sent replies go
through it when deciding attention.
- On mobile, "earns a dot" and "is read by reaching the bottom of the
channel" were one flag. Dropping a channel-sent reply's priority would
have also changed how it gets read, drifting from desktop. The dot now
comes from its own field; every other kind of message gets exactly the
same dot and read behavior as before.

## Tests

New cases drive live events through the channel list. For each, they
check the observed unread entry, whether its thread shows in Activity,
the app icon badge, the channel list's bold vs dot, and reading:

- reply sent to the channel in someone else's thread: bold, no dot, not
in Activity, counts as ordinary unread on the icon (same as a top-level
post)
- same, but mentioning the reader: dot, in Activity
- in a thread the reader follows: dot, in Activity
- in a thread the reader started: dot, in Activity
- in a thread the reader replied in: dot, in Activity

In every case, a channel catch-up mark leaves the reply unread and its
own read mark clears it.

The "someone else's thread" case fails on `main` (it gets a dot). The
pre-push mobile checks (format, analyze, full mobile test suite) passed
on this head.

## Known gaps (not changed here)

- Mobile only knows the threads you're part of from posts it has seen on
this phone. A fresh install doesn't know about older threads you joined
elsewhere, and a reply's first classification sticks even if later
loading shows you joined that thread. Desktop looks these up on the
relay.
- Mobile has no explicit "Unfollow" for a thread you started or replied
in (the menu only offers Follow there), so you can't silence one the way
desktop can. This applies to all replies, not just ones sent to the
channel.
- A reply sent to the channel still counts as unread in a muted channel.
That was already true before this change.

No screenshots: no visual element changes, only which existing state
(bold or dot) a channel shows.


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

---------

Signed-off-by: morgmart <98432065+morgmart@users.noreply.github.com>
Signed-off-by: Tom Brow <tomb@block.xyz>
Co-authored-by: Carl <c217fe6b9d958f41c3a5e030dccc7f626775a923089cb6491305eade75ea1f1b@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: studio <dc2fc481343672df31a689840c09299972e704dac592e0da6f18486646a7ee3e@buzz.block.builderlab.xyz>
2026-11-20 09:32:03 -08:00
klopez4212
14e5ea7cc4 Mobile: refine section filters and ordering in Messages (#9796)
## Summary

Give Messages sections a common options sheet for sorting, filtering and
ordering. Active sections let people choose a time window. Channel and
DM sections can reveal filtered rows in place with **Show more** and
collapse them with **Show fewer**. Reordering saves a device-local order
for the current account and community.

Failed activity lookups keep affected channels visible. The recovery
toast offers Retry and dismisses when activity loads. On iOS the sheet
dims the Messages header along with the list.

### Related work

#9707 explores a count-based disclosure. This change uses the section’s
unread or activity filter.

### iOS snapshots

| Section options with an active filter | Reorder sections |
| --- | --- |
| ![Section options with a 30-day activity
window](https://github.com/user-attachments/assets/4b0fd306-f7ba-4466-aeca-18627bc05c57)
| ![Reorder sheet with draggable Solo, project, Team and Direct messages
rows](https://github.com/user-attachments/assets/3a3f1429-6334-4c8e-a535-630ae860376c)
|

### Rename a section

Tap the emoji beside the name to open the picker. Set saves both fields,
including an emoji-only change.

![Rename section with a new emoji
selected](https://github.com/user-attachments/assets/840bf926-f29f-435e-87de-2470d32ac64c)

### Activity recovery and section order

Unfiled Solo chats support local **Show more** and **Show fewer**,
including offline. Failed activity lookups retry automatically up to
three times with jittered backoff while Messages is visible and
connected. **Retry** stays available after that budget is exhausted. The
notice dismisses on recovery.

Reorder supports drag handles and keyboard arrow keys. Saving preserves
the position of an empty Starred section and checks for a newer order.
Each signing identity has its own saved order per relay.

### Testing

Exercised filtering, reorder and dismissal in the iOS simulator. The
preview was also tested on iPhone Air. At `6135e314f3`, Flutter analysis
and the full pre-push mobile checks passed (5,613 tests passed, 71
skipped). Widget regressions cover offline Solo disclosure, retry
exhaustion, route visibility, keyboard reorder, large text, and editor
cancellation.

---------

Signed-off-by: kenny lopez <klopez4212@gmail.com>
Co-authored-by: Terp <5856f6900e8e0a4e0ea1f4f8d2ee33e4753d2119bc122f94ecafc660b46c0511@buzz.block.builderlab.xyz>
2026-11-20 17:20:08 +00:00
klopez4212
d647c9fd98 Refine iOS composer and transcribe recordings into drafts (#9574)
Refine the iOS composer with 40-point glass controls, native attachment
menus, persistent emoji access, and selected-text formatting. The mic
now transcribes recordings on device into an editable, unsent draft;
Dictation has no five-minute recording cap or timer label, and its
waveform fills the space between the controls. Voice note remains
available in attachments with its five-minute cap. Unsupported devices
fail before recording, and audio is retained until the draft is durably
saved. Stopped dictation remains recoverable across editor teardown;
failed retention and cleanup can be retried. Recovered transcripts are
inserted only once across navigation or restart, preserving live exact
mention bindings.

Preserve selection handles over glass with animated avatars. Reduce the
conversation fade to 100 points above the keyboard and transition
continuously to 180 as the keyboard closes, without a first-frame jump
when opening; Home is unchanged.

Validation: 5,117 mobile tests and 27 crypto tests pass; analysis
passes. Prior native suite on iPhone 16/iOS 26.5: 119 pass, one
pre-existing expected failure, zero unexpected failures. Physical Air
preview approved; simulator selection/dragging and attachment flows
exercised. Fixed the native navigation test's timing race and a
community-cache cleanup test that checked a parent directory before its
asynchronous removal completed. Repository-wide `just ci` previously
stopped in unchanged `buzz-test-client` load-generator tests; new-head
hosted checks are pending.

Snapshots: production composer in an iPhone Air simulator fixture with
fictional conversation text; Photos snapshot retained from the
attachment preview.

| Composer | Attachments | Photos |
| --- | --- | --- |
| ![Keyboard-up
composer](https://github.com/user-attachments/assets/b7c8f0a4-25f8-4ca2-b8ae-11e18655e64a)
| ![Native attachment
menu](https://github.com/user-attachments/assets/5eaf5259-8e04-4da7-93f5-1b2eccab3c3c)
|
![Photos](https://github.com/user-attachments/assets/a6216b7d-5eaf-482c-b587-6052825b88fc)
|

---------

Signed-off-by: Terp <5856f6900e8e0a4e0ea1f4f8d2ee33e4753d2119bc122f94ecafc660b46c0511@buzz.block.builderlab.xyz>
Signed-off-by: Tom Brow <tomb@squareup.com>
Signed-off-by: Princess Donut <b238ea756dee4d98afa5883fc7f1de61eeabe65bf700e3a5a5a80db5e42e2c2b@buzz.block.builderlab.xyz>
Signed-off-by: Tom Brow <tomb@block.xyz>
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@buzz.block.builderlab.xyz>
Co-authored-by: Princess Donut <b238ea756dee4d98afa5883fc7f1de61eeabe65bf700e3a5a5a80db5e42e2c2b@buzz.block.builderlab.xyz>
2026-11-20 16:35:20 +00:00
Logan Johnson
a45f52a95c fix(mobile): recognize agents without NIP-OA in Huddles (#8545) 2026-11-20 08:11:48 -08:00
Matt Toohey
a79cbb4664 perf(mobile): stop re-scanning the unread backlog on channel list rebuilds (#9780)
## Summary

Scrolling the mobile channel list hitched repeatedly after the app had
been closed for a long time.

To decide which rows are bold and which get a dot, the channel list read
every unread message held in memory, for every channel, on every
rebuild. After a long absence the unread catch-up holds up to 1000
messages per channel, so each list update cost more than a frame.

This change makes a list rebuild independent of the backlog size:

- A channel's messages stop being read once its bold and dot state is
decided.
- Each channel's result is reused until its messages or the read state
change. A new message re-reads only its own channel; reordering or
filtering the list re-reads nothing.

Which rows end up bold or dotted is unchanged.

### Related issue

N/A. None found.

### Testing

Before (left) and after (right), same script on an iPhone 17 simulator:
200 channels each holding 1000 unread messages, a list update every 150
ms, and a scripted finger (the crosshair) dragging at a steady 420 px
per second.


https://github.com/user-attachments/assets/07b39b61-406f-4b4b-baca-69aa5be42db7

| | Before | After |
|---|---|---|
| Frames drawn in the 11-second drag | 279 | 499 |
| Frames over 25 ms | 127 (46%) | 92 (18%) |
| Median frame | 21.1 ms | 17.2 ms |
| Worst frame | 116.8 ms | 65.2 ms |

The recording uses scripted data in a debug build, which drops some
frames even with no list updates, so the "after" side is not perfectly
smooth.

Whole frame after one list update, 200 channels, in a widget test on a
Mac (not a phone):

| Unread messages held per channel | Before | After |
|---|---|---|
| 0 | 13.3 ms | 12.7 ms |
| 300 | 16.5 ms | 6.8 ms |
| 1000 | 37.4 ms | 6.6 ms |

- New tests in `channel_unread_test.dart` compare the new pass with a
copy of the old full scan across a table of cases and 600 random steps
of adds, deletions and read marks, and count messages read to guard the
early exit and the reuse without timing.
- `flutter analyze` and the mobile channel and home tests (2,983) passed
with these two commits on `8827f986e43`. They were not rerun after the
rebase onto current `main`, so CI is the check for that.
- Not run on a phone or against a real community.

Worth a close look in review: the reuse depends on every place that
changes the stored unread messages marking that channel as changed. The
new tests drive this through a stand-in, so they do not prove each real
call site does it.

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

---------

Signed-off-by: mtoohey <mtoohey@squareup.com>
Signed-off-by: Matt Toohey <contact@matttoohey.com>
Co-authored-by: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-20 18:01:03 +11:00
Tom Brow
a303d7d5b5 fix(mobile): send Siri Bestie messages without confirmations (#9779)
Saying "Message my Bestie" to Siri (or running it from the Action button
or Shortcuts) now sends the dictated message straight away. Siri no
longer asks "Send … to <Bestie>?" before sending or shows a "Sent."
dialog afterward.

The Bestie's display name was looked up only to word that confirmation,
so that lookup is gone too: the Flutter side no longer preloads the
Bestie's profile or returns its name, and the bridge's `confirm`
callback is removed.

### Regressions

- A misheard message, or a Bestie changed on another device that this
one hasn't synced yet, now sends without a chance to cancel. We accept
that: the point of the shortcut is a hands-free send, and the message
still appears in the Bestie DM, where it can be deleted.
- This includes runs while the phone is locked and Shortcuts automations
that supply the message: both send immediately, by design.
- The community-switch guard stays: a Bestie looked up in one account or
community still can't be sent to from another.
- Nothing outside the Siri intent changes.

### Validation

- The app code at this head (the last commit only touches a test) is
built into a Buzz Dev development build installed on an iPhone 16e. The
Siri flow itself has not yet been run on that build.
- Updated
[quick_send_test.dart](https://github.com/block/buzz/blob/tomb/siri-no-confirm/mobile/test/features/channels/quick_send_test.dart)
for the `bestie` reply without a name.
- No before/after captures: the change is in Siri's own UI, which can't
be driven or recorded in the simulator.

---------

Signed-off-by: Tom Brow <tomb@block.xyz>
Co-authored-by: studio <dc2fc481343672df31a689840c09299972e704dac592e0da6f18486646a7ee3e@buzz>
2026-11-20 06:07:17 +00:00
Matt Toohey
5e8fa368a4 fix(mobile): hand message action menu scrolling off to sheet dismissal (#9760)
## Summary

On mobile, the message action menu is a modal bottom sheet whose body
scrolls when the actions overflow (long menus, large text sizes). Before
this change, dragging down inside the body only scrolled or bounced the
content: the sheet itself could be pulled down only by its handle. Now a
downward drag in the body carries on into pulling the sheet down once
the content reaches its top, in the same touch, and the sheet can be
dismissed that way.

- **Handoff in both directions.** Drag updates are split between the
content and the existing modal route. Dragging down past the top of the
content moves the sheet; reversing without lifting restores the sheet
first and then scrolls the content again.
- **Release policy is the stock sheet's.** If the finger has displaced
the sheet at release, downward velocity strictly above 700 px/s closes
it; otherwise it closes when it has been pulled more than half its
height, and settles open if not. Where the gesture began, and whether it
scrolled content on the way to the top, does not matter.
- **Guards against accidental dismissal:**
  - a release with the sheet not displaced by the finger never closes;
- ballistic and programmatic scrolling cannot start a sheet drag, so a
content fling that reaches the top after the finger lifted stops there;
  - carried scroll momentum is not added to the release velocity;
- a slow return across the top that pulls the sheet less than half way
settles open;
  - an upward release velocity keeps the sheet open.
- **Unchanged:** handle and barrier behaviour, reactions, cancellation
recovery, reduced motion, and the action/focus contracts.

The handoff lives in a shared widget,
`mobile/lib/shared/widgets/modal_scroll_handoff.dart`;
`message_actions.dart` changes by three lines to use it.
`docs/mobile-message-action-scroll.md` records the design contract and a
manual native checklist.

### Related issue

N/A. None found (searched issues and PRs for the message action menu
dismissal and scroll).

### Testing

Run at `558a79710`:

- `just mobile-check`: passed (format; analyze: no issues).
- `just mobile-test`: passed (5462 Flutter tests, 71 skipped; 27 crypto
tests).
- `just file-size-check`: passed.
- Restoring the previous release rule fails 12 of the updated tests,
including all four message action journey variants.

Coverage: the message action journey (2x text scale, iOS and Android
platform settings) drives the production sheet with timed pointer
events; the shared widget tests cover the release table at several
scroll offsets, pointer flicks on both platforms, parity with the stock
sheet drag around both thresholds, trailing bounce on short menus,
cancellation and interruption.

**Simulator recordings.** Both videos are side-by-side captures from the
iPhone 17 simulator (iOS 27.2, text size `accessibility-large` so the
menu overflows). Each side replays the same touch script.

Scroll-to-dismiss handoff. Left: base (`9bcb3e45a`), the body only
bounces and the sheet never moves. Right: branch at `23c31e2e1`, the
same touches pull the sheet down, restore it on reversal, and dismiss it
on a slow drag past half and on a flick.


https://github.com/user-attachments/assets/09b0cfc2-ed61-4822-8b35-b80d0f47e830

Scroll up slightly, then swipe down hard. Left: `23c31e2e1`, the menu
settles back open after both swipes. Right: `558a79710` (branch head),
the same touches close it, as a new touch and without lifting; the final
slow return across the top stays open on both sides.


https://github.com/user-attachments/assets/068faff4-a4d4-478f-aaf4-fc65c644632f

**Limits of this validation:**

- The touches were scripted synthetic touch events (linear motion, exact
timing), not a human finger.
- Both sides ran a dummy-data harness that calls the production
`showMessageActions` for a placeholder message, not the real channel
page. The harness is not part of this PR.
- Android, a physical device, VoiceOver and reduced motion were not
exercised natively; they are covered by widget tests only.
- The right side of the first video was built from `23c31e2e1`, one
commit before the branch head. `558a79710` changes only releases with a
fast downward velocity after content was scrolled. The gestures in that
video are slow or held releases and gestures that start at the top,
which resolve the same way under both rules; this follows from the
release rule and was not re-recorded.
- A human has not yet confirmed the behaviour by hand.

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

---------

Signed-off-by: Matt Toohey <contact@matttoohey.com>
Signed-off-by: Tom Brow <tomb@block.xyz>
Co-authored-by: Claude Fable 5.2 <noreply@anthropic.com>
Co-authored-by: Tom Brow <tomb@block.xyz>
Co-authored-by: studio <dc2fc481343672df31a689840c09299972e704dac592e0da6f18486646a7ee3e@localhost>
2026-11-20 14:41:01 +11:00
Wes
8827f986e4 mobile: follow desktop's unified sidebar workspaces (#9745)
Mobile Home now reads desktop's unified sidebar from block/buzz-app#3791
and shows the same workspaces, filings, icons and section order as the
desktop sidebar. It is read-only while a unified record exists.

## What changed

- **Reads desktop's records.** Mobile reads `channel-workspaces` and
`channel-workspace-sort`. Until the unified record exists, it falls back
to the legacy `channel-sections` and Solo groups, merging them the way
desktop imports them (`expandWorkspaceRecord`,
`importWorkspaceFallback`, `mergeLegacyWorkspaces`). Sort follows
desktop's `meta.g` registers.
- **Layout.** Sections are Starred, then the workspaces, Team, Solo and
Direct messages, in desktop's `sectionOrder`. A workspace holds Team
channels and Solo chats alike, and shows its icon: Unicode emoji as
text, `:shortcode:` as the community's custom emoji, and nothing for an
unknown shortcode.
- **Read-only lock.** While a unified record exists, mobile hides
rename, delete, move, New project and sort edits, and never publishes
the legacy records desktop would ignore. That includes:
  - an edit queued before the lock;
- a unified head arriving during a relay rate-limit wait (`mayPublish`);
  - a Team publish whose preflight read failed;
- a New project or workspace pick opened before the lock (the chat is
still created, without the filing).
- **Recovery.** A foreground refresh with a pending legacy sort still
applies a missed unified head.
- **No All/Solo/Team filter.** Desktop removed its tabs in #3791, since
workspaces now hold Solo and team chats together, so Home drops its
chips too. The Messages header keeps its title and actions and no longer
collapses on scroll.
- **Filters.** The Unreads filter uses Solo's own unread state for Solo
rows.
- **NIP-44.** Decryption accepts the extended length prefix for payloads
over 65535 bytes. A nostr-tools vector is included.

## Tests

- `workspace_layout_interop_test.dart`: a table generated by running
desktop's TypeScript from buzz-app `main` (11 layouts and 10 invalid
records). It checks that mobile computes the same sections, assignments
and order.
- `sidebar_workspaces_journey_test.dart`: Home runs on the real sections
and sort notifiers over the relay fixture. It starts on legacy sections,
receives desktop's signed heads live, then checks the order, filings,
icon, read-only sheet and Unreads. It also checks that only the filter
choice is published.
- `unified_sidebar_records_test.dart`: Team and sort publish nothing
once a unified head is seen: before an edit, while one waits, or past a
failed preflight.
- `project_creation_test.dart`: the unified layout arrives while a
workspace is being named. Nothing is written, and nothing is left to
resume.

- `solo_creation_tags_test.dart` and `me_sync_test.dart`: a project
picked or a filing queued before the lock doesn't stop a new Solo chat
from being created.

Each new guard was mutation-checked: removing it fails its test.
`flutter analyze` is clean and `flutter test` passes (5450).

## Not in this PR (open questions)

- **Forums** stay hidden on Home, as before. Desktop shows them, so a
forum filed into a workspace or starred on desktop doesn't appear on
mobile. Should mobile add a Forums section?
- **Filters** still use the legacy `channel-filter` record. Desktop
prefers `channel-workspace-filter`.
- **Solo creation without a unified record** still writes the legacy
Solo groups, as before.
- **Empty workspaces** are shown, as on desktop. Mobile rejects a
unified record that carries `meta` without `filings`; desktop never
writes that shape.
- Built-in titles now match desktop: "Team" (was "Channels") and "Direct
messages" (was "DMs").

## How to test

1. On desktop (buzz-app with #3791), create two workspaces, give one an
emoji icon, and file a Team channel and a Solo chat into it. Reorder the
sections.
2. Open mobile Home in the same community. The sections, order, icon and
filings should match desktop.
3. Open a workspace's options. You should see only Sort (disabled) and
Show. Long-press a channel: there's no "Move to section…".
4. There is no All/Solo/Team filter row under the Messages title.
5. Change the order on desktop. Mobile should follow live, or after you
foreground the app.

Screenshots are in the comment below.

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

---------

Signed-off-by: Wes <wesbillman@users.noreply.github.com>
Signed-off-by: Tom Brow <tomb@block.xyz>
Co-authored-by: Carl <32a2e2c9d428ee08902cab75d956da2c1d235a22d4766b0dd4138bf6e2e5db1d@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: studio <dc2fc481343672df31a689840c09299972e704dac592e0da6f18486646a7ee3e@localhost>
2026-11-19 18:49:12 -07:00
Matt Toohey
bea77282da fix(mobile): open message actions only from a long press on the message (#9753)
## Why
I find myself putting my finger down before scrolling and end up
triggering the long press. Each time I think "but i wasnt touching
anything?"

## Summary

On mobile, the long-press recognizer covered the whole message row, so
holding the empty space beside a bubble in a channel, DM or thread
opened that message's actions. A hold now opens the actions only when it
lands on a part of the message.

- **Bubble and media:** a hold on the painted bubble or media opens the
actions, as before.
- **Other message parts:** the avatar, author line, edited marker, photo
count label, reply footer and add-reaction button are marked as
long-press targets around their own extent, so they still open the
actions while the unused row width beside them stays inert.
- **Empty space beside a message:** a hold there opens nothing and gives
no haptic, and releasing it does not open the thread. A quick tap there
still opens the thread.
- **Unchanged:** swipe-to-reply still starts only on the bubble and
media, and the screen-reader long press, the reaction tray's long press
and the system rows' full-row hold behave as before.


https://github.com/user-attachments/assets/2ede96b0-b9dd-49f3-926f-5cad32f7242e


### Related issue

N/A. I searched issues and PRs for "long press" and found none for this;
the closest is #8500 (action sheet opening while scrolling), which is a
different problem.

### Testing

Widget tests in `swipe_reply_tests.dart` cover a hold beside the bubble
(no actions, no thread, no haptic, and a quick tap still opens the
thread), a hold on each message part in channels and threads for own and
other messages, attachment and gallery holds, the semantics long press,
and that a swipe from the non-bubble parts starts no reply.

Side-by-side recording on an iPhone 17 Pro simulator (iOS 27.2), `main`
on the left and this branch on the right, running the same four 1.0 s
holds at the same coordinates. The red ring marks the press point and
was overlaid afterwards. Holding the empty space beside a message opens
the action sheet on the left and nothing on the right; holding the
bubble opens it on both sides.

The recording was made at the first commit on this branch (`378dde654`),
before the two follow-up commits, and uses a local relay with seeded
throwaway data. It covers short messages from another author in a
channel and a thread; own messages, DMs and media are covered by the
tests only.

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

---------

Signed-off-by: Matt Toohey <contact@matttoohey.com>
Signed-off-by: Tom Brow <tomb@block.xyz>
Co-authored-by: Jitter <2b2e6415e748c35180847a37aadae06a11e30dddc76b784e7fd9354c4eb42e7a@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: studio <dc2fc481343672df31a689840c09299972e704dac592e0da6f18486646a7ee3e@buzz.block.builderlab.xyz>
2026-11-20 11:35:11 +11:00
Will Pfleger
890824f072 feat(read-state): sync mark read, channel mark unread and thread follows (#9501)
Reading, mark read, whole-channel mark unread and thread follow choices
now sync across a person's installations. This PR specifies the rules in
NIP-RS and implements them in the mobile app.

## Spec (`docs/nips/NIP-RS.md`)

- Defines *catch-up* and *displayed*.
- A catch-up advances the channel's own frontier (top-level messages) or
`thread:<root>`. `activity:` and `thread-activity:` become read-only
legacy keys.
- Explicit mark read is synchronized state. A first explicit read of a
message with no override group writes only its `msg:` frontier. Display,
dwell, scroll, catch-up and mention visibility create no `msg:` entries.
- Only whole-channel override groups are published, merged and cleared
with the counter. Readers ignore peer `msg:` and `thread:` groups.
- Single-message and thread mark unread stay on the device. They end
once the merged frontier covering them passes their baseline, from any
installation, or on display, catch-up or explicit read. The section also
states clearing scope, the accepted concurrency limitation and capacity.
- When the merged override union no longer fits the primary, the client
rewrites the primary compactly from the groups its last published
primary carried, each canonical against current frontiers. It never
omits merged groups or tombstone floors that primary carried, and
override actions fail visibly.
- Adds Buzz Thread Follow Choices: `thread-follows:<32hex>` coordinates,
validation, three-state verdict, last-writer merge with ties going to
unfollow, publication and recovery, legacy import at `at = 0`, and
capacity.

## Mobile

- Catch-up writes the main frontier. A flat timeline reads up to the
newest top-level message it reached.
- Explicit mark read publishes. Passive `msg:` marks stay on the device.
- Whole-channel mark unread publishes an override group and merges peer
groups. An explicit read or catch-up clears it, even when no frontier
moves. The action fails visibly at the uint32 limit or when the primary
is full. A synced clear the primary can't carry is rolled back, and the
channel view reports it once while the failure stands.
- Device-local message and Inbox unread overrides record a baseline and
clear when a covering frontier passes it, including one merged from a
peer.
- Thread follows move from local storage to the synced `thread-follows:`
slots. They share the read-state `client_id`, journal, `created_at`
sequence, snapshot and live subscription, and spill across up to 16
slots with stable placement. An unreadable coordinate marks follow state
incomplete and blocks this installation's follow publication.
- Follow and unfollow are refused on every cold start of the writer
until its first complete recovery of its own state succeeds and every
owned follow head is readable. Cached follows show at once. A refused
tap changes nothing and shows "Follow choices are not ready. Connect and
try again." Reads, catch-up and both kinds of mark unread are not gated.
- A follow tap is accepted only once journaled. The accepted own head,
pending edits and the exact in-flight packet are kept apart, so a retry
or restore never drops or re-attributes an edit.
- Pre-sync local follows are imported at `at = 0` after a complete
merge, once their channel is known from a relay event. An imported key
is settled, and its legacy copy retired, only when the journal write the
import awaited covered it and that entry is still current.
- An explicit unfollow suppresses ordinary replies at live and catch-up
admission. A change in follow choices drops the unread replies already
counted for an unfollowed thread. A newly followed thread re-runs
catch-up only for its own channel.
- A reading clear refused because the view hasn't completely loaded is
retried after the next complete snapshot, including when publishing was
shut off at the time. The view also counts as not completely loaded
while the live subscription is reconnecting, so a read made while the
phone is offline can't erase a newer unread mark set on another device.
Offline, whole-channel mark unread is still refused, with a message.
- Read-state events, including live ones, are verified with native
libsecp256k1 before they are used.
- A pending unread packet is counted as published only when no newer own
head outranks it. When a newer head supersedes it, a successor is built
above that head from the saved intent, and a late echo of a replaced
packet doesn't overwrite what was published.
- When the merged unread state overfills the primary and the compact
fallback can't carry a pending mark, the packet stays pending and the
"read state full" error shows. Other queued reads and follows in the
same flush still publish.
- When this installation's own unread record can't be decoded, only the
unread step is held: that record isn't overwritten, its pending marks
stay queued and the sync error shows. Other queued reads and follows in
the same flush still publish.
- The sync notice stays up after an unsupported refusal until a new
session. Offline, it can't be tapped and says it will retry when back
online.
- Two-device fixtures against an in-memory relay cover channel
round-trips and clears, stray message groups, the first explicit message
read, the primary cap, follow propagation, same-second and
backward-clock follow publication, legacy import, retry after a failed
publish, unreadable coordinates and slot packing. Recovery fixtures
cover the startup gate, journal failures during flush, interleaved
legacy imports, and restore of an older journal.

## Relay

- Conforming `thread-follows:<32 hex>` records get the NIP-RS treatment:
a replaced record is purged, and a stale resend of an older one is
refused. Records with a mismatched `t` tag keep ordinary
replaceable-event behavior.

## Known gap

- An unread packet held for capacity can age past the relay's timestamp
window. The relay then refuses it, and the refusal path retires it
without the capacity check, so the error clears and other installations
don't get that mark. The mark stays on the device.

Related:
[block/buzz-app#3552](https://github.com/block/buzz-app/pull/3552)

---------

Signed-off-by: Will Pfleger <wpfleger@block.xyz>
Signed-off-by: Will Pfleger <wpfleger@squareup.com>
Co-authored-by: Duncan <dcfd242e557282d7a1e2cf2e6877522682f1e5c6156dc92ca7d90eaedd3b0f95@buzz.block.builderlab.xyz>
Co-authored-by: Tom Brow <tomb@block.xyz>
2026-11-19 17:02:58 -05:00
Wes
cda68a9333 Fix shared stars and mutes in mobile and CLI (#9684)
## Summary

Mobile, CLI, and legacy desktop write millisecond timestamps for new
star and mute edits. They compare legacy seconds in the same unit and
retain the original timestamps of untouched entries during rollout.

Mobile and CLI cap saved records at 500 entries and repair oversized
records on a write. CLI no-op adds and removes leave oversized records
alone. They keep the current edits and evict by age, preferring clears
when timestamps tie. The CLI accepts a full flag record within the
short-form NIP-44 envelope.

Mobile builds each write from the writer's retained snapshot plus a
durable journal of local edits. The journal drains in batches of at most
500 edits. It retries transient failures and older writer snapshots with
bounded backoff and retires a pending edit after verifying that the
writer already holds it or holds a strictly newer one. Retried writes
preserve the original entry timestamps. An exact timestamp tie with a
conflicting writer value advances by one millisecond so older clients
accept the edit. An unreadable record pauses writes until a valid
snapshot or app resume.

On mobile upgrade, a verified writer snapshot lets the app recover newer
local star and mute edits from the old cache. The legacy cache has no
edit journal. Below 500 writer entries, the app also recovers absent
active flags. At 500 or above it only recovers absent active flags dated
after the snapshot's creation second. Absent legacy clears and clears
newer than the writer's recorded clear are kept locally. They enter the
publish queue when an older or equal enable appears. If the enable
disappears before preflight, the clear returns to the local cache. A
newer enable, an equal or newer clear, or a fresh tap retires the saved
clear. A cached enable is queued when it is newer than the writer entry
or ties a writer clear. A strictly newer cached enable advances the
timestamp even when both copies are enabled. Recovered enables and
promoted clears keep their original stamps in the journal. When the
relay entry is absent or uses seconds, the write keeps a recovered
seconds stamp so a later edit from an older phone can win. An existing
millisecond entry uses millisecond comparison and serialization for the
recovered edit.

## Validation

- Mobile regressions exercise a later seconds-stamped edit, two-device
eviction, a pending clear at the cap across manager replacement,
transient read recovery, a losing duplicate acknowledgement, and a
second toggle during confirmation, including at the cap.
- CLI regressions cover seconds-stamped entries, the 500-entry limit,
recovery from oversized records, and clear retention, including a
repeated remove that leaves active flags intact.
- Runtime validation uses scripted relays.
- All 702 CLI tests passed.
- Pre-push gates passed, including the full Flutter suite and analysis,
repository Rust tests, and desktop Tauri checks.
- Legacy desktop tests cover mixed-unit merges and back-to-back toggles.
Mobile upgrade regressions cover newer offline entries, eviction,
reconnect, and malformed-head recovery.

---------

Signed-off-by: Wes <wesb@block.xyz>
Co-authored-by: Star Lord <b89298dbe87c6b3fd8a425b535d9d161f23c88d555a47925ae0b04dfe02b201e@buzz.block.builderlab.xyz>
2026-11-19 14:49:16 -07:00
John Matthew Tennant
b7fb268e8b fix(mobile): keep active iOS Huddles connected while locked (#9682)
## Summary

Locking an iPhone paused Buzz and ended the current Huddle. An admitted
iOS Huddle now keeps its audio session and media connection through app
pause and resume. Detaching the app or switching communities still ends
local audio, and the main relay retains its normal pause policy.

### Related issue

None found. The disconnect was reported while using the installed Buzz
iPhone app.

### Testing

- A Flutter regression joins a Huddle, pauses the app, lets the main
relay’s background grace period expire, and resumes. The baseline left
the Huddle. With the fix, the local session remains active and detach
still stops media. The test uses fake media and transport.
- The iOS simulator package and development-signed iPhone package both
declare the background audio mode. An iPhone 15 Pro running the
development build at `18db4d969494` stayed connected when locked.
Two-way lock-screen audio and headset switching remain unverified. In a
test Huddle, exchange distinct phrases in both directions with the phone
unlocked, while it stays locked, and after unlock. Confirm that
participation continues without rejoining and that Leave stops audio.
- Before readiness, verify what peers see when the backgrounded app
exits after its main relay disconnects, and what the iPhone shows on
unlock after a prolonged media interruption.

#### Screenshots

Flutter Huddle card rendered with test data.

![Before, Foreground voice
Huddle](https://raw.githubusercontent.com/block/buzz/fbadd2ed684fbec78be68518c4b4c37bc6fc3c60/pr-9682--before.png)

![After, Voice
Huddle](https://raw.githubusercontent.com/block/buzz/fbadd2ed684fbec78be68518c4b4c37bc6fc3c60/pr-9682--after.png)

---------

Signed-off-by: John Tennant <jtennant@squareup.com>
Signed-off-by: Tom Brow <tomb@block.xyz>
Co-authored-by: Oliver <e78152627ea32fbacb070e5047afcfb8e409fa3343d9e618227baacca5b5e607@buzz.block.builderlab.xyz>
Co-authored-by: Tom Brow <tomb@block.xyz>
2026-11-19 16:48:47 -05:00
Wes
f7496607a8 fix(mobile): hash upload payloads off the UI isolate (#9736)
## Summary

Move SHA-256 for prepared mobile uploads to a worker isolate with
Flutter's `compute`, at all payload sizes. The same digest feeds the
`X-SHA-256` header and Blossom authorization. The existing cancellation
check runs before each HTTP send, including after the worker returns.

### Related issue

No matching open issue or PR found.

### Testing

- `just mobile-install mobile-check mobile-test` passed, including
`flutter analyze` and the full Flutter suite.
- The upload regression verifies that a 2 MiB attachment's `X-SHA-256`
header matches the request body's digest.
- The composer widget tests wait for the worker while exercising send,
progress, cancellation, and error handling.
- On Apple M3 Ultra, a host Flutter test ran the production
prepared-byte upload path with a stub HTTP transport. Median delay to a
queued main-isolate timer over three runs:

  | Payload | Before | After |
  | --- | ---: | ---: |
  | 50 MiB | 330 ms | 3.6 ms |
  | 100 MiB | 644 ms | 7.5 ms |

At 100 MiB, the patched isolate serviced at least 40 callbacks from a 16
ms timer before HTTP send. The baseline serviced zero. Both produced the
same hash. This measures host isolate responsiveness.

### Manual check

On a phone, attach a large file in a test conversation. Tap Send and
immediately scroll the conversation. Scrolling should stay responsive
during upload preparation. Open or download the completed attachment and
verify that it matches the original.

Signed-off-by: Wes <wesb@block.xyz>
Co-authored-by: Rocket <0c41329ade659e01801116549bc617351689892a382bc864a1186dc9191293a7@buzz.block.builderlab.xyz>
2026-11-19 14:34:30 -07:00
Wes
4079793f99 Match desktop unread cues on mobile channel rows (#9715)
## Summary

- Honor the synced `seen:<channel>` timestamp in mobile row styling and
the **Unreads** filter. Attention keeps its dot regardless of timestamp,
and the row's mark-read menu uses the underlying unread state.
- Hide the dot when the row shows a mute the relay has confirmed.
Confirmation survives reconnects within the same account and relay. The
row still exposes unread attention to screen readers. Unmuting on the
phone restores any dot supported by retained unread evidence as soon as
the bell disappears.
- Apply the same `seen:<channel>` timestamp to the app icon badge's
ordinary backlog count. Mentions and thread replies keep counting.
Includes #9721.

This reuses the existing read-state and mute sync. Pending mutes keep
the dot visible, and the patch adds no relay requests or read-state
writes.

### Related issue

No matching issue or open PR found. Earlier mobile sidebar unread parity
work is in #1303.

## Testing

- `just mobile-install mobile-check mobile-test`
- Widget coverage for backlog at and after the desktop cut, mentions on
either side of it, the **Unreads** filter, the mark-read menu, pending
and confirmed mute, and unmute while the relay still reports muted.
- Scripted relay coverage for mute confirmation across reconnects,
delayed and older responses, newer confirmations, and relay switches.
Read-state tests cover reading a peer's `seen:` context during an
ordinary mobile publish.
- Badge provider tests cover backlog at and after the cut, plus mentions
and thread replies older than the cut.

### Test on a phone with desktop alongside

1. Check out the PR. To install a local debug build, run
`./scripts/mobile-worktree-overrides.sh` from the repo root, then run
`flutter devices` and `flutter run -d <device-id>` from `mobile/` with
Hermit active. Use the device signing setup if needed for a physical
iPhone. Sign in to the same account and community on both clients. Use
an already initialized mobile account and leave the phone on the channel
list. [Device signing
setup](https://github.com/block/buzz/tree/main/mobile#ios-push-capability)
2. Have a second account post an ordinary message in a test channel.
Wait for its row to become bold on both clients. On desktop, open that
channel and switch away quickly, before the 300 ms reading dwell. After
sync, the phone row should lose bold. In the phone's section menu,
choose **Filter…**, select **Unreads**, and tap **Apply**. The row
should disappear. Use **Show hidden channels** and long-press the row to
verify that **Mark Read** is still available. Dismiss the menu, tap
**Hide filtered channels**, and have the second account send a newer
ordinary message. The row should appear bold again.
3. For a mention older than the cut, have the second account @mention
you in a different test channel before making the quick desktop visit.
After leaving the channel on desktop, the phone should still show its
attention dot. For a newer mention, do the quick desktop visit after an
ordinary post in a separate channel, wait for its phone row to quiet,
then send the @mention. Its phone row should gain a dot.
4. With the mention still unread, mute that channel on desktop. When the
phone shows the muted bell, verify that the attention dot disappears.
Turn off the phone's network connection, return to the channel list,
then reconnect. The dot should stay hidden throughout. On the phone,
long-press the row and choose **Unmute channel**. The dot should return
as soon as the bell disappears. Keep the phone on the channel list
throughout so it does not read the mention.
5. On a phone with app badges enabled, repeat the ordinary-message case
in step 2 with that message as the only unread item. After the phone
syncs the desktop visit, the app icon badge should clear. A newer
ordinary message should bring it back.

Device and desktop testing is pending.

### Before and after

Before and after captures from the Flutter channel list widget with
synthetic rows. The ordinary `desktop-seen` row loses bold, the
confirmed-muted mention loses its dot, and the unread control stays
bold.

| Theme | Before | After |
| --- | --- | --- |
| Light |
![before-light](https://raw.githubusercontent.com/block/buzz/fb3600cdb1017ef29df54305e598132c16acbf1e/pr-9715--before-light.png)
|
![after-light](https://raw.githubusercontent.com/block/buzz/fb3600cdb1017ef29df54305e598132c16acbf1e/pr-9715--after-light.png)
|
| Dark |
![before-dark](https://raw.githubusercontent.com/block/buzz/fb3600cdb1017ef29df54305e598132c16acbf1e/pr-9715--before-dark.png)
|
![after-dark](https://raw.githubusercontent.com/block/buzz/fb3600cdb1017ef29df54305e598132c16acbf1e/pr-9715--after-dark.png)
|

---------

Signed-off-by: Wes <wesb@block.xyz>
Signed-off-by: Tom Brow <tomb@block.xyz>
Co-authored-by: Star Lord <b89298dbe87c6b3fd8a425b535d9d161f23c88d555a47925ae0b04dfe02b201e@buzz.block.builderlab.xyz>
Co-authored-by: Tom Brow <tomb@block.xyz>
2026-11-19 12:21:34 -07:00
klopez4212
286095c937 feat(mobile): refresh Huddle speaking styles and iOS controls (#9716)
## Summary

Bring mobile Huddle speaking indicators closer to desktop with a close,
avatar-colored ring and subtle portrait motion, respecting reduced
motion. Use native Liquid Glass for full-screen iOS controls with clear
microphone/speaker active states; preserve the minimized sheet.

Regular iPhone and Android controls retain their existing positions and
sizes. Duo uses a side rail with End Call above minimize, microphone and
speaker below, consistent spacing, and extra cover-display status
clearance. Participants remain centered across the full display width.
Hide the emoji action while retaining reaction support for a future
return.

### Related issue

No matching open issue found. Earlier mobile control exploration: #9383;
invitation changes are outside this PR.

### Testing

- Static analysis and pre-push checks passed at `bc5eb34f4`.
- Full mobile suite: 5,126 passed; companion suite: 27 passed.
- Coverage includes speaking-ring geometry, reduced motion, glass
selected states, both Duo rail sides and display sizes, standard-phone
control geometry, and minimizing to the original sheet.
- Physical Duo previews reviewed during iteration; final build installed
on iPhone Air for owner testing. Owner approved proceeding to PR.

---------

Signed-off-by: kenny lopez <klopez4212@gmail.com>
Signed-off-by: Tom Brow <tomb@block.xyz>
Co-authored-by: Terp <5856f6900e8e0a4e0ea1f4f8d2ee33e4753d2119bc122f94ecafc660b46c0511@buzz.block.builderlab.xyz>
Co-authored-by: Tom Brow <tomb@block.xyz>
2026-11-19 19:13:13 +00:00
Tom Brow
03336d0872 fix(mobile): only say "Community changed" when the community changed (#9156)
On mobile, a text send that failed for almost any reason showed **"Not
sent. Community changed."** The composer caught every `StateError` as a
community switch, and relay failures such as a briefly disconnected
socket (`RelaySession.publish` throws "Relay session is not connected")
are also `StateError`s. So a reconnect blip during a send told the user
they had switched communities when they hadn't.

The community-switch guards in message, forum and channel-action
delivery now throw a dedicated `ActiveCommunityChangedError`, and an
unconnected publish throws `RelayNotConnectedError`. Both still extend
`StateError`, so every existing `on StateError` caller behaves as
before. The composer now reports:

| Failure | Message |
| --- | --- |
| Active community changed mid-send | Not sent. Community changed. |
| Relay socket not connected | Not sent. No connection. |
| Relay never acknowledged the event (ack timeout) | Not confirmed. The
relay didn't respond. |
| A relay request timed out before the event was published (e.g. a
roster lookup) | Not sent. The relay didn't respond. |
| Connection lost after the event was sent, before its acknowledgement |
Not confirmed. Connection lost. |
| Relay rejected the event, or anything else | Not sent: *relay reason
or error text* |

The two "Not confirmed" cases may still have been accepted by the relay,
so they avoid a definite "Not sent" that would invite a duplicate
resend. Pending publishes rejected by a disconnect or backgrounding now
complete with a typed `RelayAckLostError` instead of a generic
exception, and an unacknowledged publish times out with
`RelayAckTimeoutError` (still a `TimeoutException`) so it can be told
apart from earlier timeouts.

The draft is restored in every case, as before.

### Validation

- Added [composer widget
tests](https://github.com/block/buzz/pull/9156/files#diff-101740841aadcb902d0717f3909debe16073c672e73be74a5b908bf11dfc8782)
for each non-community failure (disconnect, timeout before publishing,
ack timeout, connection lost before acknowledgement, relay rejection,
other `StateError`), checking the snackbar text, that the draft is
restored, and whether the message EVENT was sent. The disconnect,
timeout and connection-lost cases run through the real relay session (a
pending publish rejected by backgrounding, a history request that times
out before any message EVENT). The existing community-switch journey
goes through the real channel-action guard.
- Simulator (iPhone 17 Pro, debug build of this branch signed in to a
test community): opened a channel and sent a message; it was delivered
and the composer cleared normally. Limitation: the error paths
themselves were exercised only by widget tests, since the simulator
shares the Mac's network and I couldn't drop the relay connection for it
alone.

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

---------

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-19 12:02:38 -07:00
klopez4212
42b89f9b5f fix(mobile): align Huddle cards and preserve conversation navigation (#9713)
Hide generated private Huddle rooms from mobile channel lists, including
cached rooms and older rooms with creator-matched creation receipts.
Ended Huddle cards keep **View** available while membership is unknown.
Known non-members see disabled **Ended**. Unknown membership is checked
with the relay before opening history, and explicit access denials clear
cached transcript rows. Opening history never joins audio. Known members
can reopen loaded history offline. Already-authorized history stays
mounted through a disconnect or transient revalidation failure while the
route remains open; reconnects recheck access, and explicit denial
clears it. Rooms without sufficient evidence remain visible.

Match desktop card colours, borders, 20-point corners, elapsed duration,
participant avatars and ended-call icon. Active cards retain headphones
and mobile tap targets. Replace the minimized Huddle's full-app UIKit
background with Flutter clipping: the native background caused the
two-pane iOS conversation to appear blank even though its messages were
loaded and scrollable. The owner reproduced the failure and confirmed
the Flutter surface restores the timeline on iPhone Duo.

Lifecycle updates share one live subscription and merge into history.
Start/end discovery has its own query budget and survives a failed
participant-history read; avatar rosters use revision and admission
metadata for same-second reconnects. Explicit denials propagate without
trying a fallback transport. Creation receipts coalesce overlapping list
refreshes and reconcile after the list loads, retain verified
classifications in scoped snapshots, and stop sending batches after a
community switch. Removed the unused native backdrop and bottom-corner
options.

Validation on `7f1a278dbe`: 5,133 Flutter tests plus 27 companion tests
passed (71 skipped), analyzer and file-size checks passed, and the iOS
release build passed. The updated Buzz Huddles preview is installed on
iPhone Duo. The phone locked before launch, so the exact-revision native
journey is still pending. Regressions cover cached-history denial,
live-only lifecycle events across recovery, busy-call discovery,
same-second rejoining, slow and overlapping receipt lookups, cached
classifications, community switching, and HTTP denial with a transient
WS failure configured. Both transport-denial and overlapping-refresh
regressions were verified failing before the fixes. Tom’s follow-up from
#9719 adds held-revalidation, known-member offline reopen and
partial-roster failure coverage. The original blank-screen fix was
verified by the owner on iPhone Duo; this review revision still needs
their on-device minimized-Huddle/two-pane and VoiceOver checks. The
surface retains Flutter's existing 24-point shape instead of
iOS-adaptive concentric corners.

### Snapshots

Synthetic widget previews; no private conversation data.

| Active | Ended | Dark mode |
| --- | --- | --- |
| ![Active
Huddle](https://github.com/user-attachments/assets/9abbeb94-e55c-4991-bd56-e2a78a5915a0)
| ![Ended
Huddle](https://github.com/user-attachments/assets/f3d7c3c1-57d2-4ae2-a669-17c64d0e214e)
| ![Dark
Huddle](https://github.com/user-attachments/assets/b0ff47d1-708d-46b8-9082-e57076053ae0)
|

![Large
text](https://github.com/user-attachments/assets/87a63108-3773-4317-990d-f3d7c7412bbd)

---------

Signed-off-by: kenny lopez <klopez4212@gmail.com>
Signed-off-by: Tom Brow <tomb@block.xyz>
Co-authored-by: Terp <5856f6900e8e0a4e0ea1f4f8d2ee33e4753d2119bc122f94ecafc660b46c0511@buzz.block.builderlab.xyz>
Co-authored-by: Tom Brow <tomb@block.xyz>
Co-authored-by: studio <dc2fc481343672df31a689840c09299972e704dac592e0da6f18486646a7ee3e@localhost>
2026-11-19 18:46:30 +00:00
klopez4212
1ac0b1dad1 Match mobile mention chips to desktop styling (#9706)
Mobile mentions now use the desktop chip treatment: neutral rounded
pills for other identities, the chat accent for mentions of the viewer,
and a contrasting inset fill inside outgoing messages. This applies to
message bodies and compact previews, while preserving profile taps and
resolving self-highlights by public key.

The change reuses the existing chat palette and keeps it stable across
parent rebuilds, so unchanged messages retain their parsed Markdown.
Mention routing and composer behavior are unchanged.

Validation: `just mobile-check mobile-test` passed (5,118 Flutter tests,
71 skipped, plus 27 crypto-package tests). Coverage includes light/dark
themes, 2× text, profile taps, live identity switching, outgoing
contrast, and Markdown reuse; removing self-highlighting makes the
regression fail. A signed iOS build was installed and checked on a
physical device, then approved for PR preparation.

### Snapshots

Actual Flutter component renders with synthetic identities and the
bundled app font. Each shows received/own messages, compact previews,
and enlarged text.

| Light | Dark |
| --- | --- |
| ![Light mention
chips](https://github.com/user-attachments/assets/54cd45ae-0196-4244-837c-2858e1768f11)
| ![Dark mention
chips](https://github.com/user-attachments/assets/b72be61f-c919-4a9d-8941-9d417e1309ba)
|

buzz-review-completed

Signed-off-by: kenny lopez <klopez4212@gmail.com>
Co-authored-by: Terp <5856f6900e8e0a4e0ea1f4f8d2ee33e4753d2119bc122f94ecafc660b46c0511@buzz.block.builderlab.xyz>
2026-11-19 18:31:32 +00:00
klopez4212
bf1cd5500d fix(mobile): stabilize Duo chat switching and sheet layering (#9717)
## Summary

Selecting a chat or channel in the expanded conversation layout now
switches immediately, while opening a deeper thread keeps its navigation
animation. The selected chat reuses the native iOS header and blur
surface so switching conversations does not flash; each conversation
still owns its own editor and timeline state.

Search and Activity now slide as opaque sheets over stationary native
controls, revealing them progressively on dismissal. Activity keeps its
existing title styling with Close in the Duo rail; expanded Search gains
top spacing. Compact navigation and the transparent toast composition
path are preserved.

## Validation

- Final head `bd92c40e86`: full mobile suite 5,132 passed, 71 skipped;
27 crypto tests passed. Required push checks passed.
- Native iOS suite: 115 passed. Formatting and analysis clean.
- Header-retention regression fails with the retention key removed and
passes after restoration.
- Recorded repeated native-header switches in a wide iPad simulator
fixture, plus Search/Activity transition checks in the Duo simulator.
- Owner verified both sheet motion and chat switching on the physical
Duo. The final ordinary-iPad Activity guard is covered separately by
tests.

## Snapshots

Synthetic chat fixture using the actual conversation-pane routes and
UIKit header on an iPad simulator. These illustrate two consecutive
selections; they are not screenshots of the owner's chats or the Duo
rail geometry. Recorded transition frames were also inspected for
continuous blur.

| Design selected | Mobile selected |
| --- | --- |
| ![Design
selected](https://github.com/user-attachments/assets/cf15641e-b1ee-47a1-aed4-0d20d0cadf0e)
| ![Mobile
selected](https://github.com/user-attachments/assets/c047ad37-3c86-4eb1-9cca-aeb9ec599499)
|

---------

Signed-off-by: kenny lopez <klopez4212@gmail.com>
Co-authored-by: Terp <5856f6900e8e0a4e0ea1f4f8d2ee33e4753d2119bc122f94ecafc660b46c0511@buzz.block.builderlab.xyz>
2026-11-19 17:56:11 +00:00
klopez4212
83eb59c631 fix(mobile): keep open shared sessions in Solo (#9704)
Sharing a Solo session as View only changes its access to open. Mobile
incorrectly required private access to recognize Solo, moving these
sessions into Channels. Recognize labeled Solo streams independently of
visibility, retaining their existing project placement and
membership/ownership checks.

Apply the same rule to iOS notification classification so reply routing
agrees with Flutter. Add regression coverage for open owned/shared Solo
sessions and exclusion from Channels. This changes presentation only;
access settings remain unchanged.

Validation: mobile-install and mobile-check passed; Solo regressions
passed in the full Flutter run (5,095 passed, 71 skipped, one failure in
community_provider_test.dart: startup and credential replacement discard
orphan snapshots and image caches). All 81 BuzzPushKit tests passed.
Independent agent review completed with its notification-routing finding
fixed.

Device workflow and human testing remain pending. To verify: share a
Solo session as View only, reopen mobile, and confirm it remains in its
Solo project and is absent from Channels. Verify notification replies
return to the same conversation.

Follow-up to #9348.

Pre-push rerun: analysis passed, but the Flutter compiler ran out of
disk space and the stalled test process was interrupted. The hook
subsequently returned success after 27 crypto-package tests passed; that
is not a full Flutter pass. The earlier complete Flutter result above
remains the applicable evidence.

Signed-off-by: kenny lopez <klopez4212@gmail.com>
Co-authored-by: Terp <5856f6900e8e0a4e0ea1f4f8d2ee33e4753d2119bc122f94ecafc660b46c0511@buzz.block.builderlab.xyz>
2026-11-19 16:39:38 +00:00
klopez4212
68d367cf23 fix(mobile): align channel indicators and Duo section menus (#9703)
Align the mobile channel-list indicators to one trailing column. The
unread dot stays at the right, with the temporary clock and mute
indicator to its left when present. Duo's native menus for built-in and
custom sections now place their ellipsis in the same 20-point slot while
preserving the full 44-point tap target and native menu behavior.

Validation: full mobile suite (5,098 passed, 71 skipped), 27 crypto
tests, clean Flutter analysis, native UIKit menu geometry/hit-target
checks, and a successful iOS release build. Installed on iPhone Air and
Duo using existing saved state; inspected the Duo's native section-menu
placement. Regression coverage checks row alignment, clock ordering,
native bridge geometry, and the full menu hit area.

---------

Signed-off-by: kenny lopez <klopez4212@gmail.com>
Co-authored-by: Terp <5856f6900e8e0a4e0ea1f4f8d2ee33e4753d2119bc122f94ecafc660b46c0511@buzz.block.builderlab.xyz>
2026-11-19 16:38:55 +00:00
klopez4212
7d116da335 fix(mobile): allow person mentions in Solo chats (#9705)
## Summary

Mobile Solo rejected a human member mention with “Not sent. Community
changed.” because it checked every recipient for agent ownership.
Explicit mentions now accept current chat members, matching desktop; the
implicit header agent still requires ownership. Fresh membership and
community checks remain in place.

This improves human-only and mixed person/agent sends without changing
default agent selection, nonmember invitation rules, or thread drafts.
It also fixes existing private shared Solo chats.

### Related issue

Separate follow-up to #9704; no dependency on its classification change.
Searched open issues/PRs: #9156 addresses misleading send-error wording
and #9699 addresses mention editing; neither changes this Solo recipient
ownership check.

### Testing

`just mobile-install mobile-check mobile-test` passed (5,122 Flutter
tests, 71 existing skips; 27 crypto package tests), along with `just
file-size-check` and diff checks. Regression coverage drives the actual
composer on iOS and Android and checks explicit-recipient
removal/community-switch boundaries, plus existing implicit-agent
ownership checks. Before the fix, the new composer journey retained the
human-mention draft on both platforms.

Manual check: in an owned shared Solo with a human member, send an
explicit mention of that person, then a mixed person/agent mention. Each
should send and clear its draft. Untagged messages should still use the
selected agent.

Native device/live-relay testing and human confirmation remain pending;
this PR stays draft under AGENTS.md.

Signed-off-by: Terp <5856f6900e8e0a4e0ea1f4f8d2ee33e4753d2119bc122f94ecafc660b46c0511@buzz.block.builderlab.xyz>
Co-authored-by: Terp <5856f6900e8e0a4e0ea1f4f8d2ee33e4753d2119bc122f94ecafc660b46c0511@buzz.block.builderlab.xyz>
2026-11-19 14:59:44 +00:00
Wes
8306e38742 fix(mobile): let code scroll under the code block copy button (#9612)
## What changed

The copy button on a message code block reserved a fixed 40px column
beside the horizontal scroller, so every line was clipped about 40px
short of the block's right edge. This was most visible on narrow phones.

The fix matches buzz-app desktop (`Markdown.module.css`,
`.codeActions`):

- The horizontal scroller now spans the whole block.
- The copy button floats in the top-right corner on an opaque chip, so
code scrolled under it never collides with the icon. On an own-message
bubble the chip is the code tint blended over the outgoing fill, so it
matches the block.
- The end padding moves inside the scroll content, so every line end can
still be scrolled clear of the button.
- The language label keeps its right inset, so it never runs under the
button.

## Why nothing gets worse

Same tap target, icon, copy behavior and block insets. The only visual
change is that code now uses the width the gutter used to take. Long
lines in the button's row pass under the opaque chip while scrolled, as
they do on desktop.

## Testing

- `message_content_test.dart` "renders code block with language tag" now
asserts that the scroller spans the block inside its border and that the
copy button overlaps the scroller. Without the production change it
fails (`Expected: 798.0, Actual: 746.0`), and it passes with it.
- Before/after captures were rendered with the real fonts and the mobile
appearance theme at iPhone width, for received and own (Chartreuse)
bubbles, at rest and scrolled to the end. They are in the screenshots
comment.
- Pre-commit and pre-push hooks passed.
- Not yet exercised in the native app on a device.

The iOS "Copy and Delete" screenshot paste issue from the same report is
still being diagnosed and is not in this PR yet.

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

---------

Signed-off-by: Wes <wesbillman@users.noreply.github.com>
Co-authored-by: Carl <32a2e2c9d428ee08902cab75d956da2c1d235a22d4766b0dd4138bf6e2e5db1d@buzz.block.builderlab.xyz>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-19 07:28:06 -07:00
klopez4212
5bd9d2c5d2 Transcribe Bestie hold recordings into text on device (#9645)
Hold Bestie to record with the waveform and slide-up cancel interaction
from #8665, then release to send an on-device transcript as a normal
text message. Stay on Home with a loader inside Bestie until delivery
succeeds, then open chat. Failures expose Retry/Discard; saved
recordings and signed messages remain recoverable without duplicate
sends. Saved audio is excluded from OS backup. Existing composer voice
notes are unchanged.

Separate exploration from #8665. Transcription requires iOS 26 and a
supported language. Android reports unavailable before capture because
its generic recognizer cannot guarantee saved-file input.

Validation: at `b5dc83bbf5`, 5,046 Flutter tests (71 skipped), 27 crypto
tests, analysis and required push checks pass. Prior native changes at
`30a397f83c`: Android build and 33 tests pass; iOS simulator compilation
and backup-exclusion test pass, with one unchanged document-picker
timeout passing on isolated rerun. Earlier iPhone preview was tested
with saved profile preserved; these latest fixes have not been installed
on the physical phone.

---------

Signed-off-by: kenny lopez <klopez4212@gmail.com>
Signed-off-by: Tom Brow <tomb@block.xyz>
Co-authored-by: Terp <5856f6900e8e0a4e0ea1f4f8d2ee33e4753d2119bc122f94ecafc660b46c0511@buzz.block.builderlab.xyz>
Co-authored-by: Tom Brow <tomb@block.xyz>
Co-authored-by: studio <dc2fc481343672df31a689840c09299972e704dac592e0da6f18486646a7ee3e@buzz.block.builderlab.xyz>
Co-authored-by: corey <2dafccf60ea6d431a568f6d67fc600160d92a51e415e09dc8b213b8e360663d5@buzz.block.builderlab.xyz>
2026-11-19 10:32:12 +00: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
Tom Brow
ff652ed06c perf(mobile): cache and animate custom emoji in the iOS picker (#9479)
The iOS emoji picker's custom emoji downloaded again every time the
picker opened, and animated emoji showed only their first frame.

Now each custom emoji downloads once per install and plays its
animation:

- The native picker gets image bytes from Flutter through the same path
as the rest of the app's images: the in-memory custom emoji cache, then
the persistent media disk cache, then one download through the shared
media HTTP client. Relay media is cached as immutable.
- Swift decodes every frame (no Swift-side cache) and shows the image in
a `UIImageView`, since SwiftUI `Image` draws only the first frame of an
animated `UIImage`. With Reduce Motion on, it shows the first frame,
following the setting live.
- At most four picker downloads run at once, and an emoji scrolled off
screen before its turn never starts. Emoji already saved on disk skip
the queue, so reopening a large set stays instant.
- A picker load joins any download of the same image already in flight
elsewhere in the app. A saved copy that fails to decode is evicted and
downloaded again, and only bytes that decoded are kept in memory.
- Swift decodes at most four emoji at once, including ones from cached
bytes. An emoji whose cell scrolls away gives up its place and stops
decoding between frames, and a cell that leaves the screen keeps only
its first frame.
- Each animation frame keeps its own delay. UIKit spaces animated frames
evenly, so a frame repeats for its share of the loop, and a GIF that
holds its last frame for 3 s still does.

### Why it refetched

The native picker loaded images itself with `URLSession.shared` and an
`NSCache` keyed on the whole request. Every request carried a freshly
signed media auth header, so the key never matched and nothing was
cached on disk.

### Validation

Relay media downloads for the 48 custom emoji matching "nod" (local
relay, iPhone 17 Pro simulator):

| Step | main | this PR |
| --- | --- | --- |
| First open | 48 | 48 |
| Leave and re-enter the channel, reopen | 48 | 0 |
| Relaunch the app, reopen | 48 | 0 |
| Reinstall the app, reopen | not measured | 0 |

Before (main): every reopen downloads again, and animated emoji are
still.


https://github.com/user-attachments/assets/7a43dd6a-61e0-495d-abed-6c11f7d4f965

After (this PR): reopening shows cached emoji immediately, and animated
emoji play.


https://github.com/user-attachments/assets/bf45a5c0-77ef-4501-8843-6f42e15de389

Automated app run: signed in to a local relay, opened a channel,
long-pressed a message, opened the full picker, searched, closed, left
and re-entered the channel, reopened, relaunched and reopened. Repeated
on the final head (359fdc8) with a warm cache: 0 downloads across open,
re-entering the channel and relaunch, all emoji rendered. The run used
the simulator only; device and hosted-relay behavior were not exercised.

Added tests:

- `media_disk_cache_test.dart`: encoded bytes for a native surface
download once, survive a relaunch, and bytes that never decode are not
saved.
- `emoji_picker_test.dart`: the native sheet's `mediaBytes` call returns
authorized bytes, a second call makes no request, and a cancelled call
fails.
- `emoji_picker_test.dart`: at most four loads run at once, a queued
load cancelled before it starts never downloads, and a saved emoji
doesn't wait for a slot.
- `media_disk_cache_test.dart`: a damaged saved copy (including a
truncated PNG) is evicted and downloaded again.
- `media_image_test.dart`: encoded-bytes requests share one download
with simultaneous image loads, and only decoded bytes reach observers.

- `NativeMessageImageLoaderTests.swift`: a GIF with uneven delays keeps
each frame's share, a cancelled decode returns nothing, and the decode
gate admits four in order and drops a cancelled waiter.

Removed `NativeEmojiRedirectPolicyTests` and the native concurrency test
along with the Swift loader they covered.

### Regressions

- Network: fewer requests. Cold loads keep the old picker's
four-at-a-time limit, so on a slow HTTP/1.1 origin queued requests don't
time out waiting for a connection. Downloads use the shared media HTTP
client, the same one other app images use, which on iOS now runs over
HTTP/2 since [#8897 iOS
HTTP/2](https://github.com/block/buzz/pull/8897).
- Memory: the picker keeps no image cache of its own. Each view decodes,
downsampled to 84 px and at most four at a time, from bytes Flutter
already holds in memory or on disk.
- Disk: emoji go into the existing 250 MB LRU media cache.

---------

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-17 09:04:38 -08: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
02535e1b53 perf(mobile): stop replaying stored read state on every resume (#9090)
Every time the mobile app reconnects (for example after more than 5
seconds in the background), the read-state live subscription asked the
relay for up to 500 stored read-state events. That re-downloaded every
read-state slot on the account, then the snapshot fetched the same
events again right after. On a heavy account (28 slots) that replay
alone was about 1.4 MB per resume.

The live subscription now uses `limit: 0`, so it only delivers changes.
It still opens before the snapshot, so the snapshot covers anything
published in between.

The subscription can also go live after `subscribe` has returned: on a
cold start with slow AUTH, `subscribe` returns on its 500 ms fallback
before the REQ is registered, after a transient CLOSED (rate limit,
capacity) the session reopens it on the same socket, and a reconnect
replays it. With `limit: 0` nothing replays marks published in that gap,
so the manager reads the snapshot every time the subscription reports
ready, as the channel list's `limit: 0` subscription already does.

The session keeps live subscriptions across reconnects and replays them
on the new socket, so a reconnect no longer resubscribes: the replay's
ready reads the snapshot, once per reconnect. The manager opens a new
subscription only after losing one (a terminal CLOSED or a failed
subscribe), on the next reconnect.

All snapshot reads outside a publish go through one sync loop.
Initialize and each ready ask that loop for a snapshot. A request made
before the current pass starts its read joins that read, and a request
made during the read runs one more pass, so a ready can't be swallowed
by a read already in flight. This needs no generation or
ready-transition checks, at the cost of an occasional extra read (for
example a cold start whose ready lands after the 500 ms fallback, when
the first read has already started).

Snapshot reads are numbered in start order, including a publish's own
read, and only a read newer than every settled one decides whether the
last snapshot succeeded. An older read finishing late cannot clear the
retry a newer failed read needs. A failed read waits for the next
trigger: the publish it schedules, which reads the snapshot in full
after a failure, or a later ready, resume or reconnect.

A publish with nothing to send skips its snapshot ([#9093 skip redundant
publish](https://github.com/block/buzz/pull/9093)) only when the last
snapshot succeeded, so after a failed resume snapshot the next publish
still retries it. A publish snapshot now notifies readers of the marks
it merged, since unchanged slots publish nothing whose echo would.

### Accepted gap

If the snapshot fails (timeout, discovery or HTTP error) on a device
with no local journal, read state stays local until the next successful
snapshot, which every resume, reconnect, subscription recovery and
publish retries. Falling back to a stored replay on failure would close
the gap, but it adds a late subscription path for a rare failure that
already heals on its own.

### Validation

- Added test: `live subscription replays nothing and opens before the
snapshot`. It fails without the change (`limit` 500).
- Added test: `a clean reconnect through the real session replays one
REQ and reads the snapshot once, and a lost subscription is reopened`
drives the real `RelaySessionNotifier` with a recording socket: the
connected listener runs, then the session's replay, then EOSE. It fails
against the previous revision of this PR (two `l-2` REQs and two
snapshot reads per reconnect). After a terminal CLOSED, the next
reconnect opens a new subscription and reads the snapshot.
- Added test: `readies during a held snapshot read share one more read`.
- Added test: `a mark published while the live subscription retries is
read once it recovers` puts the subscription into retry, lets another
device publish a mark, then reports it ready. It fails without the read
on ready.
- Added test: `a failed late-ready read is retried by the next publish`.
It fails without the retry.
- Added test: `a reconnect while the first snapshot downloads is not
swallowed by the cold-start connect` lets the cold-start connect queue
behind initialize, then reconnects while the first read is still
downloading and has a peer publish a mark. It fails against the previous
revision of this PR (the queued pass swallowed the reconnect) and passes
with the sync loop.
- Added test: `an older snapshot finishing late keeps a newer failed
read's retry` holds a publish's snapshot read, fails a newer read, then
lets the older one finish. It fails against the previous revision of
this PR (the older success cleared the retry) and passes with the read
ordering.
- Added test: `a mark published before a slow cold-start REQ goes live
is read then` lets `subscribe` return before ready, publishes a mark,
then reports ready. It fails without the read on ready.
- `a publish after a failed snapshot retries it, then skips again`
replaces the earlier skipped-publish test and fails without the snapshot
check. It also checks that the retried snapshot's new marks notify
readers, which fails without the notify.
- Read-state suite (95 tests), `flutter analyze` and the full mobile
suite pass.
- iPhone 12 mini, Profile build with [#9089 gzip
snapshot](https://github.com/block/buzz/pull/9089) applied, Home
backgrounded 12 s and resumed, websocket bytes received in the 15 s
after resume:

| | Websocket in | Read-state replay |
| --- | --- | --- |
| Before (gzip fix only) | 2,087 KB | 1,458 KB (28 events) |
| After (gzip fix + this) | 575 KB | none |

The table counts websocket bytes only. Each resume reads the read-state
snapshot once over HTTP, before and after this change.

Automated app run on the same phone: Home, a large channel and search
resumed after the reconnect grace period, with no read-state errors
logged. Read marks were not compared across devices.

🤖 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-15 13:09:18 -07: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
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