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

Apps without a login 2: a tiny model in the browser fills the app's spec, and the compiler catches every failure #18117

opened this in answer to

Merged 6h 5m ago, live in production

The model tier and the compiler fallback are built and tested, but the measured numbers the issue asks for are not in the doc. I had no phone, no GPU and no route to model weights in this sandbox, so download size, time to first app and memory are unmeasured, and the doc says so.

Notes

opened this

The model tier and the compiler fallback are built and tested, but the measured numbers the issue asks for are not in the doc. I had no phone, no GPU and no route to model weights in this sandbox, so download size, time to first app and memory are unmeasured, and the doc says so. The "about 2 GB" on the page is Chrome's own figure for its built-in model, not one we measured. The page shows Made in N s for each app it makes, so the numbers can be taken on a real device and added to docs/features/tab.md.

What changed

  • Compiler (src/tab/fill.ts): A sentence makes an app with no model. The first words become the name, and the items after a colon become starter issues. The forge home now has a plain "Make an app" form (POST /make), so it works with no script and no GPU.
  • Model: Optional, and it only fills a small flat JSON schema: a name and up to five starter issues, never code. FILL_SCHEMA allows no other field, and the prompt is one short line plus the sentence.
  • Checking and fallback: The forge's own worker checks every answer against the schema. Anything that fails leaves the compiler to write the app: a timeout (90 s on the page), a throw, invalid JSON, a field that is not in the schema, or a value that does not fit. The model's text is also escaped when the Spec page shows it.
  • Which one wrote it: A new Spec page, /tab/f/spec, says whether a model, the compiler or an imported file wrote the app, using a new made table. Import and make now share one keep() transaction.
  • Control: src/tab/model.ts and src/tab/boot.ts show the model section only when LanguageModel reports it is available or downloadable. A device without it sees nothing. Nothing is fetched until the person presses the button, and the page states the size, the on-device claim and that the forge's server models are not used. The terminal's tabLine says the same.
  • Tests: test/tab-fill.test.ts runs a stand-in model through a good answer, invalid JSON, a timeout, a throw and refused fields. Each ends in a valid app with the right author. It also covers the control being hidden when the API is absent or unavailable. The tab, duplicate-import, module-state and unused-exports suites pass, and tsc and design-lint are clean. I did not run the full suite or open the page in a browser; the real Prompt API path (turnOn, prompt) has not been run anywhere.

What I chose not to do

  • Runtime: I used the browser's own Prompt API instead of WebLLM or wllama. It adds no dependency, hosts no weights, accepts a JSON schema as a constraint, and sends nothing off the device. WebLLM and wllama would need their weights and runtime from a third-party host. The page's policy (connect-src 'self') blocks that, and the download would be a request leaving the device. The choice rests on reasoning, not on measurement.
  • Phones: The Prompt API is in desktop Chrome today. Where it is missing, including most phones, the tier is not offered and the compiler is the whole feature.

To try it

  1. Open /tab and press Start it.
  2. Describe an app on the forge's home and press Make it, then open Spec; it says the compiler wrote it.
  3. In a browser that has the Prompt API, a "small model" section appears with its size and a download button. Press it, then use "Make it with the model".
[{"go":"/tab","look":"the page in a browser without an on-device model","expect":"no model section is shown; Start it works as before"},{"go":"/tab","look":"press Start it, then use the Make an app form on the forge's home","expect":"it redirects to the Spec page, which says the compiler wrote the app, and the issues list shows the starter items"},{"go":"/tab","look":"in desktop Chrome with the Prompt API","expect":"a model section names the size and says it is optional; nothing downloads until the button is pressed"}]

🤖 Generated with Claude Code

Closes #18044

7 earlier comments
commented

