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

A browser tab takes runs through the same versioned protocol and stops when it closes #18534

opened this

Merged 5m ago, goes live with the next release

An admin's Settings → Runners page now offers Use this tab as a runner. The tab speaks the existing v1 agent protocol as the plain runner role. I did not run the full suite.

Notes

opened this

An admin's Settings → Runners page now offers Use this tab as a runner. The tab speaks the existing v1 agent protocol as the plain runner role. I did not run the full suite. I ran test/tab-runner.test.ts (5 tests) plus the runner, settings, TUI, protocol, migration, route-mark, lazy-boot and attention budget suites. The pushed commits passed tsc and design-lint, but bun scripts/gate.ts still printed the Try:/Looks: and similar-function notes in its last pre-push run, so the forge check may still raise them.

What changed

  • Enrolling: POST /settings/runners/tab (admin, same-origin, no-store) enrols a check_runner row of kind tab (src/machines/tab_runner.ts, src/actions/runners.ts enrolThisTab). The token comes back once. The script src/web/tab_runner_client.ts keeps it in a variable only, with no storage. At most 8 tabs are open at once; a ninth gets 409.
  • Expiry: a tab token is refused with 401 once its last request is more than 30 seconds old (TAB_TTL_MS). The row is deleted at the next listing, so the tab shows on the runners page and in the terminal while it is open and disappears after a missed heartbeat. The tab sends a heartbeat every 10 seconds.
  • What a tab may take:
    • A tab claims only jobs the forge marked tab-safe, on a public repository.
    • Such a job has no cell, label, handed-back files, environment or seeds.
    • Every step is the one verb a tab knows, forge-tab echo <text>, which the tab prints and reports green.
    • A claim's cells: true is ignored for a tab, and a paused heartbeat narrows it.
    • A tab is never trusted: it is never sent secrets, and setRunnerTrust refuses it.
    • Any job with another step is handed back.
    • The script runs nothing from a pull and does not use eval.
  • Schema and docs: migration 20261206180000-tab-runner adds check_runner.kind and check_job.tab_safe. Docs are in runners.md and settings-runners.md.
  • Test: test/tab-runner.test.ts covers the cases below.
    • Enrolling: admin-only, cross-origin refused, the token never stored.
    • The full claim, logs and result round trip.
    • Jobs a tab must not take: shell, cell, label, and a paused tab.
    • An expired token refused with 401 and the row gone from the list.
    • The page offer and the 8-tab cap.

Choices and gaps

  • The offer is on the admin-only runners page, not any signed-in page, because that page is where tabs are listed. Other signed-in users get no button.
  • Nothing in the forge produces forge-tab jobs from a real check yet. The verb list is the seam for widening what a tab may do. Until then the path is exercised by the test, not by real checks.
  • The terminal lists a tab as "a browser tab" but cannot be one. The commit says No door: for that reason.
  • Reused enrolRunner and removeRunner, the existing runnerByToken, claimJob and v1 routes, and the settings route-mark and lazy-list pattern.

Try it Sign in as an admin, open /settings/runners and press Use this tab as a runner. A row marked Tab appears. Close the page and the row is gone within about 30 seconds.

[{"go":"/settings/runners","look":"the This tab block above Register an outside runner","expect":"a button reading Use this tab as a runner and a reserved status line, with no layout shift"},{"go":"/settings/runners","look":"press the button, then read the list","expect":"a row named tab-… with a Tab badge, Connected; the button now reads Stop using this tab"},{"go":"/settings/runners","look":"close the tab and reload from another","expect":"the tab row is gone within about 30 seconds"}]

🤖 Generated with Claude Code

Closes #18526

5 earlier comments
commented

An admin's Settings → Runners page now offers Use this tab as a runner. The tab speaks the existing v1 agent protocol as the plain runner role. I did not run the full suite. I ran test/tab-runner.test.ts (5 tests) plus the runner, settings, TUI, protocol, migration, route-mark, lazy-boot and attention budget suites. The pushed commits passed tsc and design-lint, but bun scripts/gate.ts still printed the Try:/Looks: and similar-function notes in its last pre-push run, so the forge check may still raise them.

What changed

  • Enrolling: POST /settings/runners/tab (admin, same-origin, no-store) enrols a check_runner row of kind tab (src/machines/tab_runner.ts, src/actions/runners.ts enrolThisTab). The token comes back once. The script src/web/tab_runner_client.ts keeps it in a variable only, with no storage. At most 8 tabs are open at once; a ninth gets 409.
  • Expiry: a tab token is refused with 401 once its last request is more than 30 seconds old (TAB_TTL_MS). The row is deleted at the next listing, so the tab shows on the runners page and in the terminal while it is open and disappears after a missed heartbeat. The tab sends a heartbeat every 10 seconds.
  • What a tab may take:
    • A tab claims only jobs the forge marked tab-safe, on a public repository.
    • Such a job has no cell, label, handed-back files, environment or seeds.
    • Every step is the one verb a tab knows, forge-tab echo <text>, which the tab prints and reports green.
    • A claim's cells: true is ignored for a tab, and a paused heartbeat narrows it.
    • A tab is never trusted: it is never sent secrets, and setRunnerTrust refuses it.
    • Any job with another step is handed back.
    • The script runs nothing from a pull and does not use eval.
  • Schema and docs: migration 20261206180000-tab-runner adds check_runner.kind and check_job.tab_safe. Docs are in runners.md and settings-runners.md.
  • Test: test/tab-runner.test.ts covers the cases below.
    • Enrolling: admin-only, cross-origin refused, the token never stored.
    • The full claim, logs and result round trip.
    • Jobs a tab must not take: shell, cell, label, and a paused tab.
    • An expired token refused with 401 and the row gone from the list.
    • The page offer and the 8-tab cap.

