From a36db30c98e79ca388186b443db4a3aad4b65b54 Mon Sep 17 00:00:00 2001 From: mik-tf Date: Sun, 21 Dec 2025 11:47:21 -0500 Subject: [PATCH 1/2] feat: add clear conversation feature with export option - Add clear conversation button in header controls - Implement clear conversation modal with Save and Clear / Clear / Cancel options - Add clear conversation functions to ChatInterface component - Update documentation to include clearing conversations section - Clear button disabled when no messages present - Maintains tool approval functionality alongside clear feature --- .../src/components/ChatInterface.svelte | 59 +++++++++++++++++++ .../frontend/src/components/Docs.svelte | 9 +++ 2 files changed, 68 insertions(+) diff --git a/grid-agent-gui/frontend/src/components/ChatInterface.svelte b/grid-agent-gui/frontend/src/components/ChatInterface.svelte index 7ab12d9..6bd5ae8 100644 --- a/grid-agent-gui/frontend/src/components/ChatInterface.svelte +++ b/grid-agent-gui/frontend/src/components/ChatInterface.svelte @@ -34,6 +34,7 @@ let showErrorModal = false; let showSettings = false; let showDocs = false; + let showClearModal = false; let errorMessage = ""; let isExporting = false; let isAborting = false; @@ -275,6 +276,21 @@ errorMessage = ""; } + function handleClear() { + showClearModal = true; + } + + function clearConversation() { + showClearModal = false; + messagesStore.set([]); + } + + async function saveAndClear() { + showClearModal = false; + await handleExport(); + messagesStore.set([]); + } + function toggleSettings() { showSettings = !showSettings; } @@ -677,6 +693,25 @@ > {/if} + + + + + + +{/if} + (showSettings = false)} /> (showDocs = false)} /> @@ -1058,6 +1108,15 @@ background: rgba(239, 68, 68, 0.1); } + .clear-btn { + color: var(--text-secondary); + } + + .clear-btn:hover { + color: var(--error); + background: rgba(239, 68, 68, 0.1); + } + /* Floating Input Area */ .input-area { padding: 1.5rem; diff --git a/grid-agent-gui/frontend/src/components/Docs.svelte b/grid-agent-gui/frontend/src/components/Docs.svelte index 813bf60..ece772d 100644 --- a/grid-agent-gui/frontend/src/components/Docs.svelte +++ b/grid-agent-gui/frontend/src/components/Docs.svelte @@ -191,6 +191,15 @@
  • Version information and active persona
  • Optional AI-generated summary (if enabled)
  • + +
    Clearing Conversations
    +

    The clear button (🗑️) allows you to reset the current conversation. Before clearing, you'll be prompted with options:

    +
      +
    • Save and Clear: Export the current conversation first, then clear it
    • +
    • Clear: Immediately clear the conversation without saving
    • +
    • Cancel: Keep the current conversation
    • +
    +

    Note: Cleared conversations cannot be recovered, so consider saving important discussions first.

    From 47b551ec122a6066c029eec22d1302fc72e61412 Mon Sep 17 00:00:00 2001 From: Sameh Abouelsaad Date: Wed, 24 Dec 2025 23:20:36 +0200 Subject: [PATCH 2/2] feat: implement backend session clearing and refactor frontend "clear conversation" to "start new conversation" --- grid-agent-gui/app.go | 7 ++++ .../src/components/ChatInterface.svelte | 37 +++++++++++++------ .../frontend/src/components/Docs.svelte | 10 ++--- .../frontend/wailsjs/go/main/App.d.ts | 2 + .../frontend/wailsjs/go/main/App.js | 4 ++ 5 files changed, 43 insertions(+), 17 deletions(-) diff --git a/grid-agent-gui/app.go b/grid-agent-gui/app.go index e878970..0a15d93 100644 --- a/grid-agent-gui/app.go +++ b/grid-agent-gui/app.go @@ -268,6 +268,13 @@ func (a *App) SaveSettings(mnemonics, network, apiKey string) error { return nil } +// ClearSession clears the current agent session/history +func (a *App) ClearSession() error { + return a.initializeAgent(AgentInitOptions{ + ClearHistory: true, + }) +} + // Logout clears settings and returns to onboarding func (a *App) Logout() error { // Keep theme and profiles diff --git a/grid-agent-gui/frontend/src/components/ChatInterface.svelte b/grid-agent-gui/frontend/src/components/ChatInterface.svelte index 6bd5ae8..273c4cd 100644 --- a/grid-agent-gui/frontend/src/components/ChatInterface.svelte +++ b/grid-agent-gui/frontend/src/components/ChatInterface.svelte @@ -8,6 +8,7 @@ CheckTfcmdVersion, ApproveToolExecution, RejectToolExecution, + ClearSession, } from "../../wailsjs/go/main/App.js"; import { EventsOn, BrowserOpenURL } from "../../wailsjs/runtime/runtime.js"; import { @@ -276,18 +277,28 @@ errorMessage = ""; } - function handleClear() { + function handleNewConversation() { showClearModal = true; } - function clearConversation() { + async function startNewConversation() { showClearModal = false; + try { + await ClearSession(); + } catch (err) { + console.error("Failed to clear session:", err); + } messagesStore.set([]); } - async function saveAndClear() { + async function saveAndStartNew() { showClearModal = false; await handleExport(); + try { + await ClearSession(); + } catch (err) { + console.error("Failed to clear session:", err); + } messagesStore.set([]); } @@ -661,7 +672,7 @@ class="icon-btn" on:click={handleExport} title="Export Conversation" - disabled={isExporting} + disabled={isExporting || $messagesStore.length === 0} > {#if isExporting} - + + diff --git a/grid-agent-gui/frontend/src/components/Docs.svelte b/grid-agent-gui/frontend/src/components/Docs.svelte index ece772d..f8eaaa1 100644 --- a/grid-agent-gui/frontend/src/components/Docs.svelte +++ b/grid-agent-gui/frontend/src/components/Docs.svelte @@ -192,14 +192,14 @@
  • Optional AI-generated summary (if enabled)
  • -
    Clearing Conversations
    -

    The clear button (🗑️) allows you to reset the current conversation. Before clearing, you'll be prompted with options:

    +
    Starting a New Conversation
    +

    The new conversation button (➕) allows you to reset the current session. Before starting a new conversation, you'll be prompted with options:

      -
    • Save and Clear: Export the current conversation first, then clear it
    • -
    • Clear: Immediately clear the conversation without saving
    • +
    • Save and Start New: Export the current conversation first, then start a new one
    • +
    • Start New: Immediately start a new conversation and clear usage history
    • Cancel: Keep the current conversation
    -

    Note: Cleared conversations cannot be recovered, so consider saving important discussions first.

    +

    Note: Previous session history cannot be recovered once cleared, so consider saving important discussions first.

    diff --git a/grid-agent-gui/frontend/wailsjs/go/main/App.d.ts b/grid-agent-gui/frontend/wailsjs/go/main/App.d.ts index d71268c..b2148d7 100755 --- a/grid-agent-gui/frontend/wailsjs/go/main/App.d.ts +++ b/grid-agent-gui/frontend/wailsjs/go/main/App.d.ts @@ -16,6 +16,8 @@ export function CheckForUpdates():Promise; export function CheckTfcmdVersion():Promise; +export function ClearSession():Promise; + export function DeactivateProfile():Promise; export function DeleteProfile(arg1:string):Promise; diff --git a/grid-agent-gui/frontend/wailsjs/go/main/App.js b/grid-agent-gui/frontend/wailsjs/go/main/App.js index 190d599..1ad4803 100755 --- a/grid-agent-gui/frontend/wailsjs/go/main/App.js +++ b/grid-agent-gui/frontend/wailsjs/go/main/App.js @@ -30,6 +30,10 @@ export function CheckTfcmdVersion() { return window['go']['main']['App']['CheckTfcmdVersion'](); } +export function ClearSession() { + return window['go']['main']['App']['ClearSession'](); +} + export function DeactivateProfile() { return window['go']['main']['App']['DeactivateProfile'](); }