-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Prompt undo and redo command for --no-auto-commit mode #1093
base: main
Are you sure you want to change the base?
Conversation
from .main import main ImportError: attempted relative import with no known parent package if not done like this
I'm going to add a /redo command |
Hi, @Aeraxys I tried your implementation, and it works great! However, when using the /undo command, changes made to existing files are successfully reverted, but newly created files by Aider during implementation are not removed. Is there any reason or way to fix this issue? |
Hmm, I have actually thought of this and fixed it, I'm gonna check if I maybe have forgotten to push it. Thanks for notifying me! Okay so I checked, and no I haven't forgotten to push. It should work, according to line 389 to 401 in commands.py:
This should delete files if they were created by aider during the last prompt. It works for me at least. |
I now realize the /redo command doesn't restore files /undo has deleted. I'm gonna fix that real quick. |
I'm not sure why it's not working for me, but I'll validate it again. However, when I manually delete the file created by Aider and use the /redo command, it successfully recreates the file with the content that was applied earlier. |
Hmm yeah not sure what it could be. I'm running on a Macbook and it works fine |
So here is my implementation of my suggestion in issue #1018.
It's probably not perfect, but it works for me. And since there seemed to be some interest, I thought I'd make a PR.
When the --no-auto-commit flag is set, the /undo command becomes what I described in #1018. It reverts all edits done by the last prompt, resets the chat history to what it was before the last prompt was issued, and deletes all files and folders created by aider during the last prompt. This works by popping off a stack that saves states every prompt, this way the command can be issued multiple times to undo prompts in the order they were issued.
The reason I decided to just replace the /undo command is because in --no-auto-commit mode, the current /undo command doesn't do anything useful. What I have implemented here is what I would expect /undo to do in --no-auto-commit mode.
For clarification, when --no-auto-commit is not set, /undo is unchanged.
I have now also added a /redo command, which accompanies this /undo command in --no-auto-commit mode, and effectively reverses /undo.
Please let me know if you spot any issues or ways to improve!