From 6c404ba7fdb0eb2855d9f342d55968feb91d57da Mon Sep 17 00:00:00 2001 From: Blake Oliver Date: Mon, 20 Apr 2026 17:56:03 -0600 Subject: [PATCH] Run scroll to bottom in a task on the main actor for chat and dm buffer views This should hopefully avoid the reported bug where a user can't scroll to with voiceover / presumably see their last message until sending another. --- KDChat/Views/ChatBufferView.swift | 4 +++- KDChat/Views/DMConversationView.swift | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/KDChat/Views/ChatBufferView.swift b/KDChat/Views/ChatBufferView.swift index 15675e5..b0c6baf 100644 --- a/KDChat/Views/ChatBufferView.swift +++ b/KDChat/Views/ChatBufferView.swift @@ -40,7 +40,9 @@ struct ChatBufferView: View { } .onChange(of: messages.count) { guard let last = messages.last, last.sessionId == manager.sessionId else { return } - proxy.scrollTo(last.persistentModelID, anchor: .bottom) + Task { @MainActor in + proxy.scrollTo(last.persistentModelID, anchor: .bottom) + } let isActive = bufferName == manager.activeBuffer let playBackground = UserDefaults.standard.bool(forKey: "sounds_background_buffers", default: true) diff --git a/KDChat/Views/DMConversationView.swift b/KDChat/Views/DMConversationView.swift index 1a4cf90..bf56813 100644 --- a/KDChat/Views/DMConversationView.swift +++ b/KDChat/Views/DMConversationView.swift @@ -36,7 +36,9 @@ struct DMConversationView: View { } .onChange(of: messages.count) { guard let last = messages.last, last.sessionId == manager.sessionId else { return } - proxy.scrollTo(last.persistentModelID, anchor: .bottom) + Task { @MainActor in + proxy.scrollTo(last.persistentModelID, anchor: .bottom) + } // Sound if UserDefaults.standard.bool(forKey: "sounds_enabled", default: true),