Repository navigation
fix(agent): show what a file edit will change before it is approved - #567
Merged
Merged
Conversation
An edit_file or write_file approval showed only the tool and the path
("Requested tool: edit_file / Project file: calculator.py"), so the
person approving could not see the change until after it was staged.
move_file approvals did not show the source or destination at all.
File-tool approval requests now carry a bounded preview (4000 characters
per field, flagged when shortened): the exact text an edit replaces and
its replacement, whether every occurrence is replaced, or the start of
a written file's content. The dialog's details view shows it as plain
text, along with move source and destination. The preview travels only
in the in-memory approval event, never in the run store.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…al-preview # Conflicts: # frontend/src/features/agent/useAgentRun.test.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
A file-edit approval showed only "Requested tool: edit_file / Project file: calculator.py", so the user had to approve an edit without seeing it. The diff appeared only after staging, in the review panel.
move_fileapprovals did not show the source or destination at all.Change
register_file_toolsapproval requests now carry a boundedpreview:edit_file: the exactoldandnewtext andreplace_all;write_file: the start of the content.Each field is capped at 4000 characters, and
truncatedis set when a field was cut.delete_fileandmove_filecarry no preview; their paths already describe them.The approval dialog's details view (from
useAgentRun.parseApproval) shows, as plain text, "Replace this text:" or "Replace every occurrence of:" with "With:", or "File content:", plus "Move from:" and "Move to:", and a note when the preview was shortened. Malformed preview fields are ignored.The preview travels only in the in-memory approval event. The run store still records only fixed approval metadata.
Tests
test_agent_file_tools.py: the edit preview andreplace_all, the 4000-character cap withtruncated, no preview for delete and move, and nothing written while gated. It fails onmain.useAgentRun.test.tsx: a table of five request shapes, covering edit, replace-all with a shortened preview, write, move, and a malformed preview. Four of them fail onmain.tests/test_agent_file_tools.py(200 passed).vitest src/features/agent(120 passed). typecheck and eslint are clean.Risk and rollback
Display only. Rollback is reverting this commit.
🤖 Generated with Claude Code