voideditor / void

https://voideditor.com
MIT License
8.01k stars 396 forks source link

Apply changes lazily #9

Closed andrewpareles closed 1 week ago

andrewpareles commented 1 month ago

Right now, the "Apply" button always takes whatever is in the box (see right side) and writes it to the whole file:

image

This means the LLM needs to rewrite the whole file every time it suggests an edit. It's not able to write out partial changes like this:

// ... rest of file 

let x = 5

// ... rest of file 

We should allow the AI to output partial changes as above. When the user clicks "Apply", the AI should rewrite the file using the partial changes. We should also add a text decoration that shows the progress of the rewrite. Once the user clicks "Apply" the whole file should be gray, and as the LLM writes, the unwritten part should remain gray.

image After we make this change, we should remove this part of the prompt, and tell the AI to output comments like // ... rest of file instead.

IDLe-Engineering commented 3 weeks ago

I will give it a shot

I understand the basic principles tho, but there's a lot of things that need to be considered. E.g. even the functionality as is, behaves strange. When the LLM changes a file and reports the entire content, and i change something manually in the file, it would still apply code lense with Accept/Reject Options, even if added manually...

Also when telling the LLM to only modify the appropriate lines, I can't tell where to put it. Not in complex files where there could be multiple occurences of the original code. Also the LLM sometimes "counts" wrong when I tell it to also report the (beginning) line number of the change - so that's unreliable

Also I can't just intercept generated code and compare it to the editor and only print the change, bc I am not sure whether its related to the opened file or just anything you would ask the LLM to generate.

we need a workshop for that 🤣

mathewpareles commented 3 weeks ago

When the LLM changes a file and reports the entire content, and i change something manually in the file, it would still apply code lense with Accept/Reject Options, even if added manually...

This is expected behavior. When the AI makes a change to the file, we diff the entire file.

Also when telling the LLM to only modify the appropriate lines, I can't tell where to put it. Not in complex files where there could be multiple occurences of the original code. Also the LLM sometimes "counts" wrong when I tell it to also report the (beginning) line number of the change - so that's unreliable

See https://aider.chat/docs/unified-diffs.html for information on how to approach this. Aider and others have found that including line numbers decreases performance.

I am currently working on this issue, and should have it pushed shortly.

andrewpareles commented 1 week ago

Fixed by #125!