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:
@@ -292,3 +292,49 @@ When the user starts typing in the input field while the model is generating a r
|
||||
}
|
||||
};
|
||||
```
|
||||
|
||||
## Session Management
|
||||
|
||||
### Problem
|
||||
Users may want to start a fresh conversation without restarting the application. Long conversations can become unwieldy, and users need a way to clear context for new tasks while keeping the same project open.
|
||||
|
||||
### Solution: New Session Button
|
||||
Provide a clear, accessible way for users to start a new session by clearing the chat history.
|
||||
|
||||
### Requirements
|
||||
|
||||
1. **Button Placement:** Located in the header area, near model controls
|
||||
2. **Visual Design:** Secondary/subtle styling to prevent accidental clicks
|
||||
3. **Confirmation Dialog:** Ask "Are you sure? This will clear all messages." before clearing
|
||||
4. **State Management:**
|
||||
- Clear `messages` state array
|
||||
- Clear `streamingContent` if any streaming is in progress
|
||||
- Preserve project path, model selection, and tool settings
|
||||
- Cancel any in-flight backend operations before clearing
|
||||
5. **User Feedback:** Immediate visual response (messages disappear)
|
||||
6. **Empty State:** Show a welcome message or empty state after clearing
|
||||
|
||||
### Implementation Notes
|
||||
|
||||
**Frontend:**
|
||||
- Add "New Session" button to header
|
||||
- Implement confirmation modal/dialog
|
||||
- Call `setMessages([])` after confirmation
|
||||
- Cancel any ongoing streaming/tool execution
|
||||
- Consider keyboard shortcut (e.g., Cmd/Ctrl+K)
|
||||
|
||||
**Backend:**
|
||||
- May need to cancel ongoing chat operations
|
||||
- Clear any server-side state if applicable
|
||||
- No persistent session history (sessions are ephemeral)
|
||||
|
||||
**Edge Cases:**
|
||||
- Don't clear while actively streaming (cancel first, then clear)
|
||||
- Handle confirmation dismissal (do nothing)
|
||||
- Ensure button is always accessible (not disabled)
|
||||
|
||||
### Button Label Options
|
||||
- "New Session" (clear and descriptive)
|
||||
- "Clear Chat" (direct but less friendly)
|
||||
- "Start Over" (conversational)
|
||||
- Icon: 🔄 or ⊕ (plus in circle)
|
||||
|
||||
Reference in New Issue
Block a user