From 0010bc6cf74fa57a1b1ea39bd49f928dcc8a1e50 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jose=20Luis=20Monta=C3=B1es=20Ojados?= Date: Sat, 17 Jan 2026 17:10:21 +0100 Subject: [PATCH] Fix bug where disabling PTT would incorrectly stop VAD capture --- cmd/tui/model.go | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/cmd/tui/model.go b/cmd/tui/model.go index 6a13686..4baa32a 100644 --- a/cmd/tui/model.go +++ b/cmd/tui/model.go @@ -706,6 +706,17 @@ func (m *Model) handleKeyPress(msg tea.KeyMsg) (tea.Model, tea.Cmd) { state := "OFF" if m.vadEnabled { state = "ON" + // Ensure capturer is running if VAD is on + if m.audioCapturer != nil && !m.audioCapturer.IsRunning() { + if err := m.audioCapturer.Start(); err != nil { + m.addLog("Error starting VAD capture: %v", err) + } + } + } else { + // Stop if PTT is also off + if !m.isPTT && m.audioCapturer != nil && m.audioCapturer.IsRunning() { + m.audioCapturer.Stop() + } } m.addLog("Voice Activation (Gate): %s", state) return m, nil @@ -714,12 +725,15 @@ func (m *Model) handleKeyPress(msg tea.KeyMsg) (tea.Model, tea.Cmd) { // Toggle voice (PTT) m.isPTT = !m.isPTT if m.isPTT { - if m.audioCapturer != nil { - m.audioCapturer.Start() + if m.audioCapturer != nil && !m.audioCapturer.IsRunning() { + if err := m.audioCapturer.Start(); err != nil { + m.addLog("Audio capture error: %v", err) + } } m.addLog("🎤 Transmitting...") } else { - if m.audioCapturer != nil { + // Stop only if VAD is also off + if !m.vadEnabled && m.audioCapturer != nil && m.audioCapturer.IsRunning() { m.audioCapturer.Stop() } m.addLog("🎤 Stopped transmitting")