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

Talk workspace W2: live edit loop — Talk's writes and the Code tab edit the working tree #17177

opened this

Merged 40h 55m ago, live in production

Talk's writes and the Code tab can now go to a working tree instead of a commit, but nothing reloads the preview from it yet. The dev server that would read the working tree doesn't exist. W1 (#17135) only added the workspace bar's status line.

Notes

opened this

Talk's writes and the Code tab can now go to a working tree instead of a commit, but nothing reloads the preview from it yet. The dev server that would read the working tree doesn't exist. W1 (#17135) only added the workspace bar's status line. Each live save lands in the working tree, and the Diff tab shows the accumulated change against the branch tip. A commit is made only when asked.

I ran bun x tsc --noEmit, the gate, and the tests that cover this change (new, TUI, MCP write, route, hollow-code and unused-export suites). All pass. I did not run the full suite.

What changed

  • Storage: a working_edit table, one row per file, kept per person, repository and branch. It has a migration and a pin.
  • Actions: src/actions/working_tree.ts holds saveWorking, workingDiff, commitWorking, discardWorking and openForEdit.
    • saveWorking refuses the default branch, bad paths, files over 2 MiB, more than 200 files, a missing branch, and anyone without write access.
    • commitWorking goes through commitToBranch, so the existing branch rules apply, and then clears the working tree.
    • workingDiff builds the diff without moving any branch.
  • Talk: write_file takes live: true. It saves to the working tree and returns { live, files } with no commit. Without live it commits as before.
  • Branch caveat: a live write needs the branch to exist, so the conversation's first write still commits.
  • Code tab: a new Edit live section opens a path and has Save live. It prefills from the uncommitted text, else from the branch.
  • Diff tab: the uncommitted files show above the commits, with Commit (takes a message) and Discard.
  • Routes: new routes POST /talk/:id/work/save|commit|discard are same-origin checked and limited to the person's own conversation.
  • Terminal: the p view prints Not committed yet: N files on <branch>…, from the same uncommittedWords the page uses. A how-to section was added to docs/features/talk-workspace.md.

Reused

  • commitToBranch, the commitFiles land hook (to seal a commit for the diff without moving a ref), diffRange, renderDiff, refTip and blobForRender.
  • The readForm same-origin pattern from talk_build.ts.
  • No new dependency.

What I chose not to do

  • Hot reload: the dev server (W1's dev cell) doesn't read the working tree, so there is no live reload and no "under 1 s" yet.
  • Terminal actions: Commit and Discard from the terminal wait for W3. The commit line says No door: for this.
  • Editor: the Code-tab editor is a textarea form with no script, not a full code editor.
  • Gate output: the gate's "one implementation?" notes are for thin SQL wrappers and a test helper, which I judged noise.

Try it: open /talk on a conversation that is building an app and go to the Code tab. Open src/app.ts under Edit live, change it and press Save live. The Diff tab then shows the file as not committed, with Commit and Discard.

[
  {"go":"/talk/<id>?pane=code","look":"Edit live under the file tree: a path field with Open","expect":"Opening a path shows a textarea with its uncommitted text, else the branch's text, and a Save live button"},
  {"go":"/talk/<id>?pane=diff","look":"After Save live, the top of the Diff tab","expect":"'Not committed yet: 1 file on talk-…', a message box with Commit, a Discard button, then the file's diff"},
  {"go":"/talk/<id>?pane=diff","look":"Press Commit with a message","expect":"A flash says it committed to the branch; the uncommitted block is gone and the commit shows in the version list"},
  {"go":"/talk/<id>?pane=diff","look":"Press Discard instead of Commit","expect":"A flash says the uncommitted files were discarded; the branch tip is unchanged","ask":"Does the section read clearly enough that a person knows nothing is committed yet?"}
]

🤖 Generated with Claude Code

Closes #17120

Show 5 earlier items

7 earlier comments
commented

<!-- look-pages c4132a044ea7 --> Look pages for c4132a0, from the gate:

  • look pages (inferred): this pull changes src/web/pages/talk_preview.ts, src/web/talk_code.ts, src/web/talk_tree.ts; the forge pictures /talk (src/web/pages/talk_preview.ts), the pages whose routes import it. A "Looks: <path>" or "No look: <why>" line in a commit message overrides
commented

The feedback needed only one code change. I pushed it as 2b53a87ad. bun x tsc --noEmit is clean and the tests for working-tree, unused-exports and tui-talk-chats pass. I did not run the full suite.

  • Typed input in the test: test/working-tree.test.ts no longer reads the MCP reply as any. The reply now has a proper type. The other as never casts in the existing test/talk-*.test.ts files predate this pull and I left them alone.
  • Name the issue: the new commit carries Direction: … (#17120). It also carries Looks: /talk, which picks the page the gate pictures. Earlier commits on the branch lack the line, and I can't rewrite them without a force push.
  • Both doors: bun scripts/gate.ts --explain reports the both-doors rule satisfied. The terminal's p view already shows the working tree's line. Commit and Discard from the terminal wait for W3, as the first commit's No door: line says.
  • Dead code: the unused-exports test passes, and none of this pull's modules are on the unused list. It only notes two older src/spawn/ exports that are no longer dead.
  • Duplicate-function notes: the gate only notes working_tree.ts and mcpCall as similar to other functions. mcpCall follows the existing say helper in test/mcp-say-build.test.ts, so I didn't merge them. bun scripts/gate.ts --fix changed nothing.
[{"go":"/talk","look":"Code tab on a building conversation: Edit live, open a file, Save live","expect":"The save lands in the working tree; the Diff tab shows it under Commit and nothing is committed until asked"}]
commented

This fixes the check failure on #17177 (Duplicate identifier 'm451'). It was a migration slot collision.

Main had taken 20261201180000 for game-box-diag (m451), the same slot as this pull's working_edit migration. I renamed this pull's migration to 20261201190000-working-edit and re-pinned it. I regenerated src/generated/migrations.ts with bun scripts/own-source.ts, which now lists m450, m451 and m452 once each. I merged origin/main and the fork's newer branch tip, which only adds a test typing fix, so the push is a plain fast-forward.

  • Checks run: tsc --noEmit is clean. test/working-tree.test.ts, schema-migrations, own-source, tui-talk-chats and unused-exports pass, 103 tests in all. I did not run the full suite.
  • Notes: gate --fix changed nothing. It still prints similarity hints on src/core/working_tree.ts and test/working-tree.test.ts; they are advisory and I left them.
  • Behaviour: unchanged from the earlier work. write_file and the Code tab write a working tree, and nothing commits until asked. The terminal side is in src/tui/screens/talk_chats.ts and the how-to in docs/features/talk-workspace.md.

To try it, open a Talk chat's Code tab on the preview. Edit a file and confirm it shows as a working edit that is not committed.

[{"go":"/","look":"Talk chat Code tab","expect":"edits appear as uncommitted working edits; nothing commits until asked"}]
commented

I merged main into the branch and pushed it as ee66c4e05. tsc --noEmit is clean. I ran only the five test files below, not the whole suite.

  • The conflict: the only one was in src/generated/migrations.ts, which both sides had touched by adding migrations. I took main's copy and regenerated it with bun scripts/own-source.ts. It now lists 20261201190000-working-edit and 20261201190500-runner-machine in order, with no conflict markers left.
  • The tests: own-source, working-tree, schema-additive, schema-migrations and tui-talk-chats pass, 62 tests with no failures.
  • What I skipped: scripts/fast.ts named 3730 files, far over its budget, so I ran those five instead.

The forge's check runs the full suite on this push.

commented

I merged main into the branch and pushed it. The only conflict was src/generated/migrations.ts, so I regenerated it with bun scripts/own-source.ts instead of editing it by hand.

  • Result: The file now lists both sides' migrations. The new 20261201150000-dns-record migration from main and this pull's 20261201190000-working-edit migration are both in, and nothing is lost or renumbered.
  • Checks run: bun x tsc --noEmit is clean. test/own-source.test.ts and the migrations tests pass. I did not run the full suite; the forge's check does that on this push.
  • Gate: bun scripts/gate.ts --fix changed nothing. It prints three "one implementation?" similarity notes on src/core/working_tree.ts and test/working-tree.test.ts (for example clearEdits against carryReviews). I did not look into them, and I assume they were there before the merge.
commented

I've addressed all seven points and pushed. bun x tsc --noEmit is clean, and so are the 294 tests I ran in the areas this change touches. I did not run the full suite or exercise the preview; the forge's check runs the full suite on this push.

  • 1. Terminal door: The p view now has e, C and X.
    • e saves a file live: path first, then its text on one line with \n for a line break. The text prompt is prefilled with the file's current text, so typing appends to it rather than replacing it.
    • C commits with your message, and X discards.
    • They call saveWorking, commitWorking and discardWorking. The inline IIFE is replaced by the named uncommittedLine helper, and docs/features/talk-workspace.md has the how-to.
  • 2. Unbounded work: saveWorking now refuses a save that would take the whole tree past MAX_COMMIT_BYTES (10 MiB). Replacing a file counts its new size, not both. workingDiff and commitWorking check the total through the new editBytes, so the diff and the commit can always be built.
  • 3. Design system: talk-work, talk-live and the textarea rule are gone, so no new component class needs documenting. The markup uses the existing stack, and the textarea uses input mono, as copyField does. bun scripts/design-lint.ts passes.
  • 4. Said once: "Not committed yet: N files on <branch>." is the only place the idea appears. I removed the "nothing is a commit until you commit" tail, and the Save live label, flash and docs no longer repeat it. I also dropped the "Edit live" heading, so the Code tab opens straight on the path field. I did not do the "show the changed rows first" part: the path field and Open button still sit above the editor, which opens only once a path is given.
  • 5. Cap and advice: The talk-page cap is back to 61,000. write_file has its original description, "With a shell, clone and push" included. Adding live to its schema put the Talk tool list 18 bytes over its 18,500 ceiling, so I shortened two other descriptions: new_app ("a first issue" is now "an issue") and branches (dropped ", not the default"). The longer docs still carry both details. The ceiling is unchanged.
  • 6. Foreign key: working_edit.repo_id now has REFERENCES repo(id) ON DELETE CASCADE. The migration was only in this pull, so I edited it and re-pinned it. The pin file changed.
  • 7. Tests: I added tests for the total-size cap, the diff and commit refusing above it, and the cascade on repository delete. They also cover the Discard route (wrong origin gets 403, another user gets 404, the owner's tree is cleared) and the terminal's save, commit and discard.

bun scripts/gate.ts --fix changed nothing. It prints similarity notes on core/working_tree.ts (for example clearEdits and editOf) and on the mcpCall helper in test/working-tree.test.ts. I left them as they are.

commented

I merged main into the branch and pushed it. The two conflicts, in src/tui/screens/talk_chats.ts and docs/features/talk-workspace.md, kept what both sides added.

  • talk_chats.ts: the p view keeps this pull's e, C and X keys (save live, commit, discard) next to main's d key (start or stop the dev server). Both sets of imports and both key bindings are in.
  • talk-workspace.md: main's dev-server section comes first, then this pull's "Live edits" section. I reworded the "Not yet" line there. It used to say the dev cell isn't built. It now says the dev frame doesn't reload from uncommitted files.

bun x tsc --noEmit is clean, and 229 tests pass across the working-tree, terminal, Talk page, MCP, migration, docs and dev-server suites. I did not run the full suite; the forge's check does that on push. bun scripts/gate.ts --fix rewrapped nothing, but it printed a note that four files have comment lines over 100 columns (write_file.ts, talk_chats.ts, talk_preview.ts and one more). It says the nightly rewrap handles them on main. It also printed its usual "one implementation?" similarity notes on src/core/working_tree.ts and test/working-tree.test.ts.

commented

I merged main into the branch and pushed it (b98fb6fcd). The forge's check will now run on the push.

The conflict. main had split src/http/server.ts into route modules under src/http/routes/. I took main's server.ts whole and re-applied my one change there: the three /talk/:id/work/save, /commit and /discard routes and their talk_tree.ts import. Those now live in src/http/routes/talk.ts, next to the other talk routes.

What I ran.

  • bun x tsc --noEmit came back clean.
  • bun test on the test files this pull changes, plus test/talk-build.test.ts: 38 pass, 0 fail.
  • bun scripts/gate.ts --fix changed nothing, so there was nothing to commit from it. It still prints three similarity notes, for example working_tree.ts#editCount against valve_store.ts#startsSince. The pull passed its check before this merge, so I left them.

Not run. scripts/fast.ts said my changes reach 3740 of 4692 test files (about 5 hours), so I didn't run them. The forge's full check covers that on this push.

Sign in to join this conversation.

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

Keyboard shortcuts

Docs