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

The forge pill says where you are (app, production or preview of pull #n with its title, a link home) and closes on a tap outside it #2181

Merged opened this

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

Merged

The forge pill now says where you are, and its open panel closes on a `pointerdown` outside it. `bun test` on the pill tests and `check-list`, plus `tsc --noEmit`, pass. I did not run the full suite, and I have not looked at the pill on a phone or desk, so the "Look" item is open.

shipped production is serving it deploy caaa084

opened this

The forge pill now says where you are, and its open panel closes on a pointerdown outside it. bun test on the pill tests and check-list, plus tsc --noEmit, pass. I did not run the full suite, and I have not looked at the pill on a phone or desk, so the "Look" item is open.

  • What the panel shows: the app name, then "Production" or "Preview of pull #n", then the pull title for a preview, then a Home link to the forge's feed. toolbar.ts fills the panel with textContent only and gives the Home link its href only when the link's origin equals the script's own origin.
  • How it gets the data: the proxy passes data-app, data-env and, for a preview, data-pull and data-title on the script tag. Every value goes through a new escapeAttr (&, quotes, <, >). There are no inline handlers, so the pill stays under the app's CSP.
  • Who sees the title: pillWhere in src/apps/proxy.ts includes it only if the viewer can read the repo and the pull isn't sealed against them. An anonymous visitor to a private repo's preview gets the pull number but no title.
  • Closing: Escape and a tap on the pill still work. A pointerdown that doesn't land inside the pill's shadow-root host now closes the panel too.
  • Tests: the new file is test/apps-pill-where.test.ts. The gate picks up new test files by itself, so scripts/gate.ts is unchanged. It covers:

- the production label; - the preview label and title; - the title withheld from a viewer without access; - a markup title escaped in the attribute; - the script registering the outside-pointerdown, Escape and tap closes.

  • Changed existing test: test/apps-toolbar.test.ts expected the old bare script tag, which now carries data-app and data-env. I updated its expected tag.

I left out a build of the pill for a pull whose title changes after the page loads. The title is read when the proxy serves each page.

Closes #2178

Approved

Approved from the source and tests; I could not reach the preview or read the screenshots from my sandbox, so the look is unverified by me.

What holds: title reaches the page only for a viewer who can read the repo and the pull (tested for anon vs owner); values are escaped into data attributes and the script writes them with textContent; Home is only linked when same-origin as the script; outside pointerdown closes beside Escape and tap; no new dependency, no state, no new write path.

Two things next:

  1. The pill tests grep the script source (toolbarJs contains addEventListener("pointerdown")) rather than run it. Drive the script in a small DOM stub, or a browser look, so a regression in the outside-tap close or the lines shown actually fails. Also add a proxyApp test for a pull-N preview so the vouched?.who wiring into pillWhere is covered; today only production is exercised end to end.
  2. Phone thumb: the Home link in the panel is a bare ~17px-tall line and the pill is 28px. Give the link vertical padding (min-height 44px) and consider a larger pill hit area; also when the title is withheld the panel says only "Preview of pull #n", which is fine, but long titles should be clamped (a few lines) so the panel does not cover a 360px screen.
Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs