Skip to content

fix(chat): mark a page last when it reaches the beginning, cache topic names - #29590

Open
chrisnojima wants to merge 1 commit into
nojima/chat-ordinal-gap-invariantfrom
nojima/chat-last-page-and-topic-cache
Open

fix(chat): mark a page last when it reaches the beginning, cache topic names#29590
chrisnojima wants to merge 1 commit into
nojima/chat-ordinal-gap-invariantfrom
nojima/chat-last-page-and-topic-cache

Conversation

@chrisnojima

Copy link
Copy Markdown
Contributor

Service-side half of the thread-window work, split out of the pr this is based on so it can be reviewed on its own.

patchPaginationLast

A page that reaches message ID 1 - or the nukepoint an expunge recorded - is the last page whatever the pager says. Without this the client keeps asking for more of a conversation it has already seen the whole of, and the thread walks backwards through an expunged history one page at a time.

Topic-name cache

Resolving #channel tokens is charged per message: every body holding one read the inbox and then fetched the METADATA message of every channel in the team, so unboxing one page of a busy channel in a team with a few dozen channels cost thousands of single-message fetches. A short-TTL memory cache collapses the steady state.

Nothing invalidates the entry, so the TTL is the only bound on staleness and is deliberately short - the constant carries the argument, including what expiry does not heal, since a resolution is written into the message and persisted. A result missing channels is cached shorter still: the inbox read asks for every member status, so a team almost always carries channels the user has left or never joined and those fail on every pass, which makes "incomplete" the steady state rather than the exception.

Tests

convsource_patchpagination_test.go covers the last-page rule at both ends and that a settled page is left alone; teamchannelsource_topicnamecache_test.go covers the round trip, key separation, both-way copying, expiry on each of the two windows, and the clear paths. Run with go test ./chat/ -run 'TestPatchPagination|TestTopicName' - the rest of the package needs a local kbweb.

@chrisnojima
chrisnojima force-pushed the nojima/chat-last-page-and-topic-cache branch from b1c2726 to 1d2dcee Compare September 4, 2026 13:46
@chrisnojima
chrisnojima force-pushed the nojima/chat-last-page-and-topic-cache branch from 1d2dcee to 1c66413 Compare September 4, 2026 13:53
@chrisnojima
chrisnojima force-pushed the nojima/chat-last-page-and-topic-cache branch from 1c66413 to 8f4a1f1 Compare September 4, 2026 14:06
…c names

Split out of the client-side thread window work, which is the pr under this
one.

patchPaginationLast: a page that reaches message ID 1 - or the nukepoint an
expunge records - is the last page whatever the pager says, so the client
stops asking for more and stops walking a conversation it has already seen
the whole of.

The topic-name cache collapses the per-#token fan-out: every message body
holding a channel token used to read the inbox and then fetch the METADATA
message of every channel in the team, thousands of single-message fetches for
one page of a busy channel. The TTL is short because nothing invalidates the
entry, and a result missing channels is cached shorter still - a team almost
always carries channels the user cannot resolve, so refusing to cache those
would mean never caching anything.
@chrisnojima
chrisnojima force-pushed the nojima/chat-last-page-and-topic-cache branch from 8f4a1f1 to a4041c2 Compare September 4, 2026 20:28
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