Sessions: confirm chat delete actions
- confirm sidebar/session-list chat deletes - confirm library chat menu deletes - confirm archived chat permanent deletes
This commit is contained in:
@@ -2059,6 +2059,7 @@ let _libraryArchivedView = false; // Documents tab showing archived docs?
|
|||||||
{ label: 'Copy', action: () => _copyChatById(s.id) },
|
{ 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: 'Archive', action: async () => { await fetch(API_BASE + '/api/session/' + s.id + '/archive', { method: 'POST', headers: {'Content-Type':'application/json'} }); _renderLibChats(); } },
|
||||||
{ label: 'Delete', action: async () => {
|
{ 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' });
|
await fetch(API_BASE + '/api/session/' + s.id, { method: 'DELETE' });
|
||||||
card.style.maxHeight = `${Math.max(card.getBoundingClientRect().height, card.scrollHeight)}px`;
|
card.style.maxHeight = `${Math.max(card.getBoundingClientRect().height, card.scrollHeight)}px`;
|
||||||
card.classList.add('memory-tidy-removing');
|
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: 'Open', action: () => { if (window.sessionModule) window.sessionModule.selectSession(s.id); } },
|
||||||
{ label: 'Copy', action: () => _copyChatById(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: '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: () => {
|
], { onSelect: () => {
|
||||||
_arcSelectMode = true;
|
_arcSelectMode = true;
|
||||||
_arcSelected.add('chats:' + s.id);
|
_arcSelected.add('chats:' + s.id);
|
||||||
|
|||||||
@@ -616,6 +616,10 @@ function createSessionItem(s) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
dropdown.style.display = 'none';
|
dropdown.style.display = 'none';
|
||||||
|
if (!await uiModule.styledConfirm('Delete this session?', { confirmText: 'Delete', danger: true })) {
|
||||||
|
_forceSidebarOpen();
|
||||||
|
return;
|
||||||
|
}
|
||||||
// Optimistic: remove from UI immediately
|
// Optimistic: remove from UI immediately
|
||||||
const sessionEl = document.querySelector(`.list-item[data-session-id="${s.id}"]`);
|
const sessionEl = document.querySelector(`.list-item[data-session-id="${s.id}"]`);
|
||||||
if (sessionEl) sessionEl.remove();
|
if (sessionEl) sessionEl.remove();
|
||||||
@@ -1871,12 +1875,7 @@ export function setCurrentSessionId(id) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Session list keyboard navigation: arrows to move, Delete to delete
|
// Session list keyboard navigation: arrows to move, Delete to delete
|
||||||
function _onSessionListKeydown(e) {
|
async 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;
|
|
||||||
|
|
||||||
const item = e.target.closest('.list-item[data-session-id]');
|
const item = e.target.closest('.list-item[data-session-id]');
|
||||||
if (!item) return;
|
if (!item) return;
|
||||||
|
|
||||||
@@ -1904,6 +1903,8 @@ function _onSessionListKeydown(e) {
|
|||||||
uiModule.showToast('Unfavorite before deleting');
|
uiModule.showToast('Unfavorite before deleting');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
const ok = await uiModule.styledConfirm('Delete this session?', { confirmText: 'Delete', danger: true });
|
||||||
|
if (!ok) return;
|
||||||
_sessionListFocused = true;
|
_sessionListFocused = true;
|
||||||
(async () => {
|
(async () => {
|
||||||
await fetch(`${API_BASE}/api/session/${s.id}`, { method: 'DELETE' });
|
await fetch(`${API_BASE}/api/session/${s.id}`, { method: 'DELETE' });
|
||||||
|
|||||||
Reference in New Issue
Block a user