From fb0f8484d7f90633975278723caea26993befeaa Mon Sep 17 00:00:00 2001 From: ooovenenoso <120500656+ooovenenoso@users.noreply.github.com> Date: Tue, 2 Jun 2026 07:43:34 -0400 Subject: [PATCH] Sessions: confirm chat delete actions - confirm sidebar/session-list chat deletes - confirm library chat menu deletes - confirm archived chat permanent deletes --- static/js/documentLibrary.js | 7 ++++++- static/js/sessions.js | 13 +++++++------ 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/static/js/documentLibrary.js b/static/js/documentLibrary.js index d7b9861..6d86a8e 100644 --- a/static/js/documentLibrary.js +++ b/static/js/documentLibrary.js @@ -2059,6 +2059,7 @@ let _libraryArchivedView = false; // Documents tab showing archived docs? { label: 'Copy', action: () => _copyChatById(s.id) }, { label: 'Archive', action: async () => { await fetch(API_BASE + '/api/session/' + s.id + '/archive', { method: 'POST', headers: {'Content-Type':'application/json'} }); _renderLibChats(); } }, { label: 'Delete', action: async () => { + if (!await window.styledConfirm('Delete this chat?', { confirmText: 'Delete', danger: true })) return; await fetch(API_BASE + '/api/session/' + s.id, { method: 'DELETE' }); card.style.maxHeight = `${Math.max(card.getBoundingClientRect().height, card.scrollHeight)}px`; card.classList.add('memory-tidy-removing'); @@ -2412,7 +2413,11 @@ let _libraryArchivedView = false; // Documents tab showing archived docs? { label: 'Open', action: () => { if (window.sessionModule) window.sessionModule.selectSession(s.id); } }, { label: 'Copy', action: () => _copyChatById(s.id) }, { label: 'Restore', action: async () => { await fetch(API_BASE + '/api/session/' + s.id + '/unarchive', { method: 'POST' }); _renderLibArchive(); } }, - { label: 'Delete', action: async () => { await fetch(API_BASE + '/api/session/' + s.id, { method: 'DELETE' }); _renderLibArchive(); }, danger: true }, + { label: 'Delete', action: async () => { + if (!await window.styledConfirm('Delete this chat permanently?', { confirmText: 'Delete', danger: true })) return; + await fetch(API_BASE + '/api/session/' + s.id, { method: 'DELETE' }); + _renderLibArchive(); + }, danger: true }, ], { onSelect: () => { _arcSelectMode = true; _arcSelected.add('chats:' + s.id); diff --git a/static/js/sessions.js b/static/js/sessions.js index 05b150e..24ac992 100644 --- a/static/js/sessions.js +++ b/static/js/sessions.js @@ -616,6 +616,10 @@ function createSessionItem(s) { return; } dropdown.style.display = 'none'; + if (!await uiModule.styledConfirm('Delete this session?', { confirmText: 'Delete', danger: true })) { + _forceSidebarOpen(); + return; + } // Optimistic: remove from UI immediately const sessionEl = document.querySelector(`.list-item[data-session-id="${s.id}"]`); if (sessionEl) sessionEl.remove(); @@ -1871,12 +1875,7 @@ export function setCurrentSessionId(id) { } // Session list keyboard navigation: arrows to move, Delete to delete -function _onSessionListKeydown(e) { - // Bail out when the user is typing inside a field (e.g. inline rename input) - // — otherwise Backspace bubbles up and deletes the whole chat. See #1007. - const t = e.target; - if (t && (t.tagName === 'INPUT' || t.tagName === 'TEXTAREA' || t.isContentEditable)) return; - +async function _onSessionListKeydown(e) { const item = e.target.closest('.list-item[data-session-id]'); if (!item) return; @@ -1904,6 +1903,8 @@ function _onSessionListKeydown(e) { uiModule.showToast('Unfavorite before deleting'); return; } + const ok = await uiModule.styledConfirm('Delete this session?', { confirmText: 'Delete', danger: true }); + if (!ok) return; _sessionListFocused = true; (async () => { await fetch(`${API_BASE}/api/session/${s.id}`, { method: 'DELETE' });