buzz icon indicating copy to clipboard operation
buzz copied to clipboard

Read state does not sync between the iOS app and Desktop (both directions)

Open FabianHertwig opened this issue 3 months ago • 6 comments

Describe the bug

Read state does not stay in sync between the iOS app and the Desktop app. Messages read on one device still show as new on the other, and it happens in both directions: channels read on iOS come back as unread on Desktop, and new activity seen on Desktop is sometimes not flagged as new on iOS.

Steps to reproduce

  1. Sign in with the same identity on the iOS app and on Buzz Desktop.
  2. On iOS, open a channel with unread messages and read to the bottom.
  3. Switch to Desktop and look at the same channel.
  4. The channel is still marked unread there.
  5. The reverse also happens: read a channel on Desktop, then open iOS and it is not marked as new even though there is new activity.

Expected behavior

Read state is per identity, not per device. What one client marks read should be reflected on the other within a few seconds.

Version and platform

  • Buzz version: iOS 0.10.0 (App Store); Desktop version unknown
  • OS: iOS, macOS

Logs / additional context

No error is shown on either client; the unread state is simply different. Closest existing report is #6046, but that describes one specific cause (a future-dated message suppressing unread state inside a single client) rather than the two clients disagreeing.

FabianHertwig avatar Aug 19 '26 11:08 FabianHertwig

Filling in the version that was left as unknown: reproduced on Desktop 0.5.17 and iOS App Store 0.11.0, both the newest available builds at the time of the report.

FabianHertwig avatar Aug 21 '26 06:08 FabianHertwig

