be424703c4
Replace one-shot VAD calibration with a rolling deque window that continuously recalibrates the noise floor throughout TTS playback, preventing false barge-in triggers from stale calibration. Add a grace period before VAD activates so TTS playback establishes first. Suppress duplicate text rendering when token streaming is enabled. Mirror the barge-in and TTS stream stop logic to the TUI gateway path so both CLI and gateway use the same VAD semantics. Rolling-window VAD: - 90th percentile of rolling window (~3s) for noise floor - 8x multiplier (was 5x) for TTS volume variation headroom - 4000 RMS trigger ceiling so genuine speech can still trip - min_floor clamped to SILENCE_RMS_THRESHOLD * 2 - sustained_ms=1000, calibration_ms=800 Barge-in grace period (barge_in_grace_seconds, default 2.0s): Delays VAD activation so TTS playback establishes before the mic opens. Duplicate render suppression: When streaming_enabled, pass display_callback=None to stream_tts_to_speaker so the token stream is the sole display path. TUI gateway mirror: Mirror _tts_stream_stop and _tts_stream_barge_in_monitor changes to tui_gateway/server.py so both code paths use the same VAD parameters, grace period, and TTS CUT diagnostic logging. Profile-scoped session DB and MoA progress events in tui_gateway/server.py were necessitated by the TTS pipeline changes affecting session state and event routing. Normal-exit flag and TTS CUT diagnostic logging at all cut paths. Regression tests: - test_quiet_then_loud_playback_does_not_trip - test_8x_multiplier_absorbs_tts_volume_spikes - test_trigger_ceiling_lets_genuine_speech_trip - test_silence_calibration_does_not_false_trip_on_tts - test_tts_stream_stop_latches_interruption_for_next_turn - test_tts_stream_stop_after_natural_finish_does_not_latch - Profile-scoped session DB tests (10 tests)