In a text editor, undo is easy. You typed something and now you haven't.
In an AI coding chat, it's a harder question. The agent wrote some messages and changed some files, and you might have changed some of those too. So what does going back even mean?
I had to answer that for the Chat Thread block in HextaUI, where checkpoints became restore points. Here's a working version with made-up content. Hover Restore, then press it.
Show what goes before it goes
The riskiest thing about undo in a chat is that you can't see what it'll affect. So hovering or focusing Restore shows it right away: everything that would be removed fades, and nothing's happened yet.
Then the confirmation names the cost in actual numbers.
Removes 4 messages, and reverts 3 files.
A generic "Are you sure?" gives you nothing to decide with. A count and a list of files does, because you can look down and notice that one of those files has work you want to keep.
Conversation and code are separate things
I think this was the most important decision here. They're two different requests, so you get two options.
You usually want to try again
Nobody restores a chat because they enjoy going backwards. You do it because you want another go at that message.
So your message goes back in the composer, ready to edit. It's a very small touch, and it turns "undo" into "try that differently", which is what you came for.
- Restore
- Your message is back in the composer
- Change a few words
- Send
Undo the undo
Restoring is itself a big action, so it can't be the one thing you can't take back. After it runs, a toast tells you what happened, with an Undo button.
It's easy to think that's overkill. But a confirmation asks you to be sure ahead of time, and undo lets you find out afterwards. People are much better at the second one.
The rules I'd keep
Chat interfaces are new enough that there aren't many settled patterns, so here's what I'd reuse from this:
- Preview the effect before you ask.
- Use real numbers in the confirmation.
- Separate what the AI said from what the AI did.
- Bring back the person's words.
- Make the undo undoable.
And there's the rule behind all of them. An agent acting on your behalf is only as trustworthy as your ability to take it back. The more that AI does for us, the more the back button is doing the real design work.