Skip to content

Commit c10a206

Browse files
committed
🚨 Wait for the frame a startup focus and an admission are carried in (#883)
Two rows read a settled fact off whichever frame happened to be current. A startup focus claim and a draft cleared by an admission are both resolved in the frame that carries them, and on a loaded CI machine that is not always the frame that arrives first — so both passed locally and failed in CI twice, which is a divergence rather than a flake. Both now wait for the screen they are about, through the fixture's own `awaiting`. Neither claim moved: the startup row additionally states that the Sidekick's box does *not* hold focus, which is the half that was only implied before. Verified under Bun as well as Deno, Bun being where the admission row failed.
1 parent d8890e4 commit c10a206

1 file changed

Lines changed: 18 additions & 3 deletions

File tree

‎packages/cli/tests/repl-sidekick-presentation.test.ts‎

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,16 @@ describe("Tier MP — one Sidekick per command, acquired without working", () =>
161161

162162
// Focus is the draft's, not the Sidekick's: the pane being the one showing
163163
// is a reading, and somebody who starts typing is typing their entry.
164-
expect(focusedField(repl.terminal, DRAFT_PROMPT)).toBe(true);
164+
//
165+
// Waited for rather than read off the first drawn frame. A startup focus
166+
// claim is resolved when the frame that carries it is built, and on a
167+
// loaded machine that is not always the frame that arrives first — so a
168+
// row that read it immediately reported "the Sidekick took the focus" for
169+
// a screen that had simply not caught up. Nothing is pressed either way.
170+
yield* awaiting(repl.terminal, "the draft holding focus with nothing pressed", (one) =>
171+
focusedField(one, DRAFT_PROMPT),
172+
);
173+
expect(focusedField(repl.terminal, MESSAGE_PROMPT)).toBe(false);
165174

166175
// Selecting the Sidekick is what focuses its box, because that is somebody
167176
// asking to type into it.
@@ -289,8 +298,14 @@ describe("Tier MP — the first explicit message is what upgrades the history",
289298
yield* running.started();
290299

291300
// The entry is admitted and is still going: its source left the draft, and
292-
// the record it is writing has not landed.
293-
expect(draftText(repl.terminal)).toBe("");
301+
// the record it is writing has not landed. Waited for, because the
302+
// admission clears the draft in the frame after it and this row is about
303+
// *that* the source left rather than about which frame carried it away.
304+
yield* awaiting(
305+
repl.terminal,
306+
"the admitted source leaving the draft",
307+
(one) => draftText(one) === "",
308+
);
294309

295310
// Now ask the Sidekick, through its own box and its own control.
296311
yield* activate(repl.terminal, "Sidekick");

0 commit comments

Comments
 (0)