feat: implement undo button to revert file changes and remove message from history
- Modified handleUndoMessage in server.js to remove the undone message from session history - Added persistState() call to save the updated session state after undo - Message is now removed from UI when undo is completed - Works for opencode/build messages that are completed, errored, or cancelled
This commit is contained in:
@@ -15920,6 +15920,16 @@ async function handleUndoMessage(req, res, sessionId, messageId, userId) {
|
||||
log('Cleared todos from undone message', { sessionId, messageId, clearedCount: todoCount });
|
||||
}
|
||||
|
||||
// Remove the message from session history
|
||||
const messageIndex = session.messages.findIndex(m => m.id === messageId);
|
||||
if (messageIndex !== -1) {
|
||||
session.messages.splice(messageIndex, 1);
|
||||
log('Removed message from history', { sessionId, messageId, remainingMessages: session.messages.length });
|
||||
}
|
||||
|
||||
// Persist the updated state
|
||||
await persistState();
|
||||
|
||||
log('Undo command completed', { sessionId, messageId });
|
||||
sendJson(res, 200, { ok: true, message: 'Undo command sent successfully' });
|
||||
} catch (error) {
|
||||
|
||||
Reference in New Issue
Block a user