From 32f97fb33f279955ae80ab8eb15770706ab26f70 Mon Sep 17 00:00:00 2001 From: Lokesh Date: Fri, 25 Sep 2026 09:35:55 +0400 Subject: [PATCH] test(tui): wait for operation ownership before steering in queue order test The injection-order test typed steering and follow-up input as soon as the fake model was called. The daemon reaches the model before the TUI has the session.send reply and has projected the active operation, so input typed in that gap took the pre-ownership path and was enqueued as plain prompts. The pending list never appeared and the test timed out waiting for "4. Follow-up: follow B" (about 1 run in 5). Wait for the TUI's projected activeOperationId, the same condition submit() checks before steering, before typing. The assertions are unchanged. Signed-off-by: Lokesh --- packages/tui/test/app.test.ts | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/packages/tui/test/app.test.ts b/packages/tui/test/app.test.ts index 6672c956..511136c4 100644 --- a/packages/tui/test/app.test.ts +++ b/packages/tui/test/app.test.ts @@ -1881,6 +1881,15 @@ test("pending steering and follow-ups display their actual injection order above input.write("one\r"); await until(() => calls === 1, "first model call"); + // The daemon reaches the model before the TUI projects the active operation; + // input typed in that gap is queued as prompts instead of steered. + const projected = app as unknown as { + sessionSubscription?: { projector: { overview: { activeOperationId?: string } } }; + }; + await until( + () => projected.sessionSubscription?.projector.overview.activeOperationId !== undefined, + "TUI to own the active operation", + ); input.write("follow A\x1b[13;3usteer A\rfollow B\x1b[13;3usteer B\r"); await until(() => text().includes("4. Follow-up: follow B"), "ordered queue"); const queuedTerminal = new VirtualTerminal(100, 24);