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

Tab forge: serve the forge as the tab's own page in the hosted shell, no frame #18306

opened this

Merged 3h 12m ago, live in production

The forge in /tab is now drawn into the page itself, with no iframe, under the hosted forge's own topbar and navigation. The test/tab.test.ts files pass (41 tests), tsc is clean, and the gate is green. I did not check it in a browser at 390, 820 or 1440, because this sandbox has none.

Notes

opened this

The forge in /tab is now drawn into the page itself, with no iframe, under the hosted forge's own topbar and navigation. The test/tab*.test.ts files pass (41 tests), tsc is clean, and the gate is green. I did not check it in a browser at 390, 820 or 1440, because this sandbox has none.

What changed

  • I took option 1 from the issue. A click on a /tab/f/ link or a form in the view goes straight to the database worker (src/tab/view.ts). The reply's main replaces the view's content, and the document title is updated. The page never navigates, so the worker never unloads.
  • The place is kept in the address fragment (/tab#/issues/3), so Back works and a reload stays on /tab.
  • view.ts is a separate file, served as /tab/view.js. It is fetched only once the forge starts, which keeps boot.js under its 4096-byte budget (3729 bytes now).
  • A redirect after a write is followed in place. A file reply, such as app.json, is downloaded. Links outside /tab/f/ and modified clicks are left to the browser. A form whose action points elsewhere is not taken.
  • The "Make an app" preview was also a sandboxed iframe. It is now a div filled with the renderer's escaped markup (previewMarkup replaces previewDocument). That markup now runs in the host page's context rather than a sandbox. Every field is escaped, as the renderers' tests check.
  • The forge's own few styles for those pages now sit under .tab-view in style/content.ts, using the forge's tokens, so they don't affect the surrounding chrome. /tab no longer asks for frame-src 'self'.

Tests and docs

  • test/tab-view.test.ts is new. It covers the first page from the fragment, link interception, a form post followed by its redirect, and an off-site action being left alone.
  • test/tab.test.ts now expects no iframe and no frame-src 'self'.
  • docs/features/tab.md and docs/design/areas/tab.md are updated.

Not done

  • The service worker and its /tab/f/ registration are unchanged. It still answers a direct visit to /tab/f/..., but the page no longer uses it.
  • I did not move the database into the service worker (option 3) or reopen it per page (option 2).
  • The commits carry No door: and No look: lines. The terminal's tab screen only names the feature, and /tab is not one of forge.json's looks pages.

Try it: open /tab on the preview and press Start it. Follow Home and Issues, open an issue and make an app. The address should stay /tab#/… and the page should have no iframe.

[
 {"go":"/tab","look":"Press Start it; the forge's Home appears under the facts, inside the page, with no frame","expect":"document has no iframe; topbar unchanged; address is /tab#/"},
 {"go":"/tab","look":"Click Issues, open one, add one, then press Back","expect":"page never reloads; address /tab#/issues...; Back returns to the previous view"},
 {"go":"/tab","look":"At 390, 820 and 1440 wide, type a sentence in Make an app","expect":"preview draws inline under the box without horizontal scroll or layout jump"}
]

Closes #18305

4 earlier comments
commented

The forge in /tab is now drawn into the page itself, with no iframe, under the hosted forge's own topbar and navigation. The test/tab*.test.ts files pass (41 tests), tsc is clean, and the gate is green. I did not check it in a browser at 390, 820 or 1440, because this sandbox has none.

What changed

  • I took option 1 from the issue. A click on a /tab/f/ link or a form in the view goes straight to the database worker (src/tab/view.ts). The reply's main replaces the view's content, and the document title is updated. The page never navigates, so the worker never unloads.
  • The place is kept in the address fragment (/tab#/issues/3), so Back works and a reload stays on /tab.
  • view.ts is a separate file, served as /tab/view.js. It is fetched only once the forge starts, which keeps boot.js under its 4096-byte budget (3729 bytes now).
  • A redirect after a write is followed in place. A file reply, such as app.json, is downloaded. Links outside /tab/f/ and modified clicks are left to the browser. A form whose action points elsewhere is not taken.
  • The "Make an app" preview was also a sandboxed iframe. It is now a div filled with the renderer's escaped markup (previewMarkup replaces previewDocument). That markup now runs in the host page's context rather than a sandbox. Every field is escaped, as the renderers' tests check.
  • The forge's own few styles for those pages now sit under .tab-view in style/content.ts, using the forge's tokens, so they don't affect the surrounding chrome. /tab no longer asks for frame-src 'self'.

Tests and docs

  • test/tab-view.test.ts is new. It covers the first page from the fragment, link interception, a form post followed by its redirect, and an off-site action being left alone.
  • test/tab.test.ts now expects no iframe and no frame-src 'self'.
  • docs/features/tab.md and docs/design/areas/tab.md are updated.

Not done

  • The service worker and its /tab/f/ registration are unchanged. It still answers a direct visit to /tab/f/..., but the page no longer uses it.
  • I did not move the database into the service worker (option 3) or reopen it per page (option 2).
  • The commits carry No door: and No look: lines. The terminal's tab screen only names the feature, and /tab is not one of forge.json's looks pages.

Try it: open /tab on the preview and press Start it. Follow Home and Issues, open an issue and make an app. The address should stay /tab#/… and the page should have no iframe.

[
 {"go":"/tab","look":"Press Start it; the forge's Home appears under the facts, inside the page, with no frame","expect":"document has no iframe; topbar unchanged; address is /tab#/"},
 {"go":"/tab","look":"Click Issues, open one, add one, then press Back","expect":"page never reloads; address /tab#/issues...; Back returns to the previous view"},
 {"go":"/tab","look":"At 390, 820 and 1440 wide, type a sentence in Make an app","expect":"preview draws inline under the box without horizontal scroll or layout jump"}
]
commented

I merged main into the branch and pushed it. There were conflicts in src/tab/boot.ts and src/web/style/content.ts, and I resolved both. tsc is clean, bun test test/tab passes (93 tests), and the gate has no complaints. I didn't run the full suite, and I couldn't check it in a browser.

What the merge kept

  • From main: the storage-persistence request, the "browser cleared this forge" line and its footer, the Runners and What works pages, and the new nav links.
  • From this pull: the forge drawn into /tab itself with no iframe.
  • Restore: main reopens the page you were last on. That now works through the view. mount takes the page to open on, used when the address has no fragment, and a callback that records each page drawn. boot.ts passes it the saved place and a function that stores it. A test covers this.

What I dropped

  • main hid the page's topbar and footer while the forge ran (html[data-running]), so the framed forge filled the whole tab. This issue asks for the hosted topbar to stay, so I removed that rule and the data-running attribute.
  • I rewrote the lines in docs/features/tab.md that described the frame and the missing topbar.

Try it: open /tab on the preview and press Start it. Follow Issues and What works. The page should stay /tab#/… with the hosted topbar and no iframe, and a reload should reopen the page you were last on.

commented

The forge is now drawn into /tab itself, with no frame. This round addresses all six review points except removing the service worker (point 2). tsc, the design lint and the gate are clean, and the tab test files pass: tab-view, tab-whole, tab-own-page and tab. I did not run the full suite, and I took no browser pictures.

Changes this round

  • Doc comment (1): src/tab/render.ts keeps one doc comment on previewMarkup; the old one-liner is gone.
  • Accessibility (3): the preview is now role="region" with aria-live="polite". After each render, src/tab/view.ts focuses the new view's first heading (it gets tabindex=-1). It falls back to the section only when there is no heading.
  • Errors (4):
    • remember() and the # address entry now run only for a GET that answered 200, so a failed or posted path such as /tab/f/new is never reopened on reload.
    • An error reply with no main (the service worker's "stopped" 503 or a 403) now shows "That did not work" and a link to the forge's home. A designed 404 page that has a main is still drawn as it is.
  • Test (4): new in test/tab-view.test.ts, a failed POST is not remembered and shows the sentence with the way out.
  • Styling (5): I dropped the .kept class from the footer in src/tab/shell.ts and styled .tab-view footer as muted instead. The design lint wanted a named class otherwise. .tab-view .items li now has flex-wrap: wrap.
  • Docs (6): I wrapped the two paragraphs I had edited in docs/features/tab.md to 100 columns. The rest of that file has long lines from before this pull. I left them alone to keep the diff reviewable.

Not done: removing the service worker's /tab/f/ document serving (2)

  • What still needs it: the page no longer uses it, but a /tab/f/ link opened outside the page (new tab, bookmark, middle-click) is a real navigation. Only the service worker answers that, by asking the /tab window that holds the database. Removing it would turn those links into 404s.
  • Why I stopped: deciding whether that is acceptable is a product call, so I have not opened a removal issue. docs/features/tab.md now says this is the only thing keeping it.
  • What I need from you: say so if you want it removed in this pull anyway.

To try: open /tab, press Start it, and follow a link inside the forge. The address becomes /tab#/…, no document loads, and Back works.

[
  {"go": "/tab", "look": "Start the forge, then follow a link in it", "expect": "The page stays on /tab, the address gets a #/ place, focus lands on the new heading"},
  {"go": "/tab", "look": "At 360px wide, an app list with a long title next to its button", "expect": "The button wraps below the title instead of being squeezed"}
]
commented

The check failure was test/tab-browser.test.ts, which still drove the removed iframe (#tab-frame), so the page never drew it and the browser run timed out. I rewrote its walk to drive the in-page view. I couldn't run it here because the sandbox has no Chromium, so the walk is untested; the forge's check will run it on this push.

What changed

  • The walk: it now works inside #tab-view through the same steps as before (make, edit, issue, import, remove).
  • How it follows the page: it reads the place from the address fragment (#/apps/3 is /tab/f/apps/3) and treats a changed view as the page having drawn.
  • Dropped check: I removed the old test that read each post's Origin and Referer, since there is no longer a document post for DevTools to record. In its place a test asserts the page's writes make no network POST.
  • Cost: the browser no longer exercises the service worker's same-origin guard for form posts. The guard is still unit-tested, and a link opened outside the page still goes through the service worker.
  • Merge and checks: I merged main first, which is where this test came from. tsc and the gate are clean, and the two parse-only tests in test/tab-browser.test.ts pass.
commented

The in-page browser walk failed because the test waited on a flag the code no longer sets. I haven't run the browser test: Chromium doesn't run in this sandbox, so the six browser tests were skipped here. This is a diagnosis from reading the code, and the forge's check on this push is the first real run. bun test test/tab passed, tsc is clean and the gate passes every rule, including the four the check refused the crew for most.

What was wrong. test/tab-browser.test.ts started the forge and then waited for document.documentElement.dataset.running === "1". When the forge moved into the page (src/tab/boot.ts), that flag was removed, and nothing else reads it. The wait could never finish. It sat until the 20 s limit on a single devtools command cut it off, which is the "Runtime.evaluate took longer than 20000 ms" failure.

What changed, tests only; no product code.

  • Start wait: the start script now waits for #tab-view to be shown, which is what "running" means once the forge draws into the page.
  • Time limits: in test/helpers/chrome.ts, a script that waits on the page now gets its own limit: 35 s for starting and 75 s for the walk, with the outer waits matching. The 20 s default stays for ordinary devtools commands. Without this, a slow check machine would cut off the five-post walk even once it works.

Not done. I did not split the issue or change what "done" means, because the failure was a test bug rather than a design problem. The 390/820/1440 browser check from the issue isn't repeated here, since it needs Chromium.

To try it. Run bun test test/tab-browser.test.ts on a machine where Chromium runs. Or open /tab on the preview, press Start, and follow the links and forms. The page should stay on /tab with the hash holding the place, and no iframe should appear.

the crew's run was interrupted: restart, resumes on the next pass — cancelled
Sign in to join this conversation.

Search
↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs