Stabilize realtime voice meter sampling across redraws (#43695)

## Why

Footer updates and transcript animation can trigger redraws before more audio arrives, consuming peaks too early and adding spurious quiet samples. Old peaks also linger in the meter after a channel becomes quiet.

## What changed

- Sample microphone and speaker peaks at most once every 100 ms, preserving accumulated peaks on early redraws and scheduling the next sampling frame.
- Clear each channel's meter history on its first quiet sample without clearing the other channel.

## Testing

Add regression tests for early redraw scheduling, peak preservation, independent channel silence, delayed sampling, and sampling after a conversation reset. Snapshot the meters at wide and narrow widths and after each channel becomes quiet.

GitOrigin-RevId: d7b116af2c099a2eaeb6db0d66bca93b230db970
This commit is contained in:
Benjamin Carlsson authored and copyberry committed 2026-09-08 04:21:46 +00:00
1 parent 45305dd229
commit 9a3af22d01
4 files changed
+137 -6

No files matched your search

+1
View File
@@ -145,6 +145,7 @@ pub(super) struct RealtimeConversationUiState {
microphone_history: VoiceAmplitudeHistory,
speaker_history: VoiceAmplitudeHistory,
audio_meter_history: VecDeque<(u8, u8)>,
next_audio_meter_sample_at: Option<Instant>,
speaker_active_until: Option<Instant>,
interruption_acknowledged_until: Option<Instant>,
speaker_suppression_generation: Option<u64>,