mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-05-06 02:37:05 +08:00
fix(cli): avoid voice TTS restart race
This commit is contained in:
@@ -1040,6 +1040,25 @@ class TestDisableVoiceModeReal:
|
||||
class TestVoiceSpeakResponseReal:
|
||||
"""Tests _voice_speak_response with real CLI instance."""
|
||||
|
||||
def test_async_scheduling_clears_done_before_thread_start(self):
|
||||
cli = _make_voice_cli(_voice_tts=True)
|
||||
starts = []
|
||||
|
||||
class FakeThread:
|
||||
def __init__(self, target=None, args=(), daemon=None):
|
||||
self.target = target
|
||||
self.args = args
|
||||
self.daemon = daemon
|
||||
|
||||
def start(self):
|
||||
starts.append(cli._voice_tts_done.is_set())
|
||||
|
||||
with patch("cli.threading.Thread", FakeThread):
|
||||
cli._voice_speak_response_async("Hello")
|
||||
|
||||
assert starts == [False]
|
||||
assert not cli._voice_tts_done.is_set()
|
||||
|
||||
@patch("cli._cprint")
|
||||
def test_early_return_when_tts_off(self, _cp):
|
||||
cli = _make_voice_cli(_voice_tts=False)
|
||||
|
||||
Reference in New Issue
Block a user