fix: auto-scroll chat when messages exceed display limit

LaunchedEffect key was based on messages.size which stays constant
at INITIAL_LOAD_COUNT (50) once the DB has enough messages. Use the
latest message ID instead so the effect re-fires on every new message.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Kohei 2026-02-19 22:22:19 +09:00
parent c7f6095904
commit dda0dd9d5f

View file

@ -146,7 +146,7 @@ fun ChatScreen(
derivedStateOf { listState.firstVisibleItemIndex <= 3 }
}
LaunchedEffect(uiState.messages.size) {
LaunchedEffect(uiState.messages.firstOrNull()?.id) {
if (isNearBottom) {
listState.animateScrollToItem(0)
}