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

The forge toolbar in a preview shows the pull's check as one word #14868

Merged opened this

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

Merged

This behaviour already holds on main, so I added only the test that proves it. I changed no app code, so there is no page change and no review block. What already holds: Stored verdict only: a preview's toolbar pull line reads "Pull #N: green", "red" or "checking" from the pull's stored check run.

Notes

shipped production is serving it deploy 15342fb

opened this

This behaviour already holds on main, so I added only the test that proves it. I changed no app code, so there is no page change and no review block.

What already holds:

  • Stored verdict only: a preview's toolbar pull line reads "Pull #N: green", "red" or "checking" from the pull's stored check run. pillCheck in src/apps/pill_check.ts makes one indexed read of the newest check run for the pull's head. The client then does no live fetch and no polling.
  • No layout shift: the pull line is a row inside the pill panel that opens over the page, so it never moves the app's layout.
  • Origin: #14060 and #11252 added this on main.

What I added: test/toolbar-check.test.ts.

  • Stored ok, failed and running runs read green, red and checking, taken from the run row through to the word the toolbar draws.
  • The newest run of the head wins, and another commit's run is ignored.
  • A pull with no run reads "no check yet", and a toolbar that is sent no check draws plain "Pull #N".

What I left out: the word has no fixed-width reservation. I judged it unnecessary because of the overlay panel above.

Checks: bun scripts/gate.ts --fix and bun x tsc --noEmit ran clean. The new test and toolbar-pull-state pass: 10 tests, 0 failures. I did not run the full suite; the forge runs it on push.

To try it: run bun test test/toolbar-check.test.ts. Or open a preview and the toolbar's panel shows "Pull #N: <word>".

🤖 Generated with Claude Code

Closes #14858

3 earlier comments · 1 event
commented

This behaviour already holds on main, so I added only the test that proves it. I changed no app code, so there is no page change and no review block.

What already holds:

  • Stored verdict only: a preview's toolbar pull line reads "Pull #N: green", "red" or "checking" from the pull's stored check run. pillCheck in src/apps/pill_check.ts makes one indexed read of the newest check run for the pull's head. The client then does no live fetch and no polling.
  • No layout shift: the pull line is a row inside the pill panel that opens over the page, so it never moves the app's layout.
  • Origin: #14060 and #11252 added this on main.

What I added: test/toolbar-check.test.ts.

  • Stored ok, failed and running runs read green, red and checking, taken from the run row through to the word the toolbar draws.
  • The newest run of the head wins, and another commit's run is ignored.
  • A pull with no run reads "no check yet", and a toolbar that is sent no check draws plain "Pull #N".

What I left out: the word has no fixed-width reservation. I judged it unnecessary because of the overlay panel above.

Checks: bun scripts/gate.ts --fix and bun x tsc --noEmit ran clean. The new test and toolbar-pull-state pass: 10 tests, 0 failures. I did not run the full suite; the forge runs it on push.

To try it: run bun test test/toolbar-check.test.ts. Or open a preview and the toolbar's panel shows "Pull #N: <word>".

🤖 Generated with Claude Code

Changes requested — before the latest push

The test is sound and covers the three states plus no check, so boxes 1 and 3 are met. Box 2 (reserved width for the word) is not met, and the pull says so itself. It adds no reservation and no test for one. The overlay argument may be right, but the issue asked for the reservation. The word is built into one text string in src/apps/toolbar.ts (line 122) with no fixed-width or min-width slot. When the check goes from checking to green the row text changes length, which can reflow or rewrap the panel line on a 360px phone. Fix: render the word in its own span with a min-width (or min-inline-size in ch) that fits the longest word, "no check yet", and add a test asserting the reservation. If you keep the overlay argument instead, ask the issue owner to drop box 2. Also, the test uses check as any and new Function over the toolbar source, so it is brittle. Prefer exporting the pill row text builder and testing that.

commented

Box 2 (reserved width) now has an implementation and a test. The toolbar tests and tsc pass, and gate.ts exits 0 with one warning (below). I did not run the full suite; the forge runs it on push.

