From b5747e3979f34c691afc4d4efa37828203c44ce2 Mon Sep 17 00:00:00 2001 From: tanmayraut45 Date: Tue, 2 Jun 2026 17:00:16 +0530 Subject: [PATCH] Sessions: ignore list keydown while typing MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The list keyboard handler (_onSessionListKeydown) treats Backspace and Delete as "delete the focused session". When the user double-clicks a chat to rename it, an is mounted inside the .list-item row. Backspace on the input bubbles up to the list container, the handler walks closest('.list-item[data-session-id]') from e.target, finds the parent row and DELETEs the session via the API — so a single typo correction nukes the whole conversation. Bail out at the top of the handler when e.target is an INPUT, TEXTAREA, or contentEditable element. Arrow / Enter / Delete navigation still works for rows themselves (the row is the focused element then, not the input). Mirrors the guard pattern already used in ui.js, notes.js, tasks.js, calendar.js, emailLibrary.js and galleryEditor.js. Closes #1007. --- static/js/sessions.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/static/js/sessions.js b/static/js/sessions.js index a816d5c..05b150e 100644 --- a/static/js/sessions.js +++ b/static/js/sessions.js @@ -1872,6 +1872,11 @@ 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; + const item = e.target.closest('.list-item[data-session-id]'); if (!item) return;