The model tier and the compiler fallback are built and tested, but the measured numbers the issue asks for are not in the doc. I had no phone, no GPU and no route to model weights in this sandbox, so download size, time to first app and memory are unmeasured, and the doc says so. The "about 2 GB" on the page is Chrome's own figure for its built-in model, not one we measured. The page shows Made in N s for each app it makes, so the numbers can be taken on a real device and added to docs/features/tab.md.

What changed

  • Compiler (src/tab/fill.ts): A sentence makes an app with no model. The first words become the name, and the items after a colon become starter issues. The forge home now has a plain "Make an app" form (POST /make), so it works with no script and no GPU.
  • Model: Optional, and it only fills a small flat JSON schema: a name and up to five starter issues, never code. FILL_SCHEMA allows no other field, and the prompt is one short line plus the sentence.
  • Checking and fallback: The forge's own worker checks every answer against the schema. Anything that fails leaves the compiler to write the app: a timeout (90 s on the page), a throw, invalid JSON, a field that is not in the schema, or a value that does not fit. The model's text is also escaped when the Spec page shows it.
  • Which one wrote it: A new Spec page, /tab/f/spec, says whether a model, the compiler or an imported file wrote the app, using a new made table. Import and make now share one keep() transaction.
  • Control: src/tab/model.ts and src/tab/boot.ts show the model section only when LanguageModel reports it is available or downloadable. A device without it sees nothing. Nothing is fetched until the person presses the button, and the page states the size, the on-device claim and that the forge's server models are not used. The terminal's tabLine says the same.
  • Tests: test/tab-fill.test.ts runs a stand-in model through a good answer, invalid JSON, a timeout, a throw and refused fields. Each ends in a valid app with the right author. It also covers the control being hidden when the API is absent or unavailable. The tab, duplicate-import, module-state and unused-exports suites pass, and tsc and design-lint are clean. I did not run the full suite or open the page in a browser; the real Prompt API path (turnOn, prompt) has not been run anywhere.

What I chose not to do

  • Runtime: I used the browser's own Prompt API instead of WebLLM or wllama. It adds no dependency, hosts no weights, accepts a JSON schema as a constraint, and sends nothing off the device. WebLLM and wllama would need their weights and runtime from a third-party host. The page's policy (connect-src 'self') blocks that, and the download would be a request leaving the device. The choice rests on reasoning, not on measurement.
  • Phones: The Prompt API is in desktop Chrome today. Where it is missing, including most phones, the tier is not offered and the compiler is the whole feature.

To try it

  1. Open /tab and press Start it.
  2. Describe an app on the forge's home and press Make it, then open Spec; it says the compiler wrote it.
  3. In a browser that has the Prompt API, a "small model" section appears with its size and a download button. Press it, then use "Make it with the model".
[{"go":"/tab","look":"the page in a browser without an on-device model","expect":"no model section is shown; Start it works as before"},{"go":"/tab","look":"press Start it, then use the Make an app form on the forge's home","expect":"it redirects to the Spec page, which says the compiler wrote the app, and the issues list shows the starter items"},{"go":"/tab","look":"in desktop Chrome with the Prompt API","expect":"a model section names the size and says it is optional; nothing downloads until the button is pressed"}]

🤖 Generated with Claude Code

commented

<!-- look-pages 45bee271aaa4 --> Look pages for 45bee27, from the gate:

  • look pages (none): this pull changes src/web/pages/tab.ts but the forge could not trace the route of /, /admin/telemetry, /explore and 29 more (an inline or wrapped handler), so it could not infer a page; the reviewer decides. A "Looks: <path>" line naming the nearest page, or a "No look: <why>" line (10+ characters), says it
commented

This push only changes commit messages, so the code is the same as before. It clears the two rules the gate refused, and bun scripts/gate.ts now passes locally. The gate still prints one non-blocking warning, described below.

