Self-hosted AI workspace.
Python
Sessions: confirm chat delete actions
ooovenenoso3025f2ebe764
diff --git a/static/js/documentLibrary.js b/static/js/documentLibrary.jsindex d7b98614d..6d86a8ec3 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.jsindex 05b150e0f..24ac99230 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 immediatelyconst 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' });