mirror of
https://github.com/block/buzz.git
synced 2026-11-24 02:02:07 +00:00
0e7fd48d41db0ea00f4baa60d36d4fdfce31df40
3650 Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
0e7fd48d41 |
ci(mobile): run the Mobile Swift Native lane only for native changes (#9847)
## What changes The Mobile Swift Native job rebuilds the iOS simulator app from scratch. On the run in #9809, `xcodebuild build-for-testing` took about 19 minutes and RunnerTests took about a minute. That PR changed the pubspec files, so it would select Native under this filter. For PRs, select Native for changes to `mobile/ios/`, `mobile/packages/`, `mobile/assets/`, `mobile/scripts/`, the pubspec files, the Flutter SDK pin, the four native test scripts, or either CI workflow that configures it. Changes to the SDK pin or the four native test scripts also select mobile CI. At GitHub’s 3,000-file listing limit, the selector runs all suites. When a PR selects mobile CI and touches none of the Native paths, Mobile Swift runs the unsigned iOS release build and skips the debug simulator build and its Apple Silicon linking check (#7646). Dart-only and Android-only mobile PRs are examples. Pushes to `main` and `release` run both Swift lanes whenever mobile CI is selected. A RunnerTest starts the normal Dart entry point in a Flutter engine. A Dart change that passes PR checks can therefore fail a simulator test on the merge commit. ## Validation - The local CI selection suite passed against the pinned `dorny/paths-filter` action with 83 passes and eight Linux-only skips. The required-context isolation contract also passed. - GitHub scheduled both Swift lanes on the initial revision `a34746e6`. Native passed in 14m35s and Release passed in 6m24s. [CI run](https://github.com/block/buzz/actions/runs/44863694135) - To verify hosted Release-only scheduling after merge, check the next mobile PR that changes none of the Native paths. Mobile Swift should show Release only, and the required Mobile check should report its result. --------- Signed-off-by: Wes <wesb@block.xyz> Co-authored-by: Gamora <a0291282695a734997579812cc077d006bd2c5a73855019e537a0cddd46887c1@buzz.block.builderlab.xyz> |
||
|
|
80131055dc |
Revert "perf(db): stop per-id planning of wide #e reads (#9591)" (#9848)
Reverts #9591 (`perf(db): stop per-id planning of wide #e reads`). Hiding the `#e` id arrays from the planner made reads in large communities much slower in prod. This is a straight revert. ## Evidence - **8 → 9 row cliff on the channel head read with `include_aux`:** 125ms at 8 rows, 1.4s at 9 rows, about 2.3s at 20 rows. - **Replica `EXPLAIN ANALYZE`, 20-id aux query:** 130ms with the ids visible to the planner, 2240ms with them hidden. The hidden plan reads and discards about 625k rows in `events_p2026_07_08_legacy`. - **200-id thread page (1,593-reply thread):** | ids | plan | exec | |---|---|---| | visible (this PR) | 78ms | 1,387ms | | hidden (#9591) | 10ms | 18,146ms | #9591 saves planning time but makes execution about 13x slower. - **Prod:** #9591 reached bb-block prod with `main-20261120032502-8d4b301` (2026-11-20 14:48Z). ## Notes - #9674 used the same trick for thread-window aux reads and had the same risk. It's now closed. - Any future change like this should be checked with `EXPLAIN ANALYZE` on the replica first. A test that runs EXPLAIN against a large community is a follow-up, not part of this PR. ## Testing - `cargo test -p buzz-db --lib e_tag` 🤖 Generated with [Claude Code](https://claude.com/claude-code) Signed-off-by: Bradley Axen <baxen@squareup.com> Co-authored-by: mbot <3754f8729004d95654c46dbab3129e4ab9ef05cc2534e2a3fbfc155983bd637b@buzz.block.builderlab.xyz> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>mobile-v1.5.0-rc.7 |
||
|
|
7382130948 |
feat(mobile): count networking events for diagnostics (#9810)
Implements the networking counts in docs/mobile-diagnostic-reporting.md:
every request through the shared HTTP client and every relay connection
event is counted, with backend (host), endpoint (from a fixed list),
outcome and kind of failure, plus a duration for requests and time to
connect.
## Changes
- **HTTP:** `newAppHttpClient` returns a counting wrapper, and the relay
HTTP query client wraps its own transport the same way. A failure status
is counted at its headers, a transport failure when it happens, and a
success once its body ends or its reader stops (duration is still time
to headers). A caller deadline noted with `noteHttpDeadline` makes a
request still waiting for headers or still reading its body a timeout;
the invite mint now notes its deadline too. Requests the app cancels are
not counted, and a throwing reporter never changes a request's result. A
request counts only for the member who started it, and is dropped if it
finishes while anyone else, or no one, is signed in. Only failed
requests leave a breadcrumb, so successes don't push useful entries out
of the SDK's buffer.
- **Backend names:** only the app's own hosts are named (relays this run
has used, the build's Builderlab origin and hosted relay domains, the
push gateway). Any other host, such as a remote image's, is counted as
`external`.
- **Relay:** the session counts connected (with time to connect),
disconnected or a failed attempt (once per attempt), reconnect attempts,
history queries (EOSE, CLOSED, timeout), publishes (OK true or false,
ack timeout) and live subscriptions closed by the relay. Queries and
publishes still unanswered when the socket drops are counted as
disconnected. A refused protected upgrade is counted before its renewal,
and the relay's authorization denial makes the following close an auth
refusal. Intentional disconnects (background pause, sign-out, community
switch) are not counted. The session's debug hooks moved to
`relay_session_test_hooks.dart` to stay under the file-size limit.
- **Install ID on counts:** metrics carry scope attributes but not scope
tags, so startup also sets `install.id` as an attribute, and the filter
allows it.
- **Spec:** marks counts as implemented and records that the destination
can filter counts by member, so the log-line fallback isn't needed.
### Endpoints
`relayConnection`, `relayReconnect`, `relayQuery`, `relayPublish`,
`relaySubscription`, `relayHttpQuery` (`/query`, `/count`,
`/profiles/search`), `relayInfo` (GET of a server's root),
`mediaDownload`, `mediaUpload`, `communityAdmission`,
`builderlabAccount`, `otherHttp`.
### Failure kinds
| Source | Kind |
|---|---|
| 401, 403 | `authRefused` |
| 408, abort before headers, timeouts | `timeout` |
| 429 | `rateLimited` |
| 5xx | `serverError` |
| Other 4xx | `clientError` (new) |
| No network | `offline` |
| Host unreachable | `unreachable` |
| TLS failure | `insecure` |
| Connection closed or reset (including ECONNRESET) | `disconnected` |
| Relay `rate-limited:` / `query timed out` | `rateLimited` / `timeout`
|
| Other relay refusal prefixes (`restricted:`, `auth-required:`,
`invalid:`, ...) | `relayRefused` |
| Anything else | `relayError` or `other` (new) |
## Validation
New tests:
- `counted_http_client_test.dart`: status and endpoint tables, transport
failure kinds (the error still reaches the caller and nothing is
reported as an error), a closed client, a throwing reporter, success
settled at body end, deadlines before headers and mid-body, requests
held across a member switch and a sign-out, and remote media hosts
counted as external.
- `relay_network_counts_test.dart`: connect, disconnect, reconnect, auth
refusal, queries, publishes, CLOSED, operations lost with the socket, a
refused protected upgrade before renewal, the relay's authorization
denial, and another member's session counting nothing.
Full-app run on an iOS simulator at
|
||
|
|
d1236080eb |
fix(mobile): bind notification replies to the account they were typed for (#9845)
A notification reply goes out as whatever account its community signs with when the reply is sent. No sign-in path replaces a community's account in place today: signing in again as another account adds a new community, and hosted re-entry refuses a different key. But nothing tied a reply to the account its notification was for, so a future in-place credential replacement would let a reply typed for the earlier account go out as the new one, or land in its drafts. Each reply is now tied to the account its notification was for: - The notification service extension records that account in the reply context, and iOS carries it through the reply journal, so a reply recovered on a later launch keeps it too. - The app sends a reply, or keeps it as a draft, only while the community still signs as that account (the key it signs with). It checks again after connecting. - Otherwise the reply ends as lost: iOS shows "Reply not sent" with the text, and no draft is kept. This is the same path a reply takes when its community has been removed ([ADR 0004](docs/adr/0004-notification-reply.md), updated here). - A reply to a notification posted by an earlier build has no recorded account, so it is checked only by its community, as before. ### Regressions - A community whose notification snapshot has no account key offers no reply action. Every signed-in community has one, since the snapshot falls back to the key derived from its secret. - No extra work on the send path beyond a key comparison. ### Validation - [notification_reply_test.dart](https://github.com/block/buzz/blob/notification-reply-account/mobile/test/features/channels/notification_reply_test.dart): a live reply for another account and a recovered one for another community end as lost with their text kept nowhere; a reply whose community's signing key is replaced while the relay connects (same community and stored key) is neither sent nor drafted; a reply from an earlier build without an account is sent. - [BuzzNotificationReplyTests.swift](https://github.com/block/buzz/blob/notification-reply-account/mobile/ios/BuzzPushKit/Tests/BuzzPushKitTests/BuzzNotificationReplyTests.swift): the resolver records the notification's account, lowercased. An empty account is rejected, and the account survives the journal round trip. - No simulator run: the reply action needs a real push resolved by the notification service extension, which the simulator can't receive. The change is covered at both layers by the tests above, and the iOS app builds. --------- Signed-off-by: Tom Brow <tomb@block.xyz> |
||
|
|
52cbc61131 |
fix(mobile): name identity-link mention pills from their key (#9841)
Follow-up to [#9699 mention typing](https://github.com/block/buzz/pull/9699), fixing two identity problems found in its review. **Identity-link pills name the key they open.** An edit writes each mention as an identity link, `[@Name](nostr:npub1…)`, and every message from any client draws such a link as a pill. Mobile showed the label written in the link, so `[@Wes](nostr:<mallory>)` drew an ordinary `@Wes` pill that opened Mallory's profile, and two namesakes in an edited message both read `Scout`. The pill now shows the name its key resolves to in the channel (with the namesake qualifier and agent icon), as buzz-app's `ProfileMention` already does. The written label shows only when the key has no name on this device (no profile, directory or roster name), never a compact npub in its place. This holds whether or not the link's key is also tagged. A pill requests its key's profile when uncached, so a written label gives way to the key's name once it loads. Edits carry no `p` tag, so an identity-link pill resolves its own key. In channel, thread and forum rows the pill watches that one key's channel label (with the namesake qualifier and agent icon) and requests the key's profile when it builds, so only links that actually draw a pill cost a lookup, whatever Markdown surrounds them. Inbox and search previews draw identity links the same way, taking keys from the preview pieces they render. These keys never feed the text bindings, so plain `@Name` text still binds only through signed tags. **Typed names group the way the text scan reads them.** The composer grouped the roster by `toLowerCase` while the scan folds names with `foldMentionLabel`. With members `Sam` and `ſam`, typing `@ſam` sent Sam's `p` tag. Grouping, lookup and the send-time key qualifier now all fold, so namesakes under folding fail as ambiguous, as other namesakes already do. **Linked lookups stay current and bounded.** Pills and preview rows request their keys through the profile cache's revalidation path. A name restored from the last launch is revalidated, so a renamed key's link shows its current name. A lookup that fails while offline is retried once the relay reconnects, including when the reconnect comes while that lookup is still on the wire. A key the relay says has no profile is not asked for again for five minutes, and the cache remembers at most 1,000 such keys per community. Previews keep tilde and quoted code fences literal and read blockquotes as the full message does, and load only the links on lines they draw. Editing a message folds historical names the way the scan does, so a name two tagged people share under folding seeds no chip. Rendering binds signed names by the same fold, so with signed `Sam` and `ſam` a plain `@Sam` stays text instead of drawing Sam's pill. Desktop (buzz-app) already names identity-link chips from the key and needs no change. ### Validation Rows add no per-message work: message bodies are no longer scanned for links. Each drawn identity-link pill adds one label watch for its own key. Added tests: - [Channel page journey step](mobile/test/features/channels/channel_detail_page_test.dart): an edited message linking `[@Wes]` to Mallory's key draws `Mallory`, and two edited `Scout` namesakes draw distinct qualified labels, through the real channel row. - [Channel page journey step](mobile/test/features/channels/channel_detail_page_test.dart): a link to a key with no name here keeps its written label. - [Preview identity link](mobile/test/features/channels/message_content/preview_text_test.dart): an inbox/search preview shows the key's resolved name, or the written label when unknown. - [Preview keys](mobile/test/features/channels/message_content/preview_text_test.dart): a preview loads only links it draws (not ones in code or past its line limit), including labels with brackets. Full-app run (iOS simulator, debug build, signed in to a test community): posted a message with a spoofed identity link, a link to a key with no profile here, and a link inside inline code. The spoofed link drew the key's real name as a pill and opened that person's profile; the unknown key kept its written label; the code span stayed raw. The same message drew matching pills in search results and in the thread view. - [Channel row loads](mobile/test/features/channels/channel_detail_page_test.dart): a row requests profiles only for links it draws as pills, not ones in a quoted code fence or an HTML comment. - [Folded chip qualifiers](mobile/test/features/channels/compose_bar_test/exact_mention_tests.dart): picked `@Sam` and `@ſam` chips both carry their keys on send. - [Ambiguous typed names table](mobile/test/features/channels/compose_bar_test/exact_mention_tests.dart): `Sam` and `ſam` in either roster order now refuse `@ſam` as ambiguous. - [Restart and reconnect journey](mobile/test/features/channels/channel_detail_page_test.dart): a restored old name and an offline first lookup both resolve after the relay reconnects, on the same mounted pills, and a key with no profile is not requested again. - [Preview fences](mobile/test/features/channels/message_content/preview_text_test.dart): tilde and quoted fences keep links and Markdown literal and load no keys. - [Overtaken lookup](mobile/test/shared/profile/user_cache_provider_test.dart): a reconnect during a link's failing lookup asks once more after it settles. - [Folded signed names](mobile/test/features/channels/message_content_exact_mentions_test.dart): signed `Sam` and `ſam` in either tag order leave `@Sam` as text in the message and its preview. - [Folded edit chips](mobile/test/features/channels/message_edit_sheet_test.dart): `Sam` and `ſam` tagged in either order open as text, with no chip. - [Non-member labels](mobile/test/shared/identity_names/identity_names_test.dart): a non-member labels the same with or without the roster shortcut, including names shaped like qualifiers. ### Regressions - **Performance:** rows do no new scanning; each drawn identity-link pill adds one label watch. A non-member whose name can't collide no longer re-resolves the whole roster. - **Mention semantics:** unchanged for tagged mentions and plain text. Only identity-link pills change, from the written label to the key's resolved name. - **Composer:** names that differ only under Unicode folding (`ſ`/`s`, `µ`/`μ`, final `ς`/`σ`) are now one name when matching typed text, so a typed one between two such members asks for a pick instead of silently choosing one. Picked chips are unaffected. --------- Signed-off-by: Tom Brow <tomb@block.xyz> Co-authored-by: studio <dc2fc481343672df31a689840c09299972e704dac592e0da6f18486646a7ee3e@buzz> |
||
|
|
8a3912f151 |
fix(mobile): fence notification replies by the clock and settle ones whose community is gone (#9668)
Follow-up to #9439 (iOS notification reply), which merged before these non-blocking review points landed. - **Publish fence checks the clock.** `mayPublish` now compares `DateTime.now()` with the publish deadline as well as the timer flag, before and after writing the publishing mark. After a suspension, a pending lookup can finish before the overdue timer callback runs; without the clock check the reply could publish past its deadline, after iOS already showed "Reply not sent". - **A recovered reply whose community is gone settles.** If the community was removed, or the user signed out, before the relaunch, `_keepDraft` used to throw, so the reply stayed in the native journal (with its text in `UserDefaults`) and was retried on every launch. It now keeps no draft and the reply is settled as not sent. - **Doc fix:** `SendMessage`'s `mayPublish` is asked after signing and after the optimistic local message is shown; the doc now says so. - **Test fix:** the resume test asserts the EVENT frame reached the original socket before `onAppResumed`, so the injected OK can't pass it on its own. ### Regressions None expected. The clock check can only refuse a publish the timer would also refuse moments later. A recovered reply for a missing community now drops its text instead of keeping it forever in a journal no launch can drain; there is no community left to show it in. ### Validation - [notification_reply_test.dart](https://github.com/block/buzz/blob/notification-reply-fence-followup/mobile/test/features/channels/notification_reply_test.dart): the recovered reply for a missing community now expects to be settled. - [relay_reconnect_resume_test.dart](https://github.com/block/buzz/blob/notification-reply-fence-followup/mobile/test/shared/relay/relay_reconnect_resume_test.dart): asserts the EVENT frame before resume. --------- Signed-off-by: Tom Brow <tomb@block.xyz> Co-authored-by: studio <dc2fc481343672df31a689840c09299972e704dac592e0da6f18486646a7ee3e@buzz.block.builderlab.xyz> Co-authored-by: studio <dc2fc481343672df31a689840c09299972e704dac592e0da6f18486646a7ee3e@localhost> |
||
|
|
2c21174c51 |
perf(mobile): stop measuring every character of long drafts on iOS (#9825)
On iOS, a long draft in the message composer could freeze the app. In one case the main thread was blocked for 72 seconds. Flutter's stylus handwriting support (Scribble) is on by default in every iOS text field. After each frame whose text layout changed, it measures the field's text one character at a time, so iOS knows where each character sits on screen. Every measurement walks the paragraph's lines, so one pass costs time proportional to the square of the draft's length, and it runs again after every keystroke. Every sampled stack in the hang reports sits in `EditableTextState._updateSelectionRects` → `RenderEditable.getBoxesForSelection` → `getBoxesForRange`. iOS also uses those character positions for the keyboard trackpad's two-finger selection (hold Space, add a second finger, drag). So this keeps handwriting on for drafts up to 2,000 characters and turns it off past that, on iOS only, in the two fields where messages are written: the composer and the message edit sheet. Android never takes these measurements, so it keeps stylus handwriting at any length. The edit sheet rebuilds only when its draft crosses the cutoff, not on every keystroke. Whenever a draft crosses the cutoff, any open iPad Scribble writing gap is closed first, because Flutter ignores iOS closing it once handwriting is off. This holds even when the field no longer has focus, since iOS can close the input connection itself (for example on keyboard dismiss) without Flutter removing the gap. At 2,000 characters a pass should cost under a millisecond, extrapolating from the measurements below (cost grows with the square of the length). ### Validation One handwriting measurement pass in the running app (iPhone 17 Pro simulator, debug build), timed in-app with a draft of `the quick brown fox jumps over` lines: | Draft length | Before | After | | --- | --- | --- | | 23,250 chars | 100 ms | 0 ms | | 46,502 chars | 360 ms | 0 ms | | 93,000 chars | 1,376 ms | 0 ms | Before the fix, this cost was paid on every keystroke. Release builds on older phones run slower than the simulator on this Mac. - Added test: [iOS measures each character only of shorter drafts](https://github.com/block/buzz/blob/brow/mobile-text-layout-hang/mobile/test/features/channels/compose_bar_test.dart) checks that a short draft still sends iOS its character rectangles, a draft past the cutoff clears them (iOS would otherwise keep the shorter draft's), and shortening it again restores them. It also checks that a draft crossing the cutoff while the composer doesn't have the keyboard sends nothing, since iOS applies the clear to whichever field is focused. - Added test: [iOS closes a Scribble writing gap when a draft gets long](https://github.com/block/buzz/blob/brow/mobile-text-layout-hang/mobile/test/features/channels/compose_bar_test.dart) opens a writing gap, pushes the draft past the cutoff, then sends iOS's own close, and checks that no gap is left in the draft. - Added test: [Android starts stylus handwriting in a long draft](https://github.com/block/buzz/blob/brow/mobile-text-layout-hang/mobile/test/features/channels/compose_bar_test.dart) checks that a stylus tap still starts handwriting past the cutoff on Android. - Added test: [iOS closes a Scribble writing gap left after losing focus](https://github.com/block/buzz/blob/brow/mobile-text-layout-hang/mobile/test/features/channels/message_edit_sheet_test.dart) opens a writing gap in the edit sheet, has iOS close the input connection, then pushes the draft past the cutoff (as a late paste would) and checks that no gap is left. - Added test: [iOS turns stylus handwriting off only while the edit is long](https://github.com/block/buzz/blob/brow/mobile-text-layout-hang/mobile/test/features/channels/message_edit_sheet_test.dart) opens the edit sheet on a long message and shortens it. - Automated app run on the simulator, signed in to a test community: typed in the composer, used the edit menu (Select All, Paste), sent a message, then edited it in the edit sheet and saved. ### Regressions - In iOS drafts over 2,000 characters, the keyboard trackpad's two-finger selection and Apple Pencil handwriting stop working, and iOS may place its autocorrection highlight at the field's corner instead of over the word. Ordinary cursor movement with the trackpad, selection handles, the edit menu, dictation and typing are unaffected. - If a paste pushes a draft past the cutoff and undo brings back the exact earlier text, Flutter skips resending the unchanged rectangles, so iOS has none until the next edit or until the field scrolls (which a long round trip usually does). Flutter offers no public way to force the resend. - The channel description and create-agent Instructions fields can also hold long pastes and still pay this cost on iOS. They aren't in the hang reports, so they're left for a separate change. --------- Signed-off-by: Tom Brow <tomb@block.xyz> Co-authored-by: studio <dc2fc481343672df31a689840c09299972e704dac592e0da6f18486646a7ee3e@buzz.block.builderlab.xyz> |
||
|
|
f9b18c7f3a |
Cache recently opened mobile channel pages (#9809)
## What changed Previously opened channels can show their newest saved page after a cold launch, including offline. The same timeline provider combines the saved page with live edits, deletions, and optimistic sends. When the relay has loaded history, its timeline takes over and older-page navigation becomes available. The chat labels saved messages until relay history takes over. If a connected refresh fails, the chat offers Retry and keeps the saved-message label visible during the retry. - Keep verified relay events in a disposable, app-private SQLite cache per community and signing identity on iOS and Android. Close SQLite connections after each operation. - Cap the main file at 45 MiB to leave room for a rollback journal within the 100 MB per-community limit. Evict least-recently opened pages and retry once when SQLite reaches the physical limit. - Omit an oversized relay page as a whole so the cache cannot show a message without an edit or deletion from the same response. Keep readable pages available when only the recency write fails. - Purge on leave, deletion, explicit channel access refusal, and writer-confirmed loss of a known membership. Expired sessions leave the cache intact. SQLite secure deletion clears removed payloads after commit. A durable marker covers interrupted purges. Account switches and removal retire old saves. - Keep message-link lookups valid across the first connection. An access refusal still discards a late result. - After a confirmed leave or delete, record a durable cache purge before refreshing the channel list. Disk cleanup runs in the background and the refresh skips redundant writer confirmation for that channel. - For joined, unarchived channels, remove stale saved rows on channel-tagged deletions or edits the app receives while the conversation is closed. Reuse deletions from the existing reconnect catch-up. - Give an already-connected relay one 250 ms head start before reading the saved page. Offline opens start the read immediately. ## Screenshots and timing [iPhone 17e simulator captures](https://github.com/block/buzz/pull/9809#issuecomment-7050704433) show the same seeded chat before the cache, with saved messages while offline, and after the relay returns. In the debug capture run, the baseline `9c0bcd623` showed no messages within 8 seconds. The updated build `2cb28eda` showed the target saved message **752 ms** after the tap. For a first online open on the same simulator, the baseline and the instrumented `2cb28eda` build took **449 ms** and **441 ms** median from tap to target message. Each build had four measured opens after one warm-up. The ranges were 437–481 ms and 414–447 ms. In the earlier paired debug simulator experiment on `6e113d83`, the 250 ms preview delay reduced median first online open from **507 ms to 452 ms** across 15 measured opens per build. In the delay build, seeded offline opens took **488–557 ms** across the two channel medians, and reopens in the same app session took **174–245 ms**. All 20 offline opens and reopens showed the target message. ## Verification - The mobile pre-push gate and file-size check passed for `6650ebad`. Regression tests cover oversized pages, session expiry versus channel revocation, live mutations during preview, paging after relay history loads, writer-confirmed membership loss, closed-chat edits and deletions, the saved-message label across Retry and history takeover, links held across first connect, and interrupted or overlapping purges. - The host SQLite probe interrupted eviction, relay-key rotation, and a synthetic table rewrite. All three reopened with a clean integrity check. The largest observed database and journal footprint was 93.84 MB. - Physical iPhone suspension, airplane-mode reopen, and profile-mode timing are pending. ## Try it 1. While connected, open a populated channel and let its newest page save. 2. Force-quit, turn on airplane mode, and reopen the same channel. The saved page should appear. 3. Reconnect. The relay's newest page should take over without duplicating messages. A saved page can still show stale rows while the phone stays offline, for a live edit missed while the app was stopped, for an archived or unjoined public channel, or for a NIP-09 deletion without a channel tag. Reconnect catch-up covers the deletions returned by its bounded unread query. A direct online open refreshes the page. Offline thread replies are separate follow-up work. --------- 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: Rocket <0c41329ade659e01801116549bc617351689892a382bc864a1186dc9191293a7@buzz.block.builderlab.xyz> Co-authored-by: Mantis <530af7635ef7d0e1a5189d234338db88cb4ef1ede7119b4ebb4fb05c3eafe3b1@buzz.block.builderlab.xyz> Co-authored-by: Tom Brow <tomb@block.xyz> Co-authored-by: studio <dc2fc481343672df31a689840c09299972e704dac592e0da6f18486646a7ee3e@localhost> |
||
|
|
5f80ee1968 |
fix(mobile): keep Move to section working after the actions sheet closes (#9814)
Move to section has been failing on mobile: choosing a section, creating
a new one, or removing the channel from its section throws a
`StateError` ("Using ref when a widget is about to or has been
unmounted") and the channel stays where it was.
- **Disposed ref.** The section picker opens from the channel actions
sheet, which closes first. The picker read and wrote sections through
that sheet's `WidgetRef`, which is disposed by the time the user taps a
row. It now uses the page's `ProviderContainer`, which it already used
to listen for desktop's layout lock. Channel details passed its own
`ref` the same way and now goes through the same path.
- **New section never filed the channel.** It created the section, then
looked it up by name in the provider's state, which local edits only
reached after a relay round trip. The notifier now creates the section
and files the channel in one call, by the new section's ID, so a second
section with the same name can't catch it either.
- **Local edits show at once.** `createSection`, `assignChannel` and
`unassignChannel` now emit the notifier's state right away, as
`deleteSection` already did, so a picked or removed channel moves in the
sidebar immediately instead of after the relay echoes the edit.
- The New section dialog disposed its text controller while still
animating out; the dialog now owns its controller.
### Validation
- [Move to section
journey](
|
||
|
|
47b00c0b8b |
fix(mobile): keep error names in Add Members failure text (#9834)
## Summary
When adding members fails, the Add Members sheet shows each member's
error. The text came from `error.toString().replaceFirst('Exception: ',
'')`, which removes the first `Exception: ` anywhere in the text, not
just a leading one. So a relay ACK timeout read "TimeoutEvent <id> not
acknowledged within …" instead of "TimeoutException: Event <id> not
acknowledged within …".
Now a plain `Exception: ` prefix is removed only where it starts the
text or follows a wrapping error's `: `. A relay rejection still shows
as "restricted: …", and an add lost when the app goes to the background
reads "Connection lost before the relay acknowledged the event: App
moved to background" without a nested "Exception: ". Named types such as
`TimeoutException` keep their whole name.
## Validation
- New row in `channel_management_provider_test.dart`: `addMembers` with
one member whose add times out, one the relay rejects and one lost when
the app goes to the background. It checks each text in the
`AddMembersException`.
No screenshots: the change only affects the error text after a failed
add, which can't be triggered on demand against a real relay.
Full-app run on an iOS simulator (signed in, healthy relay): cold start
and session restore, channel list, opening channels and a DM with
history scrolling, channel details and the members list, Add Members
(picker, search, cancel), Settings, and background then foreground. All
passed with no new errors in the device log.
---------
Signed-off-by: Tom Brow <tomb@block.xyz>
Co-authored-by: studio <dc2fc481343672df31a689840c09299972e704dac592e0da6f18486646a7ee3e@localhost>
|
||
|
|
58695fe376 |
acceptance: read the probe key from a file; dial a connect address (#9773)
## Summary Follows https://github.com/block/buzz/pull/9771 (merged), which added the acceptance CronJob. Some NIP-FI issuers bind each key to one identity. A deployment that mints a new identity for each run then needs a new key for each run, written next to the assertion before the probe starts. The probe could only take its key from an argument or the environment, which a Kubernetes init container can't set. - **Probe:** `--private-key-file` (`BUZZ_PRIVATE_KEY_FILE`) reads the key (hex or nsec) from a file. It conflicts with `--private-key`. - **Shared read:** the key file and the assertion file use one bounded reader, `acceptance::read_secret_file`. It needs a regular, non-empty file under a size cap. - **Report:** the JSON report now includes `pubkey`, the hex key the probe ran as. An operator can match a run to the identity that was minted for it. - **Chart:** `acceptance.privateKeyFile` is passed as `--private-key-file`, not as an env var, so a probe that predates the flag fails instead of running with a new key. Exactly one of it and `acceptance.privateKeySecret.name` must be set; rendering fails with neither or both. - **A new key per run needs an agent assertion** (`nip-fi-agent+jwt` whose `nostr_owner_pubkey` is a relay member). A members-only relay refuses a new person key, and an open relay joins it to every auto-join channel. The README and `values.yaml` say so. - **Connect address:** `--connect-addr` (`BUZZ_ACCEPTANCE_CONNECT_ADDR`) dials a plaintext `host:port` for every WebSocket connection and for the NIP-11 fetch, for a probe that can't reach the relay's public host. The relay URL still sets the `Host` header, the NIP-42 relay tag and the NIP-11 `Host`, so the relay serves the same community. On that path, NIP-11 uses no proxy, follows no redirect and requires a 2xx answer. The chart passes `acceptance.connectAddr` as `--connect-addr`, not as an env var, so a probe that predates the flag fails the run instead of checking the public URL. The default is empty. `NostrWsConnection::connect_to_addr` now takes upgrade headers, so the NIP-FI assertion goes on this path too; loadgen passes none. (Folded in from #9830.) - **Chart version 0.1.13** with an `artifacthub.io/changes` entry. It publishes the acceptance CronJob from #9771, the key file and the connect address. - **Follow-up test from the #9767 review:** the fake relay gets an `accept_mismatched` setting, and `access_control_fails_when_the_relay_accepts_another_keys_write` expects `access_control` to fail at `pubkey_mismatch_rejected`. A `pubkey_mismatch_rejected` stage that always returns Ok now fails a test. ## What got simpler The assertion reader's inline bounded read is now the shared `read_secret_file`, so both secret files follow one rule instead of two copies of it. The probe's four connection call sites now share one `open` helper, and `connect_to_addr` reuses the same `upgrade_request` path as `connect_with_headers`. ## Testing - `e2e_acceptance`: `the_binary_authenticates_with_the_key_from_its_key_file` passes against a live relay with the key path in `BUZZ_PRIVATE_KEY_FILE` (the same clap argument as `--private-key-file`). It checks that the report's `pubkey` is the file's key, so a probe that ignored the file and made a new key fails. - `e2e_acceptance`: `the_binary_exits_2_when_it_cannot_run` covers a bad key, a bad key file, a missing key file, and both key flags at once. Each exits 2 with no report and no metrics. - Existing unit tests cover the shared reader through the assertion file (missing, empty, oversized, directory, FIFO). - `connect_addr_dials_the_address_and_keeps_the_relay_url`: the probe runs at an unresolvable `wss://relay.invalid` with the fake relay's address. Every upgrade has `Host: relay.invalid` and the assertion's bearer header, and every AUTH relay tag is `wss://relay.invalid`. - `nip11_goes_to_the_connect_addr_with_the_relay_host` (`GET /relay?route=probe`, `Host: relay.invalid:8443`) and `nip11_at_the_connect_addr_does_not_follow_a_redirect` (a 301 fails `nip11` with no version). - `caller_user_agent_replaces_default` now covers `connect_to_addr` too. - `tests/acceptance_test.yaml`: `acceptance.connectAddr` renders `--connect-addr <addr>` in the args, and the default args do not have it. The key file renders as `--private-key-file <path>` in the args, with neither `BUZZ_PRIVATE_KEY_FILE` nor `BUZZ_PRIVATE_KEY`, a Secret plus a file fails, and no key source fails. 🤖 Generated with [Claude Code](https://claude.com/claude-code) buzz-review-completed --------- Signed-off-by: Elrond <28d6302a099e5225b02c4155ac4236e4912603df2ab08dbfc2f4fef08ce598c8@buzz.block.builderlab.xyz> 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>chart-v0.1.13 |
||
|
|
7080811831 | docs: add VISION_GOVERNANCE for community-governed git (#9618) | ||
|
|
2074adaa85 |
fix(mobile): bring @mention typing in line with buzz-app (#9699)
## Summary The mobile composer's @mention typing was an older port of the mention rules that [block/buzz-app](https://github.com/block/buzz-app) follows (`src/bundled/mentions/README.md` there), and it trailed buzz-app in nine places. Most of them came from one difference: mobile tied a picked person to the `@Label` text and looked for that text again at send time, while buzz-app keeps the recipient on an atomic chip. Several of the gaps meant a picked person was silently not notified. This PR fixes all nine. Every change is in `mobile/`; no relay, CLI or desktop code is touched, and the event payloads mobile writes keep the same shape. ### Commits | Commit | Fixes | What it changes | |---|---|---| | |
||
|
|
930fd29f48 |
deploy: run buzz-acceptance from the relay image as a chart CronJob (#9771)
## Summary Builds on #9767 (the `buzz-acceptance` binary, now merged). Based on main. - **Image:** the relay image now carries `buzz-acceptance` next to `buzz-admin` and `buzz-pair-relay`, so no new image or workflow is needed. - **Chart:** `acceptance.enabled=true` adds a CronJob that runs the probe from the relay image. - Requires `image.tag` or `image.digest`. The chart fails to render without one, because the default `Chart.AppVersion` image has no probe. - Every 5 minutes by default, `concurrencyPolicy: Forbid`, `backoffLimit: 0` (a retry would hide a failure), `activeDeadlineSeconds: 240`. - Runs with `acceptance.serviceAccountName` or the namespace default, never the relay's service account. No token mount, no service links. - `acceptance.relayUrl` (defaults to `relayUrl`), `acceptance.stageTimeoutSeconds`. - `acceptance.privateKeySecret.name` is required. Without a key the probe would sign with a new key each run: a members-only relay refuses it, and an open relay joins each new key to every auto-join channel. - `acceptance.statsdAddr` sends DogStatsD metrics. `$(HOST_IP)` expands to the node IP, for a node-local agent. - Every series carries `probe_revision`, the probe's own image (`image.digest`, else `image.tag`), plus `acceptance.tags`. It does not identify the relay build a run reached: during a rollout, or with `acceptance.relayUrl` set, the probe can reach another build. `acceptance.tags` keys must be canonical (lowercase `[a-z0-9_./-]`, starting with a letter, not ending in `_`), so the probe-owned and repeated-key checks see the key Datadog stores. - NIP-FI: minting an assertion is deployment-specific, so the chart takes it as a file. `acceptance.extraInitContainers`, `extraVolumes` and `extraVolumeMounts` let an init container write it, and `acceptance.assertionFile` points the probe at it. These follow the existing relay Pod extension points. - **README:** a new "Acceptance probe" section with an example. The example gives the minter init container the key Secret, keeps credentials in a memory `emptyDir`, and says how to size `activeDeadlineSeconds` against `stageTimeoutSeconds`. - **Chart version:** bumped once at the top of the stack, in https://github.com/block/buzz/pull/9773 ## What got simpler The chart no longer has a "no key" mode, so there is one way to give the probe its identity. The probe reuses the relay image and the chart's existing CronJob, image-identity, label-guard and extension patterns, so it adds no new image, no new publish workflow, and no new extension concept. ## Testing - `tests/acceptance_test.yaml` (helm-unittest): off by default; the default render (relay image, `relayUrl`, no key, no metrics, no extra volumes); a full render with a key Secret, metrics, tags, a digest-pinned image, and an init-container-minted assertion; the chart-owned Datadog version label; the required image tag or digest; `probe_revision` from the probe's image even with another `relayUrl`; no service account inheritance or token mount; and rejection of a missing probe key (also with an assertion file), a tag without a key, an uppercase tag key, a tag key with a space or a trailing `_`, a probe-owned tag key, a repeated tag key, and a chart-owned pod label. The init-container test pins the full `initContainers`, `volumes` and `volumeMounts`. - CI builds the relay image from the changed `Dockerfile`. - A kind run installed the chart and ran one Job against the in-cluster relay: exit 0, all checks passed, no service account token. That run had no key, no assertion and no statsd, so the key and assertion wiring is covered by the render tests above only. ## Follow-ups (not in this PR) - Relay build attribution: the relay does not expose its build id on a public surface yet, so a run can't name the relay build it reached. A deploy gate on these metrics stays report-only until it can. - A canary run against the Rollout's canary Service needs a dial override that keeps the canonical Host (see #9767). 🤖 Generated with [Claude Code](https://claude.com/claude-code) 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> |
||
|
|
af8287d961 |
Fail CI on new triggers, functions, rules and foreign keys (#9812)
## Summary Migrations up to `0104` dropped every trigger, function and foreign key. `docs/database.md` Rules 1 and 2 forbid adding them back, but nothing enforced that. This PR adds the guard. - **Migration lint.** `migrations_after_retirement_add_no_triggers_functions_or_foreign_keys` scans each migration numbered after `0104`. It fails on `CREATE [OR REPLACE] FUNCTION | PROCEDURE | TRIGGER | RULE`, `CREATE CONSTRAINT TRIGGER`, `CREATE EVENT TRIGGER`, `REFERENCES` and `FOREIGN KEY`, outside `--` comments. The error names the file and line, for example `migrations/0105_probe.sql:2: CREATE OR REPLACE FUNCTION`. Nested `/* */` comments are skipped. Quoted identifiers and string values are data, except a string passed to `EXECUTE` or `format(`. Each dollar-quoted body is scanned as SQL up to its closing delimiter, so DDL run through `EXECUTE` in a `DO` block is caught, and an apostrophe inside `$$...$$` cannot hide the rest of the file. It runs in the infra-free `buzz-db --lib` unit lane. - **Schema file check.** `desired_state_schema_layout_is_complete_and_schemabot_shaped` allows `schema/` files only under `tables/public/`, `types/`, `partitions/` and `seeds/`, and runs the same scan on every file. A `functions/` or `triggers/` file, or an inline `REFERENCES` in a table file, fails it. - **Catalog check.** `admin_schema_parity_between_desired_state_and_migrations` now asserts that both bootstrap paths (pgschema + reconcile, and all migrations) have zero non-internal triggers, event triggers, `public` functions and procedures, rules and foreign keys. Extension members (pgcrypto) are excluded. No allowlist is needed: main with all 104 migrations applied has none of these objects. Main now has `0105`, which passes the lint. Open PRs that add a migration only need to renumber to `0106` or later. The two open ones (https://github.com/block/buzz/pull/9621 and https://github.com/block/buzz/pull/9690) add no forbidden object. ### What got simpler - The parity test's per-table trigger comparisons (`events`, `event_mentions`, and the five tables `0096` unguarded) and its separate foreign-key check are replaced by one zero-object assertion. - The scoped-key lint no longer parses foreign keys. None may exist, so checking that they lead with `community_id` is dead logic. - `schema/schema.sql` drops its empty `-- functions` and `-- triggers` sections. Its header and `docs/database.md` stop describing `functions/` and `triggers/` directories that no longer exist, and the doc's "remaining triggers stay as a backstop" text now says they are gone. ### Checklist (`docs/database.md`) - [x] Phase: none. Test and docs change only. No migration and no runtime code. - [x] No trigger, function, procedure, rule or foreign key is added. - [x] No migration mutates rows. - [x] Rule 4 locations: no schema change. `schema/schema.sql` changes only comments. ### Related issue None found. ### Testing Run on a Linux workstation with PostgreSQL 17 at `b7254f90`, before the review fixes. CI passed with the first review fixes at `0fed6b1b`. `9749e618` adds dollar-quote, nested `EXECUTE $tag$` and `$1` cases to `schema_object_lint_reports_each_construct_with_its_line`, and CI checks it. - `cargo fmt --check` and `cargo clippy -p buzz-db --all-targets -D warnings`: pass. - `cargo test -p buzz-db --lib` and `cargo nextest run -p buzz-db --lib`: 223 passed. - `scripts/postgres-test-run.sh` for `admin_schema_parity_between_desired_state_and_migrations`, `migrated_catalog_retires_universal_fences_but_keeps_deletion_guards` and `pgschema_reapply_keeps_runtime_partitions`: 3 passed. - Proof the lint can fail: a temporary `migrations/0105_probe.sql` with a function and a `REFERENCES` column fails the lint with `migrations/0105_probe.sql:2: CREATE OR REPLACE FUNCTION` and `migrations/0105_probe.sql:3: REFERENCES`. - Proof the catalog check can fail: a temporary `0105` that creates `probe()` fails the parity test with `the migrations leave a trigger, function, rule or foreign key`, `left: ["function probe()"]`. - The catalog on main at `9c0bcd62`, with all 104 migrations applied through psql, has no triggers, functions, foreign keys, rules or event triggers. 🤖 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> |
||
|
|
bc0b552894 |
fix(mobile): report failed reaction publishes instead of throwing (#9813)
Tapping a reaction while the relay is disconnected threw an uncaught `RelayNotConnectedError` (a `StateError`) from `RelaySessionNotifier.publish`, reported by Sentry from 1.5.0 builds. Every reaction call site fires `addReaction` or `removeReaction` without awaiting it, so any publish failure escaped as an unhandled error and the pill just didn't change. Now each of those call sites (pill taps, the `+` picker, the long-press quick-reaction row and grouped system rows) hands its publish to `reportReactionFailure`, which shows an error notice. It's a toast drawn above any Flutter route or sheet, including the Android reaction details sheet. While the native iOS reaction details sheet is open, that sheet shows the notice itself as an alert, since UIKit covers Flutter's overlay: - "Couldn’t add reaction. No connection." (or "remove") when the relay isn't connected; - "Reaction not confirmed. Connection lost." or "… The relay didn't respond." (or "Removal not confirmed. …") when the acknowledgement was lost or late, since the relay may have accepted it; - nothing for the relay's `duplicate:` reply to a reaction you already have (a double tap, or re-picking it from the picker), which is a success; - "Couldn’t add reaction. Try again." for anything else. Errors that aren't relay outcomes (for example the signer failing) still escape afterwards with their stack, so the uncaught-error handler reports them as before. | Before (offline tap) | After (offline tap) | | --- | --- | | <img alt="before" src="https://github.com/user-attachments/assets/7745ec5b-8f54-41a2-ba3d-b8dd599f127c" width="300"> | <img alt="after" src="https://github.com/user-attachments/assets/066fba0b-9580-4250-966e-cd0b99831ecc" width="300"> | ### Regressions - Successful reactions behave exactly as before: the UI still doesn't await the publish, and the notice only appears on failure. - Removing a reaction from a grouped system row publishes every deletion at once as before, and shows at most one notice if any fail. - Unexpected local errors reach diagnostics just as they did on main. - No new state or retries: a failed reaction isn't queued. It's reported instead of thrown. ### Validation - Added tests in [`reaction_row_test.dart`](https://github.com/block/buzz/blob/fix-reaction-publish-stateerror/mobile/test/features/channels/reaction_row_test.dart): offline add and remove, a lost ack, a duplicate and an unexpected signer failure, each with the notice it should show (or none), and whether the error escapes; plus a failed toggle from the reaction details sheet on Android and iOS. - Simulator run (iPhone 17 Pro, signed in to a Builderlab community, in a QA chat): add and remove online through the long-press quick-reaction row, the `+` picker and the reaction details sheet. The before and after captures come from builds that force reaction publishes to fail as if offline (the simulator can't drop its own network). The after build shows the toast once the quick-reaction sheet has closed. - A failed removal from the reaction details sheet shows its notice above the sheet, which stays open. Widget tests cover the Flutter sheet and the native-sheet `notice` call; a simulator run with a build that forces removals to fail showed the native alert on the iOS sheet: After: failed removal in the native reaction details sheet https://github.com/user-attachments/assets/b8d808f0-e86b-411f-82c0-c3d19a51b231 --------- Signed-off-by: Tom Brow <tomb@block.xyz> Co-authored-by: studio <dc2fc481343672df31a689840c09299972e704dac592e0da6f18486646a7ee3e@buzz.block.builderlab.xyz> |
||
|
|
0636d21479 |
feat(mobile): report push gateway replies the app cannot read (#9806)
Reports push gateway replies the app cannot read, the last explicit
error report from [the diagnostic reporting
spec](https://github.com/block/buzz/blob/main/docs/mobile-diagnostic-reporting.md)
still missing.
The gateway is called from native code (`BuzzDevPushEnrollmentDriver`),
and Dart used to see every native failure as one code. Native now fails
with its own `gateway_response_invalid` code when a reply does not match
the gateway's protocol (bad JSON, a 2xx status other than the one the
gateway sends for that call, or a challenge, installation or delegation
reply with missing or invalid fields), carrying no text from the reply.
Dart reports that as a push gateway response error and rethrows as
before.
- **Not reported:** status mismatches (including 4xx and 5xx), timeouts
and offline failures, which the spec counts as routine; local-state
failures such as an App Attest key mismatch; and a plausible challenge
that has already expired by the device's clock, since a phone whose
clock runs fast would otherwise report on every retry. An expiry no real
challenge could have (zero, negative or a relative TTL) is still
reported. Local enrollment logs keep the fixed name of the failing
route.
- **Attribution:** the report goes through the signing member, so an
enrollment that finishes after a community switch names no one else.
## Validation
- `push_bridge_test.dart`: an unreadable reply is reported once and
enrollment still fails; routine native codes report nothing.
- `BuzzDevPushEnrollmentDriverTests`: bad JSON and an unexpected 2xx
fail as an unreadable reply; a 503 stays a status mismatch; a plausible
but expired challenge is not an unreadable reply, while an expiry of 0,
-1 or 300 is.
- `notification_toggle_test.dart`: an unreadable reply during the
notification journey files one report while the member matches and none
after it changes.
Full-app run on an iPhone 17 Pro simulator at
|
||
|
|
ec1b786ef0 |
fix(mobile): diagnostic reporting follow-ups (#9808)
Follow-ups to the mobile diagnostic reporting work in
docs/mobile-diagnostic-reporting.md.
## Changes
- **Install ID repair:** if the install ID file holds something that
isn't text, the app now replaces it with a new ID, as it already does
for an empty file. Before, every report went out without an install ID.
A read that fails (for example, no file descriptor free) still keeps the
file, so a passing error never replaces a good ID.
- **Clock-window refusals are not reported as errors:** the spec treats
relay refusals for a timestamp outside the relay's clock window as
expected (counting them is still pending). The app only recognized one
of the relay's wordings ("timestamp too far from server time"), so
refusals for canvas events, relay-admin commands, leave requests and
observer frames were reported as invalid requests. The five wordings are
matched from the start of the reason, so unrelated `invalid:` reasons
that mention a timestamp, such as the feedback timestamp overflow or one
that echoes a value, are still reported.
- **Diagnostics card:** rows get subtitles, and the divider indent
matches the neighbouring Settings cards.
- **Comments:** explain why push stop gates its current-identity request
on the community key, and correct a test comment about who drops a
repeated error object.
## Validation
New tests cover:
- member attribution on relay sessions, including a missing key and an
answer that arrives after the member changed;
- push stop reports while signed out;
- reporter wiring for hosted admission and the self-hosted probe;
- frames the socket can't decode;
- a table of relay refusal reasons, each either reported or not, for
both `OK` and `CLOSED`;
- an install ID file whose reads fail keeps its ID.
Full-app run on an iPhone 17 Pro simulator at
|
||
|
|
792a9ce563 |
feat(relay): list and revoke invite links (#9680)
Stack: this PR → #9690 ## What this does Adds listing and revocation for v2 invite links, and makes every reader of an invite's expiry accept a missing value. - **`GET /api/invites?limit=&before=`** lists the community's v2 invites, newest first: id, creator, created/expiry/revoked times, uses and a computed `status` (`active`, `revoked`, `expired`, `exhausted`). Owner/admin only. The NIP-98 signature covers the full URL including the query. `limit` defaults to 50 (max 200). `next_before` is an opaque cursor holding the last row's `created_at` (microseconds) and id, so paging doesn't depend on that row still existing. - **`POST /api/invites/revoke`** takes exactly one of `{"id": "<uuid>"}` or `{"code": "v2...."}`. The code is hashed and looked up only inside the request's community. v1 and malformed codes get `400 invite_not_revocable`; an invite not in the community gets 404. Revoking twice returns the first `revoked_at`. Members who already joined stay. - **Authorization.** Mint, list and revoke share one HTTP admission helper (tenant bind → NIP-98 via NIP-FI → replay → membership/ban → NIP-OA owner link → role gate). Revoke's final decision is made in the write transaction, in the same order as mint: admission lock → actor's role row `FOR SHARE` → restriction check → invite row `FOR UPDATE`. Owners and admins can revoke any invite; any other member only one they created. A removed or restricted actor is refused. Mint now uses the same role-lock helper. - **Mint response** now includes `invite_id`. - **Nullable expiry readers.** Claim, list, the mint response and operator mint treat a missing `expires_at` as "never expires". The column is still `NOT NULL` here. - **Secrets.** No list/revoke response or access-log line contains a code or its hash; request errors are fixed strings that never echo input. Revoke logs only `invite_id`. A revoke the database refuses is logged as denied with its reason. ## Deploy order A follow-up PR adds links that never expire (`expires_at` nullable). **It depends on this PR being deployed everywhere first**, so every serving relay can read a missing expiry before one is written. ## Tests - DB (`relay_invite/manage_postgres_tests.rs`): revoke by code targets exactly one of two near-identical invites, idempotent revoke, community scoping, creator demoted to member can revoke theirs, a member who didn't create it is refused, a removed creator is refused, a restricted admin is refused, a demotion holding the role row or a restriction holding the admission lock makes revoke wait and then refuse with the row unchanged, a paused claim and a revoke serialize with the member kept, revoke is refused while the community is quiescing, paging survives deleting the cursor row, and a row with no expiry is listed, claimed, kept by the reaper and revocable (on a scratch database with `NOT NULL` dropped). - Relay (`invites/postgres_tests/manage_tests.rs`): list/revoke by id and code end to end, no code or hash in responses, member/non-member refusals, bad selectors, other-community lookups, query-string signature binding, malformed requests not echoing a code in responses or access logs, refused revokes logged as denied, and replayed list/revoke requests refused. --------- Signed-off-by: Will Pfleger <wpfleger@block.xyz> Co-authored-by: Duncan <dcfd242e557282d7a1e2cf2e6877522682f1e5c6156dc92ca7d90eaedd3b0f95@buzz.block.builderlab.xyz> |
||
|
|
81b4054e5d |
fix(push-gateway): answer 429, not 404, when the delivery quota is exhausted (#9803)
When an endpoint's delivery quota is exhausted, both authority stores
returned `AuthorityError::Rejected`, so `/v1/deliveries` answered `404
invalid_grant`. NIP-PL already specifies `429 {"error":"rate_limited"}`
for this case.
The 404 matters because the relay treats a 404 on a retry attempt as a
terminal replay and completes the wake, so a throttled wake was silently
dropped. On a first attempt it failed the wake. A 429 takes the relay's
existing retry-with-backoff path instead.
### Change
- Memory and Postgres stores return `RateLimited` on quota exhaustion.
`http.rs` already maps that to `429 rate_limited`.
- The rate-limited attempt still charges no quota and consumes no
auth-event or request-id fence, so the relay's retry with the same
request id is admitted once the window reopens.
- No doc change: NIP-PL and the deployment doc already describe 429.
### Validation
- Memory store: an exhausted quota returns `RateLimited`, leaves replay
rows and the quota counter unchanged, and the same auth event and
request id are admitted after the window.
- Postgres (ignored test, run locally against a temporary database): the
quota-ceiling race test now also asserts the loser is `RateLimited`.
- HTTP: the eleventh delivery under a quota of ten answers `429
{"error":"rate_limited"}` and reaches no transport.
- With the two store lines reverted, all three tests fail.
### Regressions
None expected. Only the quota-exhaustion result changes; grant,
authority and replay failures still collapse to `404 invalid_grant`.
---------
Signed-off-by: Tom Brow <tomb@block.xyz>
Co-authored-by: studio <dc2fc481343672df31a689840c09299972e704dac592e0da6f18486646a7ee3e@buzz.block.builderlab.xyz>
|
||
|
|
e21606bf96 |
feat(cli): leave archived identities out of users get --name (#9752)
`buzz users get --name` now leaves out identities on the relay's NIP-IA archive list. `--include-archived` brings them back, each marked `"archived": true`. `--pubkey` lookups always return the profile and mark it when archived. - The list is read by `fetch_archived_snapshot`, the same reader as `buzz agents archived`, so only a kind:13535 event signed by the relay's NIP-11 `self` key (with the NIP-70 tag) counts. A profile that sets its own `archived: true` is not marked unless the signed list names it. - Fail open: if the list can't be read, can't be verified, or takes longer than 5s, results come back unfiltered with a JSON warning on stderr. The search never fails because of it. - Name searches and `--pubkey` lookups read the profiles and the archive list in parallel. A profile error returns at once as the usual single JSON error, without waiting for the archive read or printing its warning. `--owner` with no matching agents returns `[]` straight away. - Documented in the CLI README. Out of scope: the relay and `send`/`dm`. Related: [buzz-app#4021](https://github.com/block/buzz-app/pull/4021) --------- Signed-off-by: Will Pfleger <wpfleger@block.xyz> Co-authored-by: Hayt <211b96e6a2b7f45fd4047988976c7bbbeeda0c15f3ae7b32eec20834b5a55118@buzz.block.builderlab.xyz> |
||
|
|
51b0ea62be |
fix(mobile): skip the emoji picker when its opener is gone (#9820)
On iOS, opening the emoji picker from a context that had already been
unmounted threw `StateError('No ProviderScope found')` from
`ProviderScope.containerOf`. It threw after the picker had taken its
one-sheet-at-a-time guard, so every later emoji picker open in that
session was silently refused until the app restarted.
The message actions sheet hits this: its "+" tile opens the picker on
the long-pressed message row's context, which the timeline can rebuild
away while the sheet is open (the reported crash came from a phone in
landscape, tapping "+" in the quick reaction row).
`showEmojiPicker` now returns early, completing the caller's
`onDismiss`, when its context is no longer mounted, and the guard is
never taken. That tap still opens no picker (the message usually stays
on screen, but its row was rebuilt), so the user has to retry, but later
opens keep working.
### Validation
- Added [an iOS picker
test](https://github.com/block/buzz/blob/fix-ios-emoji-picker-dead-context/mobile/test/features/channels/emoji_picker_test.dart)
that opens the picker from a rebuilt-away context, then checks the
caller's dismissal runs and a later open from a live context still
presents the native sheet.
- Ran the fixed build in an iPhone 17 Pro simulator against a live
community: long-pressed a message, tapped "+" in the quick reaction row,
picked an emoji from the native sheet and saw the reaction land; then
repeated on a second message to confirm the picker opens again (with the
first pick under Frequently used). The simulator can't reproduce the
rebuilt-row race itself; the added test covers that.
### Regressions
None expected. The only behavior change is for an opener whose widget is
already gone, which previously threw and blocked the picker. Mounted
callers take exactly the same path as before.
Signed-off-by: Tom Brow <tomb@block.xyz>
Co-authored-by: studio <dc2fc481343672df31a689840c09299972e704dac592e0da6f18486646a7ee3e@buzz.block.builderlab.xyz>
|
||
|
|
eae69483fd |
fix(push-gateway): retry, don't drop, a delivery replayed while its first attempt is in flight (#9802)
The relay gives up on a push gateway delivery call after 2 seconds and
retries the same `request_id` with a fresh NIP-98 event. A gateway send
can take much longer than that: an FCM token mint has a 15 second
deadline, and the APNs and FCM sends each have a 15 second timeout. A
retry that arrived while the first attempt was still sending hit the
request replay fence and got `404 invalid_grant`. The relay reads a 404
on a retry as "the earlier attempt already finished" and completes the
wake. If the first attempt then failed retryably, nothing ever sent the
wake, and the notification was silently lost.
This change makes the gateway tell an in-flight request apart from a
finished one:
- Admission records the request id as in flight. A terminal outcome
marks it finished, and a retryable outcome releases it, as before.
- A replay of an in-flight id now gets `503
{"status":"retry","retry_after_seconds":5}`. Nothing is sent and no
quota is charged, so the relay's existing 503 path retries with backoff.
- A replay of a finished id still gets 404, so the relay's existing
handling of a finished attempt is unchanged.
Postgres gets a `finished` column on
`push_gateway_delivery_request_replays` (gateway migration 0009,
mirrored in relay migration 0105). It defaults to `true`, and the
gateway writes `false` explicitly on admission. Rows written before this
migration, or by an older gateway during a rollout or rollback,
therefore keep today's behavior. The constant default adds the column
without rewriting the table.
### Validation
-
[`replay_while_first_attempt_is_in_flight_is_retried_not_dropped`](
|
||
|
|
7681371b94 |
fix(mobile): clear the Duo top edge in the Activity header (#9807)
## Summary On iPhone Duo, the Activity page's custom header put Close and the "Activity" title 8 points below the window's top edge. The Duo panes report no top safe area beside the strip, so the 8-point row padding was the only clearance. This happened on the cover display and in the inner display's wide layout. Other Duo pane headers already reserve 24 points above their 44-point controls (`FrostedAppBar` and the native bar in `IosNavigationBar.swift`). Activity now does the same: - `activity_page.dart`: on iOS with a Duo strip, the header row's top padding is `duoHeaderTopClearance` (24). Otherwise it stays `Grid.xxs` (8). The bottom padding stays 8. - `duo_toolbar.dart`: adds `duoHeaderTopClearance = 24`. - `frosted_app_bar.dart`: uses the constant in place of its literal `+ 24`. No value change. **Pareto:** better on the Duo cover and in the wide layout. No change on regular iPhones (no strip), Android, or the Duo inner display in portrait (no side strip; it already has an 82-point top inset). No new rebuild dependencies: `strip` was already read through `DuoToolbarScope.maybeStripOf`. ### Related issue None found. ### Testing - New widget test `Activity header clears the top edge on …` checks the header row's top edge on the Duo cover (466×678, right strip), the Duo wide layout (951×669), an iPhone (62-point top inset), and Android. It fails on `main` for both Duo cases (8, expected 24) and passes with this change. - `dart format --set-exit-if-changed .` and `flutter analyze`: clean. - `flutter test` (mobile): passes on macOS. - iOS 27.2 simulators, measured in points from the top edge: | Device / layout | Before | After | |---|---|---| | Duo cover, Close and title row | 8 | 24 | | Duo wide layout, title row (Close in the rail) | 8 | 24 | | iPhone 18 Pro | 70 | 70 | #### Before / after Captured on iOS 27.2 simulators. Before is `main` at `9c0bcd6239`, after is this branch at `4400d021b`. In each pair, before is on the left and after is on the right. Duo cover display: open Activity from the bell, hold, then Close. https://github.com/user-attachments/assets/5bda190c-cadf-44a8-9a8e-58bc68838e7b     🤖 Generated with [Claude Code](https://claude.com/claude-code) Signed-off-by: Stephen Barnes <799470+smbarne@users.noreply.github.com> Co-authored-by: Stephen Barnes <799470+smbarne@users.noreply.github.com> |
||
|
|
9f49216f8b |
feat(test-client): add buzz-acceptance relay probe (#9767)
## Summary
Adds `buzz-acceptance`, a third binary in `buzz-test-client` (next to
`buzz-loadgen`). One run checks the relay's core jobs once against one
relay and exits. It is meant to run on a schedule (for example a
Kubernetes CronJob) or as a deployment step (for example an Argo
Rollouts `job` analysis against the canary Service).
Checks, in order:
| Check | Stages |
|---|---|
| `relay_info` | `nip11` (the response must be a NIP-11 document) |
| `connect_auth` | `ws_connect`, `nip42_auth` |
| `channel_create` | `create` (a private, per-run channel with a 1 h
TTL) |
| `publish` | `ok` |
| `fanout` | `connect_second`, `subscribe`, `publish`, `receive` |
| `history` | `req_eose` (the published event is in a fresh REQ, intact)
|
| `access_control` | `unauthenticated_rejected`,
`pubkey_mismatch_rejected` |
| `cleanup` | `connect`, `delete_channel` (on a fresh connection) |
`access_control` passes only on the relay's own denial reasons:
`auth-required:` for a write on a socket that sent the NIP-FI assertion
but skipped NIP-42 AUTH, and `invalid: event pubkey does not match
authenticated identity` for a write signed by another key. A closed
socket or any other reason fails the stage.
`fanout` reads the listener while the publish waits for its OK, so
`receive` measures delivery (publish → arrival on the second socket),
not the publisher's acknowledgement.
`fanout` and `history` verify the event they get back (`Event::verify`:
id and signature against its content). An event the relay corrupted
under its original id fails the stage.
A channel is never stranded on purpose. If the create times out or the
socket drops, the probe keeps the channel id and `cleanup` deletes it
over a fresh connection. A failed cleanup names the channel. The TTL
archives any channel a killed run leaves behind.
Output:
- A JSON report on stdout: each check's result, the stage that failed,
and each completed stage's duration.
- Optional DogStatsD metrics (`--statsd-addr`): `<prefix>.runs`,
`<prefix>.run.seconds`, `<prefix>.check.runs{check,result,stage}`,
`<prefix>.check.seconds{check,result}`,
`<prefix>.stage.seconds{check,stage}`. Every series also carries
`relay_version` (from NIP-11) and any `--tag k:v`.
- Exit code 0 when every check passed, 1 when a check failed, 2 when the
probe could not run or send its metrics.
A check whose prerequisite failed is reported as `skipped`, so each
failure is counted once, at its cause, and every run reports the same
set of checks.
### NIP-FI
On a relay that enforces NIP-FI, pass `--assertion-file` (a regular
file, at most 16 KiB; a FIFO or larger file fails the connection at
once). The probe reads the file before every connection and sends it as
`Nostr-Federated-Identity: Bearer …`. Another process (for example a
sidecar) keeps it fresh. How the assertion is minted is deployment
configuration and stays out of this repo.
## What got simpler
Nothing got simpler. This adds one binary. It reuses `buzz-ws-client`
and the crate's existing dependencies, and adds no new crate and no new
dependency (`clap` gains its `env` feature).
## Testing
- Unit tests drive the probe against a scripted relay: a publisher OK
that arrives 600 ms after delivery (`receive` stays under 300 ms), a
refusal with the wrong reason and a closed socket (both fail
`access_control`), an unanswered create and a socket lost after create
(both still delete that exact channel), and a failed cleanup (the error
names the channel). Also: metric lines and tags, one datagram per line,
stage timeout, assertion file limits, and an unreachable relay.
- `tests/e2e_acceptance.rs` runs in CI's Relay E2E lane against a live
relay. It runs the shared runner and the binary itself: exit 0 with JSON
and datagrams on a pass, exit 1 when a check fails, exit 2 when the
probe cannot run.
## Follow-ups (not in this PR)
- Image and CronJob / Rollouts wiring.
- Before the probe can gate a canary: a dial override that keeps the
canonical Host and signed relay URL (like `buzz-loadgen`'s
`connect_addr`).
- Before it can gate a promotion: a build identifier from the relay.
`relay_version` is the Cargo package version, which several image builds
can share.
- Confirm the delete took effect: read the channel back after
`delete_channel` returns `OK true`. This needs a stable relay read
contract for deleted channels. Until then the 1 h TTL bounds any channel
a silent delete failure leaves behind. The scheduled deployment can also
sweep stale probe channels at start.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
---------
Signed-off-by: Elrond <28d6302a099e5225b02c4155ac4236e4912603df2ab08dbfc2f4fef08ce598c8@buzz.block.builderlab.xyz>
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>
|
||
|
|
e95d7a9509 |
feat(relay): add pinned messages (nip-pm) (#9729)
## Summary Implements NIP-PM on the relay. A member signs one command to pin or unpin a message, and the relay publishes the channel's pins as one relay-signed list. The NIP is `docs/nips/NIP-PM.md`, added in #9712. - **Kinds.** `40010` pin and `40011` unpin commands (one `h`, one `e`, empty content) and the relay-signed `30623` pin list, one addressable event per channel, newest pin first. The list carries the channel in `d` and in `h`. - **Ordering.** Every writer of a channel's list takes that list's replacement lock, so pins, unpins and deletes of pinned messages apply one at a time. A command, the new list and the notice are stored in one transaction. - **Idempotency.** A command sent again answers `duplicate:` and is not applied again. Pinning a pinned message or unpinning an unpinned one is accepted and changes nothing. - **Validation.** The author must be able to post in the channel, and the channel must not be archived. A pin target must be a live message of that channel. A channel holds at most 250 pins. - **Deletes.** A delete by the author, the owner of the agent that wrote the message, a channel admin or a relay admin removes the message from the list in the deleting transaction and publishes the new list. A delete removes its messages first and then takes the list locks in channel order, rewriting each list once. Each list write records its timestamp, and a delete reads that first: a delete of a message that is not pinned locks only its own month of `events`, plus the list month when the channel has a list (#9743). The pin list itself cannot be deleted. - **Notice.** A pin that changes the list posts a `message_pinned` system message naming the member, the message and the command. - **Reads.** The list is readable by those who can read the channel. Clients read it with `#h`, which names the channel under NIP-CL, and each new list is delivered to `#h` subscribers. - **Configuration.** None. A relay running this build accepts the commands; it does not advertise pins in NIP-11. - **Threads.** A pin or unpin command cannot be the parent of a reply or the target of an edit or a vote. - **Account erasure.** Content cleanup removes a member's pin and unpin commands. One under an hour old keeps its ID, timestamp, kind and channel so that a resend stays a duplicate. The leader's periodic maintenance tick removes those records once the command is an hour old. `docs/operator-user-account-retention.md` describes this. ### Related issue N/A. #8809 is an earlier draft of message pins with a different event model. ### Testing - Postgres-backed store tests for the list writes: ordering, concurrent pins, resends, the limit, deletes, the lock order of a delete of several messages, the partitions a delete locks, the refusal to delete the list, erasure records and their expiry across communities. - Postgres-backed handler tests through ingest and REQ: the pin and unpin journey with notices and live delivery, who can read the list (private channel, DM and an unlisted channel read by a non-member), every refusal, a reply to a command, and deletes that rewrite the list. - `e2e_channel_pins` runs over WebSocket against a relay and is added to the relay integration job. - Run against a local relay started with no pins configuration: the end-to-end test. On an earlier revision, the periodic tick removed expired erasure records from an archived channel while leaving younger records, live commands and other kinds. - `cargo fmt --check`, clippy with warnings denied on the touched crates, and the file-size check. - `just test-unit`, which includes the buzz-db source-policy tests. --------- Signed-off-by: Kalvin Chau <kalvin@block.xyz> 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> |
||
|
|
9c0bcd6239 |
Align Duo chat headers, inset Home selections, and fix received photo-stack swipes (#9795)
- In unfolded Duo portrait, place the live chat avatar and name together beside Back. Align the Messages and Activity headers with the status controls and keep the filters full width. - Center the stacked avatar and chat title over the sticky date with the Duo rail on either side. - Give Home selections rounder corners and a shared 12-point outer gutter for channels, DMs, and Solo chats. Preserve icon and label alignment. - Mirror drag distance and flick velocity for received photo stacks so a rightward swipe advances the stack. The combined release preview was installed and checked on a physical Duo. Widget tests cover the portrait header geometry, filter width, and return to landscape. ### Portrait layout references Cropped headers from the earlier Duo preview used as the design reference.   ### Simulator snapshots The fixtures use sample content and a 76-point right rail inset.   --------- Signed-off-by: Terp <5856f6900e8e0a4e0ea1f4f8d2ee33e4753d2119bc122f94ecafc660b46c0511@buzz.block.builderlab.xyz> Signed-off-by: Tom Brow <tomb@block.xyz> Co-authored-by: Terp <5856f6900e8e0a4e0ea1f4f8d2ee33e4753d2119bc122f94ecafc660b46c0511@buzz.block.builderlab.xyz> Co-authored-by: Tom Brow <tomb@block.xyz> Co-authored-by: studio <dc2fc481343672df31a689840c09299972e704dac592e0da6f18486646a7ee3e@buzz> |
||
|
|
97bec174a4 |
fix(mobile): only dot channel-sent replies in the reader's threads (#9696)
## What changed Mobile matches block/buzz-app#3938. A reply someone sends with **Also send to channel** used to light the channel's attention dot and count toward the app icon badge for everyone in the channel, even people who never joined that thread. Now it follows the same rule as any other reply: - **Dot** if it mentions you, or it's in a thread you're part of (you started it, replied in it, or follow it). - **Bold only** otherwise, like a new top-level post. It no longer counts toward the app icon badge. Reading is unchanged. These replies are still marked read individually, as desktop reads them, so reaching the bottom of the channel doesn't silently mark them read on one device but not the other. ## How - The "is this one of my threads" check that already decides which ordinary replies count is now shared, and channel-sent replies go through it when deciding attention. - On mobile, "earns a dot" and "is read by reaching the bottom of the channel" were one flag. Dropping a channel-sent reply's priority would have also changed how it gets read, drifting from desktop. The dot now comes from its own field; every other kind of message gets exactly the same dot and read behavior as before. ## Tests New cases drive live events through the channel list. For each, they check the observed unread entry, whether its thread shows in Activity, the app icon badge, the channel list's bold vs dot, and reading: - reply sent to the channel in someone else's thread: bold, no dot, not in Activity, counts as ordinary unread on the icon (same as a top-level post) - same, but mentioning the reader: dot, in Activity - in a thread the reader follows: dot, in Activity - in a thread the reader started: dot, in Activity - in a thread the reader replied in: dot, in Activity In every case, a channel catch-up mark leaves the reply unread and its own read mark clears it. The "someone else's thread" case fails on `main` (it gets a dot). The pre-push mobile checks (format, analyze, full mobile test suite) passed on this head. ## Known gaps (not changed here) - Mobile only knows the threads you're part of from posts it has seen on this phone. A fresh install doesn't know about older threads you joined elsewhere, and a reply's first classification sticks even if later loading shows you joined that thread. Desktop looks these up on the relay. - Mobile has no explicit "Unfollow" for a thread you started or replied in (the menu only offers Follow there), so you can't silence one the way desktop can. This applies to all replies, not just ones sent to the channel. - A reply sent to the channel still counts as unread in a muted channel. That was already true before this change. No screenshots: no visual element changes, only which existing state (bold or dot) a channel shows. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Signed-off-by: morgmart <98432065+morgmart@users.noreply.github.com> Signed-off-by: Tom Brow <tomb@block.xyz> Co-authored-by: Carl <c217fe6b9d958f41c3a5e030dccc7f626775a923089cb6491305eade75ea1f1b@buzz.block.builderlab.xyz> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: Tom Brow <tomb@block.xyz> Co-authored-by: studio <dc2fc481343672df31a689840c09299972e704dac592e0da6f18486646a7ee3e@buzz.block.builderlab.xyz> |
||
|
|
7f88572be8 |
docs: point community invite at buzz.communities (#9797)
## Summary Point the README's community invite at the Buzz community (`buzz.communities.buzz.xyz`) instead of the feedback community, and call it "Buzz community". ### Related issue N/A. No existing issue or PR found. ### Testing Docs only. `curl` on the new invite URL returns 200. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Signed-off-by: Diem Nguyen <diem@squareup.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
14e5ea7cc4 |
Mobile: refine section filters and ordering in Messages (#9796)
## Summary Give Messages sections a common options sheet for sorting, filtering and ordering. Active sections let people choose a time window. Channel and DM sections can reveal filtered rows in place with **Show more** and collapse them with **Show fewer**. Reordering saves a device-local order for the current account and community. Failed activity lookups keep affected channels visible. The recovery toast offers Retry and dismisses when activity loads. On iOS the sheet dims the Messages header along with the list. ### Related work #9707 explores a count-based disclosure. This change uses the section’s unread or activity filter. ### iOS snapshots | Section options with an active filter | Reorder sections | | --- | --- | |  |  | ### Rename a section Tap the emoji beside the name to open the picker. Set saves both fields, including an emoji-only change.  ### Activity recovery and section order Unfiled Solo chats support local **Show more** and **Show fewer**, including offline. Failed activity lookups retry automatically up to three times with jittered backoff while Messages is visible and connected. **Retry** stays available after that budget is exhausted. The notice dismisses on recovery. Reorder supports drag handles and keyboard arrow keys. Saving preserves the position of an empty Starred section and checks for a newer order. Each signing identity has its own saved order per relay. ### Testing Exercised filtering, reorder and dismissal in the iOS simulator. The preview was also tested on iPhone Air. At `6135e314f3`, Flutter analysis and the full pre-push mobile checks passed (5,613 tests passed, 71 skipped). Widget regressions cover offline Solo disclosure, retry exhaustion, route visibility, keyboard reorder, large text, and editor cancellation. --------- Signed-off-by: kenny lopez <klopez4212@gmail.com> Co-authored-by: Terp <5856f6900e8e0a4e0ea1f4f8d2ee33e4753d2119bc122f94ecafc660b46c0511@buzz.block.builderlab.xyz> |
||
|
|
5268caa866 |
feat(push-gateway): mint FCM tokens through AWS workload identity federation (#9692)
## Summary Block's GCP projects forbid service account keys, so the push gateway can now get its FCM access token by federating its AWS identity (Google workload identity federation), with no key file. - `BUZZ_PUSH_FCM_SERVICE_ACCOUNT_PATH` is renamed `BUZZ_PUSH_FCM_CREDENTIALS_PATH` (no deployment sets it yet). The file is dispatched on its JSON `type`: `service_account` keeps today's JWT flow; `external_account` is Google's standard AWS credential configuration, the file Block's `identity-federation-aws` Terraform module generates. - Only the minting step changed. `TokenSource` caching, refresh, backoff and the Rejected/Unavailable split are as they were. - A federated mint: AWS credentials (EKS Pod Identity, IRSA or static env keys; no EC2 metadata), a SigV4-signed STS `GetCallerIdentity` subject token, Google STS, then `generateAccessToken` for the FCM scope. One 15 s deadline covers the whole chain. - Faults: network errors, 5xx and 429 on any hop are Unavailable; other 4xx are Rejected. - Startup checks the file's shape and the AWS environment but calls neither AWS nor Google, so an outage can't stop the gateway from serving iOS. The first mint's result is logged once. - Helm: `android.fcmServiceAccount` is renamed `android.fcmCredentials`, mounted as `credentials.json`. ## Validation - New tests drive `TokenSource` against fake AWS, Google STS and impersonation servers: the full chain, each hop's failure classification, a failed refresh keeping a valid cached token, the overall deadline, and config rejection cases. - SigV4 known-answer tests use AWS's documented example credentials, checked against an independent implementation. Checked live against the dev Firebase project from a local AWS identity: the federated mint succeeds and FCM accepts the resulting token. Not yet run from a gateway pod. --------- Signed-off-by: Tom Brow <tomb@block.xyz> Co-authored-by: studio <dc2fc481343672df31a689840c09299972e704dac592e0da6f18486646a7ee3e@buzz.block.builderlab.xyz> |
||
|
|
e2bbd8430c |
feat(mobile): report explicit diagnostic errors (#9673)
Step one of [mobile diagnostic
reporting](https://github.com/block/buzz/blob/main/docs/mobile-diagnostic-reporting.md),
second piece: the explicit error reports the spec lists, through the
reporter added in [#9613 diagnostic reporting
module](https://github.com/block/buzz/pull/9613). A build without a
destination (every build from this repository alone) still reports
nothing.
### What's in it
Each report carries its `operation` tag, the error's type and stack
trace, and no error text (the filter replaces it).
- **Event subscriber (`eventSubscriber`):** a subscriber that throws
while the relay session delivers a buffered batch is reported, and the
rest of the batch is still delivered. In a build without a destination
the error still surfaces as uncaught, so it fails the test that hit it
and prints in development, as before. Before, one throw dropped the rest
of the batch, and those events never came back because their delivery
keys were already recorded.
- **Relay frames (`relayFrame`):** a frame the socket can't decode, or
whose body isn't a JSON array, is reported instead of silently skipped.
- **Relay queries (`relayQuery`):** an HTTP query body that can't be
decoded, including the read-state snapshot.
- **Invalid-request rejections (`relayRejection`):** an `OK false` or
`CLOSED` whose reason starts with `invalid:`, reported as a fixed
`RelayInvalidRequest` with no relay text, including an `OK` with no
pending publish (a typing indicator, or a reply after a timeout).
Refusals the app handles as expected outcomes (an archived channel, an
Unarchive of a channel that is no longer archived, an open channel name
that is taken, an agent whose `policy:` refuses being added, a sole
owner's Leave refused as the last owner, a guest's Add Members refused
because only members can add people, an event whose timestamp is outside
the relay's window, so a wrong device clock does not report every
publish) are left out. The long-lived relay session, the short-lived
sockets (hosted admission, the self-hosted probe, one-shot publishes
such as agent registration and push tombstones) and the account
assertion requests made for a community's key (relay access and push
stop assertions) report frames and rejections the same way, except while
reports name a member other than the key they sign with. A removed or
inactive community's tombstone, or the probe of a community being
joined, then reports nothing rather than naming the wrong member. With
no member set (first run, or after the last community is removed) it
reports under the install identifier.
- **Account responses (`accountResponse`):** a Builderlab account
response that isn't a JSON object, or a 2xx exchange or `/v1/auth/me`
response missing its credential, subject or expiry. Non-2xx statuses are
expected outcomes and aren't reported.
- **Push gateway responses (`pushGatewayResponse`):** a malformed push
capability descriptor from the relay. A relay that leaves
`supported_extensions` out or sends none has no push and isn't reported,
and a fetch that finishes after a community switch has begun isn't
reported either, since it would name the next member. Push gateway
replies aren't reported yet.
- **Stored data (`storedData`):** a saved community list that can't be
read back.
- **Member on switch:** switching communities now looks the new member
up in storage, not in the provider's list, which can still be the
previous one while it reloads after sign-in. It reads storage before
tearing anything down, so a failed read leaves the switch unchanged and
retryable.
- **Filter:** also drops a report's additional data (`extra`). Nothing
sets it today.
- The spec's status line now says what is implemented.
- Event delivery moves from `relay_session.dart` into a part file,
unchanged apart from the subscriber guard, so the session stays under
its size limit.
### Regressions
None expected: each change only adds a report where an error was already
caught or skipped. The one behavior change is that a throwing event
subscriber no longer costs the rest of its batch.
### Validation
Added tests for each report site (relay session, socket frames, one-shot
publishes, read-state snapshot, closed-reason policy, account client,
push descriptor and capability provider, community storage), for the
relay session (member changed mid-request), one-shot sockets and
assertion requests reporting nothing while another member is set and
reporting with none set, for the member on switch and a switch whose
read fails then retries, and for the filter dropping additional data and
leaving a message-less event without one.
Full-app run on an iPhone 17 Pro simulator at
|
||
|
|
03d09e20e3 |
fix(mobile): keep the agent poster over a failed iOS player (#9693)
Co-authored-by: studio <dc2fc481343672df31a689840c09299972e704dac592e0da6f18486646a7ee3e@buzz.block.builderlab.xyz> |
||
|
|
47c9a672d7 |
perf(push-gateway): evict the oldest signed-call window without scanning (#9799)
The push gateway's signed-call limiter keeps one counter per attested key, capped at 100,000 keys. Once the map was full, every call from a key not already in it scanned the whole map (once to drop expired windows, again to find the oldest), all while holding the limiter's lock. Under heavy load from many new keys, that serialized each signed call behind a 100,000-entry scan. The limiter now keeps a queue of window starts, oldest first, and evicts from its front. A key whose window restarts leaves a stale entry behind, which eviction skips; the queue is compacted once stale entries make up half of it, so a call stays O(1) amortized. Rate-limit behavior is unchanged, except that a full map now drops one oldest window per new key instead of every expired window at once. The map and the queue share one copy of each key; the queue can reach about twice the map's entries before compaction, so memory stays bounded. Follow-up from #9562. ### Validation | 1,000 new keys on a full map (release build) | Time | | --- | --- | | Before | 277 ms (about 0.28 ms per call, under the lock) | | After | 0.11 ms | - [`a_full_map_drops_the_key_with_the_oldest_window`](https://github.com/block/buzz/blob/push-gateway-limiter-eviction/crates/buzz-push-gateway/src/signed_call_limiter.rs) checks that eviction picks the oldest window. - [`eviction_skips_a_restarted_window`](https://github.com/block/buzz/blob/push-gateway-limiter-eviction/crates/buzz-push-gateway/src/signed_call_limiter.rs) checks that eviction skips a stale entry and keeps a key whose window just restarted. - [`restarted_windows_do_not_grow_the_queue`](https://github.com/block/buzz/blob/push-gateway-limiter-eviction/crates/buzz-push-gateway/src/signed_call_limiter.rs) checks that compaction bounds the queue when one key keeps restarting its window. --------- Signed-off-by: Tom Brow <tomb@block.xyz> Co-authored-by: studio <dc2fc481343672df31a689840c09299972e704dac592e0da6f18486646a7ee3e@buzz.block.builderlab.xyz> |
||
|
|
d647c9fd98 |
Refine iOS composer and transcribe recordings into drafts (#9574)
Refine the iOS composer with 40-point glass controls, native attachment menus, persistent emoji access, and selected-text formatting. The mic now transcribes recordings on device into an editable, unsent draft; Dictation has no five-minute recording cap or timer label, and its waveform fills the space between the controls. Voice note remains available in attachments with its five-minute cap. Unsupported devices fail before recording, and audio is retained until the draft is durably saved. Stopped dictation remains recoverable across editor teardown; failed retention and cleanup can be retried. Recovered transcripts are inserted only once across navigation or restart, preserving live exact mention bindings. Preserve selection handles over glass with animated avatars. Reduce the conversation fade to 100 points above the keyboard and transition continuously to 180 as the keyboard closes, without a first-frame jump when opening; Home is unchanged. Validation: 5,117 mobile tests and 27 crypto tests pass; analysis passes. Prior native suite on iPhone 16/iOS 26.5: 119 pass, one pre-existing expected failure, zero unexpected failures. Physical Air preview approved; simulator selection/dragging and attachment flows exercised. Fixed the native navigation test's timing race and a community-cache cleanup test that checked a parent directory before its asynchronous removal completed. Repository-wide `just ci` previously stopped in unchanged `buzz-test-client` load-generator tests; new-head hosted checks are pending. Snapshots: production composer in an iPhone Air simulator fixture with fictional conversation text; Photos snapshot retained from the attachment preview. | Composer | Attachments | Photos | | --- | --- | --- | |  |  |  | --------- Signed-off-by: Terp <5856f6900e8e0a4e0ea1f4f8d2ee33e4753d2119bc122f94ecafc660b46c0511@buzz.block.builderlab.xyz> Signed-off-by: Tom Brow <tomb@squareup.com> Signed-off-by: Princess Donut <b238ea756dee4d98afa5883fc7f1de61eeabe65bf700e3a5a5a80db5e42e2c2b@buzz.block.builderlab.xyz> Signed-off-by: Tom Brow <tomb@block.xyz> Co-authored-by: Terp <5856f6900e8e0a4e0ea1f4f8d2ee33e4753d2119bc122f94ecafc660b46c0511@buzz.block.builderlab.xyz> Co-authored-by: Tom Brow <tomb@block.xyz> Co-authored-by: Tom Brow <tomb@squareup.com> Co-authored-by: studio <dc2fc481343672df31a689840c09299972e704dac592e0da6f18486646a7ee3e@buzz.block.builderlab.xyz> Co-authored-by: Princess Donut <b238ea756dee4d98afa5883fc7f1de61eeabe65bf700e3a5a5a80db5e42e2c2b@buzz.block.builderlab.xyz> |
||
|
|
a45f52a95c | fix(mobile): recognize agents without NIP-OA in Huddles (#8545) | ||
|
|
786726907c |
test(relay): cover member-cache invalidation routes and refill orders (#9748)
## Summary Add 54 cases that verify a relay cache refill cannot restore stale channel membership after invalidation. The cases cover stale grants and denials, reader and community isolation, and three orders in which reads can finish. The publish-wrapper cases exercise the local cache drop. The receiving handlers are tested separately. Both unit-test runners select the new cases. ### Related issue Test coverage for #9735 and #9742. ### Testing The read-cache lane passed all 26 tests on the reviewed tree. Both runners selected all three new tests. The draft will remain open while repository CI and human confirmation are pending. For manual verification, run `cargo test -p buzz-relay --lib state::tests::member_channel_invalidation_tests:: -- --nocapture` and expect three passes. Generated with Codex Signed-off-by: Brad Seiler <seiler@squareup.com> |
||
|
|
a79cbb4664 |
perf(mobile): stop re-scanning the unread backlog on channel list rebuilds (#9780)
## Summary Scrolling the mobile channel list hitched repeatedly after the app had been closed for a long time. To decide which rows are bold and which get a dot, the channel list read every unread message held in memory, for every channel, on every rebuild. After a long absence the unread catch-up holds up to 1000 messages per channel, so each list update cost more than a frame. This change makes a list rebuild independent of the backlog size: - A channel's messages stop being read once its bold and dot state is decided. - Each channel's result is reused until its messages or the read state change. A new message re-reads only its own channel; reordering or filtering the list re-reads nothing. Which rows end up bold or dotted is unchanged. ### Related issue N/A. None found. ### Testing Before (left) and after (right), same script on an iPhone 17 simulator: 200 channels each holding 1000 unread messages, a list update every 150 ms, and a scripted finger (the crosshair) dragging at a steady 420 px per second. https://github.com/user-attachments/assets/07b39b61-406f-4b4b-baca-69aa5be42db7 | | Before | After | |---|---|---| | Frames drawn in the 11-second drag | 279 | 499 | | Frames over 25 ms | 127 (46%) | 92 (18%) | | Median frame | 21.1 ms | 17.2 ms | | Worst frame | 116.8 ms | 65.2 ms | The recording uses scripted data in a debug build, which drops some frames even with no list updates, so the "after" side is not perfectly smooth. Whole frame after one list update, 200 channels, in a widget test on a Mac (not a phone): | Unread messages held per channel | Before | After | |---|---|---| | 0 | 13.3 ms | 12.7 ms | | 300 | 16.5 ms | 6.8 ms | | 1000 | 37.4 ms | 6.6 ms | - New tests in `channel_unread_test.dart` compare the new pass with a copy of the old full scan across a table of cases and 600 random steps of adds, deletions and read marks, and count messages read to guard the early exit and the reuse without timing. - `flutter analyze` and the mobile channel and home tests (2,983) passed with these two commits on `8827f986e43`. They were not rerun after the rebase onto current `main`, so CI is the check for that. - Not run on a phone or against a real community. Worth a close look in review: the reuse depends on every place that changes the stored unread messages marking that channel as changed. The new tests drive this through a stand-in, so they do not prove each real call site does it. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Signed-off-by: mtoohey <mtoohey@squareup.com> Signed-off-by: Matt Toohey <contact@matttoohey.com> Co-authored-by: Claude Fable 5.2 <noreply@anthropic.com> |
||
|
|
ee4a6ed6b6 |
feat(mobile): restore the iOS share extension in the build (#9783)
Restores the iOS share extension target that #9489 unhooked from the Runner project because release builds couldn't sign it yet. Release signing for the extension's bundle identifiers is now configured, so this is a straight revert of that commit. No visible change beyond the extension reappearing in the iOS share sheet, as it did after #9433. Signed-off-by: Tom Brow <tomb@block.xyz>mobile-v1.5.0-rc.6 |
||
|
|
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> |
||
|
|
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> |
||
|
|
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> |
||
|
|
8d4b30176b | feat(cli): add many channel members per kind:9000 event (#9738) | ||
|
|
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> |
||
|
|
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> |
||
|
|
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 |
||
|
|
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> |
||
|
|
729cb10b78 | buzz-db: drop the remaining relay foreign keys (#9740) | ||
|
|
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> |
||
|
|
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> |