Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature: minimal diff #582

Open
will-lynas opened this issue Sep 14, 2024 · 7 comments
Open

feature: minimal diff #582

will-lynas opened this issue Sep 14, 2024 · 7 comments
Labels
enhancement New feature or request

Comments

@will-lynas
Copy link
Contributor

Feature request

The LLMs tend to suggest replacement of large blocks of code, even when most of the block is unchanged. This makes it harder to review the changes it wants to make. Would it be possible to generate a minimal diff and apply that inside the merge conflict markers instead?

Example: This is generated

<<<<<<< HEAD
CREATE TABLE serbian_scores (
    id INTEGER PRIMARY KEY AUTOINCREMENT,
    user_id INTEGER,
    test_id INTEGER,
    FOREIGN KEY (user_id) REFERENCES users(id)
    ON DELETE CASCADE
);
=======
CREATE TABLE serbian_scores (
    id INTEGER PRIMARY KEY AUTOINCREMENT,
    user_id INTEGER,
    test_id INTEGER,
    FOREIGN KEY (user_id) REFERENCES users(id)
        ON DELETE CASCADE,
    FOREIGN KEY (test_id) REFERENCES serbian_tests(id)
        ON DELETE CASCADE
);
>>>>>>> Snippet

But it could just be

<<<<<<< HEAD
=======
    FOREIGN KEY (test_id) REFERENCES serbian_tests(id)
        ON DELETE CASCADE
>>>>>>> Snippet

Motivation

No response

Other

No response

@will-lynas will-lynas added the enhancement New feature or request label Sep 14, 2024
@aarnphm
Copy link
Collaborator

aarnphm commented Sep 14, 2024

This is syntatic diff you are suggesting. I think that in the context of code it is better to dump the whole thing.

What we can do is to have a semantic diff support, but seems like too much work atm :))

@will-lynas
Copy link
Contributor Author

Can I make a PR to add it as an option? Just find lines that are the same in both sections and delete them?

@will-lynas
Copy link
Contributor Author

Maybe just stripping duplicates off the ends of the block to avoid turning one block into multiple

@will-lynas
Copy link
Contributor Author

I've had a go at making it. Seems to work from my testing

CREATE TABLE serbian_scores (
    id INTEGER PRIMARY KEY AUTOINCREMENT,
    user_id INTEGER,
    test_id INTEGER,
    FOREIGN KEY (user_id) REFERENCES users(id)
<<<<<<< HEAD
    ON DELETE CASCADE
=======
            ON DELETE CASCADE,
        FOREIGN KEY (test_id) REFERENCES serbian_tests(id)
            ON DELETE CASCADE
>>>>>>> Snippet
);

@aarnphm
Copy link
Collaborator

aarnphm commented Sep 15, 2024

The indentation doesn't seem correct?

@will-lynas
Copy link
Contributor Author

Yeah. Something is defo wrong. I'll investigate and update in the PR

@reaink
Copy link

reaink commented Sep 24, 2024

‌‌Perhaps it's better to have the smallest replacement when returning in the llm uplift prompt?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants