fix: settle ink input handlers after frame waits so TUI coverage runs stop flaking on Windows - #1996
Conversation
…I App tests Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
@olaservo — could you try this branch on your Windows machine? I worked #1942 independently before finding this PR, and landed on the same root cause you did: in ink 6 a visible frame does not imply armed input handlers. The frame is written during React's commit, but Two additions are being pushed onto this branch on top of your
The reason I am asking rather than just calling it done: |
…he contract Extends the previous commit's fix rather than changing it. `waitUntil` now settles, but the same window is open wherever a key is written without having just polled: `press()` reaches its `stdin.write` on a turn that may still have React's passive-effect flush queued (straight after a plain `tick`, or after an earlier key committed a render), and `mount()`'s absorbing keypress lands one tick after the mount commit. Both now `await settleInputHandlers()` before writing, so "frame visible" implies "input handlers armed" at every dispatch point, not only after a frame wait. Adds a `test helpers` case that pins the contract: a `setImmediate` sentinel stands in for the pending effect flush and must have run by the time `waitUntil` resolves. Verified it fails when the yield is removed, so a future regression surfaces here instead of as a differently-named flaky OAuth test under coverage instrumentation. Signed-off-by: cliffhall <cliff@futurescale.com>
|
Pushed one additive commit on top of your fix ( 1. The same settle at the keypress sites. Your version closes the window after a frame wait, which is where #1942 bit. But the hazard is "a key is written on a turn that still has React's passive-effect flush queued", and a poll is not the only way to arrive there:
So after this, "frame visible ⇒ input handlers armed" holds at every dispatch point rather than only after a poll. 2. A guard test for the contract. New Verification: Happy to drop either half if you'd rather keep the change minimal. |
There was a problem hiding this comment.
Pull request overview
Stabilizes TUI tests by waiting for Ink input handlers to re-arm after frame updates.
Changes:
- Adds a
setImmediate-based input-settling helper. - Applies settling before simulated keypresses.
- Adds a regression test for the synchronization contract.
💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.
|
@cliffhall Ran this branch (ae0e9d5) on the Windows machine:
The |
Closes #1942
Test-only. In ink 6 a visible frame doesn't imply armed
useInputhandlers (they re-subscribe in the passive-effect flush), so a keypress right after a frame wait could be silently swallowed — v8 instrumentation widens the window, hence the coverage-only flake.waitUntilnow awaits onesetImmediateturn after its predicate passes; check-queue FIFO guarantees the effect flush runs first. Verified: race made deterministic via a 1ms-poll amplifier (3/3 failing before, 3/3 green after) plus 3 consecutive full greentest:coverageruns. Full root-cause in the issue comment.🤖 Generated with Claude Code