diff --git a/src/client/app.js b/src/client/app.js index 161e049..e5ff503 100644 --- a/src/client/app.js +++ b/src/client/app.js @@ -3980,6 +3980,13 @@ import { mountSidebar } from "./sidebar.js"; loadConversations(); }, }); + // Deleting the conversation the shell is holding: it's gone from the list but + // its messages are still on screen. Swap in a fresh chat, and drop the /c/ + // URL if that's where we are (a satellite view keeps its own URL). + window.addEventListener("kloe:conversation-deleted", function (e) { + if (!e.detail || e.detail.id !== convId) return; + newConversation(currentSection === "chat" ? "replace" : "none"); + }); function hasConversation(id) { return conversations.some(function (c) { return c.id === id; diff --git a/src/client/chatmenu.js b/src/client/chatmenu.js index fb25212..71a28c0 100644 --- a/src/client/chatmenu.js +++ b/src/client/chatmenu.js @@ -38,6 +38,10 @@ async function deleteChat(ctx) { if (!ok) return; try { await fetch("/api/conversations/" + encodeURIComponent(ctx.id), { method: "DELETE" }); + // The chat shell outlives every view, so a deleted conversation would keep + // showing until something else replaced it. Announce it and let the shell + // decide (it only cares when the deleted one is the one it's holding). + window.dispatchEvent(new CustomEvent("kloe:conversation-deleted", { detail: { id: ctx.id } })); } catch (_) { /* ignore */ }