Skip to content

The Diff pane shows "Patch content not recorded" for every file an agent edits #448

Open

Description

@coolestnick

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:11 says "File diffs never reach the plane: the runtime strips them from its wire copy", and the file_change case 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 drops diffStr, oldStr and newStr from every file_change item it sends, and keeps diffStr only for a failed change. The on-demand item detail does the same.
  • backend/src/engines/capabilities.ts:38 still reports fileDiffs as 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.

  1. 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 as patch and the existing Diff pane would render it with no frontend change. This needs a change in the runtime fork, which I can't see.
  2. 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).
  3. 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 fileDiffs could 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_change item carrying diff text through to the step the Diff pane reads.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions