gui: add Clear button next to Compact

- Clear button sends /clear command
- /clear now resets history, chat log, and block counter
- Completely fresh start without creating a new session
- Button disabled while agent is running
This commit is contained in:
Levi Neely 2026-10-09 16:28:28 +02:00
parent c8f42b2400
commit 1c863ce9ec
2 changed files with 21 additions and 1 deletions

View File

@ -305,12 +305,19 @@ func (ag *Agent) Compact(ctx context.Context) error {
return nil
}
// Clear resets the agent history. Returns an error if the agent is running.
// Clear resets the agent history and chat log. Returns an error if the agent is running.
func (ag *Agent) Clear() error {
if ag.IsRunning() {
return fmt.Errorf("cannot clear while agent is running")
}
ag.history = nil
ag.chatMu.Lock()
ag.chatLog = nil
ag.chatStart = 0
ag.chatVers++
ag.blockCounter = 0
ag.chatMu.Unlock()
ag.chatCond.Broadcast()
return nil
}

View File

@ -381,6 +381,19 @@ Item {
ToolTip.text: "Compact context window"
}
ToolButton {
text: "🗑 Clear"
font.pixelSize: theme.fontSize > 0 ? theme.fontSize * 0.9 : 11
implicitHeight: 28
enabled: ollie.activeState === "idle"
onClicked: {
ollie.submit("/clear")
chatPane.loadChat() // Refresh the view
}
ToolTip.visible: hovered
ToolTip.text: "Clear history and start fresh"
}
ToolButton {
text: "📋 Copy Last"
font.pixelSize: theme.fontSize > 0 ? theme.fontSize * 0.9 : 11