Skip to content

Commit

Permalink
delete convo history and add loading state
Browse files Browse the repository at this point in the history
  • Loading branch information
lassejaco committed Jan 8, 2025
1 parent 0dc4de1 commit 327c20f
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
3 changes: 3 additions & 0 deletions lib/assets/icons/trash.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 20 additions & 1 deletion lib/components/ai/overlay.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import {
threadIDState,
messagesState,
} from "./state"; // Adjust the import path
import TrashIcon from "lib/assets/icons/trash.svg";
import cn from "classnames";

const Trigger = ({ className }: { className?: string }) => {
Expand Down Expand Up @@ -203,6 +204,17 @@ const DevaBot = ({
setThreadHistory(threadHistory);
};

const deleteThreadHistory = () => {
if (
window.confirm(
"Are you sure you want to delete all conversation history? This is irreversible."
)
) {
localStorage.removeItem("devabot_threads");
setThreadHistory([]);
}
};

React.useEffect(() => {
// Load conversation history on mount
syncThreadHistory();
Expand Down Expand Up @@ -296,6 +308,8 @@ const DevaBot = ({
? `http://localhost:4000/devabot/threads/${threadID}`
: `https://api.devcon.org/devabot/threads/${threadID}`;

setExecutingQuery(true);

fetch(url, {
method: "GET",
headers: {
Expand Down Expand Up @@ -936,7 +950,12 @@ const DevaBot = ({
<SquareSparkles className="mr-1" />
Conversation History
</div>
{/* <div className="shrink-0">Delete All</div> */}
<div
className="shrink-0 cursor-pointer"
onClick={deleteThreadHistory}
>
<TrashIcon />
</div>
</div>
{threadHistory?.map(
(thread: any, index: number) => (
Expand Down

0 comments on commit 327c20f

Please sign in to comment.