Skip to content

feat(chat): show file edit diffs on the tool call - #64

Open
Moep90 wants to merge 1 commit into
formulahendry:mainfrom
Moep90:feat/tool-call-diff
Open

Moep90 wants to merge 1 commit into
formulahendry:mainfrom
Moep90:feat/tool-call-diff

Conversation

@Moep90

@Moep90 Moep90 commented Aug 31, 2026

Copy link
Copy Markdown

Problem

ACP agents report file edits as diff content on the tool call: each entry carries the path plus the old and new text of a hunk. The chat ignores content entirely and renders the icon and the title, so a turn that rewrites a file shows up as a row of text like patch (replace): notes.md and nothing else. There is no way to see what the agent actually wrote.

Change

The tool call row now shows the added and removed line counts of the edit and holds the diff below it, collapsed. Clicking the row expands it, clicking again collapses it. Colors come from diffEditor.insertedTextBackground and diffEditor.removedTextBackground, the counts from gitDecoration tokens, so it follows the active theme.

Nothing is written to disk and no editor tab is opened, which keeps this independent of #43 and #37 and avoids the tab flooding described in #22.

An agent typically sends the same diff twice, once when the tool call starts and once when it completes. The second render replaces the first and an expanded diff stays open across that replacement.

The diff lives in the DOM only. A restored session shows the tool call without it, since the persisted history keeps id, title and status.

Testing

npm run lint, npm test and npm run package pass locally on Linux. Three JSDOM tests cover the collapsed initial render with its line contents and counts, the expand on click, the replacement of a repeated diff, and a tool call whose content holds no diff.

Note on overlap

The test file brings its own JSDOM harness and adds jsdom to the dev dependencies. #56 adds the same dependency for its own tests, at a different major. Whichever lands first, I am happy to rebase this one onto it and drop the duplicate harness.

Agents send file edits as ACP diff content on the tool call, carrying the
path plus the old and new text of each hunk. The chat dropped that content
and rendered only the icon and the title, so an edit was visible as a line
of text and nothing else.

The tool call row now shows the added and removed line counts and holds the
diff below it, collapsed until the row is clicked. Colors come from the
theme's diff editor tokens. Nothing is written to disk and no editor tab is
opened. When a completed tool call repeats the diff it announced at the
start, the second one replaces the first and keeps an expanded diff open.

The diff lives in the DOM only, so a restored history shows the tool call
without it.

Signed-off-by: moep90 <volleyballlive@googlemail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant