From 360c0c131e80aa0c5dc75403756dc92b149f1896 Mon Sep 17 00:00:00 2001 From: Jean-Pierre Martineau Date: Tue, 8 Sep 2026 04:30:40 -0400 Subject: [PATCH] The keystroke raced the screen that reads it MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `_run_live` pushes the picker itself, so the Enter could not be queued before the call — it was sent blind and lost about one full-suite run in six, on a machine busy enough to change the timing. `_screen_at` exists for exactly this and says so in its docstring: wait until the stack is the depth the flow reached, then press. Fifteen consecutive runs of the test, and three of the whole suite. Co-Authored-By: Claude Opus 5 (1M context) --- tests/test_navigation.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/tests/test_navigation.py b/tests/test_navigation.py index 9d50676..877dd99 100644 --- a/tests/test_navigation.py +++ b/tests/test_navigation.py @@ -181,8 +181,14 @@ async def test_the_trace_target_picker_stays_pushed_under_the_live_screen(monkey monkeypatch.setattr("meshterm.ui.trace_screen.open_trace", fake_open_trace) async def main() -> None: + # The picker is pushed by `_run_live` itself, so the keystroke cannot be + # queued before the call: sending it blind raced the screen that reads it, + # and lost about one full-suite run in six. `_screen_at` exists for exactly + # this — wait until the picker is on the stack, *then* press Enter on it. + running = asyncio.create_task(TraceTool()._run_live(ctx)) + await _screen_at(session, 1) inp.send_text(ENTER) # Enter on the leading row commits it as the target - result = await TraceTool()._run_live(ctx) + result = await running assert result.summary == {"sessions": 1, "traces": 2} await asyncio.wait_for(session.run(main()), timeout=5)