Repository navigation
Conversation
Tiny Code Reviewthe AI provider rate-limited the request This is advice, not a gate. Re-run with the |
unRekable
left a comment
There was a problem hiding this comment.
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
35b3d0a to
b87798e
Compare
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
Platforms
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, andcargo clippy -p chatd --no-default-features --all-targets.TINYCLIENT_PROVE=discord-thread-chipexits 0 and printsprove-discord-thread-chip:0.Not tested: no live Discord account, and the lab was not run.
Closes #387