Repository navigation
feat(codemode): show a script's diffs while it runs - #65247
Conversation
bf6bb5a to
3e9505d
Compare
ece63fa to
4bac436
Compare
3e9505d to
8d8d8f4
Compare
428fec7 to
1fb8cad
Compare
User decisions: - Show a script's diffs live while it runs, in the desktop and the TUI
1fb8cad to
3fd9ecb
Compare
There was a problem hiding this comment.
I couldn't confirm the live diffs end to end, but I found nothing that should block the merge. The core, session-ui (both timelines) and TUI tests you changed pass. Each package's typecheck script fails in this environment, but tsc on the changed code shows no errors. My opencode-drive run with the simulated model never showed the execute call, so I have no before/after screenshots and haven't seen diffs appear while a script runs. The recordings under artifacts/ would cover that.
The progress path reuses the existing throttle, and files() now returns a copy, so a sent update doesn't change as later changes arrive. On the desktop, placement only re-runs when the number of changes goes up or the script finishes, which the reactivity test checks.
On the decision you asked to confirm: the base already kept a failed script's metadata.files, so the new behaviour only changes the UI side, and keeping cards that were shown live seems right.
Public API: unchanged. The script's progress updates gain an optional files key in the shape the final result already uses.
User decisions: - Fix the live diff review findings - Failed and interrupted scripts keep their diffs
There was a problem hiding this comment.
I found nothing new that needs changing in ed819d566, and my earlier review left no open points. The new core tests (the move to the background in job.test.ts, the change sent on interrupt in tool-execute.test.ts) wait on deferreds rather than sleeps. The core, session-ui and TUI tests pass, and the changed files type-check. I still haven't watched it run end to end, so your recordings are the evidence for the live UI.
Public API: unchanged.
Targets
dev. Builds on #65002, which is merged.What
A Code Mode script's file diffs now show while it runs, in both desktop timelines and the TUI, not only once it finishes.
filesnext totoolCalls. They use the same per-change shape and caps (MAX_FILES,MAX_PATCH_BYTES), with no file reads. A recorded change (from an inner edit/patch/write or a Bun write/append/delete) schedules an update through the same throttle. The final result still carries the full list. Once a script moves to the background,CodeModeJobalready drops its progress, so it stops sending files, and a backgrounded script shows no diffs, as before.scriptChangesreadsrunningscripts too. Theirbackground: trueflag only means "can move to the background", so onlyjobIDhides them. Placement reads only the count of changes, andplace.tsreads the paths untracked, so the projection re-runs only when a change is added or the status settles. File fact ids (…:file:<index>:<path>) only ever get appended, so open cards keep their identity.PatchedFilesrenders by position (Index), so a running script's blocks stay in place as changes arrive. The verbosity rules are unchanged: they fold into the activity at low and show under the script at medium and high.Decision to confirm: failed or interrupted scripts keep their changes
The files really changed, so a script that errors or is interrupted keeps the changes made so far:
metadata.files;files.This way cards shown live don't vanish when the script ends. It is one switch:
keepFailedScriptChangesinpackages/session-ui/src/timeline/facts.ts.Tests
tool-execute.test.ts: progress carriesfiles, counts only grow and stay capped atMAX_FILES, and a failed script keeps them inmetadata.files.placement-reactivity(current and next timelines,--conditions=browser):{ streamed: 0, moved: 1, changed: [1, 1], scripted: 1 }. A running script whosetoolCallsgrow causes 0 re-runs, each new change exactly 1 (including a same-count report after it), and finishing with the same changes 1.session-verbosity.test.ts: a running script with changes at low, medium and high.Recordings (simulated model): desktop at Detailed in
artifacts/drive-codemode-gui/live-diffs/and TUI at medium inartifacts/drive-codemode-tui/live-diffs/.Not covered: there is no CodeModeJob test harness, so "backgrounded stops sending" relies on the existing detach gate in
codemode/job.tsand has no new test.Draft: drafts skip CI here.