Skip to content

fix(agent): show what a file edit will change before it is approved - #567

Merged
dovvnloading merged 2 commits into
mainfrom
fix/agent-edit-approval-preview
Nov 22, 2026
Merged

dovvnloading merged 2 commits into
mainfrom
fix/agent-edit-approval-preview

Conversation

@dovvnloading

Copy link
Copy Markdown
Owner

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_file approvals did not show the source or destination at all.

Change

  • register_file_tools approval requests now carry a bounded preview:

    • edit_file: the exact old and new text and replace_all;
    • write_file: the start of the content.

    Each field is capped at 4000 characters, and truncated is set when a field was cut. delete_file and move_file carry 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 and replace_all, the 4000-character cap with truncated, no preview for delete and move, and nothing written while gated. It fails on main.
  • 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 on main.
  • Focused: 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

dovvnloading and others added 2 commits November 21, 2026 22:31
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
@dovvnloading
dovvnloading merged commit ccb9154 into main Nov 22, 2026
19 checks passed
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