Declare Ctrl+C and Ctrl+D as priority Textual bindings so the focused prompt cannot consume them. Drive exit and silent-stream cancellation regressions through Pilot key events instead of calling action handlers directly.
This commit is contained in:
+20
-2
@@ -123,6 +123,23 @@ def test_stream_error_remains_visible_after_finish():
|
||||
asyncio.run(_run())
|
||||
|
||||
|
||||
@pytest.mark.parametrize("key", ["ctrl+c", "ctrl+d"])
|
||||
def test_priority_exit_bindings_reach_app_while_prompt_is_focused(key):
|
||||
pytest.importorskip("textual")
|
||||
from nexusos_cli.tui_app import NexusTUI
|
||||
|
||||
app = NexusTUI.build_app(api_url="http://127.0.0.1:9")
|
||||
|
||||
async def _run():
|
||||
async with app.run_test() as pilot:
|
||||
assert app.is_running
|
||||
await pilot.press(key)
|
||||
await pilot.pause()
|
||||
assert not app.is_running
|
||||
|
||||
asyncio.run(_run())
|
||||
|
||||
|
||||
def test_tool_request_is_denied_with_stream_token():
|
||||
_ApprovalClient.calls.clear()
|
||||
names = _deny_tool_request(
|
||||
@@ -262,13 +279,14 @@ def test_interrupt_cancels_silent_stream_and_accepts_next_message(monkeypatch):
|
||||
pytest.fail("stream did not become idle within one second")
|
||||
|
||||
async def _run():
|
||||
async with app.run_test():
|
||||
async with app.run_test() as pilot:
|
||||
app._start_chat("first")
|
||||
assert await asyncio.to_thread(first_stream_started.wait, 2)
|
||||
app.action_interrupt()
|
||||
await pilot.press("ctrl+c")
|
||||
await _wait_until_idle()
|
||||
|
||||
log = app.query_one("#log")
|
||||
assert any("interrupt requested" in line.text for line in log.lines)
|
||||
assert not any("ReadTimeout" in line.text for line in log.lines)
|
||||
|
||||
app._start_chat("second")
|
||||
|
||||
Reference in New Issue
Block a user