feat(chat): Add Clear button to history popup

Lets you wipe all saved conversations from localStorage (not just
today's) after a confirmation prompt.
This commit is contained in:
2026-07-28 10:13:00 +02:00
parent eee4addd86
commit 3b4fc7159e
+30
View File
@@ -247,6 +247,22 @@
.history-item:hover { .history-item:hover {
background: var(--hover-bg); background: var(--hover-bg);
} }
.clear-history-btn {
display: block;
width: 100%;
margin-top: 0.5rem;
padding: 0.3rem;
background: var(--bg-secondary);
color: var(--text-primary);
border: 1px solid var(--border-color);
border-radius: 0.3rem;
font-size: 0.9em;
cursor: pointer;
transition: background-color 0.2s;
}
.clear-history-btn:hover {
background: var(--hover-bg);
}
.history-time { .history-time {
font-weight: 700; font-weight: 700;
color: var(--text-secondary); color: var(--text-secondary);
@@ -360,6 +376,9 @@
<span class="history-excerpt" x-text="getExcerpt(item.messages)"></span> <span class="history-excerpt" x-text="getExcerpt(item.messages)"></span>
</div> </div>
</template> </template>
<template x-if="historyItems.length > 0">
<button class="clear-history-btn" @click="clearHistory">Clear</button>
</template>
</div> </div>
</details> </details>
</div> </div>
@@ -526,6 +545,12 @@
this.$refs.historyPanel.removeAttribute("open"); this.$refs.historyPanel.removeAttribute("open");
this.scrollToBottom(); this.scrollToBottom();
}, },
clearHistory() {
if (!confirm("Clear all saved conversations?")) return;
this.historyItems = clearAllHistory();
this.$refs.historyPanel.removeAttribute("open");
},
}); });
function attachCopyButtons($el) { function attachCopyButtons($el) {
@@ -767,6 +792,11 @@
return all[today]; return all[today];
}; };
const clearAllHistory = () => {
localStorage.removeItem(STORAGE_KEY);
return [];
};
document.addEventListener("alpine:init", () => { document.addEventListener("alpine:init", () => {
Alpine.data("chatApp", chatApp); Alpine.data("chatApp", chatApp);
}); });