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

The forge toolbar in a preview names its pull and the check's state in plain words #14060

Merged opened this

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

Merged

A preview's toolbar panel now has a link line reading Pull #N: checking, Pull #N: green or Pull #N: red, pointing at the pull. The new test file and the existing toolbar tests pass (58 across 5 files), and tsc, the gate and the design lint are clean. I didn't run the full suite; the forge's check does that on the push.

Notes

shipped production is serving it deploy 4adf612

opened this

A preview's toolbar panel now has a link line reading Pull #N: checking, Pull #N: green or Pull #N: red, pointing at the pull. The new test file and the existing toolbar tests pass (58 across 5 files), and tsc, the gate and the design lint are clean. I didn't run the full suite; the forge's check does that on the push.

  • Words: a new STATE_WORDS table in src/apps/pill_check.ts maps the newest check of the pull's head. Running and queued both read "checking", passed reads "green", failed reads "red". The two cases the issue doesn't name read "cancelled" and "no check yet".
  • Drawing: src/apps/toolbar.ts draws the line from the data-check attribute the proxy already sends. That attribute is escaped, and production's toolbar draws no pull line.
  • Reload only: the state is read from the page's attributes when it loads, so nothing polls.
  • Tests: test/toolbar-pull-state.test.ts has one test per state (checking, green, red), plus production having no pull line and an injection attempt in the attribute being escaped. The no-polling check is a weak text match on the script source, not a behavioural test.

The pull link and the "Checks passed/failed" line from #13690 and #11233 were already on main. I added the plain-word line next to them instead of replacing them, so the panel now says the check state twice (for example "Pull #12: green" and "Checks passed"). Dropping the older line would mean editing the existing toolbar tests.

To try it, open any open pull's preview and press the forge pill.

Closes #14051

1 earlier comment · 1 event
commented

A preview's toolbar panel now has a link line reading Pull #N: checking, Pull #N: green or Pull #N: red, pointing at the pull. The new test file and the existing toolbar tests pass (58 across 5 files), and tsc, the gate and the design lint are clean. I didn't run the full suite; the forge's check does that on the push.

  • Words: a new STATE_WORDS table in src/apps/pill_check.ts maps the newest check of the pull's head. Running and queued both read "checking", passed reads "green", failed reads "red". The two cases the issue doesn't name read "cancelled" and "no check yet".
  • Drawing: src/apps/toolbar.ts draws the line from the data-check attribute the proxy already sends. That attribute is escaped, and production's toolbar draws no pull line.
  • Reload only: the state is read from the page's attributes when it loads, so nothing polls.
  • Tests: test/toolbar-pull-state.test.ts has one test per state (checking, green, red), plus production having no pull line and an injection attempt in the attribute being escaped. The no-polling check is a weak text match on the script source, not a behavioural test.

The pull link and the "Checks passed/failed" line from #13690 and #11233 were already on main. I added the plain-word line next to them instead of replacing them, so the panel now says the check state twice (for example "Pull #12: green" and "Checks passed"). Dropping the older line would mean editing the existing toolbar tests.

To try it, open any open pull's preview and press the forge pill.

Changes requested — before the latest push

The words are right and the tests cover the three states, but the panel now says the same thing twice and links to the pull twice in a row. On a 360px phone the panel is capped at 70vh and scrolls, so every duplicate row pushes Home, the comment box and the Serving line further down. Fix first: make the existing pull link carry the new words instead of adding a second link. Then drop the now-redundant check line.

  1. Replace, don't add. The panel already has the link 'Preview of pull #N: title' (toolbar.ts ~L111-118), an 'Environment: preview' line, and the 'Checks passed/failed' line (CW). Your new line adds a third row that is a second link to the same URL, directly above the first, each a 44px tap target. Draw one link: 'Pull #N: green' (keep the title in its title/aria text or on a line below), and drop the CW line for previews. Update the existing toolbar tests that assert the old wording. That is the work the issue asks for, and it is not a reason to leave the duplicate.
  2. Strengthen the no-polling test. The text match on setInterval near 'pull' passes for almost any script. Instead assert in the harness that setInterval and fetch are not called when the line is drawn. The escaping test checks only the serialized HTML, so also assert that a hostile data-check draws no line.
  3. Check whether the toolbar's how-to belongs in docs/features/ (a toolbar page, if one exists). Say there what the pull line reads and that it updates on reload only. Nothing goes in README.

What is fine: the production toolbar has no pull line, the state is read from the allow-listed STATE_WORDS table via hasOwnProperty, and the href is built from the script's own origin.

commented

The preview toolbar now draws one link to the pull, with the check state in its words, and the review points are fixed. The nine toolbar-related test files I ran pass (112 tests), as do tsc, the gate and the design lint. I didn't run the full suite; the forge's check does that on the push.

  • One link: the old "Preview of pull #N: title" link and my extra row are replaced by a single link reading Pull #N: checking, Pull #N: green or Pull #N: red. The pull's title is now the link's tooltip instead of its text.
  • Other states: running and queued both read "checking". The panel also says "cancelled" and "no check yet". An unknown state key draws a bare Pull #N with no state word.
  • Checks line gone: the "Checks passed/failed" line is removed from previews.
  • One table: CHECK_WORDS in src/apps/pill_check.ts now holds the new words, and the second table I added is gone.
  • Old tests updated: the existing toolbar tests that asserted the old wording now assert the new words.
  • Tests: in test/toolbar-pull-state.test.ts, a spy on setInterval and fetch shows nothing is polled. fetch is not asserted to be zero, because the pill makes one /__forge/crew lookup at load that has nothing to do with the pull. I assert only that no fetch asks for the pull or its check. A hostile data-check is escaped in the tag and draws no state word.
  • Docs: docs/features/forge-toolbar.md now says what the pull line reads and that it updates on reload only. Nothing went in the README.
Approved

Earlier asks are met: one link reads Pull #N: checking, green or red; the older Checks row and the second word table are gone; the title is the tooltip; the no-poll test spies on setInterval and fetch; the docs are updated and nothing went in the README. The state is read from the tag at load only. I could not see the toolbar on the preview root (the forge app is not wrapped by the toolbar there), so I judged it from the source and tests. The toolbar is a page-only overlay, so no TUI screen is needed. Two next steps, both non-blocking. First, test/apps-pill-check.test.ts still asserts no line matches /^(Checks|No checks)/. That is now vacuous, so assert on the new words. Second, in test/toolbar-pull-state.test.ts the last test wraps tag() in a pointless IIFE, and test/apps-pill-freshness.test.ts has a test title that still says the line follows the pull when there is no title. Tidy both.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs