Clean up post-merge delete handler artifacts

This commit is contained in:
Tremendoussly
2026-04-14 17:08:42 +02:00
parent 19ebf1a834
commit 2ee081a619
-71
View File
@@ -770,77 +770,6 @@ export function onMessageDeleted() {
saveChatData(); saveChatData();
} }
/**
* Event handler for when a message is deleted.
* Re-syncs lastGeneratedData, committedTrackerData, and all UI panels to the
* new last assistant message's active swipe — or clears everything if no
* assistant messages remain.
*/
/* Removed during merge resolution.
return;
// console.log('[RPG Companion] 🗑️ EVENT: onMessageDeleted');
// Invalidate any pending or in-flight separate-mode generation so
// its result is not applied to the (now-changed) chat tail.
incrementSeparateGenerationId();
const currentChat = getContext().chat;
// Walk backward to find the new last assistant message.
let lastAssistantIndex = -1;
for (let i = currentChat.length - 1; i >= 0; i--) {
if (!currentChat[i].is_user && !currentChat[i].is_system) {
lastAssistantIndex = i;
break;
}
}
if (lastAssistantIndex === -1) {
// No assistant messages remain — clear all state.
lastGeneratedData.userStats = null;
lastGeneratedData.infoBox = null;
lastGeneratedData.characterThoughts = null;
committedTrackerData.userStats = null;
committedTrackerData.infoBox = null;
committedTrackerData.characterThoughts = null;
// console.log('[RPG Companion] 🗑️ No assistant messages remain — cleared all tracker state.');
} else {
// Restore display state from the new tail message's active swipe.
// If the message has no swipe data yet, null the fields so we
// don't show stale data from the deleted message.
const hadSwipeData = syncLastGeneratedDataFromSwipeStore(currentChat);
if (!hadSwipeData) {
lastGeneratedData.userStats = null;
lastGeneratedData.infoBox = null;
lastGeneratedData.characterThoughts = null;
committedTrackerData.userStats = null;
committedTrackerData.infoBox = null;
committedTrackerData.characterThoughts = null;
// console.log('[RPG Companion] 🗑️ No swipe data for last assistant message — cleared display state.');
}
// Commit context from the message *before* the new tail assistant message,
// so any subsequent generation uses the correct N-1 world state.
commitTrackerDataFromPriorMessage(lastAssistantIndex);
}
// Re-render all panels.
renderUserStats();
renderInfoBox();
renderThoughts();
renderInventory();
renderQuests();
renderMusicPlayer($musicPlayerContainer[0]);
// Update widget strips.
updateFabWidgets();
updateStripWidgets();
// Persist updated state.
saveChatData();
*/
/** /**
* Update the persona avatar image when user switches personas * Update the persona avatar image when user switches personas
*/ */