Skip to content

fix(bots): show the latest messages in bot chats - #472

Merged
nixuuu merged 1 commit into
devfrom
fix/bot-chat-latest-messages
Nov 10, 2026
Merged

nixuuu merged 1 commit into
devfrom
fix/bot-chat-latest-messages

Conversation

@nixuuu

@nixuuu nixuuu commented Nov 10, 2026

Copy link
Copy Markdown
Member

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 botEntries and the 100-entry web window introduced in #289. botEntries returned messages followed by all approvals. ChatView sliced that array before layoutChat sorted 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 inside layoutChat could 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 seq tail query, cursor/delta merging and routine message_user rows 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

  • Regression failed before the fix: the latest user, bot and routine messages were absent from the visible window. Added domain and real gateway tests for forwarded approvals, the bounded initial page, sidebar agreement, cached deltas, later messages and older-page merges.
  • 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 format and bun run format:check passed. Fixed the new fixtures' lint spacing findings before the final clean runs.
  • Real browser with an isolated seeded gateway and scripted worker: temporarily restoring the original projection rendered zero message rows and approved cards at the bottom while the sidebar showed the routine reply. Restoring the fix rendered all 50 loaded messages, with the same latest routine reply as the sidebar. Checked light/dark at 1280×800 and 390×844; the last message remained visible at the bottom without horizontal overflow. Temporary servers and browser tab were closed.
  • Full-suite 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

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
@nixuuu
nixuuu merged commit a8c7461 into dev Nov 10, 2026
9 checks passed
@nixuuu
nixuuu deleted the fix/bot-chat-latest-messages branch November 10, 2026 08:43
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