Skip to content

fix(thread): reply thread header counts the server's total, not the loaded page - #5159

Closed
stamp-build[bot] wants to merge 2 commits into
mainfrom
agent/lagoon/thread-header-reply-total
Closed

stamp-build[bot] wants to merge 2 commits into
mainfrom
agent/lagoon/thread-header-reply-total

Conversation

@stamp-build

@stamp-build stamp-build Bot commented Nov 20, 2026

Copy link
Copy Markdown
Contributor

Lagoon from raft opened this pull request through Stamp
View in Stamp →


Problem

Report (Android, 1.27.0): the reply count at the top of a reply thread is the number of replies on screen, not the thread's total. A very long thread opened from the channel says "30 replies" (one page).

Cause

The header shows max(loaded replies + hidden history, the origin's reply summary) (threadHeaderReplyCount). The origin's summary was 0, so the loaded page won:

  1. ThreadPage.kt hands the tapped row to SharedThreadDataSource.rememberReplyParentCandidate. The row comes from the timeline slice, which carries no reply facts (withoutThreadReplyMetadata), so the remembered parent has replyCount = 0. The thread resolves its origin from that remembered copy (resolveReplyParentMessageFromStore) and never reads the parent again, so nothing corrects it.
  2. The thread's own open, POST /channels/:id/threads, answers { threadChannelId, replyCount, lastReplyAt, participantIds } (server getThreadInfoForChannel). loadReplyThread parsed replyCount and dropped it.

Not a 1.27 regression: the row has been handed over without reply facts since 2026-06-27 (8912d610c7 / 4b83c28e06), and the header has used this formula since 1.24.0 (#4557). Opens that read the parent from messages/context (no remembered copy) were right, because that response carries threadSummariesByParentMessageId.

Fix

  • ThreadSnapshot.replyThreadReplyCount: the reply load keeps the open answer's total. The data source puts it on the resolved parent and on the remembered copy (withReplyThreadReplyCountOnParent), so the thread's own read replaces an older count.
  • rememberReplyParentCandidate(replyCount = ...): the row's reply count rides the candidate. This is for opens that already know the thread channel, which ask the server nothing that carries a total (same as the web, which uses its cached thread summary there).
  • rememberReplyParentReplyCount: a thread:updated also grows the remembered parent's count, so a later open does not start from an old total.

No new request. Web reference (botiverse/slock 7c3e67b8): ThreadPanelHeader counts max(loaded + hidden, threadSummaries[parent].replyCount); the summary comes from the channel page / messages/context threadSummariesByParentMessageId, from GET /channels/:id/threads/:messageId when the thread channel is unknown, and from thread:updated.

ThreadPage.kt: two one-line argument additions inside the onThreadEvent lambda (the row's count is only known there).

Not covered

  • A parent behind the plan's history window has no origin row, so the header still counts loaded + hidden replies there.
  • The web also falls back to the followed-threads list's replyCount; mobile does not.

Tests

  • SharedThreadReplyThreadReplyTotalTest: a thread opened from its row counts what the row knew; the open answer's total replaces an older remembered count and is remembered; a live count only grows the remembered parent; the total never lowers a count; which conversation a thread:updated names.
  • ConversationRepositoryReplyThreadReplyCountTest: the reply load keeps replyCount from the canonical POST /channels/:id/threads body.

Not run locally (no JDK); hosted CI on this PR. Needs a device check: open a thread with more than 30 replies from its channel row, from Activity and from a notification.

🤖 Generated with Claude Code

Lagoon and others added 2 commits November 20, 2026 11:38
…oaded page

A long thread opened from its row in the channel said "30 replies": one page.
The header shows max(loaded replies, the origin's reply summary), and the
origin's summary was 0 there:

- The row handed to rememberReplyParentCandidate comes from the timeline
  slice, which carries no reply facts (withoutThreadReplyMetadata), so the
  remembered parent said replyCount = 0. The thread resolves its origin from
  that remembered copy and never reads the parent again.
- The thread's own open (POST /channels/:id/threads) answers
  { threadChannelId, replyCount, ... }; loadReplyThread parsed replyCount and
  dropped it.

Now:
- The reply snapshot keeps the open answer's total
  (ThreadSnapshot.replyThreadReplyCount) and the data source puts it on the
  resolved parent and on the remembered copy, so it replaces an older count.
- The row's reply count rides the parent candidate (the web's cached thread
  summary), for opens that already know the thread channel and so ask the
  server nothing that carries a total.
- A thread:updated also grows the remembered parent's count, so a later open
  does not start from an old total.

Web reference (botiverse/slock 7c3e67b8): ThreadPanelHeader counts
max(loaded + hidden, threadSummaries[parent].replyCount); the summary comes
from the channel page / messages/context threadSummariesByParentMessageId,
GET /channels/:id/threads/:messageId when the thread channel is unknown, and
thread:updated.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@stamp-build

stamp-build Bot commented Nov 20, 2026

Copy link
Copy Markdown
Contributor Author

Merged by Stamp in batch 894d75681ac8d24d90255bd7f50b16c5: 99f4e64 . The batch passed its required CI; this PR is closed because its commit was included by fast-forward.

Review in stamp.build

@stamp-build stamp-build Bot closed this Nov 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants