Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions grid-agent-gui/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
74 changes: 73 additions & 1 deletion grid-agent-gui/frontend/src/components/ChatInterface.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
CheckTfcmdVersion,
ApproveToolExecution,
RejectToolExecution,
ClearSession,
} from "../../wailsjs/go/main/App.js";
import { EventsOn, BrowserOpenURL } from "../../wailsjs/runtime/runtime.js";
import {
Expand All @@ -34,6 +35,7 @@
let showErrorModal = false;
let showSettings = false;
let showDocs = false;
let showClearModal = false;
let errorMessage = "";
let isExporting = false;
let isAborting = false;
Expand Down Expand Up @@ -275,6 +277,31 @@
errorMessage = "";
}

function handleNewConversation() {
showClearModal = true;
}

async function startNewConversation() {
showClearModal = false;
try {
await ClearSession();
} catch (err) {
console.error("Failed to clear session:", err);
}
messagesStore.set([]);
}

async function saveAndStartNew() {
showClearModal = false;
await handleExport();
try {
await ClearSession();
} catch (err) {
console.error("Failed to clear session:", err);
}
messagesStore.set([]);
}

function toggleSettings() {
showSettings = !showSettings;
}
Expand Down Expand Up @@ -645,7 +672,7 @@
class="icon-btn"
on:click={handleExport}
title="Export Conversation"
disabled={isExporting}
disabled={isExporting || $messagesStore.length === 0}
>
{#if isExporting}
<svg
Expand Down Expand Up @@ -677,6 +704,27 @@
>
{/if}
</button>
<button
class="icon-btn clear-btn"
on:click={handleNewConversation}
title="Start New Conversation"
disabled={$messagesStore.length === 0}
>
<svg
xmlns="http://www.w3.org/2000/svg"
width="20"
height="20"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
><rect width="18" height="18" x="3" y="3" rx="2" /><path
d="M8 12h8"
/><path d="M12 8v8" /></svg
>
</button>
<button class="icon-btn" on:click={toggleDocs} title="Help">
<svg
xmlns="http://www.w3.org/2000/svg"
Expand Down Expand Up @@ -893,6 +941,21 @@
</div>
{/if}

<!-- New Conversation Modal -->
{#if showClearModal}
<div class="modal-overlay" on:click={() => showClearModal = false} transition:fade>
<div class="modal" on:click|stopPropagation transition:fade>
<h2>Start New Conversation</h2>
<p>Starting a new conversation will clear the current session history.</p>
<div class="modal-actions">
<button class="btn primary" on:click={saveAndStartNew}>Save and Start New</button>
<button class="btn danger" on:click={startNewConversation}>Start New</button>
<button class="btn secondary" on:click={() => showClearModal = false}>Cancel</button>
</div>
</div>
</div>
{/if}

<Settings show={showSettings} on:close={() => (showSettings = false)} />
<Docs show={showDocs} on:close={() => (showDocs = false)} />

Expand Down Expand Up @@ -1058,6 +1121,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;
Expand Down
9 changes: 9 additions & 0 deletions grid-agent-gui/frontend/src/components/Docs.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,15 @@
<li>Version information and active persona</li>
<li>Optional AI-generated summary (if enabled)</li>
</ul>

<h5>Starting a New Conversation</h5>
<p>The new conversation button (➕) allows you to reset the current session. Before starting a new conversation, you'll be prompted with options:</p>
<ul>
<li><strong>Save and Start New:</strong> Export the current conversation first, then start a new one</li>
<li><strong>Start New:</strong> Immediately start a new conversation and clear usage history</li>
<li><strong>Cancel:</strong> Keep the current conversation</li>
</ul>
<p><strong>Note:</strong> Previous session history cannot be recovered once cleared, so consider saving important discussions first.</p>
</div>

<!-- Grid Operations -->
Expand Down
2 changes: 2 additions & 0 deletions grid-agent-gui/frontend/wailsjs/go/main/App.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ export function CheckForUpdates():Promise<main.UpdateInfo>;

export function CheckTfcmdVersion():Promise<main.VersionMismatchInfo>;

export function ClearSession():Promise<void>;

export function DeactivateProfile():Promise<main.Settings>;

export function DeleteProfile(arg1:string):Promise<main.Settings>;
Expand Down
4 changes: 4 additions & 0 deletions grid-agent-gui/frontend/wailsjs/go/main/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -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']();
}
Expand Down