Additional data point, Android + Windows Desktop (2026-09-03):

  • Devices: Samsung Galaxy Z Fold8 (One UI) running the Buzz Android app, and the Buzz Desktop client on Windows 11, same account.
  • Reading a channel on Desktop leaves it shown as unread on the phone, and vice versa; the user could not tell on mobile which channels were actually unread.
  • We checked the last 30 events of the affected channel for a future-dated created_at (the #6046 cause) and found none, so that cause is ruled out for this case.

Happy to provide logs from either client on request.

Yesol-Pilot avatar Sep 03 '26 21:09 Yesol-Pilot

Same symptom here on a self-hosted relay, on both clients, and I believe I can add a mechanism and cross-device evidence.

Environment: self-hosted relay (ghcr.io/block/buzz:sha-822c5ab), Buzz Desktop 0.5.23 (macOS), Buzz iOS, one identity on both devices, 7 users. Also relates to #6428.

The synced read-state document stores channel contexts only. A channel badge compares the newest event in the channel — thread replies included — against that channel timestamp, so a channel whose latest activity is a thread reply badges forever. Reading it, or restarting the app, cannot clear it.

Buzz Desktop publishes read state as a NIP-78 document: kind 30078, d-tag read-state:<id>, NIP-44 self-encrypted. Decrypted payload:

{ "v": 1, "client_id": "<uuid>", "contexts": { "<id>": <unix seconds>, … } }

Measured on one install, 2026-09-10 (two documents present, two client_ids):

contexts in the newest document                        179
of those keyed by a thread root                          0
channels whose newest event is a thread reply            9

Not a single thread context exists — the format has no place to record that a thread was read.

Concrete case, one channel:

contexts[<channel>]                    1789018514  = 07:35:14   (newest top-level message)
newest event in the channel                        = 09:13:35   (a thread reply)
events in the channel                        20
of those unread by any reasonable reading     0

Opening the channel rewrites the context to 07:35:14 again, because that is the newest top-level message. The badge is therefore permanent. Eight further channels on the same install were in the identical state.

The local observed-unread.db is downstream of this: backfilling read_markers there — including thread-root markers, which the app never writes (0 markers across 62 threads) — clears nothing, because the badge is derived from the synced document. That is what makes this look like "the badge points at no thread" (#6428): the unread item is a thread reply, and the channel timeline shows nothing new.

Cross-device proof (2026-09-11). On 09-10 I rewrote the desktop client's document and set that channel's context to the newest event (11:43). By 09-11 both documents — one per client_id, i.e. one per device — had been republished by the apps (10:44 UTC and 14:18 UTC) and both carried 07:35:14 again. Each client independently derives the channel context as "newest top-level message" and pushes it; the relay document is a mirror of client state, not a source. That is why the badge is identical on iOS and desktop, and why no relay-side fix can hold. Desktop version at the time: 0.5.23 (latest). The relay itself has no server-side read/unread table at all (full schema checked).

Workaround that does not hold: decrypting the document, advancing each channel context to the newest event where the newest top-level message is already covered, re-encrypting and republishing under the same d-tag clears the badges — until the next client sync overwrites it. Per user only, since every member's document is encrypted with their own key.

Three suggestions

  1. Give contexts thread entries, or advance the channel context past thread replies. As it stands the two sides of the comparison cannot converge.
  2. Write a read marker for a thread root when the thread is opened, and when the user posts into it.
  3. Surface "N unread replies in threads" so a badge is explainable, instead of pointing at a channel whose visible timeline shows nothing new.

Side note: deleting a channel server-side leaves its observed_events rows in the local database, so a removed channel can keep contributing to the app badge. 16 deleted channels still held 71 rows here.

florianmatthias avatar Sep 11 '26 15:09 florianmatthias

Still happening as of 2026-11-09, on Windows desktop and the mobile app, signed in with the same identity on a hosted community (communities.buzz.xyz).

  • Channels and messages read on desktop still show as unread on the phone, and the reverse.
  • Notifications go the same way: the phone keeps alerting for messages that were already read on desktop.

Related: #9219 (the badge doesn't refresh when read state changes on another device), #9218 and #3238.

This is the most visible rough edge for us using Buzz as our day-to-day chat, so it gets a +1 from us for priority.

troyhoffman-oss avatar Nov 09 '26 20:11 troyhoffman-oss

🤖 Posted by an AI agent on behalf of @eeSeeGee.

Another data point, with a measurement: in our case the synced read state has no channel markers at all, and reading a channel on either device does not add one.

Environment: Buzz Desktop 1.0.5 (macOS), Buzz iOS, same identity, Block-hosted relay (advertises read_state_snapshot v1).

Symptom: iOS shows far more unread channels than Desktop, including channels that have been read on Desktop.

Measurement: ran buzz channels unread (the CLI bundled with Desktop 1.0.5, paired to Desktop as the same identity). It loads the NIP-RS atomic snapshot and max-merges every slot, so it is a proxy for what a fresh client derives from synced state.

  • The snapshot came back complete: true. There was no read_state_slots_skipped warning, so no slot was left out for an unknown schema.
  • last_read_at is null for all 27 member channels. Several show hundreds of unread messages, and one is capped at 1000.

Repro (2026-11-23, about one minute apart):

Action last_read_at after unread after
Opened a channel on Desktop and scrolled to the bottom null 3 (unchanged)
Opened a different channel on iOS null 6 (unchanged)
A DM actively read on both devices null 18

So neither client's read made it into the merged snapshot. From the outside I can't tell whether that's because neither client published, or because the relay didn't retain or return what they published.

One more observation, Desktop side: the WKWebView localStorage for this profile has no buzz.channel-read-state.v2:<pubkey> or buzz.channel-read-state.publishable.v1:<pubkey> key, which is where readStateStorage.ts on main persists local read state. The neighbouring per-identity keys (scroll positions, drafts, sidebar) are present. That points to Desktop not recording read state locally either, though 1.0.5 may store it somewhere main doesn't.

This looks like a stronger form of the original report: not stale markers, but none at all. Related: #9219, #6428. I'm happy to run any further diagnostic that helps.

eeSeeGee avatar Nov 23 '26 15:11 eeSeeGee

🤖 Correction to my comment above: the "zero synced markers" measurement was wrong. The CLI was authenticating as an agent identity, not my own, so it read that identity's empty read state. Re-measured as myself: markers are present on 42/76 channels and mutes round-trip correctly. Please disregard that data point.

eeSeeGee avatar Nov 23 '26 22:11 eeSeeGee