Previously, the auto-scroll LaunchedEffect was keyed to `state.streamingMessage?.content?.length`, which resulted in the scroll animation coroutine being cancelled and restarted for every single token received during message generation. This caused a heavy performance hit and interrupted smooth scrolling. This commit updates the `LaunchedEffect` key to use `state.streamingMessage != null` instead. The scroll-to-bottom logic now appropriately initiates when a message *begins* streaming (or finishes thinking), while avoiding continuous job restarts as the payload streams in. Resolves #274
This commit is contained in:
1 file changed
+1
-1
@@ -212,7 +212,7 @@ fun ChatScreen(
|
||||
}
|
||||
|
||||
// Auto-scroll to bottom on new messages
|
||||
LaunchedEffect(state.messages.size, state.streamingMessage?.content?.length, state.isThinking) {
|
||||
LaunchedEffect(state.messages.size, state.streamingMessage != null, state.isThinking) {
|
||||
val totalItems =
|
||||
state.messages.size +
|
||||
(if (state.streamingMessage != null) 1 else 0) +
|
||||
|
||||
Reference in new issue
Block a user