Skip to content

Discord: a message's thread chip shows no faces, no unread count and a stale reply count - #814

Closed
itz4blitz wants to merge 1 commit into
mainfrom
issue/387-thread-chip
Closed

itz4blitz wants to merge 1 commit into
mainfrom
issue/387-thread-chip

Conversation

@itz4blitz

Copy link
Copy Markdown
Collaborator

What changed and why

A message that starts a Discord thread now keeps a current chip. New replies raise the reply count, show the newest faces, and carry the thread's unread count. A later thread update raises the count when Discord's number is ahead, without dropping those faces. Opening the thread does not count a reply Discord had already included.

Type

  • feature
  • fix
  • perf
  • refactor
  • chore
  • docs

Platforms

  • windows
  • macos
  • linux
  • android
  • ios

Proof

Scenario: e2e/scenarios/discord-thread-chip

Lab run: not run

Compatibility

No protocol change. Older clients and servers keep working. A build without this change ignores TINYCLIENT_PROVE=discord-thread-chip and stays up, so the scenario driver fails there.

Risk and rollback

A wrong chip can show a stale count or the wrong faces on the starter message. Revert this change.

Release note

A Discord thread chip shows who replied, how many replies there are, and how many are unread.

Testing

cargo test -p chatd --no-default-features --test discord a_thread_chip_counts_replies_and_shows_their_faces, plus the history and start-thread Discord tests, and cargo clippy -p chatd --no-default-features --all-targets. TINYCLIENT_PROVE=discord-thread-chip exits 0 and prints prove-discord-thread-chip:0.

Not tested: no live Discord account, and the lab was not run.

Closes #387

@github-actions

github-actions Bot commented Nov 17, 2026 •

Copy link
Copy Markdown

Tiny Code Review

⚠️ Code review unavailable · run

the AI provider rate-limited the request

This is advice, not a gate. Re-run with the agent:review label or a /review comment.

@unRekable unRekable left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

🟢 No findings.

The diff makes a Discord thread chip live by seeding a persisted note (parent, starter, newest seen reply id) when a starter is carried or a thread is started, folding live replies onto it behind a snowflake seen-gate so replies Discord already counted are not counted again, and raising count, timestamp and unread from THREAD_UPDATE while keeping the learned faces. The design holds: the seen-gate plus monotonic max() keeps the count consistent whichever of MESSAGE_CREATE or THREAD_UPDATE arrives first, faces stay capped at THREAD_FACES, unread always resyncs from the conversation row, deletions leave the tombstone foldable, and the wire is untouched. The double-count invariant is proven only for payloads that carry last_message_id, which the fixture always does; that and two smaller edges are residual, not defects in the diff.

Residual risk

  • If a carried starter's thread object ever lacks last_message_id while message_count is ahead of it, chip.seen stays 0 and the thread's first page fetch re-counts its stored replies; both carried_thread and note_thread_update only raise replies, so the chip would stay over-counted. The fixture always carries last_message_id, so the tests cannot catch such a payload.
  • For a thread whose starter has scrolled off the parent's newest page, no chip note exists and note_thread_update's starter guess (known.root, which is the thread id, not the starter message id) never matches a stored message, so such a chip stays frozen until a page carries the starter again.
  • read_chip parses the tab-joined note with parse().unwrap_or(0), so any malformed or extended note silently resets seen to 0, which would re-count old replies; the format has no version mark.
  • Deleting replies lowers Discord's message_count, but carried_thread's max(had.replies) and note_thread_update's count > summary.replies both refuse to lower a learned count, so a chip can stay high after moderation deletes replies.

A reply updates the starter chip with the count, the newest faces, and unread. A thread update copies Discord's count when it is ahead.

Closes #387
@itz4blitz

Copy link
Copy Markdown
Collaborator Author

Superseded by and merged in #903 (d387971 — Release 2026-11-20 combined PR).

@itz4blitz itz4blitz closed this Nov 21, 2026
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.

Discord: a message's thread chip shows no faces, no unread count and a stale reply count

2 participants