Support assistant: fix the delete-chat confirmation opening twice (panel click handler was added again on every reload)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-13 21:50:55 +02:00
co-authored by Claude Opus 5.5
parent 51bd769d6e
commit 6f52873b69
+3 -2
View File
@@ -1887,7 +1887,8 @@ function initAi() {
AI.chat = aiChats().find((c) => c.id === e.target.value) || null; AI.chat = aiChats().find((c) => c.id === e.target.value) || null;
aiRender(); aiRender();
}; };
p.addEventListener('click', async (e) => { // onclick statt addEventListener: initAi() läuft bei jedem reload(), sonst doppelte Handler (z. B. zwei Löschdialoge)
p.onclick = async (e) => {
const a = e.target.closest('[data-ai]')?.dataset.ai; const a = e.target.closest('[data-ai]')?.dataset.ai;
if (a === 'new') { if (AI.busy) api.call('ai:stop', AI.chat?.id); AI.chat = null; aiRender(); ta.focus(); } if (a === 'new') { if (AI.busy) api.call('ai:stop', AI.chat?.id); AI.chat = null; aiRender(); ta.focus(); }
if (a === 'del' && AI.chat && await confirmBox(T('Delete chat?'), `“${AI.chat.title}”`, T('Delete'))) { if (a === 'del' && AI.chat && await confirmBox(T('Delete chat?'), `“${AI.chat.title}”`, T('Delete'))) {
@@ -1907,7 +1908,7 @@ function initAi() {
// Nur einfügen, nicht ausführen – der Nutzer prüft und bestätigt mit Enter // Nur einfügen, nicht ausführen – der Nutzer prüft und bestätigt mit Enter
if (b.dataset.cmd === 'paste' && t?.kind === 'ssh') { t.term.paste(code); t.term.focus(); } if (b.dataset.cmd === 'paste' && t?.kind === 'ssh') { t.term.paste(code); t.term.focus(); }
else { api.call('clipboard:write', code); toast(b.dataset.cmd === 'paste' ? T('Copied – no terminal tab is active') : T('Copied')); } else { api.call('clipboard:write', code); toast(b.dataset.cmd === 'paste' ? T('Copied – no terminal tab is active') : T('Copied')); }
}); };
if ($('#aiPanel').classList.contains('open')) aiRender(); if ($('#aiPanel').classList.contains('open')) aiRender();
if (AI.init) return; if (AI.init) return;
AI.init = true; AI.init = true;