Skip to content

Bug: apply_diff tool hangs indefinitely when modifying XML files #4851

@hannesrudolph

Description

@hannesrudolph

NOTE: THIS ISSUE WAS OPENED WITH THE OLD ISSUE-FIXER MODE

App Version

3.21.0 (accc5fb)

API Provider

Open Router

Model Used

Anthropic/Opus 4

🔁 Steps to Reproduce

  1. Start a task with Roo.
  2. Instruct Roo to modify a moderately large file (e.g., ~300 lines), specifically an XML file.
  3. Observe as Roo attempts to use the apply_diff tool.

💥 Outcome Summary

Expected: Roo applies the changes to the XML file successfully within a few seconds. The diff view loads, and the user can approve or reject the changes.

Actual: The "Roo wants to edit this file" dialog appears, but the progress bar hangs indefinitely. The file is never updated, and no error messages are shown in the UI or output channel. The operation must be manually canceled.

📄 Relevant Logs or Errors

No error messages or logs were observed.

Technical Analysis

Based on my investigation, the root cause appears to be related to how the apply_diff tool is implemented and potentially how it handles XML content.

  1. Dual apply_diff Implementations: The codebase contains two versions of the apply_diff tool.

  2. Point of Failure: The hang occurs during the approval phase, after Roo has decided on the change but before the file is written. The issue is likely within the applyDiff function called from either multiApplyDiffTool.ts or applyDiffTool.ts.

  3. Potential Cause: Given that the problematic content is XML, the issue could stem from:

    • XML Parsing in multiApplyDiffTool: The new tool's reliance on parseXml could be failing silently or entering an infinite loop when the diff content itself is malformed or complex XML.
    • HTML Entity Unescaping: Both tools unescape HTML entities from the diff content (unescapeHtmlEntities(diffContent)). If the model provides XML content within an XML tool call, this double-parsing/unescaping could be corrupting the diff and causing the diffing library to hang.
    • Diff Strategy: The underlying diffStrategy might have a performance bottleneck or bug when processing structured text like XML, especially with a large number of changes.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Issue/PR - TriageNew issue. Needs quick review to confirm validity and assign labels.bugSomething isn't working

    Type

    No type

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions