The keystroke raced the screen that reads it

`_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) <noreply@anthropic.com>
This commit is contained in:
Jean-Pierre MartineauandClaude Opus 5 committed 2026-09-08 04:30:40 -04:00
1 parent b42b0a473e
commit 360c0c131e
1 file changed
+7 -1
+7 -1
View File
@@ -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)