Skip to content

Teams: a thread with more than 200 replies cannot be read past the first page - #824

Closed
itz4blitz wants to merge 1 commit into
mainfrom
issue/633-teams-chain-paging
Closed

itz4blitz wants to merge 1 commit into
mainfrom
issue/633-teams-chain-paging

Conversation

@itz4blitz

Copy link
Copy Markdown
Collaborator

What changed and why

A Teams thread longer than 200 replies can be read by scrolling up. Opening a link to an old reply loads the page that ends there. Once the start of the chain is stored, the post's reply count is every reply stored, not only the last page.

No client read names a reply-count field on the post, so the count is taken from the replies that were stored. This was not checked against a live tenant. The lab was not run.

Type

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

Platforms

  • windows
  • macos
  • linux
  • android
  • ios

Proof

Scenario: e2e/scenarios/teams-chain-paging

Lab run: not run

Compatibility

No protocol change. An older build ignores TINYCLIENT_PROVE and stays up, so the scenario fails there.

Risk and rollback

If a chain does not page with the same cursor a chat uses, scrolling asks for a page the service may not return. Revert this change.

Release note

A Teams thread longer than 200 replies loads the rest when you scroll up.

How tested

cargo test -p chatd --no-default-features --test teams (the new 450-reply chain and the existing channel test) and cargo clippy -p chatd --no-default-features --all-targets. Not tested on a live tenant. Lab not run.

Closes #633

@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

🟡 2 findings (0 blocking).

The fix lets a Teams reply chain keep Teams' paging cursor the way a chat does, reads a chain at 200 per page so scrolling up passes the first page, and adds a jump-into-chain path, a tested fake, and the lab's e2e scenario. The paging design matches the existing chat flow and the caps hold. Two gaps sit in the new jump path: held_older samples the chain's oldest stored ids instead of the rows adjacent below the scroll edge, so it can skip the one fetch that reconnects a jump window, and a jump page near the chain's start makes record() stamp a partial reply count onto the post. Both are majors; the cursor and window handling themselves are sound.

Residual risk

  • after() still returns early for chains on a line this diff does not touch, so rows newer than a jump target stay unread until the thread is reopened at its newest page.
  • For a chain long enough that its final page holds a full 200 replies, exact_chain never runs and the post keeps the approximate count earlier pages produced; replies_held also caps at 800 stored replies, so chains of roughly 800 to 1000 replies can show a capped count even when fully read.


/// True when a reply older than `before` is already stored, so this scroll was fetched.
fn held_older(&self, conversation: &str, before: &str) -> Result<bool, Fault> {
let ids = self.ctx.stored_ids(conversation, "", before, 8)?;

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.

⚠️ Major: stored_ids answers ids oldest first, so these 8 are the chain's oldest stored replies, not the rows adjacent below before. Once the new chain jump in around() has stored a detached window near the chain's start (say replies 1..30 while 51..450 are paged), every scroll at the 51 boundary returns true here and the catch-up fetch the server still queues for that window (the post-jump follow-up and blank-page anchors) is skipped, so the replies between the jump window and the paged region can never be fetched. Compare the ids nearest before (the tail of the query), or drop the early return; the cursor or time-window fetch is idempotent and record dedups.

if chain {
self.remember_cursor(conversation, &messages, &older);
}
self.record(conversation, &messages, !older.is_empty())

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.

⚠️ Major: A jump into a chain fetches the window ending just after the target. When the target sits near the chain's start, that window is short and carries no cursor, so record() runs exact_chain and rebuilds the post's summary from the stored replies only: jumping to reply 10 of a 450-reply thread stamps the post in the channel with a 10-reply count and the wrong last activity until the thread happens to be read to its end. Record jump pages with more_before true so only the true paging paths (backfill and older) exact the summary; a short chain still gets its count when it is opened.

Suggested change
self.record(conversation, &messages, !older.is_empty())
self.record(conversation, &messages, true)

Scrolling up follows the cursor Teams sends with each page, and opening an old reply loads the page that ends there. Once the start of the chain is stored, the post counts every reply that was stored.

Closes #633
@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.

Teams: a thread with more than 200 replies cannot be read past the first page

2 participants