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

Talk workspace W2: a hot-reloading dev cell per workspace #17154

opened this

Merged 36h 34m ago, live in production

Workspaces now get a hot-reloading dev cell. The pull is pushed. The new tests pass (test/dev-cell.test.ts and test/dev-cell-launch.test.ts, which drives the real launcher), and so do tsc, design-lint, the touched Talk/route/hollow/unused-export suites and the gate's rules.

Notes

opened this

Workspaces now get a hot-reloading dev cell. The pull is pushed. The new tests pass (test/dev-cell.test.ts and test/dev-cell-launch.test.ts, which drives the real launcher), and so do tsc, design-lint, the touched Talk/route/hollow/unused-export suites and the gate's rules. I ran the targeted suites, not the full one. The Chromium frame test is skipped here (no Chromium), so the frame was not drawn in a browser.

What changed

  • Starting it: a writer on a repository that is an app gets a Start dev server button in the pane bar, or d in the terminal's p view. It runs in the same cell an app of that repository uses. The dev command is app.dev in forge.json, else bun run dev when package.json has a dev script, else the app's run command with bun made bun --hot (src/apps/dev_command.ts).
  • Status: while a cell is held, paneStatus reads the server itself, and both doors print the same line. It is Starting until the port answers, then Live. It is Reloading while the crew works on top of a live server. If the server stops, it is Error in file:line, taken from its last output. The pane redraws when the state changes (a new dev.state event). With no cell held, W1's behaviour is unchanged.
  • Hot reload: the branch is checked out under <data>/dev/. Reading the pane syncs any new commit on the branch into that checkout, and the running server picks it up. test/dev-cell-launch.test.ts shows a commit reaching a live server through the frame path.
  • Idle sleep: a cell sleeps after 10 minutes unused (the process stops, the checkout stays). A forge holds at most 8, and the least recently used sleeps first. I used my own idle sweep rather than #16840's.
  • The frame: it is served at /talk/dev/<token>/… (src/web/pages/talk_dev.ts), never as the forge's own origin. The iframe has no allow-same-origin, and every answer carries Content-Security-Policy: sandbox. No cookie goes in either direction, and only GET and HEAD are relayed. A sandboxed frame sends no session, so the 192-bit token in the path is the credential. Redirects are rewritten to stay under the token.
  • Docs and reuse: docs/features/talk-workspace.md describes the dev server. I reused startProcess, cellFor, runLocal, resolveOid, heldOf and the W1 status types, and edited talk_preview.ts and talk_chats.ts in place.
  • One existing test changed: in test/talk-pane-bar.test.ts, "falls to Live" still expected W1's old "Live" option label, which W1 had already broken. It now matches the branch label.

What I left out

  • A page POST or form inside the dev frame won't work. Mutations from a sandboxed origin can't be same-origin checked, so only GET is relayed.
  • Absolute links like /x written by the app point at the forge, not the app.
  • No WebSocket relay.
  • The dev cell has no app secrets or database bindings.
  • Only the branch of the pull shown (or the default branch) can be run; there is no free branch picker.
  • Where the host can't hold cells, the process runs as an app's does, uncontained.
  • The gate still prints a "one implementation?" note for section in src/apps/dev_command.ts and git in test/dev-cell.test.ts (0.60 and 0.61 similarity). It did not stop the push.

Try it: open /talk on a repository that is an app, press Start dev server, then commit a change to that branch and watch the frame reload.

🤖 Generated with Claude Code

Closes #17140

8 earlier comments
commented

Workspaces now get a hot-reloading dev cell. The pull is pushed. The new tests pass (test/dev-cell.test.ts and test/dev-cell-launch.test.ts, which drives the real launcher), and so do tsc, design-lint, the touched Talk/route/hollow/unused-export suites and the gate's rules. I ran the targeted suites, not the full one. The Chromium frame test is skipped here (no Chromium), so the frame was not drawn in a browser.

What changed

  • Starting it: a writer on a repository that is an app gets a Start dev server button in the pane bar, or d in the terminal's p view. It runs in the same cell an app of that repository uses. The dev command is app.dev in forge.json, else bun run dev when package.json has a dev script, else the app's run command with bun made bun --hot (src/apps/dev_command.ts).
  • Status: while a cell is held, paneStatus reads the server itself, and both doors print the same line. It is Starting until the port answers, then Live. It is Reloading while the crew works on top of a live server. If the server stops, it is Error in file:line, taken from its last output. The pane redraws when the state changes (a new dev.state event). With no cell held, W1's behaviour is unchanged.
  • Hot reload: the branch is checked out under <data>/dev/. Reading the pane syncs any new commit on the branch into that checkout, and the running server picks it up. test/dev-cell-launch.test.ts shows a commit reaching a live server through the frame path.
  • Idle sleep: a cell sleeps after 10 minutes unused (the process stops, the checkout stays). A forge holds at most 8, and the least recently used sleeps first. I used my own idle sweep rather than #16840's.
  • The frame: it is served at /talk/dev/<token>/… (src/web/pages/talk_dev.ts), never as the forge's own origin. The iframe has no allow-same-origin, and every answer carries Content-Security-Policy: sandbox. No cookie goes in either direction, and only GET and HEAD are relayed. A sandboxed frame sends no session, so the 192-bit token in the path is the credential. Redirects are rewritten to stay under the token.
  • Docs and reuse: docs/features/talk-workspace.md describes the dev server. I reused startProcess, cellFor, runLocal, resolveOid, heldOf and the W1 status types, and edited talk_preview.ts and talk_chats.ts in place.
  • One existing test changed: in test/talk-pane-bar.test.ts, "falls to Live" still expected W1's old "Live" option label, which W1 had already broken. It now matches the branch label.