I added one empty commit (88ffffb91) with three lines:

  • Name the issue: Direction: name the issue this pull serves and its doors (#18044).
  • Both doors: a No door: line. It says the spec filler is a step inside the web Tab page's describe-an-app flow, so the terminal has no Tab page to mirror it. It also says a how-to waits for the model shipping.
  • Look pages: a No look: line, because the forge can't trace the route for src/web/pages/tab.ts, which is an inline handler. It points the reviewer to /tab.

I did not run bun x tsc --noEmit or any tests this turn, since no code changed. The forge's check will run them on this push.

The gate still warns that test/tab-fill.test.ts#open looks like test/tab.test.ts#viaBun (0.74 similar). It's a question ("one implementation?"), not a refusal, and I left both tests as they are.

I used #18044 from the branch name as the issue number. The pull itself is #18117, so correct that if the issue number is different.

Try: open /tab, press Start it, then describe an app on the forge's home and open its Spec page.

commented

The failing timers test is fixed and pushed. It flagged the model deadline timer in src/tab/fill.ts (setTimeout(() => stop.abort(), ms)), which ran outside background. That timer now runs inside background("tab-fill-deadline", …), as the other server-side timers do.

Locally, test/timers-named.test.ts and test/tab-fill.test.ts pass (20 tests), bun x tsc --noEmit is clean, and the gate shows only the earlier non-blocking duplicate-test warning. I did not run the full suite; the forge's check does that on this push.

commented

I merged main into the branch and pushed it (52ab9bd80). The src/tab and test/ changes that came out of the merge are below. bun x tsc --noEmit, bun scripts/gate.ts and bun scripts/design-lint.ts are clean, and the tab and timers tests pass (73). I did not run the full suite; the forge's check does that on this push.

Two things collided beyond the three conflicted files:

  • Table name: main's stored apps use a table called made, and mine used the same name for who wrote the spec. Mine is now authored.
  • Element id: both sides had a form with id tab-make. The model's form is now tab-idea-form.

The merged /tab script came to 5,663 bytes, over the 4,096 budget in test/tab-apps.test.ts. I did not raise the budget. The model's browser code moved into src/tab/offer.ts, served at /tab/offer.js like make.js. boot.ts fetches it only when the page has the model section.

Other changes:

  • Timer allow-list: my earlier fix for the timers test pulled server code (bun:jsc) into the browser bundle and broke the /tab build. I reverted it. The model deadline timer in src/tab/fill.ts is now allowed by name in test/timers-named.test.ts, with the reason given there.
  • Spec link: I added a Spec link to the tab forge's navigation in src/tab/shell.ts, because boot.ts opens /tab/f/spec after the model writes an app.
  • Shared test helper: both new tab test files built the same in-memory database. They now share test/support/tab-db.ts, which also clears the gate's duplicate-test warning.

Try: open /tab, press Start it, then describe an app on the forge's home and open its Spec page.

commented

This pull now merges cleanly into main and is pushed. The tab, timers-named, unused-exports and module-state tests pass, and tsc is clean. I did not run the full suite, boot the app, or try the model in a browser.

Main had since added the block-app compiler (#18080), which replaced the issues-spec model this branch was built on. The old /make route, made table and issues-spec fill no longer fit, so I redid the model tier on main's compiler.

What changed

  • The model's job: src/tab/fill.ts has the model fill a small closed schema: title, kind (list, tracker, counter, notes or board), and a tracker's unit or a board's noun and columns. settle checks the answer. It must be JSON with only those fields, each within its bound. The block itself comes from a new blockFor in compile.ts, which compile now uses too, so the model writes no labels or button text. Any failure falls back to compile.
  • Routing: there is no separate model route. POST /apps takes an optional answer, bounded to 4000 characters. The first line of the app's How this app was made page says which wrote it.
  • The page: the model section on /tab appears only where LanguageModel exists. Its code (/tab/model.js, built in tab-asset.ts) is fetched only there, which keeps /tab's script under its 4096-byte budget. Once the model is on, the existing "Make it" asks it first, with a 90 s limit.
  • Docs and tests: docs/features/tab.md and the terminal line (TAB_MODEL) say the model is optional, runs on this device, nothing leaves it, and the forge's own models are not used. test/tab-fill.test.ts uses a stand-in model for a good answer, invalid JSON, a timeout, a throw, refused fields, escaping and the plain form with no model.
  • Merge fix: an earlier merge commit on the fork had added src/tab/offer.ts and a /make route. I removed offer.ts. I kept its test/support/tab-db.ts helper, which my test now uses.

Checks the crew listed

  • Dead code: Runtime and askModel are used; FILL_SCHEMA and promptFor are no longer exported.
  • Module state: the new module-level variables in boot.ts are plain lets, not a Map, Set or array.
  • Timers: the model deadline is a browser timer, so it is named in the test/timers-named.test.ts allow-list. It no longer imports the server's background.
  • Issue number: each commit names #18044.

Left as it was

  • Gate note: it says test/support/tab-db.ts#open is 0.74 similar to viaBun in test/tab.test.ts, so I left the two helpers separate.
  • Measurements: download size, time to first app and memory are still not measured. This run had no device or GPU, and the docs say so. The runtime is the browser's Prompt API, with no added dependency.

To try it: in desktop Chrome, open /tab, press Start it, then Turn on the model. Type a sentence and press Make it, then open How this app was made. Without the model, or if it times out, the compiler writes the app and that page says so.

[
  {"go": "/tab", "look": "Without an on-device model there is no model section. The Make an app box is unchanged.", "expect": "No broken control and no request to /tab/model.js"},
  {"go": "/tab", "look": "In desktop Chrome, a section offers the model and says nothing downloads until you press its button.", "expect": "Section visible, text says optional, on this device, checked", "ask": "Press it, make an app, open 'How this app was made'."}
]
commented

This round addresses all five review points except the phone measurements, which I could not take. tab-fill and tab tests pass (33), and tsc, the gate and design-lint are clean. I did not boot the app or open the preview.

What changed

  • Duplicate doc section (1): docs/features/tab.md now carries one "A small model fills the spec (#18044)" section, the copy that matches the code. The dropped POST /make, starter-issue and /tab/f/spec text is gone, and the section's sentence on TAB_MODEL now matches the shorter words.
  • Wording (3): TAB_MODEL in src/tab/words.ts shrinks from four rows to two. One row says it is optional, about 2 GB, and downloads only when you press the button. The other says your sentence and its answer never leave the device and this forge's own models are not used. /tab and the terminal's tabLine both read from it, so each fact is stated once.
  • Tests (4): test/tab-fill.test.ts now has a fake LanguageModel suite that restores the global in afterEach.
    • It covers offer for no API, unavailable, downloadable, downloading, available and a throw.
    • It covers turnOn reporting progress, and prompt cloning the session and destroying the clone, including when the prompt throws.
    • It covers the error turnOn gives when there is no API.
    • The "control starts hidden" check that read the page source is gone.
  • offer() (5): offer() in src/tab/model.ts now uses plain if statements; "downloading" still maps to "downloadable".

Not done: the phone measurements (2). I had no device, GPU or route to a model, so download size, time to first app and memory are still unmeasured. I would rather say so than write invented numbers. The doc now states what a person with a phone gets today: most phones lack the Prompt API, so the tier is not offered and the compiler writes the app, with no download and no model memory. The numbers have to come from a real device before the tier is relied on.

Not covered: the "control starts hidden" behaviour, which lives in boot.ts's offerModel, now has no test. The only runnable test for it was the source-string check you rejected, so I removed the claim.

commented

Left #18044 open: 1 unticked item remain (An optional local tier on /tab: a small model run in the browser on the device's GPU. Choose the runtime (WebLLM, wllama or another) by measuring on a phone-class device, and say in the pull what was measured: download size, time to first app, memory. Nothing is downloaded until the person asks for it, and the page says how large it is first.).

Sign in to join this conversation.

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

Keyboard shortcuts

Docs