@@ -151,6 +151,7 @@ func (m consoleModel) Init() tea.Cmd {
151151 }
152152 if m .textMode {
153153 cmds = append (cmds , textinput .Blink )
154+ m .applyTextMode (true )
154155 }
155156 return tea .Batch (cmds ... )
156157}
@@ -216,6 +217,7 @@ func (m consoleModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
216217 m .showShortcuts = false
217218 m .partialTranscript = ""
218219 m .textInput .Focus ()
220+ m .applyTextMode (true )
219221 return m , textinput .Blink
220222 case "?" :
221223 m .showShortcuts = ! m .showShortcuts
@@ -259,6 +261,7 @@ func (m consoleModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
259261 m .audioError = ""
260262 m .inputDev = "Default Input"
261263 m .outputDev = "Default Output"
264+ m .applyTextMode (false )
262265 }
263266 return m , nil
264267
@@ -289,6 +292,7 @@ func (m *consoleModel) switchToAudio() tea.Cmd {
289292 m .showShortcuts = false
290293 m .textInput .Blur ()
291294 m .audioError = ""
295+ m .applyTextMode (false )
292296 return nil
293297 }
294298 // Lazy init audio in a goroutine
@@ -297,6 +301,34 @@ func (m *consoleModel) switchToAudio() tea.Cmd {
297301 }
298302}
299303
304+ // applyTextMode pauses the local audio pipeline and asks the agent to
305+ // disable/enable audio I/O so STT/TTS aren't running in text mode.
306+ func (m * consoleModel ) applyTextMode (text bool ) {
307+ if m .pipeline .HasAudio () {
308+ m .pipeline .SetPaused (text )
309+ }
310+
311+ m .reqCounter ++
312+ reqID := fmt .Sprintf ("console-io-%d" , m .reqCounter )
313+ audioOn := ! text
314+ transcriptionOn := ! text
315+ req := & agent.SessionRequest {
316+ RequestId : reqID ,
317+ Request : & agent.SessionRequest_UpdateIo {
318+ UpdateIo : & agent.SessionRequest_UpdateIO {
319+ Input : & agent.SessionRequest_UpdateIO_Input {
320+ AudioEnabled : & audioOn ,
321+ },
322+ Output : & agent.SessionRequest_UpdateIO_Output {
323+ AudioEnabled : & audioOn ,
324+ TranscriptionEnabled : & transcriptionOn ,
325+ },
326+ },
327+ },
328+ }
329+ go m .pipeline .SendRequest (req )
330+ }
331+
300332func (m * consoleModel ) beginShutdown () tea.Cmd {
301333 m .shuttingDown = true
302334 m .textMode = false
0 commit comments