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:
@@ -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>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user