Skip to content

Keep a local mark-read from being undone by a stale network count - #146

Merged
itz4blitz merged 4 commits into
mainfrom
fix/stale-read-counts
Nov 3, 2026
Merged

itz4blitz merged 4 commits into
mainfrom
fix/stale-read-counts

Conversation

@itz4blitz

Copy link
Copy Markdown
Collaborator

Summary

  • Opening a Tiny chat can clear unread locally, then bouncing Inbox → Tiny server → Inbox put the badge back: OpenSpace refresh called set_counts with a stale unread (and often no last_read on channels).
  • set_counts now keeps a local last_read that is ahead of the network's cursor, and never restores a badge when the list omits a cursor while this install is already caught up.
  • Regression: a_stale_network_count_does_not_undo_a_local_read (failed red before the guard, green after).

Proof

  1. Red: after mark_read to the newest id, set_counts(unread=2, last_read=None) returned changed and left unread=2 — the Tiny channel refresh shape.
  2. Green: same sequence leaves unread=0; an older network cursor cannot rewind last_read; a newer network cursor still wins.
  3. cargo test -p chatd --lib --no-default-features store::tests — 24 passed.

Test plan

  • Install the release build after merge.
  • Tiny server: open an unread DM or channel until the badge clears.
  • Go Inbox → Tiny server → Inbox (or People). Badge should stay cleared.
  • A genuinely new message afterward should still raise unread.

Made with Cursor

itz4blitz and others added 4 commits November 2, 2026 18:23
Tiny OpenSpace refresh was restoring unread after this install had already caught up, because set_counts trusted every network badge even when our last_read was ahead or the list omitted a cursor.

Co-authored-by: Cursor <cursoragent@cursor.com>
The stale-count guard was treating every omitted last_read as a Tiny refresh, which blocked Discord's CHANNEL_UNREAD_UPDATE and unopened-channel MESSAGE_CREATE paths that intentionally pass no cursor with a newer updated time.

Co-authored-by: Cursor <cursoragent@cursor.com>
Loading a Slack thread was advancing last_read past Slack's marker because past outgoing replies cleared unread like a send, so the stale-count guard then ignored Slack's real unread=1. Only a live send clears now.

Co-authored-by: Cursor <cursoragent@cursor.com>
…live.

Teams (and the shell) store the pending row with unread=false; after history stopped clearing on outgoing, that left the badge up until an echo whose timestamp could not beat pending's updated time. Pending outgoing clears again; past history still does not.

Co-authored-by: Cursor <cursoragent@cursor.com>
@itz4blitz
itz4blitz merged commit eceb2af into main Nov 3, 2026
6 checks passed
@itz4blitz
itz4blitz deleted the fix/stale-read-counts branch November 3, 2026 01:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant