From 913530402dfa0fcf4a565eb91be73313166379c7 Mon Sep 17 00:00:00 2001 From: Gustavo Madeira Santana Date: Mon, 26 Jan 2026 23:41:19 -0500 Subject: [PATCH] fix: local updates for PR #2471 Co-authored-by: kennyklee --- .../Sources/ClawdbotChatUI/ChatView.swift | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/apps/shared/ClawdbotKit/Sources/ClawdbotChatUI/ChatView.swift b/apps/shared/ClawdbotKit/Sources/ClawdbotChatUI/ChatView.swift index bc8c3493e..99b32779f 100644 --- a/apps/shared/ClawdbotKit/Sources/ClawdbotChatUI/ChatView.swift +++ b/apps/shared/ClawdbotKit/Sources/ClawdbotChatUI/ChatView.swift @@ -13,6 +13,7 @@ public struct ClawdbotChatView: View { @State private var showSessions = false @State private var hasPerformedInitialScroll = false @State private var isPinnedToBottom = true + @State private var lastUserMessageID: UUID? private let showsSessionSwitcher: Bool private let style: Style private let markdownVariant: ChatMarkdownVariant @@ -141,7 +142,19 @@ public struct ClawdbotChatView: View { } } .onChange(of: self.viewModel.messages.count) { _, _ in - guard self.hasPerformedInitialScroll, self.isPinnedToBottom else { return } + guard self.hasPerformedInitialScroll else { return } + if let lastMessage = self.viewModel.messages.last, + lastMessage.role.lowercased() == "user", + lastMessage.id != self.lastUserMessageID { + self.lastUserMessageID = lastMessage.id + self.isPinnedToBottom = true + withAnimation(.snappy(duration: 0.22)) { + self.scrollPosition = self.scrollerBottomID + } + return + } + + guard self.isPinnedToBottom else { return } withAnimation(.snappy(duration: 0.22)) { self.scrollPosition = self.scrollerBottomID }