From c1bf40184acd712f82512bbdf15dcd38d10d1052 Mon Sep 17 00:00:00 2001 From: ayn2op Date: Sun, 17 May 2026 19:24:14 -0400 Subject: [PATCH] fix(chat): synchronize typing timer access --- internal/ui/chat/message_input.go | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/internal/ui/chat/message_input.go b/internal/ui/chat/message_input.go index f225beb..009b505 100644 --- a/internal/ui/chat/message_input.go +++ b/internal/ui/chat/message_input.go @@ -102,6 +102,8 @@ func (mi *messageInput) reset() { } func (mi *messageInput) stopTypingTimer() { + mi.typingTimerMu.Lock() + defer mi.typingTimerMu.Unlock() if mi.typingTimer != nil { mi.typingTimer.Stop() mi.typingTimer = nil @@ -237,15 +239,21 @@ func closeFiles(files []sendpart.File) tview.Cmd { } func (mi *messageInput) sendTyping() tview.Cmd { - if !mi.cfg.TypingIndicator.Send || mi.typingTimer != nil { + if !mi.cfg.TypingIndicator.Send { return nil } + mi.typingTimerMu.Lock() + if mi.typingTimer != nil { + mi.typingTimerMu.Unlock() + return nil + } mi.typingTimer = time.AfterFunc(typingDuration, func() { mi.typingTimerMu.Lock() mi.typingTimer = nil mi.typingTimerMu.Unlock() }) + mi.typingTimerMu.Unlock() selectedChannel := mi.chat.SelectedChannel() if selectedChannel == nil { @@ -284,10 +292,7 @@ func (mi *messageInput) send() tview.Cmd { editMessage = *message } - if mi.typingTimer != nil { - mi.typingTimer.Stop() - mi.typingTimer = nil - } + mi.stopTypingTimer() mi.reset() mi.chat.messagesList.clearSelection() mi.chat.messagesList.ScrollBottom()