diff --git a/gateway/slash_commands.py b/gateway/slash_commands.py index f1cdaea2ca..12548e5ac0 100644 --- a/gateway/slash_commands.py +++ b/gateway/slash_commands.py @@ -4287,6 +4287,12 @@ class GatewaySlashCommandsMixin: ) else: self._busy_input_mode = arg + # busy_input_mode is the source of truth for the text mode + # too (run.py:_load_busy_text_mode) — re-derive it so the + # adapter refresh below doesn't read a stale value and keep + # interrupting after e.g. /busy queue (config IS saved; only + # the live session lagged until restart). + self._busy_text_mode = self._load_busy_text_mode() adapter = self._adapter_for_source(event.source) if adapter is not None: diff --git a/tests/gateway/test_busy_command.py b/tests/gateway/test_busy_command.py index 7236541dcc..dfeb806de2 100644 --- a/tests/gateway/test_busy_command.py +++ b/tests/gateway/test_busy_command.py @@ -68,11 +68,26 @@ class TestBusyCommandPersistence: async def test_set_mode_persists(self, monkeypatch, initial_mode, new_mode): """Each supported /busy mode is saved and applied.""" runner = _make_runner(busy_mode=initial_mode) + runner._busy_text_mode = "interrupt" monkeypatch.setattr("cli.save_config_value", lambda k, v: True) + # The handler re-derives _busy_text_mode from the saved config; + # emulate the write that the mocked save_config_value skipped. + monkeypatch.setattr( + gateway_run, + "_load_gateway_runtime_config", + lambda: {"display": {"busy_input_mode": new_mode}}, + ) + monkeypatch.delenv("HERMES_GATEWAY_BUSY_TEXT_MODE", raising=False) + monkeypatch.delenv("HERMES_GATEWAY_BUSY_INPUT_MODE", raising=False) event = _make_event(f"/busy {new_mode}") result = await runner._handle_busy_command(event) assert new_mode in str(result).lower() assert runner._busy_input_mode == new_mode + # busy_input_mode is the source of truth for the text mode: /busy + # queue must stop live text messages from interrupting (#97932). + assert runner._busy_text_mode == ( + "queue" if new_mode == "queue" else "interrupt" + ) @pytest.mark.asyncio async def test_save_failure_preserves_mode(self, monkeypatch):