Delete empty untitled chat on navigate-away from ChatView

Previously the empty-conversation cleanup only fired when switching
between chats (convId watcher). Navigating to /notes, /tasks, etc.
left orphaned untitled empty conversations. onUnmounted now runs the
same check, deleting the current conversation if message_count === 0.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-10 18:02:57 -04:00
parent 16220c57a0
commit 3ef0e9f2c5
+7
View File
@@ -476,6 +476,13 @@ function onGlobalKeydown(e: KeyboardEvent) {
onUnmounted(() => {
document.removeEventListener("keydown", onGlobalKeydown);
// Clean up empty conversation when navigating away from the chat view entirely
if (prevConvId) {
const conv = store.conversations.find((c) => c.id === prevConvId);
if (conv && conv.message_count === 0) {
store.deleteConversation(prevConvId);
}
}
});
</script>