paul-gauthier / aider

aider is AI pair programming in your terminal
https://aider.chat/
Apache License 2.0
18.56k stars 1.71k forks source link

/redo would be great as I changed my mind about /undo #1427

Open paul-hammant opened 1 week ago

paul-hammant commented 1 week ago

I have "live page reload" going and sometimes I regret my /undo decision :-O

lockmeister commented 1 week ago

I find more fine-grained control useful. I keep VSCode open at the same time I'm using aider. I use the diff view in VSCode's version control tab. For aider, I actually use the --no-auto-commits flag, and then manually commit each time.

However, you could keep the auto commit on and if you regret anything, you could git checkout HEAD~1 --soft This moves your branch pointer back one commit (to HEAD~1) but leaves all the changes from that commit in your working directory and staging area as uncommitted changes. This allows you to make adjustments or re-commit the changes as needed without losing any work.

I prefer using full version control tools in this way because I can pick and choose what I want to keep, and easily make manual edits at the same time. VSCode has handy Stage Block/Revert Block buttons that you can use for this. image

If you did it the way I'm suggesting, undo could be implemented with git stash Step 1: aider auto commits the change Step 2: if you don't like it you git checkout HEAD~1 --soft - this will keep the uncommitted changes in your workspace, you can pick and choose Step 3: for a full "undo", git stash will remove the changes from your workspace Step 4: for "redo", git stash apply will bring the changes back, ready for you to commit

I think this is better than a simple undo/redo, because often I find I want to pick and choose what I want to keep.

For git, I found these resources handy: https://learngitbranching.js.org/ https://ndpsoftware.com/git-cheatsheet.html#loc=index

boukeversteegh commented 3 days ago

redo could be implemented without keeping the commit or relying on git, if aider could keep the last iteration(s) in memory, and just reapply them