From bb3a4fc68e026ee78a430ba749ab206dfa241460 Mon Sep 17 00:00:00 2001 From: Tranquil-Flow Date: Fri, 10 Apr 2026 13:47:19 +1000 Subject: [PATCH] test(gateway): add /background to active-session bypass tests Adds a regression test verifying that /background bypasses the active-session guard in the platform adapter, matching the existing test pattern for /stop, /new, /approve, /deny, and /status. --- .../test_command_bypass_active_session.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/tests/gateway/test_command_bypass_active_session.py b/tests/gateway/test_command_bypass_active_session.py index e90dee69c1..318b14dd82 100644 --- a/tests/gateway/test_command_bypass_active_session.py +++ b/tests/gateway/test_command_bypass_active_session.py @@ -160,6 +160,22 @@ class TestCommandBypassActiveSession: assert sk not in adapter._pending_messages assert any("handled:status" in r for r in adapter.sent_responses) + @pytest.mark.asyncio + async def test_background_bypasses_guard(self): + """/background must bypass so it spawns a parallel task, not an interrupt.""" + adapter = _make_adapter() + sk = _session_key() + adapter._active_sessions[sk] = asyncio.Event() + + await adapter.handle_message(_make_event("/background summarize HN")) + + assert sk not in adapter._pending_messages, ( + "/background was queued as a pending message instead of being dispatched" + ) + assert any("handled:background" in r for r in adapter.sent_responses), ( + "/background response was not sent back to the user" + ) + # --------------------------------------------------------------------------- # Tests: non-bypass messages still get queued