Repository navigation
Open chat history at any message, and page towards the present (GRYT-1686) - #282
Merged
Merged
Conversation
…1686) chat:fetch could only page backwards, with `before`. Jumping to an old pin or reply meant loading every page in between, and the client gave up after 1,000 messages. It now takes two more options: - `around: <message id>` returns half a page each side of that message, with the message itself. `anchorFound` is false when it's gone or is a thread reply. - `after: <time>` returns the next page, oldest first, for scrolling down from an old window towards the present. Both answers carry `hasNewer`, so the client knows when it has reached the newest message. A request that uses neither gets exactly the response it always did, which keeps older clients working. listMessagesAfter is the one new query: the mirror of listMessages, with `created_at >` and ascending order. The test checks that the two halves join around a message with no gap or repeat, and that paging forward walks the whole channel once. The page limit is now capped at 100. It was whatever the client sent. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The server half of opening chat history at any message, instead of paging back to it. Task: GRYT-1686. The client half is client#812. It falls back to paging on a server without this, so the two can land in either order.
What changed
chat:fetchtakes two more options:around: <message id>returns half a page each side of that message, plus the message itself.anchorFoundcomes backfalsewhen the message is gone or is a thread reply.after: <ISO time>returns the next page, oldest first, for scrolling down from an old window towards the present.Both answers carry
hasNewer, and the client merges its window back into the channel's list once that's false. A request with neither option gets exactly the response it always did.listMessagesAfterinsrc/db/sqlite/messages.tsis the only new query. It mirrorslistMessages:created_at >and ascending.Look at
src/dbis review-required. The query is one prepared statement with the sameconversation_id/thread_id IS NULLfilters aslistMessages, using the existing(conversation_id, created_at)index.created_at, likebeforealready did, so a message sharing the anchor's exact millisecond would be skipped. That's the existing pagination behaviour, not new.before.Tested
messagesWindow.test.ts: forward pages, thread replies left out, a short last page, the two halves joining around a message with no gap or repeat, and a forward walk covering all 30 messages exactly once. The full suite passes (1,991).afterpages reached the present, and the window mergedaround) fell back to paging and found it in about 4 s.🤖 Generated with Claude Code