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:
@@ -247,6 +247,22 @@
|
||||
.history-item:hover {
|
||||
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 {
|
||||
font-weight: 700;
|
||||
color: var(--text-secondary);
|
||||
@@ -360,6 +376,9 @@
|
||||
<span class="history-excerpt" x-text="getExcerpt(item.messages)"></span>
|
||||
</div>
|
||||
</template>
|
||||
<template x-if="historyItems.length > 0">
|
||||
<button class="clear-history-btn" @click="clearHistory">Clear</button>
|
||||
</template>
|
||||
</div>
|
||||
</details>
|
||||
</div>
|
||||
@@ -526,6 +545,12 @@
|
||||
this.$refs.historyPanel.removeAttribute("open");
|
||||
this.scrollToBottom();
|
||||
},
|
||||
|
||||
clearHistory() {
|
||||
if (!confirm("Clear all saved conversations?")) return;
|
||||
this.historyItems = clearAllHistory();
|
||||
this.$refs.historyPanel.removeAttribute("open");
|
||||
},
|
||||
});
|
||||
|
||||
function attachCopyButtons($el) {
|
||||
@@ -767,6 +792,11 @@
|
||||
return all[today];
|
||||
};
|
||||
|
||||
const clearAllHistory = () => {
|
||||
localStorage.removeItem(STORAGE_KEY);
|
||||
return [];
|
||||
};
|
||||
|
||||
document.addEventListener("alpine:init", () => {
|
||||
Alpine.data("chatApp", chatApp);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user