What I left out

  • A page POST or form inside the dev frame won't work. Mutations from a sandboxed origin can't be same-origin checked, so only GET is relayed.
  • Absolute links like /x written by the app point at the forge, not the app.
  • No WebSocket relay.
  • The dev cell has no app secrets or database bindings.
  • Only the branch of the pull shown (or the default branch) can be run; there is no free branch picker.
  • Where the host can't hold cells, the process runs as an app's does, uncontained.
  • The gate still prints a "one implementation?" note for section in src/apps/dev_command.ts and git in test/dev-cell.test.ts (0.60 and 0.61 similarity). It did not stop the push.

Try it: open /talk on a repository that is an app, press Start dev server, then commit a change to that branch and watch the frame reload.

🤖 Generated with Claude Code

commented

I've fixed the failing scan and budget tests for the hot-reloading dev cell. The five tests behind the red check, plus the dev-cell and page-budget-file tests, now pass locally. The type check is clean. I did not run the full suite; the forge runs it on this push.

  • Event audience: dev.state was emitted but not classified. It is now for the actor, meaning the person who owns the cell, in src/core/event_audience.ts.
  • Timers: the dev-cell sweep setInterval in src/apps/dev_cell.ts is now wrapped in during("dev-cell-sweep", …), so it shows up in the job ring.
  • Unwalked routes: /talk/dev/:token and /talk/dev/:token/*path are now listed in NOT_WALKED in test/no-polling.test.ts, each with a reason: they proxy a running cell and the seed starts none. MAX_UNFIXTURED in test/pages-budget.test.ts went from 168 to 170 for the same two routes.
  • /talk budget: the page now costs 64 SQL statements warm, so I raised its ceiling in test/budgets/pages/talk.json from 62 to 64. The extra two come from the workspace bar reading the repository and its dev cell. I accepted the cost rather than trimming those reads.

bun scripts/gate.ts --fix rewrapped nothing. It still prints advisory notes about long comment lines and two near-duplicate functions (dev_command.ts section against talk.ts parse, and dev-cell.test.ts git against sync-shapes.test.ts git); I left those alone. The commit says "No door:" because it only touches rule registries and test budgets.

commented

I merged main into the branch and pushed it. The five test files I ran afterward (pages-budget, no-polling, timers-named, event-audience-coverage, page-budget-files) pass and tsc is clean. I did not run the full suite.

The only conflict was in test/pages-budget.test.ts. main replaced the MAX_UNFIXTURED counter, with its long comment trail, by one file per route in test/budgets/unfixtured/. I took main's version. The two dev-cell frame routes (/talk/dev/:token and /talk/dev/:token/*path) now each have their own file there (talk-dev-token.json and talk-dev-token-path.json), so the "no fixture" reason I wrote earlier is kept.

commented

The failing test was job-slices, which wants every job wrapped in during to be either timed or listed in UNTIMED with a reason. The dev-cell-sweep timer I wrapped earlier was in neither.

I added it to UNTIMED in test/job-slices.test.ts. The reason given is that it walks at most DEV_CELLS_MAX in-memory entries once a minute and only kills an idle cell. test/dev-cell.test.ts already drives sweep directly. job-slices and timers-named pass locally, and the fix is pushed. I did not run the full suite or tsc this time.

commented

This pull gives each Talk workspace its own hot-reloading dev cell. I changed no code this turn. I merged the current main into the branch and pushed.

The check's last failure was fork flows > the MCP tool answers the same data. I couldn't reproduce it. test/fork-flows.test.ts passed 11 of 11 after the merge, so I think main fixed it or the failure was a timing flake. The forge's own check on this push is the real confirmation.

I ran these locally and they pass (30 tests):

  • unused-exports
  • both-doors
  • dev-cell
  • dev-cell-launch
  • the llms.txt budget test

bun x tsc --noEmit printed nothing.

Gate:

  • It reports no hard errors.
  • It notes three long comment lines in src/tui/screens/talk_chats.ts, src/web/pages/talk_preview.ts and test/talk-pane-bar.test.ts. The nightly rewrap fixes those on main.
  • It flags two possible duplicates: src/apps/dev_command.ts#section against src/web/pages/talk.ts#parse, and the git helper in test/dev-cell.test.ts against the one in test/sync-shapes.test.ts. I left both alone.

Not run: the full suite. scripts/fast.ts named 3140 files, over the 5-minute budget, so I stopped it.

To try it: run bun test test/dev-cell.test.ts test/dev-cell-launch.test.ts.

🤖 Generated with Claude Code

commented

I merged main into this branch and pushed it. The only conflict was in test/talk-pane-bar.test.ts.

Resolution: both sides had edited the same assertion block. I kept main's version, which names the Live option for the branch it serves (#17135). It also keeps this branch's expect(html).toMatch(/<option value="live" selected>…/) check, so nothing from this side was lost.

Checks:

  • test/talk-pane-bar.test.ts passes (9 tests).
  • bun x tsc --noEmit is clean.
  • I did not run the full suite or the gate script. The forge runs the full check on this push.
commented

Still red on current main: Talk: every control is 44 px each way under a finger, and every button has a name. Fix it and push.

commented

I fixed the security-floor-routes failure and pushed. The phone-targets failure is not fixed.

  • security-floor-routes (fixed): The new /talk/dev/:token and /talk/dev/:token/*path routes need a one-time token, so the test's seed can't fill them. I added both to the test's UNSEEDED list, each with a reason pointing at test/dev-cell.test.ts. The file now passes locally (13 pass), and tsc --noEmit shows no errors.
  • phone-targets (not fixed): The forge's own log marks it "red on main at bb7aa5d too, the same tests: not counted against this pull". Here it only skips, because no Chromium starts in this sandbox, so I couldn't run it.

I ran only that one test file and tsc, not scripts/gate.ts or scripts/design-lint.ts. The commit message carries No door: because the change touches only a test list.

commented

All of @sentinel's findings are fixed in one round on this branch; no review item was declined. tsc, the design lint, the gate and the 12 test files that cover this change pass. I did not run the whole suite, which the forge's check does on this push. The sandbox denied one apps.test network call during the run, and none of those tests failed.

What changed

  • 1 (HIGH, forge-wide cap). DEV_CELLS_MAX and its eviction are removed, and there is no per-person bound in its place. The ten-minute idle sleep is the only bound, and nobody's cell is stopped to make room for another's. One writer can still start many cells; say if you want a per-person limit added.
  • 2 (HIGH, identity key). The dev process gets a key derived from the app's key for its own dev environment (devIdentityKey in dev_launch.ts), so the app's real key is never handed over. No forge token is given either. The header comment and docs now match, and a launch test shows the branch's server sees neither.
  • 3 (HIGH, tests).
    • POST /talk/dev is tested for a cross-origin refusal, a guest, a non-writer, a repository that is not an app, and start then stop for a writer.
    • The terminal d key is tested for a repository that is not an app, a non-writer, start, and stop.
    • The pane button is tested for what a writer and a reader are offered, and for the sandboxed frame and note while a cell is live.
  • 4 (MEDIUM, git on the read path). devReading now only reads: no git, no touch. Checkouts sync on the push event, which commitToBranch and the git hook both emit, and a push that lands mid-sync is synced afterwards. Only the frame's own requests keep a cell awake.
  • 5 (MEDIUM, lost access). talkDevFrame re-checks that the cell's owner can still write. If not, it answers 404 and stops the person's cells on that repository.
  • 6 (MEDIUM, absolute Location). relayedLocation rewrites a redirect to the dev server's own port under the token path. Any other absolute or protocol-relative address gets a 502 that names no port.
  • 7 (MEDIUM, design). The pane's info line says "The dev server runs in a sandboxed frame: sign-in and forms that post do not work in it" while a dev frame is live. The terminal's p view says the same, and the docs state it as a limit of the feature.
  • Minor (token index). Cells are now indexed by token, so a token lookup no longer scans every cell.

Left out

  • Making sessions and forms work in the frame. A sandboxed frame has no origin the forge can check a POST against, so the relay stays GET and HEAD only.
  • The gate's two duplicate-function notes (git in the test helper, section in dev_command.ts) and the over-100-column comment note. The gate marks all three as notes with nothing to do.

Try it

  1. Open a Talk pane on a repository that is an app, as a writer.
  2. Press "Start dev server", or d in the terminal's p view.
  3. Push to the branch and watch the frame reload.
  4. As a reader, the button is absent.
[
  {"go": "/talk (a conversation working on an app you can write to)", "look": "the bar's Start dev server button, then the line under the bar once it is Live", "expect": "the button flips to Stop dev server, and the info line says the frame is sandboxed and that sign-in and forms that post do not work in it"},
  {"go": "the same conversation as someone who can only read the repository", "look": "the pane bar", "expect": "no dev server button"}
]
Sign in to join this conversation.

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

Keyboard shortcuts

Docs