What changed

  • The word has a slot. In src/apps/toolbar.ts the check word now sits in its own inline-block span with min-width set to CHECK_WIDTH. CHECK_WIDTH is the length of the longest word, computed in src/apps/pill_check.ts, so it is 12ch for "no check yet". Going from checking to green no longer changes the row's width. A pull sent with no check draws plain "Pull #N", with no slot.
  • Slot test. test/toolbar-check.test.ts asserts that every state's word is in a span with that min-width and inline-block, and that no span exists when there is no check. That test fails without the slot.
  • Casts. I removed the check as any casts in the new test. The existing toolbar-pull-state.test.ts still has its own.
  • Mocks. The mock DOMs in test/toolbar-check.test.ts and test/toolbar-pull-state.test.ts now add a child's text to its parent, as a real DOM does, because the row is now a label plus a span.

Where I disagree or deviated

  • Pill row builder not exported. I didn't export one to test, as you suggested. The toolbar is one injected script string that can't import anything, so the test still runs the real script through new Function. That is the only way to cover the reservation actually drawn. Only CHECK_WIDTH and CHECK_WORDS are shared, so the width and the words come from one table.
  • Re-pinned the size budget. The slot needed about 228 bytes. test/apps-toolbar-state.test.ts caps the added script at 300 bytes against BASE_SCRIPT_BYTES = 22623. Main was already 295 bytes past that, so nothing could fit. I re-pinned it to main's size before this change, 22918, and the 300-byte cap is unchanged. The check's own change was within it; please confirm you want the pin moved.
  • Duplication warning. scripts/gate.ts flags the test's DOM harness as 0.59 similar to the one in toolbar-pull-state.test.ts. I left it, because sharing it would mean refactoring that file.

To try it: open a preview and the panel's "Pull #N: <word>" keeps the same width across states. Or run bun test test/toolbar-check.test.ts.

🤖 Generated with Claude Code

commented

I merged main into the branch and pushed. The toolbar tests (223) and tsc pass; I did not run the full suite, which the forge runs on push.

  • Conflict: test/apps-toolbar-state.test.ts conflicted over the toolbar script's size budget. I took main's side, which pins the base at 22918 bytes and allows 1150 more bytes for the 7-day dismissal (#14463).
  • Size budget: main's side leaves no room for the check word's reserved-width slot, which adds 228 bytes. I added a named CHECK_SLOT_ALLOWANCE = 230 next to the dismissal allowance. The 300-byte cap on anything else is unchanged.
  • Warning: gate.ts still flags my test's DOM harness as 0.59 similar to the one in toolbar-pull-state.test.ts, with the same exit 0 as before.

The rest of the pull is as in the earlier description: the check word sits in a slot as wide as "no check yet", with a test that fails without it.

🤖 Generated with Claude Code

commented

The only failure this pull caused is fixed and pushed. It was in test/apps-pill-check.test.ts. I ran that file plus the two other toolbar tests (toolbar-check, toolbar-pull-state) and tsc --noEmit; all pass. I did not run the rest of the suite.

Cause. Since the check word moved into its own fixed-width slot, the panel draws "Pull #3: " and the word (for example "red") as two separate text nodes. The test still expected one string, Pull #3: red. The slot change was intended, so the test was wrong, not the code.

Fix. The test now joins "Pull #3: " with the word that follows it before comparing. It checks the same wording as before. The unknown-key and production cases are unchanged.

Other failures. The other seven failing tests in the check log (pages-budget, page-budget, time-element, fetch-timeout, llms-budget and the two others) are red on main at 35988ae too. The check log marked five as not counted against this pull, and I did not touch them.

bun scripts/gate.ts prints a similarity note (toolbar-check.test.ts#row against toolbar-pull-state.test.ts#line) and exits 0. I did not touch either file.

To try it. Run bun test test/apps-pill-check.test.ts.

Approved

Earlier asks: the reserved-width slot now exists and is tested, and the apps-pill-check test is updated for the split text nodes. Both are met. The slot is one shared CHECK_WIDTH derived from CHECK_WORDS, so the width cannot drift from the words. A pull with no check draws plain "Pull #N" with no slot. The size allowance is named and bounded, not a loosened cap.

Next two things:

  1. Non-blocking: the DOM harness in test/toolbar-check.test.ts duplicates the one in toolbar-pull-state.test.ts (gate warns at 0.59). Pull it into a shared test helper in a small follow-up.
  2. Non-blocking: set the slot width in CSS (a class in the panel style) rather than per-element inline style, so the script bytes shrink and the allowance can go back down.
Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs