codetether-agent 4.7.0-a-002.3

A2A-native AI coding agent for the CodeTether ecosystem
Documentation
//! Poll the pending voice transcription slot and inject text into input.

use crate::tui::app::state::AppState;

/// Check for a completed transcription and append text to the input buffer.
/// Called from the tick loop. Clears the slot after consuming.
pub fn drain_voice_transcription(state: &mut AppState) {
    let slot = match &state.pending_voice_text {
        Some(s) => s.clone(),
        None => return,
    };
    let text = match slot.try_lock().ok().and_then(|mut g| g.take()) {
        Some(t) => t,
        None => return,
    };
    state.pending_voice_text = None;
    if text.is_empty() {
        state.status = "Voice transcription produced no text".into();
        return;
    }
    state.insert_text(&text);
    state.status = "Voice transcribed ✓".into();
}