test(gateway): verify routed busy persistence

This commit is contained in:
Samuel Odio
2026-08-29 05:44:11 -07:00
committed by kshitij
parent 8d1d193f11
commit e8591ae509
@@ -6,7 +6,6 @@ from unittest.mock import AsyncMock, MagicMock, patch
import pytest
import gateway.run as gateway_run
from gateway.config import GatewayConfig, Platform, PlatformConfig
from gateway.platforms.base import (
BasePlatformAdapter,
@@ -196,25 +195,36 @@ async def test_busy_status_dispatches_through_active_session_path(tmp_path):
@pytest.mark.asyncio
async def test_busy_change_updates_only_routed_profile(tmp_path, monkeypatch):
"""A profile-scoped /busy change refreshes its snapshot and adapter."""
"""A routed /busy change persists and refreshes only that profile."""
default_home = tmp_path / "default"
default_home.mkdir()
default_config = default_home / "config.yaml"
default_config.write_text(
"display:\n busy_input_mode: interrupt\n",
encoding="utf-8",
)
monkeypatch.setenv("HERMES_HOME", str(default_home))
runner = _runner(default_mode="interrupt")
profile_home = tmp_path / "research"
adapter = await _load_profile_snapshot(
runner,
tmp_path / "research",
profile_home,
"queue",
)
event = _event(profile="research")
event.text = "/busy steer"
monkeypatch.setattr("cli.save_config_value", lambda _key, _value: True)
monkeypatch.setattr(
gateway_run,
"_load_gateway_runtime_config",
lambda: {"display": {"busy_input_mode": "steer"}},
"hermes_cli.profiles.get_profile_dir",
lambda _profile_name: profile_home,
)
runner._handle_message = runner._handle_busy_command
response = await runner._handle_busy_command(event)
response = await runner._make_profile_message_handler("research")(event)
assert "steer" in str(response).lower()
assert "busy_input_mode: steer" in (profile_home / "config.yaml").read_text()
assert "busy_input_mode: interrupt" in default_config.read_text()
assert runner._busy_input_mode == "interrupt"
assert runner._effective_busy_input_mode(event.source) == "steer"
assert adapter._busy_text_mode == "interrupt"