Commit Graph

3611 Commits

Author SHA1 Message Date
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
Tom Brow
34c8f5c7a5 feat(mobile): add Dart notification body formatter (#9556)
Adds a pure Dart function, `notificationBody`, that turns a message's
Markdown content into the plain-text notification body defined by [ADR
0002](https://github.com/block/buzz/blob/main/docs/adr/0002-notification-message-text.md).
It is a port of the Swift `BuzzPushNotificationResolver.previewBody` in
`BuzzPushKit`, which today is the only implementation.

Android notifications will be built from the app's Dart code, as in the
[Android push design](https://github.com/block/buzz/pull/9555), and will
reuse this function so the body reads the same on both platforms.
Nothing calls it yet and the Swift side is unchanged.

Notes on the port:

- The cap stays at 256 UTF-16 code units, the same as iOS (the fixtures
set `maxLength` to 256).
- Dart's regex engine differs from the ICU one the Swift code uses
(`\s`, `.` and `$`), so the patterns spell those out to keep identical
results. Trimming also matches Swift's `whitespacesAndNewlines`, which
trims U+200B and keeps U+FEFF, where Dart's `trim` does the opposite for
both.
- Truncation counts whole characters (extended grapheme clusters) via
`package:characters`.

### Validation

- A table-driven test runs every case in
`test-fixtures/notification-body.json` (47 cases) and checks the
fixture's `maxLength` against the function's cap.
- Added tests: 8 rows in the shared fixture pin the ICU details the port
must match. U+000B and U+0085 beside a marker keep it, U+000B and U+000C
inside a run keep its markers, U+200B is trimmed at the edges and
doesn't count toward the cap, and U+FEFF at the edges is kept. The Swift
fixture test runs them too and passes them unchanged.
- Proved falsifiable: with code-span and fence handling disabled, 18
fixture cases fail; restored, all pass.
- `just mobile-install mobile-check mobile-test` passes.

### Regressions

None: new code that nothing calls yet. The Swift formatter is untouched.
Its fixture test now also runs the 8 new rows and passes them unchanged.

---------

Signed-off-by: Tom Brow <tomb@squareup.com>
Co-authored-by: studio <dc2fc481343672df31a689840c09299972e704dac592e0da6f18486646a7ee3e@localhost>
2026-11-20 00:40:40 -05: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
Will Pfleger
8d4b30176b feat(cli): add many channel members per kind:9000 event (#9738) 2026-11-19 22:25:02 -05:00
Luke Tornquist
7e94503fe9 Stop using the unused delivery_log and subscriptions tables (#9746)
## Summary

`delivery_log` and `subscriptions` came with the initial schema for a
delivery feature that was never built. No code has ever written to them.
This PR removes every reader, writer, partition-manager entry and
deletion selection, so a follow-up contract migration can drop both
tables (`docs/database.md` Rule 5: drop only after the release that
stops using a table is fully deployed).

- **Partition manager:** manages `events` only. It no longer creates or
audits `delivery_log` partitions.
- **User deletion:** the content, account and profile handlers no longer
select, delete or recheck rows in either table.
- **Community deletion:** both tables move from
`EXPECTED_SCOPED_TABLES`/`PURGE_SCOPED_TABLES` to a new
`RETIRING_SCOPED_TABLES` list. The catalog accepts each one present or
absent. The purge deletes its rows only while it exists.
`validate_approved_schema` accepts a frozen retiring table that has
since been dropped, and no other missing table. Without this, every
community deletion would fail its exact catalog check once the tables
are gone.
- **Docs:** a short "Retiring a tenant-owned table" section in
`docs/database.md`, plus partition-monitoring and cleanup docs.

The tables, their schema files, `.pgschemaignore` entries and the
partition primary-key lint exception stay until the drop migration.

### Rollout

1. Deploy this release to every relay, deletion executor and operator
CLI. Older binaries fail community deletion's exact catalog check after
the drop.
2. Then ship the drop migration and remove the schema entries. Operators
with external tooling that expects `delivery_log` to exist must update
it first.

The partition audit stops emitting `buzz_partition_audit_*` series with
`table="delivery_log"`. Alerts keyed on that label will go quiet.

### What got simpler

Two tables' worth of code paths are gone: partition management, the
audit, and five deletion handlers stop special-casing them. The
follow-up removes the tables and the `RETIRING_SCOPED_TABLES` entries.

### Testing

On a remote workstation at `3675ff17`: `cargo fmt --check`, `clippy -D
warnings` for buzz-db, buzz-deletion and buzz-relay (all targets), unit
tests for buzz-db (lib and tests), buzz-deletion and buzz-relay bins,
and `scripts/postgres-test-run.sh` for buzz-db
partition/deletion/migration tests (294 passed) and all buzz-deletion
Postgres tests (44 passed). The new tests cover: retiring tables purged
and verified while present; a request inventoried before a real `DROP
TABLE` still purges and verifies; `validate_approved_schema` tolerates
only retiring tables vanishing.

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

---------

Signed-off-by: Luke Tornquist <tornquist@squareup.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-19 22:19:15 -05: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>
mobile-v1.5.0-rc.5
2026-11-20 11:35:11 +11:00
ravarora2
69ea27343c Fix media deletion’s community ownership and share agent discovery (#9670)
## Summary

Deleting a human must preserve an agent's uploads in communities where
someone else owns that agent or its profile is missing. Media cleanup
now carries community/key pairs through database and storage discovery,
shared-file decisions, and uploader-row deletion.

Media, content, account and profile cleanup share one direct-agent
discovery utility. Each caller retains its previous limits and
transaction behavior. Media discovers ownership once per invocation,
including retries, and uses a hash set for storage matching. The report
shape stays unchanged. The operator guide explains that community/agent
pairs have no separate cap and sit outside the inventory budget. The
discovery helper documents that global, identity-grouped discovery
requires `lock: false` because PostgreSQL cannot combine `GROUP BY` with
`FOR SHARE`.

Run a read-only preview first, then keep writers stopped throughout
deletion. Reverting the binary restores the old cross-community
selection bug; it cannot restore deleted objects.

### Related issue

Follow-up to the merged media handler in #9365 and the
content/account/profile handlers in #9363, #9364 and #9580. No duplicate
of this ownership correction was identified.

### Testing

Exercised the rebuilt `buzz-admin user-deletions media-batches --pubkey
<fixture-human> --read-only`, then `--delete`, against isolated
PostgreSQL and versioned MinIO. Preview changed neither rows nor
storage. Exclusive versions and in-scope uploader rows were deleted;
shared originals, thumbnails and historical versions survived. All four
handler commands agreed before and after a between-invocation ownership
change. Failure followed by retry used fresh ownership, and repeat
deletion removed zero versions.

Compared the production candidate SQL with the pre-PR query on about
50,000 local upload/audit rows. With 9,999 agents, execution took
120–185 ms per 500-row page versus 38–83 ms before community matching.
Three runs per query; this excludes planning, Rust preparation and
storage operations. The added per-version ownership queries are removed
entirely.

Full database/deletion/admin package runs passed (339 tests). The
PostgreSQL database/deletion run passed 904 tests; after strengthening
the retry fixture, the full deletion PostgreSQL package passed all 45
tests. The retry case retains ownership in another community, and media
tests assert exactly one ownership lookup per invocation.

Local `just test` completed with one failure in the unchanged relay
logging test `composition_log_does_not_leak_issuer_url` (expected
warning not captured); all other test groups passed. Two pre-push
attempts failed in unchanged ACP tests: first a launch timeout, then
credential tests using Git 2.40 where 2.46+ is required. All four
credential integration tests passed with Git 2.54; the full pre-push
retry was stopped at the author’s request to skip local checks and push.
Local `just ci` was also stopped before completion. Neither interrupted
run is a full pass; local hooks were skipped for publication.

The follow-up for the optional review comments changes documentation
only. Its statements were checked against the query and all five
production callers; `git diff --check` passed. Runtime suites were not
repeated for this follow-up.

Human local acceptance remains pending.

Generated with Codex

---------

Signed-off-by: Ravneet Arora <rarora@squareup.com>
Signed-off-by: dessert <7d616e7e143e5d408159614dccff1371350a1c1bd36c8de838a45ece5aca0aca@buzz.block.builderlab.xyz>
Co-authored-by: dessert <7d616e7e143e5d408159614dccff1371350a1c1bd36c8de838a45ece5aca0aca@buzz.block.builderlab.xyz>
2026-11-19 18:23:24 -05:00
Luke Tornquist
729cb10b78 buzz-db: drop the remaining relay foreign keys (#9740) 2026-11-19 17:51:45 -05:00
Tom Brow
9bcb3e45a4 perf(mobile): hash upload payloads in bounded worker chunks (#9747)
Follow-up to #9736, which moved upload hashing off the UI isolate with
`compute`.

`compute(_sha256Hex, bytes)` copies the whole prepared payload into the
worker while the uploader keeps the original for the PUT. For a 100 MiB
attachment that adds about 100 MiB to peak memory before the first
request.

This streams the payload to a worker isolate in 1 MiB chunks, with one
chunk in flight at a time (the worker acks each chunk before the next is
sent). Each chunk is copied with `TransferableTypedData.fromList` on its
own slice, since sending a `sublistView` would copy the whole backing
buffer. The digest, the `X-SHA-256` header, the signed Blossom `x` tag
and the cancellation checks are unchanged.

### Validation

In a 100 MiB AOT probe, peak RSS was 114 MiB hashing inline, 214 MiB
with the whole-buffer `compute` handoff, and 141 MiB with acked 1 MiB
chunks, at about the same hash time (611 / 622 / 614 ms).

Added tests in `mobile/test/shared/relay/media_upload_test.dart`: the
worker digest matches `crypto.sha256` for a 2 MiB + 123 byte payload,
sends three chunks with at most 1 MiB in flight, and handles an empty
payload.

### Regressions

- UI responsiveness: the hash still runs off the UI isolate. The UI
isolate now does one 1 MiB slice copy per chunk instead of one full
copy.
- Latency: hash time is about the same as with `compute` in the probe.
Small uploads pay one isolate spawn, as before.

---------

Signed-off-by: Tom Brow <tomb@block.xyz>
2026-11-19 22:21:26 +00: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
Luke Tornquist
e581555bf8 perf(relay): serve named-only channel access from the access caches (#9735)
## What

REQ, COUNT, `POST /query` and `POST /count` now take a reader's
named-only channel access (system channels, and any type added later)
from the two access caches they already read. Before, any filter that
opted in to system channels, or named a channel outside the implicit
set, ran `get_readable_named_only_channels` on the writer, uncached, on
every request.

## Why

Clients send such a filter on every connect. buzz-app's system channel
discovery reads `{kinds:[39002], "#p":[me], "#t":["system"]}`. So a
fleet reconnect (rollout, relay restart, network blip) paid one extra
uncached writer read per client, on top of the cached access set. This
read showed up near the top of writer SQL during reconnect herds.

## How

- `get_member_channels_read_at` and `get_listed_open_channels_read_at`
(buzz-db) return every channel type, with their connection checkout
time, and split rows into the implicit set (legacy types) and the
named-only set, with the type. They are the same two queries as before,
without the type filter. `get_member_channel_ids` and
`get_listed_open_channel_ids` keep their results.
- With no names, the two named-only halves together are exactly what
`get_readable_named_only_channels` returns. A new Postgres test pins
that equality for a member and a non-member.
- `AppState::get_channel_access_cached` returns a `ChannelAccess` from
the member cache (per pubkey, 10 s, dropped on every membership write)
and the open cache (1 s, shared reads). It yields the named-only
channels on demand, so a request that uses only the implicit set does no
extra work. `get_accessible_channel_ids_cached` is now a wrapper around
it.
- Both caches' refills are fenced against invalidation by a small shared
`LoadFence` (new `load_fence.rs`), as `MembershipCache` does.
Overlapping misses for a key share one load token, so the first read to
finish publishes. Invalidation drops the token, and a read publishes
only while its token is current. Before, a read that began before a
removal (or an open-to-private change) could finish after it and cache
the old set. That race also affected private stream/forum channels.
- The member snapshot is dated from its read's connection checkout, like
the open set, and a hit older than `MEMBER_CHANNELS_MAX_AGE` (10 s)
reads again. Before, its 10 s started at insert, so a slow read
stretched the bound.
- `readable_named_only_channels_for_filters` uses the cached set when
every channel the request names outside the implicit set is in it. The
system opt-in needs exactly that set. When a request names any other
channel (an unlisted open channel, or one it can't read), it keeps the
uncached read, unchanged.
- A `"consistency": "strong"` `POST /query` takes its named-only access
from the database, so a client that just created a system channel finds
it even on a pod that has not yet seen the invalidation. REQ, COUNT and
`POST /count` keep the cache.
- The thread-window and workflow checks keep the uncached read.

## Staleness

Same as the implicit set's today. Every membership write
(`invalidate_membership`) drops the per-pubkey entry, whatever the
channel type, and the drop is sent to every pod. On the pod that ran the
removal, the next request sees it (the refill fence closes the race). A
missed cross-pod drop keeps a removed member's system channel for up to
10 s after the read began on that pod, as for a private channel. The
open half is used for 1 s.

## What got simpler

No new access cache and no new invalidation trigger. The named-only
access now comes from the same snapshot as the implicit set, so REQ no
longer mixes a cached implicit set with an uncached named-only set.
`get_member_channel_ids` and `get_listed_open_channel_ids` no longer
have their own SQL, and their unused `Db` wrappers are gone. The two
replacement reads keep the old span names (`get_member_channel_ids`,
`get_listed_open_channel_ids`).

## Tests

-
`handlers::system_channels::tests::cached_access_answers_named_only_needs_without_a_database_read`
(unit, unreachable DB): discovery and a cached `#h` name are answered
with no read, the token scope still narrows the result, and a name
outside the cached sets reads the database.
-
`store::unlisted_channels_postgres_tests::cached_channel_sets_match_the_uncached_named_only_read`
(Postgres): the cached halves equal the uncached read and the accessible
set.
-
`state::tests::a_member_read_that_straddles_an_invalidation_is_not_cached`
(unit): a read held open through a per-user or a community-wide
invalidation answers its own request but is not cached.
-
`state::tests::an_open_read_that_straddles_an_invalidation_is_not_cached`
(unit): an open-set read held open through the community's invalidation
answers its own request, and the next request reads again.
- `state::tests::a_member_snapshot_ages_from_its_read_not_its_insert`
(unit): a member snapshot already 10 s old when published is not served.
- `state::tests::overlapping_member_reads_cache_the_first_to_finish`
(unit): a second miss that starts while the first read is in flight does
not stop the first from being cached.
-
`handlers::system_channel_postgres_tests::a_strong_query_sees_a_just_created_system_channel_past_a_stale_cache`
(Postgres): a strong `/query` finds a just-created system channel past a
stale member entry.
-
`handlers::system_channel_postgres_tests::a_token_scope_narrows_system_channels_on_both_access_paths`
(Postgres): token-scoped WS REQ and COUNT, through the cache path and
the database path.
- Must-fail mutants: always take the database branch; keep only legacy
types in the member query; drop the token scope at the REQ call site;
publish without the fence check; drop the open-set token on
invalidation; ignore the member snapshot's checkout age.

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

---------

Signed-off-by: Luke Tornquist <tornquist@squareup.com>
Signed-off-by: Tom Brow <tomb@block.xyz>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: Tom Brow <tomb@block.xyz>
2026-11-19 16:33:20 -05:00
Will Pfleger
9bc5740012 fix(mobile): stop notification extension sending cookies to Builderlab (#9741)
Builderlab's hosts set Cloudflare's `__cf_bm` cookie on every response.
The notification extension's sessions are `.ephemeral`, which keeps an
in-memory cookie store, so after the first response every later request
to Builderlab sends the cookie back. The NIP-FI assertion issuer refuses
any request carrying a `Cookie` header with 401 `session_required`, so
the extension's assertions fail and notifications from communities that
require NIP-FI fall back to "Open Buzz to view this message".

- `BuzzRelayAssertionIssuer` now turns off cookie storage and sending
(`httpCookieStorage = nil`, `httpShouldSetCookies = false`) on the
configuration it uses for both the identity-binding check and the
assertion request, whatever session it is given.
- The extension's per-notification relay session gets the same settings,
since the relay is also a Builderlab host.
- The issuer gains a `startDownload` seam, matching
`BuzzNotificationAvatarLoader`'s, and a `BuzzPushKitTests` test checks
that the assertion request carries no `Cookie` header after the identity
check's response sets one.

Signed-off-by: Will Pfleger <wpfleger@block.xyz>
Co-authored-by: Duncan <dcfd242e557282d7a1e2cf2e6877522682f1e5c6156dc92ca7d90eaedd3b0f95@buzz.block.builderlab.xyz>
2026-11-19 16:24:52 -05:00
ravarora2
d9c3f4e99e Remove personal workflow data and missed event copies (#9675)
## Summary

User content cleanup left private hide-list snapshots, saved workflow
inputs and notes, unused automation, and some delivery copies behind.
This extends the existing per-community content handler to remove them
with the same preview, ownership and retry checks.

- Delete trusted-relay hidden-DM snapshots and author-signed historical
file-metadata events (kind 1063).
- Clear recorded event-trigger text/emoji, authenticated manual inputs,
and the recorded approver's note while preserving the rest of each run
or approval.
- Delete unused workflow database definitions and their schedule claims
together. Any run, approval or linked claim protects the definition. The
entire group must fit the requested batch size, capped at 100 rows, or
planning refuses before mutation.
- Delete delivery logs under surviving subscriptions before erasing
their source events; reject newly arrived dependent rows before
committing. Check the whole event batch with hashed membership to avoid
repeated work across unrelated delivery history.

Run deletion offline with the relay, workflow engine and external
writers stopped. Shared history, canvases, artifacts, Git data and
device registrations remain outside these additions. Retained runs can
subsequently read the cleared inputs; this does not cancel them or claim
complete account erasure. Existing signed kind 30620 event cleanup is
unchanged.

This is an application-only change against existing tables. It adds no
migrations, indexes, triggers, functions or foreign keys. Existing
per-statement timeouts and community write admission remain in use.

### Related issue

Related: #9353. Extends the content handler in #9363. Shared workflow
ownership policy remains separate from these personal-field deletions.

### Testing

Ran the rebuilt `buzz-admin user-deletions content-batches --community
<fixture-community> --pubkey <fixture-user> --batch-size 100` against
disposable PostgreSQL 17 fixtures with 100 events, 500,000 unrelated
delivery logs, and 9,999 small communities. `--read-only` selected 100;
`--delete` removed 100 in 0.39 seconds locally; a second `--delete`
selected zero. All 500,000 unrelated same-community delivery rows
survived.

EXPLAIN used hashed membership under both custom and generic plans.
Independent review also exercised stale statistics. Removing the planner
safeguard made the regression fail at the executor's actual 3-second
timeout. The late-copy test still refuses deletion and preserves the
source until retry can include the new copy.

Independent agent review completed with no remaining blockers. Earlier
command validation on the original patch exercised all agreed additions:
preview nine operations, delete nine, retry zero, with whole-row
preservation checks for the other community, shared canvas, surviving
subscriptions, workflow output/provenance, and other approvers' notes.

The repository-wide `just ci` run passed static checks, then stopped on
two timeouts in unchanged `buzz-agent` OAuth tests. Both cases passed a
serial recheck. The subsequent normal push hooks passed, including the
complete Rust unit lane and Tauri checks. Later app build/test recipes
were not reached; the full local CI command is not claimed green.

Human command verification is pending, so this PR remains draft. On
disposable fixtures, run the same preview/delete/retry sequence and
verify that only the planned rows/fields change.

Generated with Codex

---------

Signed-off-by: maincourse <37ce551b493d4a998caf030929c47bce0b6a0e43f1178b3a63c4151d7c16b76e@buzz.block.builderlab.xyz>
Co-authored-by: maincourse <37ce551b493d4a998caf030929c47bce0b6a0e43f1178b3a63c4151d7c16b76e@buzz.block.builderlab.xyz>
2026-11-19 16:13:31 -05:00
Will Pfleger
946d9c3467 fix(relay): rename target log field to target_pubkey (#9739)
Rename the relay's custom structured log field from `target` to
`target_pubkey` at the affected call sites.

`tracing` also writes its own `target` field (the module path) after
callsite fields, and Datadog keeps the last value. That overwrites the
pubkey; using `target_pubkey` preserves it without changing tracing's
built-in `target` metadata used by `RUST_LOG` and Vector routing.

Signed-off-by: Will Pfleger <wpfleger@block.xyz>
Co-authored-by: Alia <d32955ad69077062930cc46cfe2df30ca9aaf6f8e76422681265e9e9af704d78@buzz.block.builderlab.xyz>
2026-11-19 20:53:12 +00:00
Luke Tornquist
379b501124 feat(push-gateway): declarative desired-state schema, one file per table (#8328)
## Summary

Gives the push gateway a declarative desired-state schema in the same
layout the relay uses since #8131: a `\i` manifest plus one file per
table, the shape SchemaBot reads.

- `crates/buzz-push-gateway/schema/schema.sql`: an ordered `\i` manifest
and nothing else.
- `crates/buzz-push-gateway/schema/tables/public/<table>.sql`: the end
state of migrations `0001`–`0008` for all six gateway tables. That
includes `0007`'s `installations.platform` column and `0008`'s dropped
delegation → installation foreign key (#9610), so the delegation table
declares no `REFERENCES`. Each file holds only its `CREATE TABLE` and
plain `CREATE [UNIQUE] INDEX` statements.
- `src/postgres.rs`: the six table names are now one `GATEWAY_TABLES`
constant shared by readiness and the runtime-role GRANT, instead of two
hand-copied lists.
- `src/postgres/desired_schema_postgres_tests.rs` adds two tests:
- `desired_state_schema_layout_is_complete_and_schemabot_shaped` (no
infra needed). It checks that the manifest includes every file exactly
once and holds only `\i` lines, that each table file creates exactly one
table, and that indexes use a plain `CREATE INDEX` on that table.
- `desired_state_schema_matches_migrations` (PostgreSQL lane). It builds
one probe database from `schema.sql` through the real `bin/pgschema
apply` and another through `GATEWAY_MIGRATOR`. It then requires the two
`public` catalogs to match: table set, columns from `pg_attribute` (full
type with typmod via `format_type`, default, nullability, identity,
generation, collation), table options (persistence, RLS flags,
`reloptions`), constraints (`pg_get_constraintdef`) and index shapes
(`pg_get_indexdef` + `indoption`). Neither probe may hold functions,
non-internal triggers, policies, views, sequences or user types, and the
declared table set must equal `GATEWAY_TABLES`. It compares the whole
`public` catalog, not a list of tables, so a future migration that
changes `public` tables, columns, table options, constraints or indexes
without a matching `schema/` change fails CI. It doesn't cover data-only
migrations or objects outside `public` (other schemas, roles, database
settings). Probe databases are created from `template0` and dropped even
when an assertion, `pgschema` or setup fails; the original failure is
re-raised unchanged. Connection details, including the password, come
from the resolved `PgConnectOptions`, so percent-encoded credentials,
`?password=` and Unix-socket URLs reach `pgschema` the way SQLx sees
them. `pgschema` 1.7.4 builds an unquoted keyword DSN, so a password or
socket path with whitespace, a quote, `=` or a backslash isn't supported
(noted in the test).

## Not changed

The gateway still migrates itself at startup: bootstrap guard, then SQLx
migrations, then runtime-role grants. The guard and grants are
operational steps, not desired-state DDL, so they stay in code. No
`schemabot.yaml` is added: SchemaBot isn't configured for the relay or
the gateway yet, so the yaml for both waits until that server-side setup
exists. The manifest header notes that the relay's post-pgschema
reconcile step (root `AGENTS.md` gotcha #7) doesn't apply, because the
gateway schema has no seed DML or storage parameters.

SchemaBot compatibility is not proven here. The parity test shows the
files are equivalent under `pgschema`. Since #9610 the gateway schema
has no foreign keys, so the earlier inline-FK caveat is gone.
`docs/database.md` Rule 4 now lists the gateway `schema/` directory as a
schema location.

## What got simpler

To read the gateway's schema today you have to replay eight migrations:
two CHECK rewrites, two dropped UNIQUE constraints, a dropped column, an
added column and a dropped foreign key. After this PR it's one
declarative file per table, in the same convention as the relay. There
is no new runtime path and no new abstraction, and the duplicated table
list in `postgres.rs` collapses to one constant.

## Testing

At `c4336392` (rebased on main after #9610; mirrors gateway
`0007`/`0008`; reads the `pgschema` password from a copy with a URL-safe
host and username, so a `PGHOST` or default-search socket no longer
panics and a `/role` username no longer drops the password):

- `cargo fmt --all -- --check` and `cargo clippy -p buzz-push-gateway
--all-targets -- -D warnings`: pass.
- `cargo test -p buzz-push-gateway --lib desired_schema`: pass,
including
`resolved_password_reads_through_a_socket_host_and_slash_username`.
Removing the username normalization makes that test fail.
- `scripts/postgres-test-run.sh -p buzz-push-gateway --lib --tests`:
17/17 passed, including `desired_state_schema_matches_migrations`.

At `df3ff104` (password from resolved connect options), same
workstation:

- fmt, clippy (`-D warnings`, with and without
`personal-dev-app-attest`): pass. `cargo nextest run -p
buzz-push-gateway`: 80/80, and 82/82 with the feature.
`scripts/postgres-test-run.sh -p buzz-push-gateway --lib --tests`:
13/13.
- `?password=`: with `PGPASSWORD` unset,
`postgres://<role>:wrong@localhost/postgres?password=<encoded
p@ss:w/rd#x>` passes the parity test, so `pgschema` gets the
query-parameter password that SQLx uses. A wrong `?password=` is
rejected (`28P01`).
- The CHECK-bound falsification still fails with `constraint parity
mismatch`. Every run leaves 0 probe databases.

At `f937924a` (probe cleanup and connection-URL follow-up), on a Linux
workstation against PostgreSQL 16 with the repo's pinned `bin/pgschema`:

- `cargo fmt --all -- --check`, plus `cargo clippy -p buzz-push-gateway
--all-targets -- -D warnings` with and without `--features
personal-dev-app-attest`: pass.
- `cargo nextest run -p buzz-push-gateway`: 60/60 passed, and 62/62 with
`personal-dev-app-attest`. `scripts/postgres-test-run.sh -p
buzz-push-gateway --lib --tests`: 12/12 passed.
- Probe cleanup: with a CHECK bound changed (2048→4096), the previous
test code fails and leaves both `push_gateway_{desired,migrated}_*`
databases behind. The new code fails with the same `constraint parity
mismatch` panic and leaves none. A table file that makes `pgschema
apply` fail (`no_such_column`) also reports `pgschema apply failed: ...
column "no_such_column" does not exist` and leaves none.
- Connection URLs: the parity test passes as a role whose password is
`p@ss:w/rd#%x`, given percent-encoded in the URL with `PGPASSWORD`
unset. It also passes over
`postgres://<user>@%2Fvar%2Frun%2Fpostgresql:5432/postgres` (Unix
socket, peer auth).

Earlier, at `ee2745cb78`:

- `scripts/postgres-test-packages.sh` discovers `buzz-push-gateway`. The
parity test lives under a `*_postgres_tests` module so the `postgres-ci`
nextest filter selects it.
- `cargo fmt --all -- --check` and `cargo clippy -p buzz-push-gateway
--all-targets -- -D warnings` both pass.
- `cargo nextest run -p buzz-push-gateway`: 60/60 passed, including the
layout test.
- `scripts/postgres-test-run.sh -p buzz-push-gateway`: 12/12 passed,
including `desired_state_schema_matches_migrations`.
- Falsification checks:
- Dropping the partial predicate from
`push_gateway_installations_active_token` makes the parity test fail
with an index-shape mismatch.
- Adding an unmirrored `0007` migration (`ADD COLUMN probe TEXT`) makes
the parity test fail with a column mismatch. Mirroring the column in the
table file makes it pass again.
- Putting `CREATE TABLE` DDL in `schema.sql` makes the layout test fail.
- A `0007` adding `probe VARCHAR(64)` mirrored as `VARCHAR(128)` fails
with a column mismatch (typmod); mirroring it exactly passes.
- An unmirrored `0007` `ALTER COLUMN expires_at TYPE TIMESTAMP` fails
with a column mismatch.
- An unmirrored `0007` `ENABLE ROW LEVEL SECURITY` fails with a
table-option mismatch.
- A `0007` creating a function and trigger fails the "only tables and
indexes" check.

Known gap: `sqlx::migrate!` doesn't notice a *new* migration file on an
incremental build. The crate has no `build.rs` `rerun-if-changed`, and
neither does any other crate in the workspace. For the `0007` check
above I touched `src/postgres.rs` to force the macro to re-expand. Clean
CI builds aren't affected.





buzz-review-completed

---------

Signed-off-by: Elrond <28d6302a099e5225b02c4155ac4236e4912603df2ab08dbfc2f4fef08ce598c8@buzz.block.builderlab.xyz>
Co-authored-by: Elrond <28d6302a099e5225b02c4155ac4236e4912603df2ab08dbfc2f4fef08ce598c8@buzz.block.builderlab.xyz>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-19 15:50:39 -05:00
Tom Brow
7e7ec731cd test(cli): keep the raw refusal exit test independent of BUZZ_* env (#9733)
## Summary

Follow-up to #9653. Its new test
`cli_exits_nonzero_when_the_relay_refuses_a_raw_publish` went through
`run_from_args`, which resolves credentials from the caller's
environment. With `BUZZ_AUTH_TAG` set (as it is for agents run by the
ACP harness), the test client's key doesn't match the auth tag and the
test exits 3 instead of 2.

The check moves to an integration test,
[`tests/raw_publish_exit.rs`](c77555c348/crates/buzz-cli/tests/raw_publish_exit.rs),
that runs the built `buzz` binary against a fake relay answering
`accepted:false`, with every `BUZZ_*` variable removed from the child
only. It asserts exit 2, empty stdout, a `relay_error` and one
submission, so it covers the binary's real route and exit mapping.

## Regressions

None: test-only change.

### Validation

Ran the `buzz-cli` suite with a junk `BUZZ_AUTH_TAG` and
`BUZZ_FEDERATED_IDENTITY_TOKEN` set. Replacing the `Cmd::Raw` dispatch
with `Ok(())` makes the new test fail.

---------

Signed-off-by: Tom Brow <tomb@block.xyz>
2026-11-19 20:13:00 +00:00
Kalvin C
7bff21e513 docs(nip-pm): define pinned messages (#9712)
## Summary
Adds NIP-PM, the wire contract for pinned messages in a channel. A Buzz
DM is a channel here.

- `kind:40010` and `kind:40011`: member-signed pin and unpin commands,
one message per command. Each new command carries a fresh `client-id`
value, so two commands for one message in the same second are different
events.
- `kind:30623`: the relay-signed pin list, one addressable event per
channel, newest pin first, in the tag shape of NIP-29 `kind:39005` plus
an `h` tag. Clients read it with `#h`, which names the channel under
NIP-CL.
- Relay processing: every change to a channel's list, from a command or
from the deletion of a pinned message, applies one at a time in one
order. A resent command answers `duplicate:`, pinning an already pinned
message changes nothing, and a channel holds at most 250 pins.
- Whoever may post a message in the channel may pin and unpin in it.
- Deleting a pinned message removes it from the list, whoever deletes
it.
- A `message_pinned` system message announces each pin and names the
command that made it.
- A relay does not advertise the NIP. A relay that does not accept the
commands refuses them as unknown kinds.

The relay implementation follows in a stacked pull request.

### Related issue
N/A

### Testing
Documentation only. Checked the rendered Markdown, the relative NIP
links against the other documents in `docs/nips/`, and that kinds
`40010`, `40011` and `30623` are unused in the repository.

---------

Signed-off-by: Kalvin Chau <kalvin@block.xyz>
Co-authored-by: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-19 11:46:46 -08:00
Luke Tornquist
bc3023a050 push-gateway: drop the delegation → installation foreign key (#9610)
## Summary

Retire the last foreign key in the push gateway schema:
`push_gateway_delegations.installation_id →
push_gateway_installations(id)`. This follows `docs/database.md` Rule 2
and the relay FK retirement work (#9399, #9404).

- **Gateway migration 0008** drops the constraint.
- **Relay migration 0101** drops the relay's legacy copy (Rule 4:
gateway schema changes go in both).
`schema/tables/public/push_gateway_delegations.sql` loses the inline
`REFERENCES`.

## Required stop

Every gateway and rollback target must run #9627 (`44cdd9fe`) or later
before this merges and deploys. #9627 makes the reaper lock expired
installations before it deletes their delegations. Without the FK, an
older reaper can leave an orphaned delegation. This is step 2 of the
Rule 5 retirement sequence; #9627 is step 1.

## Why the app already enforces the reference

| Path | Check |
|---|---|
| `upsert_delegation` (only delegation insert) | Locks the installation
`FOR UPDATE` in the same transaction; rejects a missing or revoked one.
|
| `create_installation` (replaces expired installations) | Locks the
matching installations `FOR UPDATE`, deletes their delegations, then the
installations. |
| `reap_expired` | Locks expired installations `FOR UPDATE`, deletes
their delegations, then the installations (#9627). |
| `authorize_delivery` | Reads the installation through the delegation;
a missing installation is `Rejected`. |
| `revoke_delegation` | Updates the delegation only; an orphan has no
effect. |
| `revoke_installation`, `rotate_endpoint`, `advance_assertion_counter`
| Update the installation; they never delete it. |

The relay never reads or writes the `push_gateway_*` tables (the gateway
requires its own database), so dropping the relay copy changes no relay
behavior.

## Tests

The gateway tests run against the migrated schema, which no longer has
the FK, so they prove the app check.

- `migrated_schema_has_no_foreign_keys` (new): the gateway schema has no
foreign keys after migrations. It fails if gateway migration 0008 is
removed.
- `delegation_for_missing_installation_is_rejected` and
`reaper_deletes_delegation_committed_while_it_waits` (from #9627) now
run without the FK.
- `reaper_retains_revocation_tombstones_until_authority_expiry`: its
hand-built schema drops the FK too.
- Relay: `push_gateway_delegations` joins the constraint parity check in
`admin_schema_parity_between_desired_state_and_migrations`, and the
migration count test covers 0101.

## Validation

Blox at `33f7df90` (before the rename to 0101; CI covers the rebased
head):

- `cargo fmt --check`, clippy (`buzz-push-gateway`, `buzz-db`, all
targets), gateway unit tests, `buzz-db` migration unit tests: pass.
- `scripts/postgres-test-run.sh -p buzz-push-gateway --lib --tests`:
16/16 pass.
- `buzz-db` Postgres tests for migrations, parity, push, floor
retirement and retained guards: 56/56 pass, including
`admin_schema_parity_between_desired_state_and_migrations`.
- Must-fail check: with gateway migration 0008 removed,
`migrated_schema_has_no_foreign_keys` fails (1 foreign key vs 0).

## Coordination

- On main after #8696, #9398 and #9710 (relay 0095–0100). #9627 shipped
this PR's reaper fix and tests separately, so this PR is the schema drop
only.
- Renumbered to relay 0101 after #9710 took 0098–0100 (rename only; file
contents unchanged). #9690 and #9621 also add a relay 0098; whichever
merges second renumbers.
- #8328 adds the gateway's declarative schema with the inline FK.
Whichever PR merges second removes it there.

## What got simpler

One fewer database object. Every gateway reference check now lives in
one place: the gateway's own transactions.

buzz-review-completed

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

Signed-off-by: Luke Tornquist <tornquist@squareup.com>
Co-authored-by: Elrond <28d6302a099e5225b02c4155ac4236e4912603df2ab08dbfc2f4fef08ce598c8@buzz.block.builderlab.xyz>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-19 14:43:46 -05: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
5ccbb61190 feat(cli): add raw query and publish escape-hatch commands (#9653)
## Summary

Agents using the CLI had no way to answer questions like "which channels
is key X a member of" (kind 39002 with `#p`) without scanning channels
one at a time, which runs into identity-adapter rate limits. This adds a
small escape hatch that reuses the CLI's existing credentials (signing
key, auth tag, federated identity assertion):

- `buzz raw query <filter>`: send one filter object or an array of
filters (or `-` for stdin) to the relay's `/query` endpoint and print
the relay's JSON as-is (an event array, or an object for filters such as
read-state snapshots).
- `buzz raw publish`: build, sign and send an arbitrary event, either
from `--kind`, repeatable `--tag` (JSON arrays, as in `social set-list`)
and `--content`, or from a full `--event-json` template. Signing goes
through `sign_event`, so the auth tag is attached as for every other
command; a caller-supplied `auth` tag is refused. Ephemeral kinds (20000
to 29999) use the ephemeral publish path, except the NIP-43 leave
request (28936), which goes over HTTP because the relay revokes the
submitting socket on success. Gift wraps (1059) are refused, since they
need NIP-59 signing with a throwaway key.

Malformed input (bad JSON, a filter that isn't an object, a bad tag)
exits 1 with the usual `user_error` JSON; the relay validates filter
fields itself, and its rejection exits 2 as a relay error. A publish the
relay refuses (`accepted:false`, over HTTP or the WebSocket) exits 2
with the event id and message. README and TESTING.md list the new
commands and their limits (replaceable and addressable kinds replace the
whole event; kind-scoped credentials can fail artifact revisions).

## Regressions

None expected: this adds a new command group and does not change
existing commands. `submit_event` now also gives the relay-admin kinds
(9030 to 9033), identity archive and unarchive requests (9035, 9036) and
the leave request (28936) the moderation retry policy (no blind resend
after an ambiguous outcome). `agents archive` and `agents unarchive`
send 9035 and 9036, so after a lost response they now report an unknown
outcome instead of resending, which could re-archive over a later
unarchive.

### Validation

Tried against a live relay as a signed-in user: a kind 39002 `#p` query
listed one key's channels, a two-filter array and an `ids` lookup
returned the expected events, and `raw publish` sent a typing indicator,
a reaction and a deletion of that reaction, all accepted.

New tests in
[`raw.rs`](489e0014a4/crates/buzz-cli/src/commands/raw.rs (L202))
run against a local fake relay:
[query](489e0014a4/crates/buzz-cli/src/commands/raw.rs (L393))
sends the filters with the CLI's credentials and prints the relay's
response;
[publish](489e0014a4/crates/buzz-cli/src/commands/raw.rs (L445))
signs the given kind, tags and content with exactly one auth tag, [keeps
a `p` tag naming the
signer](489e0014a4/crates/buzz-cli/src/commands/raw.rs (L481)),
[sends the NIP-43 leave request over
HTTP](489e0014a4/crates/buzz-cli/src/commands/raw.rs (L576))
and [prints the
acknowledgement](489e0014a4/crates/buzz-cli/src/commands/raw.rs (L589));
a relay refusal [is a relay
error](489e0014a4/crates/buzz-cli/src/commands/raw.rs (L604))
and [exits 2 from the CLI entry
point](489e0014a4/crates/buzz-cli/src/commands/raw.rs (L627));
and [bad
input](489e0014a4/crates/buzz-cli/src/commands/raw.rs (L549))
is a usage error that sends nothing. In
[`client.rs`](489e0014a4/crates/buzz-cli/src/client.rs (L2123)),
every no-dedup command kind, identity archive requests included, is
submitted once and reports an unknown outcome on a
[502](489e0014a4/crates/buzz-cli/src/client.rs (L2123))
or a [lost response
body](489e0014a4/crates/buzz-cli/src/client.rs (L2147)).

---------

Signed-off-by: Tom Brow <tomb@block.xyz>
2026-11-19 12:07:54 -07: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
Will Pfleger
4e1d0b27fd chore: require relay owner review for the relay and db crates (#9728)
## Summary

Make the relay database owners also the code owners for the relay crate,
`/crates/buzz-relay/`, and the relay database crate, `/crates/buzz-db/`.
This uses the same five owners that #9708 gave the migration and schema
paths.

The `main` ruleset requires code owner review, so any PR that touches
either crate now needs an approval from one of these owners instead of
`@block/buzz-oss-team`. Any one of them can approve. The ruleset still
requires one approval in total.

### Related issue

N/A. Extends #9708.

### Testing

`GET
/repos/block/buzz/codeowners/errors?ref=wpfleger/relay-crate-codeowners`
returns no errors.

---------

Signed-off-by: Will Pfleger <wpfleger@block.xyz>
2026-11-19 13:48:16 -05: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
Soheyl
98e2b7cbbc feat(relay): push mentions to people outside a listed channel (#9623)
## Summary

A message that `p`-tags someone in a listed channel they haven't joined
now sends them a push. Before this, push woke only channel members. This
is the relay part of "Let them know", a choice for mentioning people
outside a public channel. The client changes are
https://github.com/block/buzz-app/pull/3769,
https://github.com/block/buzz-app/pull/3771 and
https://github.com/block/buzz/pull/9629.

- The matcher wakes a non-member only when a `p` tag names them and the
channel is open, not unlisted, and a stream or forum. It reuses the
channel directory's `LISTED_CHANNEL_SQL`.
- Delivery checks again before sending. The channel must still be
listed, the event must still mention them, and they must still be able
to connect. A ban on them or their agent's owner blocks the push, and so
does a missing membership or allowlist entry when the relay requires
one.
- Members, private and unlisted channels, DMs and system channels are
unchanged.

**Needs security review.** This decides who gets push wakes. A wake goes
only to someone who could already read the event with `REQ`, and it
carries no message content.

Follow-up: a banned or removed channel member still gets wakes until
their lease expires. That predates this PR, and the fix belongs in the
ban and removal code.

### Related issue

None found.

### Testing

- Postgres tests run ingest through delivery against a fake gateway.
They cover private, unlisted and system channels, a switch to private
before delivery, bans, removal, a missing allowlist entry, and an agent
relying on its owner's membership. I made 20 small changes that each
broke one of these checks, and each one made a test fail.
- On a local relay with a stand-in gateway, an outsider's mention push
arrived, and nothing went out after a ban, a removal or a switch to
private. With the new delivery check turned off, the banned and removed
people got pushes.
- Not tested: a real gateway and a phone.

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

---------

Signed-off-by: Soheyl Vakili <soheyl@squareup.com>
Signed-off-by: Tom Brow <tomb@block.xyz>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: Tom Brow <tomb@block.xyz>
2026-11-19 11:29:10 -07:00
Luke Tornquist
9ea57cba2a fix(db): undo migration 0097 (#9710)
## What

Migrations `0098`–`0100` undo migration `0097` (community artifact
expand). The declared schema goes back to its shape before #9650.

#9650 added `0097`. The revert, #9689, removed the feature but kept
`0097` byte for byte, because databases that auto-migrated recorded its
checksum. No code on `main` reads or writes what `0097` added. This PR
removes it with forward migrations, as `docs/database.md` requires
("Never edit a merged migration. Fix forward.").

`artifact_heads.channel_id` gets `NOT NULL` back in the three steps from
*Adding `NOT NULL` to a populated table*:
- `0098` checks that the artifact head key is `(community_id,
artifact_id)`, then adds `CHECK (channel_id IS NOT NULL) NOT VALID`.
- `0099` validates the check under `SHARE UPDATE EXCLUSIVE`, so channel
artifact reads and writes continue.
- `0100` sets `NOT NULL` from the validated check (no scan), drops the
check, drops `artifact_heads_live_type`,
`artifact_heads_scoped_identity` and
`artifact_revisions_scoped_identity`, and drops `artifact_heads.scope`,
`artifact_revisions.scope`, `artifact_revisions.community_event`,
`artifact_revisions.redacted` and `communities.artifact_type_policies`.

The primary keys don't change. `0097` never changed them.

## Review checklist (docs/database.md)

- **Phase:** contract. It follows the expand in #9650 (`0097`) and the
code revert in #9689.
- **Required stop:** every relay pod, job and rollback target must run
#9689 (`sha-a406191`) or later before `0100` runs. The chart's upgrade
notes (`deploy/charts/buzz/README.md`) say this, along with how to roll
back with auto-migration off. No tagged relay release contains #9650.
Only rolling images from `eebf62b6` up to, but not including, `a4061916`
are affected. Relays built from #9650 itself read `artifact_heads.scope`
and write with `ON CONFLICT` on `artifact_heads_scoped_identity`.
Releases before #9650 never read these objects.
- **Fails closed:** `0098` refuses a database whose artifact head key is
the scoped key from #9650's removed operator contract script or declared
schema. That database needs the recovery in #9689's Compatibility
section. `0099` fails if any head has a null `channel_id`. Both stop
before any cleanup.
- No trigger, function, procedure, rule or foreign key is added. No
migration changes existing rows.
- Every schema location in Rule 4 is updated: `migrations/` and
`schema/tables/public/` (`artifact_heads.sql`, `artifact_revisions.sql`,
`communities.sql`). No reconcile-script or gateway change applies.
- **Currently deployed relay:** a relay from #9689 or later doesn't use
these objects, and neither does a relay from before #9650. The
populated-table test runs every migration over channel artifact data.
- **Locks:** each migration sets `lock_timeout = '5s'` and
`statement_timeout = '30s'`. No index is built.

## Tests

- `admin_schema_parity_between_desired_state_and_migrations` compares
`artifact_heads`, `artifact_revisions` and `communities` across the
desired-state and migrated paths. It fails without `0100`.
- `populated_artifact_tables_auto_migrate_through_every_migration`
checks that a channel head and revision written before `0097` survive
with the same channel and event.
- `artifact_unexpand_validates_while_channel_heads_are_written`: `0099`
completes while a channel head write is still open. It fails if `0099`
sets `NOT NULL` directly.
- `artifact_unexpand_refuses_scoped_head_key`: `0098` stops on the
scoped key and leaves `0097`'s columns in place.

## What got simpler

The schema loses 5 unused columns and 3 unused indexes.
`artifact_heads.channel_id` is required again, as the channel code
assumes.

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

---------

Signed-off-by: Luke Tornquist <tornquist@squareup.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-19 13:18:37 -05:00
Tom Brow
7361326717 fix(mobile): keep glass controls mounted and the wide thread push parallax (#9726)
Fixes three regressions that #9717 (Duo chat switching) introduced.

**Glass controls blank when anything covers their route.** #9717 gated
`IosGlassNavigationButton` and `IosGlassNavigationAction` on
`useNativeRouteControlsVisible`, so every glass control (Home's filter
chips, glass Back, Close, Done) unmounted under any dialog, alert or
modal sheet and during every push, pop and back swipe, then came back as
a new platform view near the end of the transition. This drops the gate
from those two widgets, which restores their behaviour from before
#9717. The problem #9717 targets is unaffected: under Search and
Activity sheets the hook already returns true and the opaque backing
hides the controls. Home's gate, the Channels route sync and
`IosMessageCreateButton` keep the hook.

**The visibility hook rebuilt its host on every animation frame.** It
subscribed to the route's animation values but only reads whether the
covering animation is at zero and whether the route is reversing. It now
uses `useListenableSelector` on those two booleans, so a host rebuilds
only when visibility can change.

**A wide thread push lost the outgoing chat's slide.** For an immediate
wide selection, `_ConversationDetailRoute.buildTransitions` returned its
child directly, which also discarded the secondary animation that moves
the chat left when a thread is pushed over it. It now builds the
platform transition with a completed primary animation, so selection
stays immediate and the covered chat keeps its parallax.

### Regressions

- Glass controls go back to staying mounted under covering routes, as
they did before #9717. Platform-view bleed under non-sheet routes is
therefore the pre-#9717 behaviour, not new.
- No change to compact navigation or to the Search and Activity sheet
composition.

### Validation

Added tests:
-
[native_route_controls_test.dart](fb0d16ef56/mobile/test/shared/widgets/native_route_controls_test.dart):
glass controls stay mounted, with the same channels, under a dialog and
keep receiving appearance updates, while only the create control
unmounts and returns; glass controls stay mounted with no platform-view
churn across a modal bottom sheet; the `bottomUp=false` composition case
keeps the glass views; the hook rebuilds its host a small constant
number of times across a full push and pop.
-
[adaptive_conversation_pane_test.dart](fb0d16ef56/mobile/test/shared/widgets/adaptive_conversation_pane_test.dart):
in the wide layout, the covered chat has moved left 150 ms into a thread
push on iOS.

Signed-off-by: Tom Brow <tomb@block.xyz>
Co-authored-by: studio <dc2fc481343672df31a689840c09299972e704dac592e0da6f18486646a7ee3e@localhost>
2026-11-19 18:09:17 +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>
mobile-v1.5.0-rc.4
2026-11-19 17:56:11 +00:00
Luke Tornquist
65c7d64c94 Require relay schema owner review for migrations and schema (#9708)
## Summary

Make @TheSentinel454, @wpfleger96, @bradseiler, @salman1993 and
@ravarora2 the code owners for the relay database migrations and schema:

- `/migrations/`
- `/schema/`
- `/scripts/reconcile-schema-after-pgschema.sql`
- `/.pgschemaignore`

The `main` ruleset requires code owner review. So any PR that touches
these paths needs an approval from one of these five. Any one of them
can approve. When one of them writes a migration PR, another owner
approves it.

CODEOWNERS uses the last matching line. For these paths, this entry
replaces `@block/buzz-oss-team` as the owner. The ruleset still requires
one approval in total.

What got simpler: nothing. This adds four ownership lines and no code.

### Related issue

N/A. No duplicate found.

### Testing

`GET /repos/block/buzz/codeowners/errors` on this branch returns no
errors. All five users have write access or higher.

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

---------

Signed-off-by: Luke Tornquist <tornquist@squareup.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
mobile-v1.5.0-rc.3
2026-11-19 12:36:34 -05:00
Wes
4704fbafb6 fix(relay): resurface a hidden DM when someone else messages it (#9678)
## Summary

A DM hidden with **Hide conversation** (kind 41012) stayed out of the
sidebar for good, even after new messages arrived. The only way back was
New message → same people → Send. This makes the relay clear the hide
when *another* member posts a message (kinds 9 / 40002 / 40008) in the
DM, like Slack does. The author's own hide is kept, so replying from
another device doesn't resurface it.

- `buzz-db` `dm.rs`: `unhide_dm_for_recipients` clears `hidden_at` for
every other active member. `lock_dm_visibility` takes the same advisory
lock that replacing the viewer's kind 30622 snapshot uses, then reads
that viewer's hidden DMs and latest snapshot time.
- `side_effects.rs`: `persist_dm_message` stores the message, clears the
hides and replaces each affected viewer's snapshot in **one
transaction**, then fans out after commit. A snapshot that doesn't land
rejects the message, so the client's resend tries again. When someone
hid the DM, the message takes the DM's membership lock before its
insert, as a removal does, so it can't deadlock against a removal or
reopen. The hide/open path (`publish_dm_visibility_snapshot`) shares the
same lock → read → write seam.
- Used by both message paths: client ingest (`ingest.rs`) and
relay-signed workflow messages (`workflow_sink.rs`, author resolved via
`effective_message_author`).
- `NIP-DV.md`: documents the rule.

**Deploy order:** relay first. The client companion is
block/buzz-app#3889, which rereads visibility from the writer when a
message lands in a hidden DM. Against an older client the row returns on
the next roster refresh.

### Related issue

N/A. None found.

### Testing

- New Postgres test `dm_message_from_someone_else_unhides_it`
(`membership_notice_postgres_tests.rs`): hide → the viewer's own message
keeps it hidden → a peer's message whose snapshot is blocked by a
trigger is rejected, not stored and not delivered → its resend, parked
at fan-out, already shows the DM visible and is delivered once. It is
`#[ignore]` (needs Postgres) and runs in Backend Integration CI. It was
not run locally.
- Pre-push `rust-tests` lane (`just test-unit`) and local clippy pass;
`observability_source` source-policy test updated for the new
transaction seam.
- Reviewed by the Royal Court agents. Their findings (atomicity,
lock-before-read, workflow path) are fixed in follow-up commits.
- Human test pending.

🤖 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 10:21:17 -07:00
Wes
5f08ed2511 fix(deploy): pin self-host installs to relay 0.3.0 (#9714)
## Summary

- Pin the Compose fallback and example environment to
`ghcr.io/block/buzz:0.3.0`. Document how to opt into rolling `:main`
builds and how to update the image tag before running `./run.sh
upgrade`.
- Set the Helm chart's default relay image to `0.3.0` through
`appVersion` and bump the chart and quickstart to `0.1.12`.
- Add a relay release checklist step to update both deployment defaults
after each stable image is available. The existing chart release
workflow publishes the bumped chart after merge.

### Related work

[#2824](https://github.com/block/buzz/pull/2824) also touches self-host
Compose. This PR covers release tags and upgrade instructions.

### Testing

- Rendered Compose with the example environment, the fallback, and
explicit image overrides. A fresh isolated Compose install reached
readiness with `ghcr.io/block/buzz:0.3.0` and returned `ok` from
`/_liveness`.
- Passed Helm lint and all 85 unit tests. Rendered all four chart
fixtures, verified the default image and an override, and packaged chart
`0.1.12` with app version `0.3.0`.
- The repository-wide `just ci` run passed. It started at `cf357b241`,
and the final commit changes only the Compose upgrade text.

---------

Signed-off-by: Star Lord <b89298dbe87c6b3fd8a425b535d9d161f23c88d555a47925ae0b04dfe02b201e@buzz.block.builderlab.xyz>
Co-authored-by: Star Lord <b89298dbe87c6b3fd8a425b535d9d161f23c88d555a47925ae0b04dfe02b201e@buzz.block.builderlab.xyz>
chart-v0.1.12
2026-11-19 10:09:04 -07: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
damienrj
b68c4edda5 feat(cli): show and search verified identity in users get (#9647)
## Summary

`buzz users get` reads only kind:0 profiles, so the CLI can't find or
confirm a person by their verified username. This adds relay-verified
profiles (kind:30382) to `users get`.

- `--pubkey` adds a `verified` object (`username`, `display_name`,
`full_name`, `issuer_label`, `verified_at`) for subjects that have one.
A requested person with a verified profile but no kind:0 is still
returned.
- `--name` uses the relay's `POST /profiles/search` when the community
advertises verified profiles with `searchable: true`, so it matches
verified names (word prefix). Otherwise, or for queries over the
endpoint's 100-character limit, it runs the existing NIP-50 substring
search and attaches verified profiles where the community advertises
them.

Verified profiles are read only when NIP-11 advertises
`federated_identity.public_profile`. A projection is trusted only if it
is kind 30382, signed by the relay's `self` key with a valid signature,
and follows the NIP-FI projection rules the mobile client applies: empty
content, exactly the projection tags (each once with one value), `p`
equal to `d`, `active` set to `true`, a valid username, names of 1–64
characters with no surrounding whitespace or control characters (looser
than mobile, which also requires NFC and rejects more Unicode
categories), and a decimal `verified_at` no later than `created_at`. The
newest projection per subject wins (the lower id breaks a same-second
tie), so a retraction clears the verified name. Any `verified` key in
user-authored kind:0 content is dropped on every path, so only a
relay-signed projection can set it.

`users get` now makes one NIP-11 request. If that request fails, the
advertisement is malformed, or the kind:30382 lookup fails, it still
prints the kind:0 results and writes a `verified_profiles_unavailable`
warning to stderr. This applies to `--pubkey`, no args, and `--name`.

### Related issue

Related: #8745 (verified profile spec), #9624 (verified-name mentions in
workflows).

### Testing

- `cargo test -p buzz-cli` passes, with tests for trust checks,
retraction, both lookup paths, search without the advertisement, and a
forged `verified` object in kind:0 (no advertisement, impostor-only
projection, and a valid projection replacing it).
- `cargo fmt` and `cargo clippy -p buzz-cli -D warnings` are clean.
- An earlier revision of the built CLI was run against a live community
with verified profiles: `--name <verified username>` found a user whose
kind:0 name differs, and `--pubkey` returned the expected `verified`
objects.

---------

Signed-off-by: damienrj <damien@squareup.com>
2026-11-18 22:02:21 -08:00
Tom Brow
39ffc3dcc5 fix(mobile): keep agent poster up until the iOS video draws (#9688)
On iOS, an animated agent avatar (a preset character with a transparent
video) blinks out for one to three frames right after navigation
settles. Opening a Solo chat blanks the header avatar; going back to
Messages blanks the bestie bubble.

The cause is the hand-off from the still poster to the video. While a
route animates, `PresetAgentAvatar` shows the poster; once it settles it
replaced the poster with a native `AVPlayerLayer`, which draws nothing
until its first video frame arrives. The avatar picker and the
create-agent page already covered this by passing a preloaded poster;
the DM and Solo header and the bestie bubble pass none, so they went
straight to the bare player.

Now every iOS caller gets that hand-off, using its own poster when it
passes none: the poster stays up, below the player, until playback
advances in that showing, then fades out over 160 ms. The poster sits
below the native layer rather than over it, because a Flutter overlay
above a platform view also costs a blank frame when the view first
appears. Each showing starts covered again and waits for playback to
advance from where the player actually is, so coming back to a chat from
a page above it doesn't blink either. The poster is keyed by its URL, so
when the avatar changes to another character (for example a synced
bestie change) it never shows the previous character's poster. Android
is unchanged; it already waits for a presented frame.

### Validation

Measured on an iPhone 17 Pro simulator, recording at 60 fps and checking
the avatar region frame by frame, opening a Solo chat with an animated
agent and going back:

| | Header blank on open | Bubble blank on back |
| --- | --- | --- |
| main, 3 runs | 1 frame every run | 2 to 3 frames every run |
| this PR, 3 runs | none | none |

Before (left) and after (right), slowed 4x: the Solo header on open,
then the bestie bubble on back.

<video
src="https://github.com/user-attachments/assets/4ddf16c0-bb8d-4d77-b53e-84f83ff45e98"
width="480"></video>

Added test: [iOS keeps the poster over a new player until playback
advances](2b172d1b68/mobile/test/shared/widgets/preset_agent_avatar_test.dart),
covering a first showing, a return to the route, and a change of
character while the video is showing.

### Regressions

- No extra work: the poster image was already loaded for the transition,
and the video plays exactly as before.
- During the 160 ms fade, poster and video overlap. They show the same
character, so the fade reads as a single image, as it already did in the
avatar picker.
- If the video never starts playing, the poster just stays up, which is
what callers showed before the video was ready anyway.





buzz-review-completed

---------

Signed-off-by: Tom Brow <tomb@block.xyz>
Co-authored-by: studio <dc2fc481343672df31a689840c09299972e704dac592e0da6f18486646a7ee3e@buzz.block.builderlab.xyz>
2026-11-18 19:57:44 -08:00
Matt Toohey
008d72a133 test(relay): stop bridge cancel_fixture tests timing out on the first replica connect (#9691)
## Problem

All seven tests that share `cancel_fixture` in
`crates/buzz-relay/src/api/bridge.rs` got a replica pool with a 1 s
`acquire_timeout`. Only
`shed_history_read_maps_to_503_on_every_bridge_branch` needs that
budget: it holds the replica full and measures how fast a read sheds.
sqlx applies `acquire_timeout` to opening connections as well as to
waiting for a free one, so the budget also governed the fixture's
initial connect and every later acquire that had to open a connection.

A transient Postgres stall on the shared CI server therefore failed
tests that never hold the replica full. CI showed `connect scratch:
PoolTimedOut` at `bridge.rs:10309` in
`aborted_history_read_logs_events_already_queued` and
`failed_history_read_closes_and_reconnect_replays_the_history` (run
44205074529 shows eight tests finishing together after a ~3 s gap, which
is the stall). Pools with sqlx's 30 s default waited the stall out; the
1 s replica did not. No connection leaked and the pool was not too
small.

The replica's 300 ms database-level `statement_timeout` had the same
flaw: migrations and seeding ran under it, so a stall during setup
failed `seed community` with 57014.

## Fix (test code only)

- The six non-shed tests now use default pool budgets.
- Only the shed test asks for the short budget, via `budgeted_reader`.
That helper pre-opens all of the reader pool's connections under the 30
s default, and does not ping on acquire, so the 1 s budget covers only
the wait for a free connection.
- sqlx still pings each connection on release and closes it if the ping
fails, so `budgeted_reader` waits until `num_idle()` equals
`max_connections` before returning. A fill-and-drain loop (acquire to
`max_connections`, drop, re-check) reopens any connection a failed
release ping closed, under one 30 s deadline, and panics with the `N of
M idle` count if the deadline passes.
- The replica's `statement_timeout` is applied after migrations and
seeding, and the replica is reopened so new sessions pick it up.
- The shed test asserts each shed `/query` case completes in under 10 s,
so a silent fallback to the 30 s default fails instead of passing
slowly.

## Verification

Reproduced locally by pausing the Postgres container for 2 s at random
intervals while running `api::bridge::postgres_tests` at CI's 8 threads:
`connect scratch: PoolTimedOut` appeared in 1 of 4 runs before the fix
and in 0 of 8 after. With the fix, the 62 bridge postgres tests passed
at 8 threads against a local Postgres (`--ignored`, including the shed,
statement-cancel, and both history-read tests). `cargo fmt` is clean.

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

---------

Signed-off-by: mtoohey <mtoohey@squareup.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-19 14:00:02 +11:00
Will Pfleger
a406191694 Revert "feat(relay): support community-scoped NIP-AR artifacts" (#9689)
Reverts #9650 (squash commit `eebf62b6`), except for migration `0097`
and the channel artifact sync fences it added.

Community scope adds a relay access gate based on community admission
rather than channel membership, a new relay-admin command kind (`9034`)
and an operator-run key transition. Its design and NIP-AR text need
relay maintainer review before they ship. Two integration gaps also
remain:

- Media download authorization looks up references only in `events`, so
an attachment referenced only by a community artifact is unreadable when
media-read enforcement is on.
- User erasure retires a community head in the database without
signaling live syncs, so members who are already syncing keep the erased
copy.

The feature can return as a new PR once those are resolved.

## Kept from #9650

- **Migration `0097`, byte for byte.** Published images already include
it, and databases that auto-migrated have recorded it. Dropping it would
stop those relays from starting. It only adds columns and indexes that
the channel code ignores. The declared schema matches that expanded
shape and keeps the `(community_id, artifact_id)` primary key, so the
operator key transition no longer exists.
- **Channel artifact sync fences.** Snapshot and live sends check for a
pending resync and for connection cancellation under the queue lock. A
reader who loses access, or whose content is redacted, while a frame is
in flight therefore receives no further payload. Handler-backed tests
cover a resync recorded while a snapshot payload waits for queue room
and one recorded after a live head read.

## Compatibility

This revert supports databases that applied only migration `0097`, which
is all that auto-migration runs. A database that ran #9650's operator
contract script, or was bootstrapped from #9650's declared schema, has
no `(community_id, artifact_id)` key, so channel artifact writes fail
there. Before deploying to such a database, check that
`artifact_heads_pkey` is on `(community_id, artifact_id)` and that
`artifact_heads` has no rows with `scope = 'community'`; if either check
fails, it needs a separate recovery step.

---------

Signed-off-by: Will Pfleger <wpfleger@block.xyz>
Co-authored-by: Paul <4a1bfa0013bc6d14a8d600d8bf6392efefbd2a26ac3c96c9b2a106b0d12297ca@buzz.block.builderlab.xyz>
2026-11-19 02:38:17 +00:00
Taylor Ho
db40da87b4 feat(relay): add conditional Solo member role updates (#9667)
**Category:** improvement
**User Impact:** Solo chat owners can lower the access of any current
non-owner, including people and agents.

**Problem:** Using invitations to change Solo chat access can restore a
removed member, reject a downgrade because of the target’s invitation
policy, or show a join notice for a role change.

**Solution:** Add signed role updates that require an active member at
the expected role when the relay commits the change. A Solo owner can
downgrade any current non-owner. Moving a viewer to Participating
requires a verified agent, and granting Admin requires ownership of that
agent. The relay refreshes signed group state without emitting a join
notice.

Companion to
[block/buzz-app#3704](https://github.com/block/buzz-app/pull/3704). The
[app
review](https://github.com/block/buzz-app/pull/3704#pullrequestreview-5962147206)
identified the need for conditional writes, verified agent identity and
live relay validation. [#9592](https://github.com/block/buzz/pull/9592)
introduced the atomic removal that uses the same membership lock.

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

**crates/buzz-core/src/kind.rs**

Register signed Solo role updates as kind 9050.

**crates/buzz-db/src/store/channel_members.rs**

Authorize the transition under the channel membership lock and commit
the active row update and signed event together.

**crates/buzz-relay/src/handlers/event.rs**

Give the new command a bounded metrics label.

**crates/buzz-relay/src/handlers/ingest.rs**

Use the shared signed ingest path and require the channel administration
scope.

**crates/buzz-relay/src/handlers/mod.rs**

Register the command handler and its PostgreSQL test.

**crates/buzz-relay/src/handlers/solo_member_role.rs**

Parse the command, route it to the conditional write, and refresh signed
group state after commit.

**crates/buzz-relay/src/handlers/solo_member_role_postgres_tests.rs**

Exercise human and agent changes, restrictive invitation policy,
promotion authorization, stale and removed membership, duplicate
receipt, and signed roster updates through the relay’s production ingest
path.

**docs/solo-mobile-contract.md**

Describe the wire format, permitted transitions, and handling when an
older relay rejects the command.

</details>

### Try it

1. Run the updated relay and the companion app against a disposable Solo
chat with a current human and agent. Open **Chat access** as the owner.
2. Lower the human to **Viewing only**. Reopen **Chat access** and
confirm the saved role. A role change should produce no join notice.
3. Downgrade an agent with a restrictive invitation policy. Confirm its
role changes. Check that **Admin** can be granted only to your own
verified agent.
4. Run `solo_owner_edits_active_members_and_publishes_the_new_roster`
with PostgreSQL to check that a pending change for a removed member is
refused and the signed roster stays clear of that member.

### Validation

- The PostgreSQL regression passes at relay commit `405f7d1da`. It
covers role and invite-policy enforcement, signed roster refresh,
duplicate receipts, and rejection after removal.
- The companion app at `a470947dc6` passes 138 administration tests. Its
production command builder, validator, and signed roster reader also
passed over WebSocket against a local relay backed by PostgreSQL and
Redis. A human moved from Admin to Participating to Viewing only, then
was removed. The app preflight and relay both refused a further role
edit, and the signed roster still excluded the member.
- The live check exercised the app’s relay code headlessly. The UI
walkthrough is pending.

---------

Signed-off-by: Taylor Ho <taylorkmho@gmail.com>
Signed-off-by: Tom Brow <tomb@block.xyz>
Co-authored-by: Carl <acda9e433d19dcd0e6b6840f7f4b98f3a56f1fab98049d444c087019e6d36560@feedback.communities.buzz.xyz>
Co-authored-by: Tom Brow <tomb@block.xyz>
2026-11-18 17:16:25 -08: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
LordMelkor
eebf62b61d feat(relay): support community-scoped NIP-AR artifacts (#9650)
## Summary

NIP-AR clients can store community-scoped artifacts and subscribe to
live changes for one exact artifact type. Community and channel
artifacts share revision and retry semantics and use separate identity
scopes. Community owners and admins can choose whether a type accepts
edits from all admitted members or only administrators. This PR combines
the protocol from #9638 with the relay implementation.
[Protocol](0b8949f5e2/docs/nips/NIP-AR.md (community-scoped-artifacts-proposed-extension))

- Kind `45010` binds community writes to a signed tenant UUID. Explicit
community filters select signed HTTP reads and WebSocket sync. NIP-11
advertises capability after the schema transition.
- Kind `9034` sets per-type policy using compare-and-set. The relay
commits the policy update and audit entry together. Readers fetch the
current policy and its revision through the explicit policy view.
- Kind `9005` redacts a community revision. Relay peers send
tenant-scoped change metadata and re-read the authorized head for
delivery. This reuses the existing snapshot, bounded buffering, and
resync semantics.

## Rollout

Migration `0097` expands storage and retains the existing channel write
key. Deploy compatible serving backends, deletion executors and operator
tools with community scope disabled. Then run the guarded key transition
and enable the capability. The resulting rollback floor is the first
compatible relay version. [Rollout
guide](0b8949f5e2/docs/community-artifact-rollout.md)

## Why each change belongs in the relay or protocol

| Change | Necessity | Minimality |
| --- | --- | --- |
| NIP-AR community scope | The current protocol gives every artifact a
home channel and defines channel-based access. Clients need a shared
contract for community identity, admission, reads and moderation to
interoperate.
[NIP-AR.md:9](493cb4cc13/docs/nips/NIP-AR.md (L9))
[NIP-AR.md:65](493cb4cc13/docs/nips/NIP-AR.md (L65))
| An optional version-1 section reuses the artifact envelope version and
revision operations. The channel sections state where their existing
rules apply.
[NIP-AR.md:242](0b8949f5e2/docs/nips/NIP-AR.md (L242))
|
| Signed community revisions | The validator requires an `h` tag, and
the write path stores an event and mentions for that channel. A
client-defined tag cannot establish a different audience on the relay.
[artifact.rs:122](493cb4cc13/crates/buzz-core/src/artifact.rs (L122))
[artifact.rs:196](493cb4cc13/crates/buzz-db/src/store/artifact.rs (L196))
| The existing event kind accepts a mutually exclusive, signed community
UUID. HTTP and WebSocket bind it to the resolved tenant at ingest and
reuse the revision authentication checks.
[community_artifact.rs:120](0b8949f5e2/crates/buzz-relay/src/handlers/community_artifact.rs (L120))
[community_artifact.rs:174](0b8949f5e2/crates/buzz-relay/src/handlers/community_artifact.rs (L174))
|
| Scoped heads and revisions | The database key places every artifact in
one identity space per community. Only the relay can advance an accepted
head atomically across clients.
[artifact_heads.sql:2](493cb4cc13/schema/tables/public/artifact_heads.sql (L2))
[artifact.rs:187](493cb4cc13/crates/buzz-db/src/store/artifact.rs (L187))
| The head and revision ledger gain a scope discriminator. Community
revisions keep their signed payload in the ledger and reuse the
compare-and-set, replay and tombstone rules.
[community_artifact.rs:350](0b8949f5e2/crates/buzz-db/src/store/community_artifact.rs (L350))
|
| Community admission | Channel reads check channel visibility and
membership. A client can filter its own view but cannot enforce
admission for other readers or synchronize delivery with a revocation.
[artifact_query.rs:65](493cb4cc13/crates/buzz-db/src/store/artifact_query.rs (L65))
| Explicit community reads and writes share an admission check against
current membership, verified delegation and bans. Administrative
authority requires a direct role.
[community_artifact.rs:36](0b8949f5e2/crates/buzz-db/src/store/community_artifact.rs (L36))
|
| Per-type write policy | The administrative scope dispatch has no
artifact-policy command. A client preference cannot enforce an edit rule
against another client or a concurrent write.
[ingest.rs:650](493cb4cc13/crates/buzz-relay/src/handlers/ingest.rs (L650))
| One signed admin command sets policy for one exact type using
compare-and-set. A bounded map on the existing community row records the
policy and revision. A shared lock orders policy changes with writes,
and the existing audit chain commits in the same transaction.
[community_artifact.rs:183](0b8949f5e2/crates/buzz-db/src/store/community_artifact.rs (L183))
[community_artifact.rs:365](0b8949f5e2/crates/buzz-db/src/store/community_artifact.rs (L365))
[community_artifact.rs:189](0b8949f5e2/crates/buzz-relay/src/handlers/community_artifact.rs (L189))
|
| Signed HTTP reads | The artifact endpoint dispatches to the channel
store. It cannot return a community head, its history or the
authoritative write policy.
[artifact.rs:70](493cb4cc13/crates/buzz-relay/src/api/artifact.rs (L70))
[artifact_query.rs:65](493cb4cc13/crates/buzz-db/src/store/artifact_query.rs (L65))
| One scope selector on the existing signed endpoint extends the
current, history and head views and adds an exact-type policy lookup.
Counts and HTTP incremental tokens stay channel-only.
[artifact.rs:73](0b8949f5e2/crates/buzz-relay/src/api/artifact.rs (L73))
[artifact_sync.rs:154](0b8949f5e2/crates/buzz-relay/src/api/artifact_sync.rs (L154))
|
| Community WebSocket sync | The relay requires channel IDs and confirms
live interest on those channels. A client cannot register community
interest through the existing filter.
[artifact_sync.rs:51](493cb4cc13/crates/buzz-core/src/artifact_sync.rs (L51))
[artifact_sync.rs:440](493cb4cc13/crates/buzz-relay/src/handlers/artifact_sync.rs (L440))
| One exact type selects the community set. The relay reuses
subscription ownership, snapshot paging, bounded buffering, EOSE and
resync, with a current admission check before delivery.
[artifact_sync.rs:683](0b8949f5e2/crates/buzz-relay/src/handlers/artifact_sync.rs (L683))
[artifact_sync.rs:755](0b8949f5e2/crates/buzz-relay/src/handlers/artifact_sync.rs (L755))
[artifact_sync.rs:934](0b8949f5e2/crates/buzz-relay/src/handlers/artifact_sync.rs (L934))
|
| Cross-node delivery | Redis routes channel and ordinary global events.
A connected client cannot coordinate when peers reread an authorized
head.
[topic.rs:15](493cb4cc13/crates/buzz-pubsub/src/topic.rs (L15))
| One tenant-scoped topic carries the identity, exact type and change
cause. Each relay filters its own subscriptions and rereads the
authorized head or signals resync.
[artifact_sync.rs:211](0b8949f5e2/crates/buzz-relay/src/handlers/artifact_sync.rs (L211))
[artifact_sync.rs:1039](0b8949f5e2/crates/buzz-relay/src/handlers/artifact_sync.rs (L1039))
|
| Ordinary event audience | Generic queries and search apply event-store
rules. A client cannot enforce who else receives a response from those
paths, including on a relay with community writes disabled.
[event.rs:785](493cb4cc13/crates/buzz-db/src/store/event.rs (L785))
[query.rs:329](493cb4cc13/crates/buzz-search/src/query.rs (L329))
| Community payloads stay in the ledger. Ordinary reads and fan-out
enforce the channel boundary, including for rows from older paths.
Explicit artifact views enforce community admission.
[event.rs:7267](0b8949f5e2/crates/buzz-db/src/store/event.rs (L7267))
[event.rs:153](0b8949f5e2/crates/buzz-relay/src/handlers/event.rs (L153))
|
| Community redaction | The moderation path requires a channel in `h`. A
client delete cannot apply relay moderation to a stored community
revision.
[side_effects.rs:671](493cb4cc13/crates/buzz-relay/src/handlers/side_effects.rs (L671))
| The existing moderation kind gains one community-scoped target form
for direct owners and admins. Redaction preserves the accepted revision
ID and sends affected syncs through the existing resync path.
[community_artifact.rs:214](0b8949f5e2/crates/buzz-relay/src/handlers/community_artifact.rs (L214))
[community_artifact.rs:609](0b8949f5e2/crates/buzz-db/src/store/community_artifact.rs (L609))
|
| Community purge | The deletion executor retains the community row as a
tombstone. Client-side removal cannot clear authoritative policy on that
row or prove it was erased.
[deletion.rs:2448](493cb4cc13/crates/buzz-db/src/store/deletion.rs (L2448))
[deletion.rs:3488](493cb4cc13/crates/buzz-db/src/store/deletion.rs (L3488))
| The existing purge covers both ledger tables. The tombstone
transaction clears the policy map when the column exists, and the
absence check verifies it.
[deletion.rs:2451](0b8949f5e2/crates/buzz-db/src/store/deletion.rs (L2451))
[deletion.rs:3489](0b8949f5e2/crates/buzz-db/src/store/deletion.rs (L3489))
|
| Schema rollout | Older writers use the existing two-column conflict
target. Clients cannot preserve that write contract during a key change
or attest which relay binaries are serving.
[artifact.rs:196](493cb4cc13/crates/buzz-db/src/store/artifact.rs (L196))
| Migration 0097 adds columns and indexes without a backfill and
preserves the old key. A separate guarded SQL operation installs the
scoped key after the compatible fleet is in place. The rollout guide
documents the sequence and rollback boundary.
[0097_community_artifact_expand.sql:7](0b8949f5e2/migrations/0097_community_artifact_expand.sql (L7))
[community-artifact-contract.sql:13](0b8949f5e2/scripts/maintenance/community-artifact-contract.sql (L13))
[community-artifact-rollout.md:38](0b8949f5e2/docs/community-artifact-rollout.md (L38))
|
| NIP-11 and enablement | The baseline artifact descriptor supplies
neither the tenant UUID nor a signal that the scoped schema is active.
Clients cannot infer activation across mixed-version deployments.
[nip11.rs:478](493cb4cc13/crates/buzz-relay/src/nip11.rs (L478))
| One optional discovery object advertises the version, canonical tenant
UUID and policy limit. The handlers and NIP-11 share the configuration
and schema-readiness gate.
[nip11.rs:482](0b8949f5e2/crates/buzz-relay/src/nip11.rs (L482))
[community_artifact.rs:51](0b8949f5e2/crates/buzz-relay/src/handlers/community_artifact.rs (L51))
|

## Size

Measured with `git diff` from `493cb4cc1` to `0b8949f5e`. Dedicated test
files and changed lines inside Rust `#[cfg(test)]` items count as tests.
Each side of a mixed hunk is classified against its own revision.

| | Added | Removed |
| --- | ---: | ---: |
| Production, including schema and rollout SQL | 2,249 | 117 |
| Tests | 1,897 | 53 |
| Docs | 180 | 8 |
| Standalone runtime probe | 397 | 0 |
| **Total** | **4,723** | **178** |

The total includes
`crates/buzz-relay/examples/community_artifact_probe.rs`. The production
and test rows exclude it. The probe supports manual mixed-version and
feature-disabled checks against a running relay.

## Validation

Validated at `0b8949f5e29f5ccf51ec5e2d487f09e2f49bffeb` against
`493cb4cc1369ff9fdb44ae6c50f18c66d1fb6474`.

- The signed HTTP and WebSocket workflow exercised the old and new
channel writers on the expanded schema, the guarded key transition,
community snapshot and live sync, policy compare-and-set and replay,
tenant binding, scope isolation, and redaction followed by resync.
Restarting the relay with community scope disabled after the transition
withheld capability advertisement and preserved channel artifact
operations.
- The normal `buzz-db` suite passed 268 tests, including doctests. All
860 `buzz-db` PostgreSQL tests passed, including the wide `#e` read
regression from #9591.
- The full eight-package PostgreSQL run passed 1,695 of 1,696 tests.
`handlers::ingest::postgres_tests::reaction_and_deletion_h_must_name_the_target_channel`
failed while setting up its private-channel fixture. The same fixture
failed on the protocol base `27a4c8a86e9e9795bfaf5fe59f35164a6389a9ed`.
- The hosted PostgreSQL run at `686b8445` passed 1,698 of 1,699 tests.
The same test was the sole failure on the PR and on `main` at
`493cb4cc13`. In both runs, fixture setup returned `restricted: not a
channel member` while storing the private target. #9640 fixes the
fixture by invalidating the author's membership cache after creating the
private channel. Its PostgreSQL run passes the test. [PR run
44325182932](https://github.com/block/buzz/actions/runs/44325182932/job/134884438543)
· [Main run
44254013047](https://github.com/block/buzz/actions/runs/44254013047/job/134638066441)
· [Fix #9640](https://github.com/block/buzz/pull/9640) · [Passing test
on
#9640](https://github.com/block/buzz/actions/runs/44248427229/job/134618695910)
- `just test-unit` and `just test` passed on Linux in separate runs. The
commands recorded 6,611 and 7,243 passing test executions, respectively,
with overlap between the suites. These runs passed the CLI socket
ownership tests and push-gateway fixture that failed during the earlier
parallel hook run. Both Tauri Clippy configurations and 3,560 Tauri test
executions also passed at this commit.
- `just ci` passed Rust formatting, workspace Clippy, and desktop,
Tauri, and web checks. It stopped at mobile formatting after the Linux
environment failed to resolve `pub.dev` for the Flutter dependencies.


## End-user test

The PR author’s agent ran the app and plugin end to end on Linux against
a local relay built at `0b8949f5e`. The final browser rerun passed all
15 steps plus the public default-channel case. The native desktop run
passed all seven steps it covered.

- A group saved by the owner appeared in a member’s open Settings
without a reload.
- Changing the write policy to owners and admins made the member’s
editor read-only. The relay refused a signed write by that member and
preserved the current record.
- The audit log identified the policy revision as the accepted
kind-`9034` event ID. The policy change back to everyone used that ID as
`prev`.
- A second relay with community artifacts disabled advertised no
community scope, and the app withheld shared group actions.

[End-user test
evidence](https://github.com/block/buzz-app/pull/3838#end-user-test-agentsmd-step-3)

Supersedes #9646. The reviewed commit is now on an upstream branch.

---------

Signed-off-by: Krish Ray <kray@block.xyz>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: Codex <codex@openai.com>
2026-11-18 18:57:40 -05: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
Wes
44e97e96f4 fix(pubsub): round the rate-limit retry hint up from PTTL (#9552)
## Summary

The Redis rate limiter built its `retry in Ns` hint from `TTL`, which
truncates to whole seconds. With 400 ms left in the window, a denied
request was told `retry in 0s`, and a client that sleeps for exactly the
hint retried straight into another refusal.

This reads `PTTL` and rounds the milliseconds up to whole seconds, so
the hint is never 0 while the window is still open. The no-expiry repair
path is unchanged.

## Testing

- New `rate_limiter::tests::retry_hint_rounds_a_partial_second_up`
(`#[ignore = "requires Redis"]`, like the other Redis tests in this
crate) seeds an exhausted window with 400 ms left and asserts the denial
reports 1 second. Against the old `TTL` code it fails with `left: 0,
right: 1`; with this change it passes.
- `cargo nextest run -p buzz-pubsub --lib`: 38 passed. Ignored Redis
`rate_limiter` and `nip98_replay` tests: 5 passed against a local Redis.
- `cargo nextest run -p buzz-relay --lib` with local Postgres and Redis:
1762 passed. The relay `rejection::`/`admission::` lane with
`--run-ignored all`: 16 passed.
- Pre-push hooks (including rust-tests) passed.

CI note: the Redis-backed pubsub tests only run in CI when they are
named in `.github/workflows/_ci-relay.yml`, so the new test isn't
selected there yet. Adding `or test(/^rate_limiter::tests::/)` to the
"Pubsub subscriber reconciliation regression" filter would cover it. I
left that out here because this branch can't push workflow file changes.

---------

Signed-off-by: Wes <wesb@block.xyz>
Co-authored-by: Groot <f4c08302591916fb4b80926bf7e18d22eef8aa0c877e4e841acc46405a45700b@buzz.block.builderlab.xyz>
Co-authored-by: Star Lord <b89298dbe87c6b3fd8a425b535d9d161f23c88d555a47925ae0b04dfe02b201e@buzz.block.builderlab.xyz>
2026-11-18 16:28:20 -05:00