paginated messages: load latest 100, scroll-up for older

Backend:
- Add before_seq + limit params to list_messages
- When limit set without after_seq, ORDER BY DESC then reverse (gets latest page)
- Reject after_seq + before_seq together (400)
- Cap limit at 1000, no default change (CLI compat)

Frontend:
- Initial load fetches ?limit=100, scrolls to bottom
- Scroll near top triggers ?before_seq=lowestSeq&limit=100
- useLayoutEffect maintains scroll position after prepend
- Gap repair loops after_seq fetches until caught up
- Auto-scroll only when near bottom (doesn't yank while reading)
- "loading older..." and "beginning of conversation" indicators

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-03-30 08:47:03 +02:00
parent 73696bc58c
commit e0b93ab141
4 changed files with 232 additions and 88 deletions

View File

@@ -124,6 +124,8 @@ pub struct AckRequest {
#[derive(Debug, Deserialize)]
pub struct MessageQuery {
pub after_seq: Option<i64>,
pub before_seq: Option<i64>,
pub limit: Option<i64>,
pub r#type: Option<MessageType>,
pub user_id: Option<Uuid>,
}