Skip to content

Limit apply diff results to changed ranges#11987

Merged
szgupta merged 3 commits into
masterfrom
oz/apply-diff-ranged-results
Jun 2, 2026
Merged

Limit apply diff results to changed ranges#11987
szgupta merged 3 commits into
masterfrom
oz/apply-diff-ranged-results

Conversation

@szgupta
Copy link
Copy Markdown
Member

@szgupta szgupta commented Jun 1, 2026

Description

This fixes the apply-diff/edit-file result payload regression where accepted file edits were reported back to the LLM as full post-edit file contents instead of only the changed ranges plus context.

Root cause: remote apply-diff support switched the result source to accepted editor-buffer contents, but the request-file-edits success path converted those buffers directly into UpdatedFileContext entries with line_range: None. That bypassed the existing changed-line ranges computed by CodeDiffView, so the server received and rendered full files. The fix keeps the editor-buffer source needed for remote correctness, but slices it using FileLocations.lines expanded by the restored 10-line context window.

Changes

  • Restores the 10-line apply-diff result context behavior.
  • Builds UpdatedFileContext fragments from accepted editor-buffer content using changed ranges when available.
  • Preserves the full-file fallback when no changed ranges are present.
  • Adds unit tests for ranged results and the no-range fallback.

Validation

  • rustup run 1.92.0 cargo fmt --manifest-path /workspace/warp/app/Cargo.toml --check
  • MACOSX_DEPLOYMENT_TARGET=10.14 rustup run 1.92.0 cargo test --manifest-path /workspace/warp/Cargo.toml -p warp updated_file_contexts_from_editor_buffers
  • MACOSX_DEPLOYMENT_TARGET=10.14 rustup run 1.92.0 cargo clippy --manifest-path /workspace/warp/Cargo.toml -p warp --all-targets -- -D warnings

Co-Authored-By: Oz oz-agent@warp.dev

Conversation: https://staging.warp.dev/conversation/2b2a0786-45a7-4d14-ac07-f300fa1aed27
Run: https://oz.staging.warp.dev/runs/019e81ed-8cc0-7ab3-a2d8-4734728412c9
This PR was generated with Oz.

Restore changed-line-only apply-diff tool results by slicing accepted editor-buffer contents using the diff ranges already computed by CodeDiffView. This keeps remote apply diff support while avoiding full-file payloads when ranges are available.

Co-Authored-By: Oz <oz-agent@warp.dev>
@cla-bot cla-bot Bot added the cla-signed label Jun 1, 2026
@szgupta szgupta requested a review from kevinyang372 June 2, 2026 06:46
@szgupta szgupta marked this pull request as ready for review June 2, 2026 06:46
@oz-for-oss
Copy link
Copy Markdown
Contributor

oz-for-oss Bot commented Jun 2, 2026

@szgupta

I'm starting a first review of this pull request.

You can view the conversation on Warp.

I completed the review and no human review was requested for this pull request.

Comment /oz-review on this pull request to retrigger a review (up to 3 times on the same pull request).

Powered by Oz

Copy link
Copy Markdown
Contributor

@oz-for-oss oz-for-oss Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overview

This PR changes request-file-edits success results to build ranged UpdatedFileContext entries from accepted editor-buffer contents, with tests for ranged output and no-range fallback.

Concerns

  • The ranged slicing path currently uses editor diff ranges as if they were 1-based file-context ranges, which can report line 0 and return the wrong content slice/context window.

Verdict

Found: 0 critical, 1 important, 0 suggestions

Request changes

Comment /oz-review on this pull request to retrigger a review (up to 3 times on the same pull request).

Powered by Oz

Comment thread app/src/ai/blocklist/action_model/execute/request_file_edits.rs
@szgupta szgupta force-pushed the oz/apply-diff-ranged-results branch from 86b1b66 to 6584d1e Compare June 2, 2026 07:40
@szgupta szgupta force-pushed the oz/apply-diff-ranged-results branch from baae9d2 to e8ce03b Compare June 2, 2026 17:18
@szgupta szgupta enabled auto-merge (squash) June 2, 2026 17:24
@szgupta szgupta merged commit 89f61b6 into master Jun 2, 2026
26 checks passed
@szgupta szgupta deleted the oz/apply-diff-ranged-results branch June 2, 2026 17:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants