Skip to content

Incorrect applying of apply_diffΒ #2556

@avtc

Description

@avtc

App Version

3.11.14

API Provider

LM Studio

Model Used

athene-v2-chat@iq4_xs

Actual vs. Expected Behavior

The diff produced looks good, but applied wrongly by Roo:
Image

The text version:
Original file:

7 | .chess-board-container {
8 |     display: flex;
9 |     gap: 1rem;
10 |     align-items: center;
11 | }
12 | 
13 | .overlay {
14 |     position: absolute;
15 |     top: 0;
16 |     left: 0;
17 |     width: 100%;
18 |     height: 100%;
19 |     background-color: rgba(0, 0, 0, 0.5);
20 |     z-index: 999; /* Ensure it's above the board but below the promotion dialog */
21 | }

The diff produced:

<<<<<<< SEARCH
:start_line:12
:end_line:13
-------
.overlay {
=======

.piece {
    will-change: transform;
}

.overlay {
>>>>>>> REPLACE

The final result:

10 |     align-items: center;
11 | }
12 | .piece {
13 |     will-change: transform;
14 | }
15 | 
16 | .overlay {
17 | .overlay {

======
Another attempt:
Image

The diff:

<<<<<<< SEARCH
:start_line:11
:end_line:13
-------
}
 

.overlay {
=======

}
.piece {
    will-change: transform;
}

.overlay {
>>>>>>> REPLACE

In the final result line with 14 | position: absolute; was deleted.

Detailed Steps to Reproduce

I am working on custom prompt for apply_diff to add context lines for better match the content, so idk if the model will produce same diff content with standard prompt, but with standard prompt I also had similar issues with applying correct diffs.

Probably unit-test will help to debug, assume original content (with correct line numbers) is:

.game-container {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.chess-board-container {
    display: flex;
    gap: 1rem;
    align-items: center;
}

.overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 999; /* Ensure it's above the board but below the promotion dialog */
}

and two diffs are provided above.

Relevant API Request Output

Additional Context

No response

Metadata

Metadata

Assignees

No one assigned

    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