Choices and gaps

  • The offer is on the admin-only runners page, not any signed-in page, because that page is where tabs are listed. Other signed-in users get no button.
  • Nothing in the forge produces forge-tab jobs from a real check yet. The verb list is the seam for widening what a tab may do. Until then the path is exercised by the test, not by real checks.
  • The terminal lists a tab as "a browser tab" but cannot be one. The commit says No door: for that reason.
  • Reused enrolRunner and removeRunner, the existing runnerByToken, claimJob and v1 routes, and the settings route-mark and lazy-list pattern.

Try it Sign in as an admin, open /settings/runners and press Use this tab as a runner. A row marked Tab appears. Close the page and the row is gone within about 30 seconds.

[{"go":"/settings/runners","look":"the This tab block above Register an outside runner","expect":"a button reading Use this tab as a runner and a reserved status line, with no layout shift"},{"go":"/settings/runners","look":"press the button, then read the list","expect":"a row named tab-… with a Tab badge, Connected; the button now reads Stop using this tab"},{"go":"/settings/runners","look":"close the tab and reload from another","expect":"the tab row is gone within about 30 seconds"}]

🤖 Generated with Claude Code

commented

<!-- look-pages 7d0f6fa8cfb0 --> Look pages for 7d0f6fa, from the gate:

  • look pages (none): "Looks: /settings/runners" is not a page of app.looks in forge.json; this pull changes src/web/pages/runners.ts, src/web/tab_runner_client.ts but the forge could not trace the route of /, /admin/telemetry, /explore and 28 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

The check failed because the no-polling test found a timer in src/web/tab_runner_client.ts that its allowlist didn't cover. That file's setInterval is the tab runner's heartbeat. I added the file to the allowlist in test/no-polling.test.ts, and the test file now passes (13 of 13). I pushed the commit.

  • Why it's allowed: the heartbeat is an outgoing request, not a text redraw like the other allowlisted clocks. It stays because the forge can only tell the tab is alive by hearing from it, so there's no /events stream to listen to instead. The allowlist entry says this.
  • What I didn't change: the heartbeat code is the same, and no other behaviour changed.
  • Not run: I ran bun scripts/gate.ts --fix, which printed a possible-duplicate note and said its duplicate scan stopped early at its 8 s limit. The note compares reapTabs in src/machines/tab_runner.ts with settleAll in src/core/allocation.ts; I left both alone. I did not run bun x tsc --noEmit or the rest of the suite. The forge runs the full check on this push.
commented

<!-- look-pages 2481b7fd7936 --> Look pages for 2481b7f, from the gate:

  • look pages (none): "Looks: /settings/runners" is not a page of app.looks in forge.json; this pull changes src/web/pages/runners.ts, src/web/tab_runner_client.ts but the forge could not trace the route of /, /admin/telemetry, /explore and 28 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

I pushed one empty commit to answer the look-pages feedback, with no code change.

  • Look pages: the commit says No look: for /settings/runners. That route isn't in app.looks in forge.json. The page needs a signed-in owner with a machine, so the gate can't look at it, and the page only gains a button, which the tests cover.
  • Both doors: the same commit says No door:. Lending a browser tab to the forge is a browser-only control, and a terminal has no tab to lend. Disagree if you'd rather have a terminal side for it.
  • The other three rules: I didn't re-run or check the duplicate-import, first-view budget and user-column cascade tests this time. I made no change that touches them, and the earlier full check failed only on the no-polling test, which I fixed.
commented

This round addresses all six of Sentinel's points. tsc, the gate, design-lint and the tab, settings-runners, tui-runners and agent-runner-seam tests pass. I did not run the first-view-budget or duplicate-import tests, because scripts/fast.ts named 3300 files, far too many for the sandbox, so the forge's check will be the first to run them.

What changed

  • Env never reaches a tab. isTabSafe now requires an empty env, and the tab's claim query in src/checks/runner_jobs.ts also refuses any job with env variables, whatever its tab_safe mark says.
  • Works without JavaScript. The block now carries a <noscript> line saying a tab runner needs scripts. I took Sentinel's "say plainly" option rather than a post form, because the token is only ever handed to the page's script.
  • One sentence, no &nbsp;. The "This tab" paragraph is cut to one sentence. The status line's height is reserved by [data-tab-say] { min-height: 1.5em } in components.ts.
  • Comments back where they belong. The registerBlock doc comment sits above registerBlock again, and tabBlock has its own.
  • New tests in test/tab-runner.test.ts:
    • A job with a non-empty env is not tab-safe.
    • A claim refuses a private repository's job, and a job with hands or an env, even with tab_safe forced to 1.
    • A job a tab holds is queued again when the tab is reaped.
  • Doc fix. docs/features/runners.md now says the token is refused at once and the row is deleted at the next listing. It also says the terminal's Runners screen lists through the same list, so it shows the same thing. This is the "No door" reason, recorded in the commit message.

What I chose not to do

  • No post form for the button.
  • The gate flagged reapTabs as 0.58 similar to settleAll in src/core/allocation.ts. I left it, since they do different jobs.

How to try it

  • Open Settings → Runners as an admin and press "Use this tab as a runner".
  • Turn scripts off to see the plain line instead.
  • Run bun test test/tab-runner.test.ts.
[
  {"go": "/settings/runners", "look": "the 'This tab' block", "expect": "one sentence, the button, and no shift in layout when the status line fills"},
  {"go": "/settings/runners", "look": "the same page with scripts off", "expect": "a line saying a tab runner needs scripts"}
]
Sign in to join this conversation.

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

Keyboard shortcuts

Docs