Conversation
The voice inactivity timer (VOICE_TIMEOUT) only counted the bot's OWN audio playback as activity. Under /voice off (text-only replies, but still in the channel — leaving is /voice leave) nothing ever reset it, so every 300s the bot disconnected and spammed "Left voice channel (inactivity timeout)." The adapter now learns the live voice-reply mode via a getter wired from run.py and skips the auto-disconnect while mode is off. It also resets the timer when a user actually speaks to the bot, so an active listener (incl. voice-on text-only sessions that never play audio) isn't dropped mid-conversation.
Assert the inactivity handler skips disconnect (and the channel spam) when the voice-mode getter reports "off", and still disconnects on genuine inactivity when the mode is active.
|
@xxxigm Thanks, this is exactly the problem and the fix seems to target exactly the part of logic that is missing. Hope this will get merged! |
|
Verification comment from code review — this PR is clean. The fix addresses a real user-facing bug:
The |
|
Merged via PR #43328. Your commits were cherry-picked onto current main with your authorship preserved in git log (rebase-merge). Thanks for the fix and the tests — and thanks to @PanBartosz for the precise root-cause report. |
Summary
Reported by PanBartosz. When a user switches to
/voice off, the bot stays connected to the voice channel (correct — leaving is/voice leave), but the 300s inactivity timer (VOICE_TIMEOUTinplugins/platforms/discord/adapter.py) only counts the bot's own audio playback as activity. Under voice-off nothing ever resets it, so every 5 minutes_voice_timeout_handler()disconnects and posts "Left voice channel (inactivity timeout)." — repeating each time the bot rejoins.Confirmed on
main:_reset_voice_timeout()is only called from playback paths (join_voice_channel,play_in_voice_channel,play_ack_in_voice); no text-only or listening path resets it, and/voice offneither cancels the timer nor disconnects.Fix
_voice_mode_getterwired fromgateway/run.py(next to the existing_on_voice_disconnect/_voice_input_callbackwiring)._voice_timeout_handler()skips the auto-disconnect while the mode is off, honoring/voice off(text-only, stay connected) vs/voice leave(disconnect) — consistent with the docs._voice_listen_loop), so an active listener isn't dropped mid-conversation. This also covers the broader case the report hints at: a voice-on session that only ever sends text (no bot audio) would otherwise hit the same 5-minute disconnect.Genuine inactivity (a speaking mode with no one talking and no bot audio) still auto-disconnects as before.
Test plan
scripts/run_tests.sh tests/gateway/test_voice_command.py(183 passed, incl. newtest_timeout_skips_disconnect_when_voice_mode_offandtest_timeout_still_disconnects_when_voice_mode_active)/voice join→/voice off→ wait >5 min → bot stays connected, no "inactivity timeout" message./voice join, keep talking past 5 min → bot stays; go silent >5 min in a speaking mode → auto-disconnects.Made with Cursor