From 68f35d45916b3044901aa3aa0e883e7faa3cea2c Mon Sep 17 00:00:00 2001 From: Dave Date: Sat, 27 Dec 2025 17:33:03 +0000 Subject: [PATCH] Fix New Session bug: use async Tauri dialog instead of window.confirm - Tauri overrides window.confirm to return Promise, not boolean - Changed clearSession to async function using Tauri's ask() dialog - Now properly waits for user confirmation before clearing state - Removed debug logging - All quality checks passing --- src/components/Chat.tsx | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/src/components/Chat.tsx b/src/components/Chat.tsx index c0c670a..d6e08b7 100644 --- a/src/components/Chat.tsx +++ b/src/components/Chat.tsx @@ -1,5 +1,6 @@ import { invoke } from "@tauri-apps/api/core"; import { listen } from "@tauri-apps/api/event"; +import { ask } from "@tauri-apps/plugin-dialog"; import { useEffect, useRef, useState } from "react"; import Markdown from "react-markdown"; import { Prism as SyntaxHighlighter } from "react-syntax-highlighter"; @@ -163,25 +164,21 @@ export function Chat({ projectPath, onCloseProject }: ChatProps) { } }; - const clearSession = () => { - // Store current state in case we need to debug - console.log("clearSession called, messages count:", messages.length); - - const confirmed = window.confirm( + const clearSession = async () => { + const confirmed = await ask( "Are you sure? This will clear all messages and reset the conversation context.", + { + title: "New Session", + kind: "warning", + }, ); - console.log("User confirmed:", confirmed); - - if (confirmed === true) { - console.log("Clearing session..."); + if (confirmed) { setMessages([]); setStreamingContent(""); setLoading(false); // TODO: Add backend call to clear context when implemented // invoke("clear_session").catch(console.error); - } else { - console.log("User cancelled, keeping messages"); } };