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:
@@ -2153,7 +2153,13 @@ function renderMessages(session) {
|
||||
});
|
||||
|
||||
// Restore loading indicator visibility after all messages are rendered
|
||||
if (loadingIndicator) {
|
||||
// Only restore if the latest message is not done or error
|
||||
const latestMsg = session.messages?.length > 0
|
||||
? [...session.messages].reverse().find(msg => !msg.isBackgroundContinuation)
|
||||
: null;
|
||||
const shouldShowLoading = latestMsg && latestMsg.status !== 'done' && latestMsg.status !== 'error' && latestMsg.status !== 'cancelled';
|
||||
|
||||
if (loadingIndicator && shouldShowLoading) {
|
||||
loadingIndicator.style.visibility = '';
|
||||
loadingIndicator.style.position = '';
|
||||
// Ensure loading indicator is at the end of chat area
|
||||
@@ -2163,6 +2169,9 @@ function renderMessages(session) {
|
||||
// Move to end to ensure it's after all messages
|
||||
el.chatArea.appendChild(loadingIndicator);
|
||||
}
|
||||
} else if (loadingIndicator && !shouldShowLoading) {
|
||||
// Remove the loading indicator if message is done/error
|
||||
loadingIndicator.remove();
|
||||
}
|
||||
|
||||
scrollChatToBottom();
|
||||
@@ -3040,6 +3049,18 @@ function streamMessage(sessionId, messageId) {
|
||||
message.status = 'running';
|
||||
|
||||
// Keep loading indicator spinning during streaming - don't hide on first chunk
|
||||
// Update loading indicator text to show we're now building
|
||||
const loadingIndicator = document.getElementById('loading-indicator');
|
||||
if (loadingIndicator) {
|
||||
const statusText = loadingIndicator.querySelector('.loading-status-text');
|
||||
const detailText = loadingIndicator.querySelector('.loading-detail-text');
|
||||
if (statusText && statusText.textContent === 'Starting build process') {
|
||||
statusText.textContent = 'Building plugin';
|
||||
}
|
||||
if (detailText) {
|
||||
detailText.textContent = 'Generating code and files...';
|
||||
}
|
||||
}
|
||||
|
||||
// Re-render messages to show new content immediately
|
||||
renderMessages(session);
|
||||
|
||||
Reference in New Issue
Block a user