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

A preview's toolbar page says what its pull changed and whether its check is green, each a link #4100

Closed opened this
Closed without merging

A preview's toolbar page now shows a line under the head: "N files, +A -R" linking to the pull's Files page, then the latest check as a badge (passed, failed, running, cancelled or no check). The new test file test/toolbar-change.test.ts passes, along with the existing toolbar tests (34 in total).

Notes

stopped closed without shipping deploy 5ccb231

opened this

A preview's toolbar page now shows a line under the head: "N files, +A -R" linking to the pull's Files page, then the latest check as a badge (passed, failed, running, cancelled or no check).

The new test file test/toolbar-change.test.ts passes, along with the existing toolbar tests (34 in total). I did not run the full suite. The bun x tsc --noEmit run reports only "Cannot find type definition file for 'bun'", which is the missing types in this sandbox. It reports no errors in the changed files.

  • Where: changeLine in src/web/studio/toolbar.ts. toolbarPage is now async because the diff read is async.
  • Check link: the badge links to the check run's log. With no run it is an unlinked "no check" badge.
  • Which commit: the check is the latest one for the pull's live head, read the same way the pull page reads it.
  • Production and 404s: production's page is unchanged, and the pull visibility check still comes first, so a viewer who may not see the pull still gets a 404.
  • Signed-out viewers: they also see the line on a preview of a pull they may view. I didn't limit it to signed-in viewers.
  • Timing: the new reads add pull-row, diff and check to the Server-Timing phases. The preview page stays under 50 ms in the test.
  • Tests: a green check, a red one and none; production has no change line; a missing pull returns 404. The green-check test also asserts the exact "2 files, +3 -1" text and the link to the Files page.

I left out a "running" case in the tests. That label shows when a check is queued or running, but no test covers it.

No new dependencies. To try it, open /<owner>/<repo>/toolbar?env=pull-N on a preview.

Closes #4088

Show 3 earlier items

7 earlier comments · 2 events
commented

The check failed because my test asserted toBeLessThan(50) on a measured request time. The repo's flake audit, in test/flake.test.ts and scripts/flake.ts, rejects any such bound below 200 ms. I raised the bound to 200 ms in test/toolbar-change.test.ts and renamed that test to say so.

Production code is unchanged. The toolbar tests and the flake audit pass locally (61 tests). I did not run the full check; the forge runs it on this push.

The 200 ms bound is looser than the issue's "under 50 ms" target, and the shared runner is why. The diff, check and pull-row phases are still in Server-Timing, so the real cost is visible there.

Shards 5 and 6 of the failed check ended with exit 143 and no named test. Shard 5 includes test/toolbar-change.test.ts. The log shows the audit as the only failing test, and I assume the two kills came from the run being torn down after it failed. If shards 5 and 6 fail again on this push, that is a separate problem.

Changes requested — before the latest push

Fix first: the change line departs from docs/DESIGN.md. The pull page already has a diff summary (src/web/diff-view.ts:565-571) that shows additions in .add and deletions in .del with a real minus sign. Here +A -R is one plain-text link in a bare <p data-change> with no tones and no spacing between the two links. Reuse that summary markup, or extract it into a small shared helper in diff-view.ts and use it in both places. Keep the badge link beside it, and give the line a named component or class rather than a bare data attribute. Anyone can test this on a 360px phone: the two inline links sit about 16px tall and touch each other, so put them in a flex row with a gap and a tappable height.

Second: the toolbar is fetched by every preview, and this change adds a git merge-base and diff plus a check lookup to each request. The issue asked for under 50 ms and the test now only asserts under 200 ms. The diff is not cached for a head that has not moved. Either cache the stat by head oid, or read the stat from a value the pull already stores. Add a test that fails when that read is slow or repeated.

The terminal gap is reasoned and stated in the README, which I accept. Security and the 404 order are fine, and the tests cover each badge state.

commented

The change line now reuses the diff summary's totals, sits in a named flex row, and reads the diff once per head. The toolbar, diff and flake tests pass (91). I didn't run the full check, and tsc reports only the missing bun types in this sandbox.

  • Totals markup: I extracted diffTotals() in src/web/diff-view.ts. It writes additions in .add and deletions in .del with a real minus sign. renderDiff's summary and the toolbar both use it, and the toolbar wraps it in the existing .diff-stat.
  • Layout: the line is now <p class="change-line">, a wrapping flex row with a gap, and each link is 36px tall. The Files link and the check badge link no longer touch. I added .change-line to src/web/style/content.ts and to the §5d list in docs/DESIGN.md. I haven't checked it on a 360px screen.
  • Caching: the new src/web/studio/change_stat.ts caches the stat by pull id and head oid. A hit does no git work at all, because the head and check lookup use the pull's stored head. An entry lives 60 seconds, because the base branch can move under a head that hasn't. This is a cache, not a stored value, so there is no schema change.
  • Tests: a unit test shows the diff is read once per head and again after a new head or after the TTL. An end-to-end test shows the second request's diff Server-Timing phase is under 1 ms. It also checks the +3 and −1 spans. The 200 ms request bound stays because the flake audit rejects anything tighter.
Changes requested

Works as the issue asks, and the cache and tests are sound. One design-system miss, so changes requested: the tap height. docs/DESIGN.md (Density, §3) says anything touchable is >=44px under @media (pointer: coarse), via padding. .change-line a is fixed at min-height: 36px with no coarse-pointer rule, so on a phone both links (Files, check badge) are under the thumb floor. Fix first: keep 36px for fine pointers and add @media (pointer: coarse) { .change-line a { min-height: 44px; } }, then update the .change-line entry in the DESIGN.md §5d list to say so. Second, smaller: the line is a hand-rolled flex row with a new page-local class; if an existing named row component (e.g. the .stack/row pattern in §5) fits, prefer it, otherwise keep the class as is since it is listed in §5d.

commented

Handed to a person by the crew: the reviewer asked for changes three times with no approval between, so the planner re-scopes it: split, replaced, or one more round with the reviewer's ask restated.

  1. juniper: The feature does what the issue asks, but it departs from docs/DESIGN.md on the check badge, and that is a change request. Fix first: replac
  2. juniper: Fix first: the change line departs from docs/DESIGN.md. The pull page already has a diff summary (src/web/diff-view.ts:565-571) that shows a
  3. juniper: Works as the issue asks, and the cache and tests are sound. One design-system miss, so changes requested: the tap height. docs/DESIGN.md (De
commented

One more round, one change: the third review's tap height. Add a @media (pointer: coarse) rule that raises the change line's links to min-height: 44px (docs/DESIGN.md, Density), and mention it in that class's §5d entry. The first two reviews' asks (runStateBadge, .add/.del spans, a named class, aria-label, the stat cached by head oid) are already met, so leave them as they are.

commented

State: one more round, unchanged since 08:35. The one change: a @media (pointer: coarse) rule giving the change line's links min-height: 44px (docs/DESIGN.md, Density), named in that class's §5d entry. If the next review still asks for changes, a person should close this pull; #4088 stays open for a fresh run.

commented

State: one more round, still the same one change: a @media (pointer: coarse) rule giving .change-line links min-height: 44px, named in its §5d entry. No new commit since 08:29; if none comes, a person should close this pull and #4088 goes to a fresh run.

commented

State: closed by the planner, its issue replaced by #4205. Three rounds of review left one ask, and no commit followed the restated ask; #4205 names that ask in its done list and points the next run at this branch's commits, which the reviews accepted.

commented

Closed by the planner: the issue this pull was built for is closed.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs