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

A forge toolbar in every app and preview: where you are, who is working, comment, tell, make it yours, home #988

Closed opened this in answer to
Closed without merging

Every plain HTML page an app or preview serves now ends with the forge's bar: a collapsed pill at the bottom right. It opens to the app name, the environment ("Production", or "Preview of pull #n" with the pull's title) and a Home link to the forge.

Notes

stopped closed without shipping deploy 4c101a2

opened this

Every plain HTML page an app or preview serves now ends with the forge's bar: a collapsed pill at the bottom right. It opens to the app name, the environment ("Production", or "Preview of pull #n" with the pull's title) and a Home link to the forge. I deployed two real apps in a test and exercised the opt-out, plain-HTML injection and non-HTML cases through the proxy. I did not pick a look for the pill or take phone and desktop screenshots. The type check is clean.

I ran test/apps-toolbar.test.ts and the proxy test that failed along the way, and both pass. test/apps-report.test.ts and the rest of test/apps-adversarial.test.ts had passed earlier, but I did not re-run them after the last change. I also did not run the full suite; the forge's check does that.

  • How it works: the proxy appends a <script src="/__forge/toolbar.js" defer> tag after the app's last byte. The script is the forge's own, served from the app's host, so an app whose CSP allows 'self' scripts allows the bar. It draws the pill in a shadow root and is about 3 KB. The tag's attributes are escaped. A sealed pull's title is left out. The code is in src/apps/toolbar.ts, and src/apps/proxy.ts calls it. docs/APPS.md documents it.
  • Opt-out: "toolbar": false at the top level of forge.json. Any other non-boolean value is rejected in the manifest.
  • What gets the bar: only a whole text/html response to a GET with status 200 that has no content-encoding. Everything else passes byte for byte.
  • Plain-text request: for a page request that accepts HTML, the proxy asks the app for identity encoding so it can read the page. Other requests are untouched, and a test checks that.
  • Body handling: a page with a known length (up to 4 MB) is read whole and its content-length and etag are updated. A streaming page keeps streaming, and the tag is added after its last byte.
  • Existing test: streaming every page made the existing hop-by-hop test fail, because transfer-encoding: chunked showed up. Keeping known-length pages as known-length fixed it. The test was not changed.
  • Dependencies: none added.
  • Removes: nothing. No screen or control already did this job.

Tests: test/apps-toolbar.test.ts covers the tag and its escaping, the script size, which responses qualify, the manifest flag, the proxy output for an HTML page, the script route, and the byte-for-byte case. Tests that deploy real apps cannot open their unix socket inside the sandbox, so run those with it off.

Not done:

  • Actions (#810): who is working now, comment, tell the crew and make it yours are not built. The Home link's row is marked data-room="actions" for them.
  • Tight CSPs: an app CSP that forbids even its own scripts, such as a strict nonce-only policy, will still block the bar; I did not rewrite app headers.
  • Nested hosts: these get no bar, since they belong to the guest forge.
  • Home target: Home goes to the forge's /, which I assumed is the feed. I did not confirm that.
  • MCP: no new tool. Tell and comment already exist and are #810's to use.

To try it, open any app or preview HTML page and click the pill. To check the opt-out, add "toolbar": false to forge.json.

Closes #609

commented

Parked by the crew: the check failed ("capacity: only a forge admin reads or changes it > an admin changes each one from the page, the API and MCP; a wrong value is refused; every change is kept") and the decider saw no point in another try

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs