Let the output "x" delete work when no model/session exists (#1431)
deleteMessage() bailed at `if (!sessionId) return;`, so the "x" on an output shown before a model/API was selected did nothing — there's no session yet (issue #1428). The session id is only needed for the server-side delete; without one (or with no persisted message ids) we now fall through to removing the DOM, so the "x" always at least dismisses the bubble. Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -4037,8 +4037,11 @@ import createResearchSynapse from './researchSynapse.js';
|
||||
const clickedIndex = allMsgs.indexOf(msgElement);
|
||||
if (clickedIndex < 0) return;
|
||||
|
||||
// No early-out on a missing session: an output shown before any model was
|
||||
// selected (issue #1428) has no session/persisted rows, but its "x" must
|
||||
// still remove it. We only need the session id for the server-side delete
|
||||
// below; without one we fall back to removing the DOM.
|
||||
const sessionId = sessionModule.getCurrentSessionId();
|
||||
if (!sessionId) return;
|
||||
|
||||
const clickedIsUser = msgElement.classList.contains('msg-user');
|
||||
|
||||
@@ -4114,8 +4117,10 @@ import createResearchSynapse from './researchSynapse.js';
|
||||
}
|
||||
}
|
||||
|
||||
if (!msgIds.length) {
|
||||
// Fallback: just remove DOM elements if no DB IDs available
|
||||
if (!msgIds.length || !sessionId) {
|
||||
// No persisted rows to delete (no DB IDs, or no session at all — e.g. an
|
||||
// error output shown before a model was selected, #1428). Just remove the
|
||||
// DOM so the "x" works regardless.
|
||||
domToRemove.forEach(el => el.remove());
|
||||
if (uiModule) uiModule.showToast('Message deleted');
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user