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.
This commit is contained in:
Blake Oliver 2026-04-20 17:56:03 -06:00
parent 76ebe0f771
commit 6c404ba7fd
No known key found for this signature in database
2 changed files with 6 additions and 2 deletions

View file

@ -40,7 +40,9 @@ struct ChatBufferView: View {
} }
.onChange(of: messages.count) { .onChange(of: messages.count) {
guard let last = messages.last, last.sessionId == manager.sessionId else { return } 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 isActive = bufferName == manager.activeBuffer
let playBackground = UserDefaults.standard.bool(forKey: "sounds_background_buffers", default: true) let playBackground = UserDefaults.standard.bool(forKey: "sounds_background_buffers", default: true)

View file

@ -36,7 +36,9 @@ struct DMConversationView: View {
} }
.onChange(of: messages.count) { .onChange(of: messages.count) {
guard let last = messages.last, last.sessionId == manager.sessionId else { return } 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 // Sound
if UserDefaults.standard.bool(forKey: "sounds_enabled", default: true), if UserDefaults.standard.bool(forKey: "sounds_enabled", default: true),