diff --git a/ios/Packages/Sybil/Sources/Sybil/SybilChatTranscriptView.swift b/ios/Packages/Sybil/Sources/Sybil/SybilChatTranscriptView.swift index 8c78d6d..b6b44c0 100644 --- a/ios/Packages/Sybil/Sources/Sybil/SybilChatTranscriptView.swift +++ b/ios/Packages/Sybil/Sources/Sybil/SybilChatTranscriptView.swift @@ -52,20 +52,26 @@ struct SybilChatTranscriptView: View { .frame(maxWidth: .infinity, alignment: .leading) .scrollDismissesKeyboard(.interactively) .onAppear { - proxy.scrollTo("chat-bottom-anchor", anchor: .bottom) + scrollToBottom(with: proxy, animated: false) } .onChange(of: messages.map(\.id)) { _, _ in - withAnimation(.easeOut(duration: 0.22)) { - proxy.scrollTo("chat-bottom-anchor", anchor: .bottom) - } + scrollToBottom(with: proxy, animated: !isLoading) } .onChange(of: isSending) { _, _ in - withAnimation(.easeOut(duration: 0.22)) { - proxy.scrollTo("chat-bottom-anchor", anchor: .bottom) - } + scrollToBottom(with: proxy, animated: true) } } } + + private func scrollToBottom(with proxy: ScrollViewProxy, animated: Bool) { + if animated { + withAnimation(.easeOut(duration: 0.22)) { + proxy.scrollTo("chat-bottom-anchor", anchor: .bottom) + } + } else { + proxy.scrollTo("chat-bottom-anchor", anchor: .bottom) + } + } } private struct MessageBubble: View {