Repository navigation
fix(bots): show the latest messages in bot chats - #472
Merged
Merged
Conversation
Order messages and approval cards together before clients select the latest history window. Previously, appended forwarded approvals could occupy the whole window while the sidebar still showed the latest reply. Cover the shared projection and real gateway paging, routine messages, cached deltas and older-page merges. Fixes: #289
This was referenced Nov 13, 2026
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.
Change
Bot chats now choose their latest visible entries after messages and approval cards have been ordered together. Later user messages, bot replies and routine notifications remain visible after a long history of approvals forwarded from bot-started threads.
The root cause is the interaction between
botEntriesand the 100-entry web window introduced in #289.botEntriesreturned messages followed by all approvals.ChatViewsliced that array beforelayoutChatsorted it. With 50 loaded messages and 105 older approval cards, the selected window contained only approvals, even though the gateway and sidebar had the latest reply. Sorting insidelayoutChatcould not recover discarded entries. The shared projection now orders entries by creation time before callers window them, using the same ordering as the existing layout.The gateway's descending
seqtail query, cursor/delta merging and routinemessage_userrows retain the latest messages; regression coverage exercises these paths through the real gRPC API and PostgreSQL. Approval resolution does not reorder cards. Mobile already lays out the complete loaded projection before reversing it and does not apply the web's slice; shared domain coverage confirms its last row agrees with the web. The fix is TypeScript only and adds no RPCs, queries, migrations or native changes.Verification
TMPDIR=/var/tmp bun test packages/domain/src/bot-chat/layout.test.ts tests/integration/bot-chat-history.test.ts tests/integration/bot-view-deltas.test.ts: 9 passed, 0 failed. Existing delta coverage includes restart, linked homes and owner/view scoping.bun install --frozen-lockfile,bun run typecheck,bun run lint,bun run formatandbun run format:checkpassed. Fixed the new fixtures' lint spacing findings before the final clean runs.check:tmp, generated-code checks and production builds remain CI gates per the task's shared-machine limits. No packaged macOS or native mobile device run; the affected colleague's database was unavailable. No new UI text or UI test suite.Fixes: #289