mirror of
https://github.com/block/buzz.git
synced 2026-11-28 04:01:45 +00:00
2c7e67fcc17ca17e6557d81fc9dec82b0cf4fa58
7 Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
c4c97119c3 |
fix(mobile): end a refused push opt-out in a visible failure with Retry (#9854)
## Summary Turning push notifications off could stay stuck forever. If the relay kept rejecting the opt-out tombstone, `setPushNotificationsEnabled(false)` swallowed the rejection, and the push bootstrap retried the tombstone on every connect, including after restarts. Settings showed the switch off the whole time, while the relay still held the lease. [docs/mobile-push-suppression.md](https://github.com/block/buzz/blob/main/docs/mobile-push-suppression.md) (rule 29) asks for the opposite: a bounded pending state, then a clear warning that notifications may continue, with no automatic retry, and the relay's actual setting on the next sync. - **Bounded pending.** An opt-out ends about 10 seconds after the tap, across every step (capability lookup, connect, authenticate, publish). While it runs, the row says "Turning off…" and the switch is held, so Off, On, Off can't race the first attempt. - **Definite vs. maybe stored.** A one-shot publish now says whether the relay could have seen the event: a refusal, or a failure before the EVENT went out, is definite; a lost acknowledgment after it went out is not. - **Refused: back to the confirmed setting.** When the relay never stored the tombstone, the saved setting goes back to On (the confirmed lease) and Settings shows "Could not confirm that notifications were turned off. Notifications may continue." with a **Retry** below it. The warning lasts for this app run; after a restart, Settings just shows On. - **Maybe stored: kept as a guard, then read back.** When the acknowledgment was lost, the saved opt-out stays as a guard (no lease or enrollment is published, and the community stays in the iOS notification snapshot), while Settings shows the confirmed On with the same warning. On the next sync, the app reads its own lease from the relay: an inactive lease or none confirms Off; an active one turns the switch back On and keeps the warning. A read that fails changes nothing and is tried again on the next connect. The read asks the relay for strong consistency, so a lagging replica can't answer with the lease the tombstone replaced. It fails if the active community changes while it waits, and it settles only the opt-out it was started for, so a Retry made during the read stays pending. - **No flash on success.** Settings reads the community from the community list, which changes in the same step as each opt-out result. The active-community projection trails it by a keychain read, which could show an accepted opt-out as failed for a frame. - **Explicit retry only.** Retry, or turning the switch off again, makes one attempt at a new generation. The bootstrap's automatic tombstone retry is removed. The warning is announced to screen readers when it appears, and Retry has its own label. This applies to every platform: the opt-out path is shared. ### Related issue None found. ### Testing - The Settings recovery journey covers a refusal restoring On with the warning, a restart that drops the warning and makes no attempt, an attempt that never answers (held switch, then the deadline, kept as a guard), a restart that keeps that warning, and a Retry that succeeds. It runs with loading, absent and failed capability, and on a small phone at text scale 2. - The toggle journey, with the real push bootstrap, covers a refusal (a reconnect neither retries nor reads), an unanswered attempt and a lease that's still active: the read on reconnect, a failed read that changes nothing, then Off or On from what the relay holds. - One-shot publish rows: a relay that stalls at authentication fails as never sent; one that stalls at OK, or closes after the EVENT, fails as maybe stored, all by the deadline. - Lease reader rows: the exact strong-read filter, an empty answer, and a community switch during the descriptor fetch or the query. A provider row holds a read while a Retry fails unanswered: the old read leaves the new opt-out pending. - A widget test with slow secure storage checks every frame of an accepted opt-out for the warning. - A relay database test reads back the author's inactive replacement lease with the filter the app uses, and the lease decryption is checked against the member's own and forged events. ### Screenshots After the relay refuses the opt-out (no relay push capability, so the toggle is reachable only because push is on). | Before | After | | --- | --- | | <img src="https://raw.githubusercontent.com/block/buzz/d2e3c753b3068a68728199096bf30e45e8948af7/pr-9854--before.png" width="300" alt="Before: switch shows off while notifications may continue"> | <img src="https://raw.githubusercontent.com/block/buzz/ebe70a39406cf2c2104788c4cbc2f3302ba5dbbb/pr-9854--after.png" width="300" alt="After: switch back on, with the warning and Retry below it"> | At text scale 2 on a small phone, Retry sits below the warning: <img src="https://raw.githubusercontent.com/block/buzz/ebe70a39406cf2c2104788c4cbc2f3302ba5dbbb/pr-9854--after-large-text.png" width="250" alt="Large text: warning readable, Retry below it"> While an opt-out attempt is in flight (new), the switch is held: <img src="https://raw.githubusercontent.com/block/buzz/ebe70a39406cf2c2104788c4cbc2f3302ba5dbbb/pr-9854--turning-off.png" width="300" alt="Notifications row with the subtitle Turning off and the switch held"> --------- Signed-off-by: Tom Brow <tomb@block.xyz> Co-authored-by: studio <dc2fc481343672df31a689840c09299972e704dac592e0da6f18486646a7ee3e@localhost> |
||
|
|
3ff4154ca6 |
fix(mobile): back off push bootstrap retries (#9092)
When push setup fails, the app retried every 5 seconds forever. On an iPhone 12 mini whose push gateway enrollment is refused (a CDN 403 on the installation challenge), each retry refetched the relay's NIP-11 document over a new TLS connection and logged the whole HTML refusal. That is about 720 attempts and roughly 14 MB of traffic an hour for as long as the app stays open, with no way to succeed. Push registration, lease publication and tombstone retries now back off: each consecutive failure of the same attempt doubles the delay from 5 seconds up to 15 minutes, with jitter between half and all of it so devices that failed together don't retry together. A success (including a renewal), a different attempt, or a channel-grammar retry (which keeps its 5-minute delay) ends the streak. The first retry still comes within 5 seconds, so a brief blip recovers as quickly as before. ### Validation - Added tests: `repeated failures back off exponentially up to a cap` checks every delay's bounds at both jitter extremes over 12 failures, `a success ends the failure streak`, and `a different attempt starts its own backoff`. The first fails when the gate goes back to a fixed delay. - Existing push suite passes. - On the 12 mini before this change: `Push lease bootstrap failed` with the 403 page and a fresh NIP-11 fetch every 5 seconds for the whole session. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Signed-off-by: Tom Brow <tomb@squareup.com> Co-authored-by: Tom Brow <tomb@squareup.com> Co-authored-by: studio <dc2fc481343672df31a689840c09299972e704dac592e0da6f18486646a7ee3e@buzz.block.builderlab.xyz> |
||
|
|
f167c4c3e1 |
fix(push): accept canonical channel UUIDs across versions (#8609)
Starter channels use UUIDv5 IDs, but mobile push accepted only UUIDv4 channel IDs, so building a subscription that included a starter channel threw locally. After #8608, no non-v4 ID reaches mobile push today: positive `#h` filters cover joined DMs only, and mutes are limited to subscribed channels. This PR is therefore a safety net for future starter-channel subscriptions, and it prepares mobile for a relay that accepts them. Mobile now accepts canonical lowercase, hyphenated UUIDs of any version in subscriptions. It recognizes both the current `uuid-v4-lowercase` relay descriptor and a future `uuid-lowercase` descriptor. Against a `uuid-v4-lowercase` relay, mobile checks positive and mute channel filters before enrollment or publication, keeps the desired filters, and rechecks relay capabilities every five minutes instead of sending a lease the relay would reject. The relay is unchanged. It keeps validating and advertising `uuid-v4-lowercase`. Installed mobile builds reject any other `h_grammar`, and they parse the descriptor before renewal, opt-out and revocation, so changing the advertisement now would leave their leases active until expiry. The relay validation and advertisement change will follow in a separate PR once those builds have drained. `docs/buzz-push.md` records this sequencing. ### Validation - Regression tests reproduced the UUIDv5 rejection in Dart before the fix. Added coverage checks positive and mute filters, persisted subscription round trips, encrypted lease content, malformed IDs, retained bounds, parsing of both descriptor grammars, and pre-publication rejection of non-v4 IDs against a `uuid-v4-lowercase` relay. - Mobile push tests on the current head: 104 passed, 4 skipped. `flutter analyze` on the push code and tests is clean. - Before the split, exercised actual mobile lease construction, NIP44 encryption and NIP42 publication against an isolated local relay. The relay half of that exercise is no longer part of this PR. - Relay source is identical to `main`, so the relay serves the same descriptor that installed builds parse today. The standing mobile test exception applies. Agent review and changed-behavior exercise are complete. buzz-review-completed --------- Signed-off-by: Tom Brow <tomb@block.xyz> Co-authored-by: george <973be878edd6d4f79692a3827f20a6f7fe0ed0362f269ff6b6ba8867033d7d8e@sprout-oss.stage.blox.sqprod.co> |
||
|
|
8f2c7710e9 |
fix(mobile): default community push notifications to on (#8425)
New mobile communities currently require a manual Settings opt-in before push can start. Default that local preference to on for new communities and stored records without a preference. Preserve every saved `true` or `false`, including values written by older clients. Older default-off values are indistinguishable from explicit opt-outs, so this does not migrate them to on. Push still requires a configured gateway, authenticated connectivity, and a valid relay capability. iOS continues to control display authorization through its existing permission prompt. Notification eligibility and subscriptions are unchanged. Settings retains its existing opt-out control for enabled communities even when capability is unavailable. Drafted from the 0.24 baseline; release-branch inclusion is a separate decision. ### Related issue Closest related issue: #3238 (synced defaults). This change is limited to the mobile device-local community preference; no duplicate found. ### Validation - Added or updated coverage for new and missing preferences, saved true/false persistence, opt-out after restart, capability-gated registration, and Settings without a configured gateway. - Full configured mobile suite: 3,499 passed, 4 skipped. Separate no-gateway suite: 4 passed. Flutter analysis passed. - Existing permission-denied and unsupported-relay tests passed as part of the mobile suite. No physical-device or end-to-end APNs validation performed. - Full local repository gate passed (formatting, lint, unit tests, desktop/web builds, Tauri checks/tests, and mobile tests). - Follow-up review edits: restored the original VISION.md wording and shared the default in one private Community constant. All 43 focused community/bootstrap tests passed. <!-- buzz-review-completed --> --------- Signed-off-by: Tom Brow <tomb@block.xyz> |
||
|
|
c09730e874 |
fix(mobile): keep notification toggle usable and match row height (#8223)
Turning Notifications off invalidated the relay capability provider because it watched the entire saved community. If the redundant NIP-11 request stalled or failed, the switch became disabled and reopening Settings did not recover it. Discovery now follows community identity and connection status, so preference and lease bookkeeping retain the validated capability while a real reconnect still refreshes it. Each opt-in also starts a fresh active lease immediately instead of waiting for the old renewal timer. Failed attempts retain their gate until the retry delay expires, preventing rebuilds from bypassing backoff. Notifications now has the same single-line height as Set status, with the full switch hit area and one combined accessibility label. This follows [#8201](https://github.com/block/buzz/pull/8201); no duplicate open PR was found. ### Validation Added iOS widget regressions mount the production settings page and push bootstrap with production storage logic, signing, and lease publication. They verify a higher-generation active replacement after off/on with accepted, failed, and pending cleanup, plus closing/reopening Settings, switch and row taps, 2× text, accessibility, and rediscovery on reconnect. A gate test verifies that rebuilds cannot bypass failure backoff. Both UI failures and the missing active replacement were reproduced before their fixes. Mobile dependency installation, formatting/static checks, 3,234 configured tests, and three unconfigured-build tests passed. Captures use the real Flutter settings widget at 375pt width, with synthetic data and mocked native/network boundaries. Native navigation is outside the capture. No device installation or deployment was performed. After merge, validate the candidate on iOS: compare Notifications with Set status, toggle off then immediately on, close/reopen Settings while off and turn on, and repeat after reconnect. Confirm delivery resumes after opt-in. ### Layout Flutter widget captures with synthetic data; native navigation is excluded. | Before | After | | --- | --- | |  |  | --------- Signed-off-by: Tom Brow <tomb@block.xyz> |
||
|
|
76f7e5ef0c |
feat(push): make gateway origin configurable (#7261)
Make the push gateway origin configurable across the relay, gateway, mobile client, and deployment chart. This is a fresh deployment. The gateway has only run on personal development infrastructure, and push has no existing enabled users. Legacy migration, configured-to-unconfigured mobile transitions, and rolling upgrades from pre-launch gateway binaries are not supported. Populated pre-launch databases are rejected with an informative error before migrations run; their data is untouched. Mobile builds may omit the gateway URL, leaving push unavailable. Once push is enabled, subsequent builds must retain that configuration. ### Validation - All applicable CI checks pass at `5f546cfaf403f0386f146d213adfb4392f4ec29c`, including Rust, mobile/Swift, desktop/integration, security, image builds, and Helm checks. An unrelated agent cancellation test passed on retry. - PostgreSQL CI passed 384 tests, including the production-entry-point regression for refusing populated pre-launch databases before migrations, fresh initialization, and subsequent initialized deployments. - Focused local validation passed all 10 gateway PostgreSQL tests under the CI discovery filter and all 3 unconfigured-mobile tests. Repository-wide PostgreSQL discovery validation and the complete pre-push hooks passed. - Physical-device APNs/App Attest behavior and deployment to a live cluster were not verified in this work. --------- Signed-off-by: Tom Brow <tomb@block.xyz> Co-authored-by: Codex <noreply@openai.com> |
||
|
|
c432a111ca |
feat(mobile): push notifications MVP (#6269)
This PR implements MVP, iOS-only,
[NIP-PL](
|