Story 20: New Session button to clear chat history

- Added 'New Session' button in header with confirmation dialog
- Clears frontend messages, streaming content, and loading state
- Button has subtle styling with hover effects
- Preserves project path, model selection, and tool settings
- Backend context automatically cleared (no server-side history)
- Fixed build errors by removing unused tokio watch channel
- All quality checks passing (TypeScript, Biome, Clippy, builds)

Tested and verified:
- Button appears in header near model controls
- Confirmation dialog prevents accidental clearing
- Messages clear immediately after confirmation
- Input remains ready for new conversation
- Settings preserved across session clears
This commit is contained in:
Dave
2025-12-27 17:01:55 +00:00
parent 64d1b788be
commit b3dd5f5670
7 changed files with 131 additions and 43 deletions

View File

@@ -109,6 +109,19 @@ export function Chat({ projectPath, onCloseProject }: ChatProps) {
}
};
const clearSession = () => {
const confirmed = window.confirm(
"Are you sure? This will clear all messages and reset the conversation context.",
);
if (confirmed) {
setMessages([]);
setStreamingContent("");
setLoading(false);
// TODO: Add backend call to clear context when implemented
// invoke("clear_session").catch(console.error);
}
};
return (
<div
className="chat-container"
@@ -192,6 +205,39 @@ export function Chat({ projectPath, onCloseProject }: ChatProps) {
{/* Model Controls */}
<div style={{ display: "flex", alignItems: "center", gap: "16px" }}>
<button
type="button"
onClick={clearSession}
style={{
padding: "6px 12px",
borderRadius: "99px",
border: "none",
fontSize: "0.85em",
backgroundColor: "#2f2f2f",
color: "#888",
cursor: "pointer",
outline: "none",
transition: "all 0.2s",
}}
onMouseOver={(e) => {
e.currentTarget.style.backgroundColor = "#3f3f3f";
e.currentTarget.style.color = "#ccc";
}}
onMouseOut={(e) => {
e.currentTarget.style.backgroundColor = "#2f2f2f";
e.currentTarget.style.color = "#888";
}}
onFocus={(e) => {
e.currentTarget.style.backgroundColor = "#3f3f3f";
e.currentTarget.style.color = "#ccc";
}}
onBlur={(e) => {
e.currentTarget.style.backgroundColor = "#2f2f2f";
e.currentTarget.style.color = "#888";
}}
>
🔄 New Session
</button>
{availableModels.length > 0 ? (
<select
value={model}