diff --git a/src/plyngent/cli/display.py b/src/plyngent/cli/display.py index d184ae8..65eabe4 100644 --- a/src/plyngent/cli/display.py +++ b/src/plyngent/cli/display.py @@ -444,11 +444,13 @@ def _wait_prefix(_args_json: str) -> str: def _wait_detail(_args_json: str, result: str) -> str: - """``wait`` outcome: slept duration, disturbed, or error.""" + """``wait`` outcome: slept duration, disturbed, cancelled, or error.""" if result.startswith("error:"): return _pretty_segments((f"({result})", "red")) if result.startswith("waited "): return _pretty_segments((f"({result.removeprefix('waited ')})", "green")) + if result.startswith("cancelled by user"): + return _pretty_segments(("(cancelled)", "yellow")) return _pretty_segments(("(disturbed)", "yellow")) diff --git a/tests/test_cli/test_display.py b/tests/test_cli/test_display.py index 0054391..7803c4f 100644 --- a/tests/test_cli/test_display.py +++ b/tests/test_cli/test_display.py @@ -553,6 +553,13 @@ async def test_pretty_wait_disturbed(capsys: pytest.CaptureFixture[str]) -> None assert "* Wait (disturbed)" in out +async def test_pretty_wait_cancelled(capsys: pytest.CaptureFixture[str]) -> None: + """Ctrl+C during the wait prompt reads as cancelled, not disturbed.""" + await render_events(_aiter([_pretty_call("wait", '{"duration": 30}'), _result("cancelled by user")])) + out = capsys.readouterr().out + assert "* Wait (cancelled)" in out + + async def test_pretty_wait_error(capsys: pytest.CaptureFixture[str]) -> None: content = "error: duration must not be negative" await render_events(_aiter([_pretty_call("wait", '{"duration": -1}'), _result(content)]))