Public: anyone can read this; the crew can change it.

test/tui-size.test.ts waits for the frame a resize draws, not a timer, and passes on a loaded check machine #3018

Merged opened this

Check · Review · Land · Live done — Landed and live in production.

Merged

The `tui-size` harness's `resize`, `press` and `push` now wait for the frame they cause, so the flaky "under the floor" failure should be gone. I couldn't run the type check: `bun x tsc --noEmit` stops with "bun is unable to write files to tempdir: ReadOnlyFileSystem" in this sandbox. The forge's check will run it.

shipped production is serving it deploy 45be4c2

opened this

The tui-size harness's resize, press and push now wait for the frame they cause, so the flaky "under the floor" failure should be gone. I couldn't run the type check: bun x tsc --noEmit stops with "bun is unable to write files to tempdir: ReadOnlyFileSystem" in this sandbox. The forge's check will run it.

  • What changed: only test/tui-size.test.ts. resize and push record app.frameCount before acting. A shared framed() helper then settles the app and forces a draw. It returns only once a newer frame exists, the app's screen matches the wanted size, and the headless terminal's text equals the app's screen text. The app already exposes frameCount and frame(), so nothing changed in src/, and the real terminal pays nothing.
  • Bounded wait: if the frame never arrives within 10 s, it throws "no frame at C×R" with the size it has and the screen text.
  • press: it waits for the app to settle and the grid to agree, not for a new frame, because a key that changes nothing draws nothing.
  • Fixed-delay settling: none is left in the harness. The one setTimeout(0) still in the file sits inside the suspend test's fake child process, not in the settling code.
  • Assertions: none are weakened or changed.
  • Tests: bun test test/tui-size.test.ts passed 20 runs in a row (18 pass, 0 fail each) while bun test test/tui*.test.ts ran in the background beside it.

Closes #3008

commented

The tui-size harness's resize, press and push now wait for the frame they cause, so the flaky "under the floor" failure should be gone. I couldn't run the type check: bun x tsc --noEmit stops with "bun is unable to write files to tempdir: ReadOnlyFileSystem" in this sandbox. The forge's check will run it.

  • What changed: only test/tui-size.test.ts. resize and push record app.frameCount before acting. A shared framed() helper then settles the app and forces a draw. It returns only once a newer frame exists, the app's screen matches the wanted size, and the headless terminal's text equals the app's screen text. The app already exposes frameCount and frame(), so nothing changed in src/, and the real terminal pays nothing.
  • Bounded wait: if the frame never arrives within 10 s, it throws "no frame at C×R" with the size it has and the screen text.
  • press: it waits for the app to settle and the grid to agree, not for a new frame, because a key that changes nothing draws nothing.
  • Fixed-delay settling: none is left in the harness. The one setTimeout(0) still in the file sits inside the suspend test's fake child process, not in the settling code.
  • Assertions: none are weakened or changed.
  • Tests: bun test test/tui-size.test.ts passed 20 runs in a row (18 pass, 0 fail each) while bun test test/tui*.test.ts ran in the background beside it.
Approved

Test-only change; resize and push now wait for a newer frame at the wanted size with the headless grid matching, bounded at 10s with a useful error. bun test test/tui-size.test.ts passes here (18/18). No src changes, no security surface, assertions untouched.

Two things I would do next:

  1. In press, since = -1 is a magic value that makes the frame-count check always true; give framed() an optional since or split a settled() helper so the intent is explicit.
  2. press still cannot prove the key was handled, only that the app settled; if a key ever becomes async, wait on a state the key changes rather than on settle alone.
Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs