eca icon indicating copy to clipboard operation
eca copied to clipboard

Support `/undo` to rollback last sent chat message or side effects

Open ericdallo opened this issue 1 year ago • 17 comments

To upvote this issue, give it a thumbs up. See this list for the most upvoted issues.

  • we should support a way to rollback a message sent, fixing a chat history if something was sent wrong
  • undo side effects is a plus

ericdallo avatar Aug 10 '25 22:08 ericdallo

I can't imagine how to handle side effects universally, I would probably skip that. Or is there some tool that can do it?

For messages, Claude can display a list of messages and you can choose which one you want to return to (from the end) and everything that follows is deleted from the context. I'm thinking about whether it would make sense to select the appropriate message in the ECA client and after calling the !confirmed! action, delete everything that follows from the context.

zikajk avatar Aug 16 '25 19:08 zikajk

Cursor does that. Side effects like tools that run we can't fix it indeed but the chat messages and what sent to LLM we can make ir work since all chat messages are saved in memory, we can just drop the last one or something

ericdallo avatar Aug 16 '25 23:08 ericdallo

It would be great if there were a status or warning letting me know when I've filled up 90% of the available context. From there, I could run a custom or built-in command to summarize the conversation. After reviewing the summary, I'd clear the chat and continue.

At the moment, the models tend to read entire files, and I can exhaust the context in just three questions. This is the biggest problem for me and makes ECA very hard to use for searching the codebase and answering questions.

Being able to delete a few messages at a time would be an excellent alternative solution. This feature is especially essential when the context is full and you can no longer summarize the conversation. And maybe we can add /clear as a part of this ticket too?

zikajk avatar Aug 25 '25 13:08 zikajk

Interesting, I never faced these problems with context, really interested in the use case.

  • I think we can create a context size UX indeed, especially in usages chat content existing message.
  • And a /summarize or similar to ask LLM to summarize conversation and remove the history replaced with the output, adding a confirmal is more complex tho, but possible

ericdallo avatar Aug 25 '25 13:08 ericdallo

there is already options to reset the chat history via clients, but a command could work too

ericdallo avatar Aug 25 '25 13:08 ericdallo

I think we can create a context size UX indeed, especially in usages chat content existing message.

Would be amazing if we could recalculate this when we switch model.

And a /summarize or similar to ask LLM to summarize conversation and remove the history replaced with the output, adding a confirmal is more complex tho, but possible

For me, it would be best if the user could configure whether they want this to happen automatically (e.g., if only 3% of the context is left) or not. However, with the automatic approach, one problem comes to mind: it's possible that I could switch to a model with a much smaller context window, so this action should only be triggered when I try to send a message, not before. But I guess this is just a 'nice to have.' And it's not completely clear to me what you mean by 'confirmal'.

there is already options to reset the chat history via clients, but a command could work too

That's great! I missed that. This + being able to remove some old message so I can summarize would effectively solve the biggest problem for me.

I'll try to come up with a good example later of how you can quickly fill the context with some open-source repository

zikajk avatar Aug 25 '25 14:08 zikajk

Would be amazing if we could recalculate this when we switch model.

Yeah, not trivial, but would be nice

And it's not completely clear to me what you mean by 'confirmal'.

Yeah, I think the manual command is the first thing. I mean, confirm the summary before apply

ericdallo avatar Aug 25 '25 14:08 ericdallo

I have to say that I find /undo very restricting once you try out the history feature of claude code. Rather than treat the history as an undo stack which can only be popped, claude code lets you double-tap escape (I'm not sure if it has a slash command) and then shows you every interaction point so you can rewind to an arbitrary point in the past.

Ramblurr avatar Sep 30 '25 12:09 Ramblurr

@Ramblurr Now there is also /rewind which can undo code changes. But I haven't really tried to see how it does (especially when the code has been edited with non-native Claude tools).

zikajk avatar Sep 30 '25 16:09 zikajk

Interesting, I haven't used that yet. For me I am not worried about undoing side effects. That is a huge can of worms especially when mcp is involved. Using git errant changes can be easily reverted. But managing context is most of the game when using agents, so being able to revert to arbitrary earlier context states is very valuable. I often have to jump back several turns after realizing some branch has gone bad and I need to refine the intermediate prompt.

Btw if you haven't used the Google AI Studio UI, it is a great study in how to give the user all the knobs they need to tweak the entire context at any point while maintaining the conversational style.

Ramblurr avatar Sep 30 '25 17:09 Ramblurr

It would be a killer feature if you could undo code changes

Kaspazza avatar Oct 15 '25 14:10 Kaspazza

I couldn't agree more! One of the few features I really miss from opencode is /undo /redo with the ability to roll back code changes

Artawower avatar Oct 22 '25 20:10 Artawower

I think we should start with something simpler, because I don't know how we could know a MCP tool changed code, would be pretty hard to know and rollback that, how claude handles that? maybe it doesn't, but for eca tools, that may be valid and should not be that hard I believe

ericdallo avatar Oct 23 '25 13:10 ericdallo

For me it would be 100% satisfying with eca tools as I don't use anything else for modifying files.

Kaspazza avatar Oct 24 '25 08:10 Kaspazza

@ericdallo It doesn't. It works with the Claude tool only:

"Claude Code automatically tracks Claude’s file edits as you work, allowing you to quickly undo changes and rewind to previous states if anything gets off track." https://docs.claude.com/en/docs/claude-code/checkpointing

Maybe some invisible preToolCall hook that creates a snapshot of the file before eca_edit_file is called could be used for that. I think that it can't be patch-based, and it must snapshot the whole file because if there are manual changes in the file, it couldn't be really reversed anymore. But I can be wrong here 😅.

Checkpoints persist across sessions, so you can access them in resumed conversations. And they are deleted after X days (configurable)

It should support three modes:

  1. Roll back the conversation only, keeping the code changes
  2. Roll back the code changes only, but keep the conversation history
  3. Both (i.e., revert both the code and the conversation)

About UX: Would it make sense to place a cursor over a specific user message in chat and call one of those actions there? That would delete the selected and following message, tool calls, or both?

(There are also some MCPs doing something similar, e.g., https://skywork.ai/skypage/en/undo-mcp-server-ai-coding/1980818302869614592. These are probably more universal and aren't tied to a specific tool, but I have no experience with them...)

zikajk avatar Oct 25 '25 10:10 zikajk

Makes sense! I think we can start with adding a action icon or text (rollback to here) to user sent messages where we can exclude from in-memory chat history the following messages, that would be easy on server side, but we need to implement a new protocol message to remove messages from chat (chat/contentRemoved?), we just have the support to add messages chat/contentReceived

ericdallo avatar Oct 25 '25 13:10 ericdallo

Done! For now edits are not rolled back, feel free to open a new issue for that if you think it's a must.

For now only Emacs support that, I will work on vscode and intellij soon.

The way it works is:

  1. Now user should have a option to expand a user message and click on rollback
Image

When clicking on it, client sends a chat/rollback message with that user content-id message, server will clear the removed messages from its db and then produce a chat/clear to clear all chat messages followed by chat/contentReceived of the kept messages.

This was the best way I found for now to not require changing a lot clients and server.

The support for rollback ECA edits should be easier now, we would need to change only server side to undo the edits queued.

ericdallo avatar Nov 24 '25 22:11 ericdallo