fix(voice_mode): generalize container phrasing and use $XDG_RUNTIME_DIR

This commit is contained in:
Wesley Simplicio 2026-05-09 15:21:12 -03:00
parent bde487c911
commit 30dd5547ad
2 changed files with 10 additions and 9 deletions

View file

@ -232,7 +232,7 @@ class TestDetectAudioEnvironment:
assert result["available"] is True
assert result["warnings"] == []
assert any("Docker" in n for n in result.get("notices", []))
assert any("container" in n.lower() for n in result.get("notices", []))
def test_docker_with_pipewire_remote_allows_voice(self, monkeypatch):
"""Docker with PIPEWIRE_REMOTE set should NOT block voice mode (#21203)."""
@ -250,7 +250,7 @@ class TestDetectAudioEnvironment:
assert result["available"] is True
assert result["warnings"] == []
assert any("Docker" in n for n in result.get("notices", []))
assert any("container" in n.lower() for n in result.get("notices", []))
def test_docker_without_audio_forwarding_blocks_voice(self, monkeypatch):
"""Docker without PULSE_SERVER/PIPEWIRE_REMOTE keeps blocking voice mode."""
@ -267,7 +267,7 @@ class TestDetectAudioEnvironment:
result = detect_audio_environment()
assert result["available"] is False
assert any("Docker" in w for w in result["warnings"])
assert any("container" in w.lower() for w in result["warnings"])
assert any("PULSE_SERVER" in w or "PIPEWIRE_REMOTE" in w for w in result["warnings"])
def test_termux_api_microphone_allows_voice_without_sounddevice(self, monkeypatch):

View file

@ -109,14 +109,15 @@ def detect_audio_environment() -> dict:
from hermes_constants import is_container
if is_container():
if os.environ.get('PULSE_SERVER') or os.environ.get('PIPEWIRE_REMOTE'):
notices.append("Running inside Docker container with host audio forwarding")
notices.append("Running inside container (Docker/Podman/LXC) with host audio forwarding")
else:
warnings.append(
"Running inside Docker container -- no audio devices.\n"
" Forward host audio with one of:\n"
" PulseAudio: -v /run/user/1000/pulse/native:/run/user/1000/pulse/native \\\n"
" -e PULSE_SERVER=unix:/run/user/1000/pulse/native\n"
" PipeWire: -e PIPEWIRE_REMOTE=/run/user/1000/pipewire-0"
"Running inside container (Docker/Podman/LXC) -- no audio devices.\n"
" Forward host audio with one of (substitute $XDG_RUNTIME_DIR for your runtime dir,\n"
" typically /run/user/$UID):\n"
" PulseAudio: -v $XDG_RUNTIME_DIR/pulse/native:$XDG_RUNTIME_DIR/pulse/native \\\n"
" -e PULSE_SERVER=unix:$XDG_RUNTIME_DIR/pulse/native\n"
" PipeWire: -e PIPEWIRE_REMOTE=$XDG_RUNTIME_DIR/pipewire-0"
)
# WSL detection — PulseAudio bridge makes audio work in WSL.