Repository navigation
Description
On a thread where the agent edited files, the Diff pane lists each file with its line counts, but opening a file shows this note where the diff should be:
Patch content not recorded for this change; only the file receipt and line stats are available.
I saw it on an OpenCode thread with twelve edited files. From the code, it happens for every engine that runs on the native runtime, so the Diff pane and the line comments added in #89 have nothing to show or comment on for those threads.
Why it happens
- The Diff pane builds each diff only from the text saved in the step's input: an edit's old and new strings, a patch body, or a full written file. With none of those it prints the note. See
frontend/components/session-ui/file-diff-view.tsx:297. - The backend never receives that text. The header of
backend/src/engines/runtime-v2-view.ts:11says "File diffs never reach the plane: the runtime strips them from its wire copy", and thefile_changecase at line 228 records only each path, its change kind and the added and removed line counts. - I read the packaged runtime in
backend/runtime-assets/(the 42ef3397fa38 archive, one version behind the pinned one). Its wire projection dropsdiffStr,oldStrandnewStrfrom everyfile_changeitem it sends, and keepsdiffStronly for a failed change. The on-demand item detail does the same. backend/src/engines/capabilities.ts:38still reportsfileDiffsas true for these engines.
So the frontend is doing the honest thing with what it gets. The text is dropped earlier, on purpose, to keep large diffs out of the database.
Ways to fix it
I'd like a maintainer's call on the direction before writing code, since two of these add a new mechanism.
- The runtime sends a size-capped diff. It already bounds these fields to 32 KB for its own storage. If the wire copy kept a bounded
diffStr(or old and new strings), the backend could pass it into the step input aspatchand the existing Diff pane would render it with no frontend change. This needs a change in the runtime fork, which I can't see. - The backend asks the runtime for the turn's diff. The runtime has
orchestration.getTurnDiff, a git diff of the thread workspace between two turns. The backend could call it when a turn settles, split it per file and store it. This needs a place to store the diff, and it would miss files written outside the workspace (a scratch file under/tmp, a second worktree). - Leave the text out and say so plainly. If keeping diffs out of the plane is the intended end state, the pane could say that diffs aren't kept for this engine instead of implying the record is incomplete, and
fileDiffscould report false.
Option 1 looks cleanest to me. I'm happy to do the backend and frontend side of 1 or 2 once the direction is settled.
Done when
- Opening an edited file in the Diff pane of a native runtime thread shows its diff, within a stated size cap.
- A file whose diff is over the cap, or isn't available, says so in plain words.
- A test covers a
file_changeitem carrying diff text through to the step the Diff pane reads.
Activity
Screenshots from real runs for useagenthq#448
Carry a file edit's old and new text to the Diff pane (#450)