From 721a6096f75143555a50e9a379e31f11f24934be Mon Sep 17 00:00:00 2001 From: GitHub Actions Date: Fri, 15 May 2026 16:14:26 +0200 Subject: [PATCH 1/2] feat: Add delete chat button with VS Code dialog confirmation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Add trash can emoji button (🗑️) to chat header for deleting current conversation - Use VS Code's showWarningMessage API with modal dialog for confirmation - Implements deleteCurrentChat() handler in llama-webview-provider - Shows chat name in confirmation dialog and provides user feedback - Properly integrates with persistence layer to remove chat from history - Clears UI after successful deletion Fixes issue where chat history accumulates tokens, consuming context window. Users can now easily manage and delete old conversations to free up context. --- package-lock.json | 6 ++--- src/llama-webview-provider.ts | 39 +++++++++++++++++++++++++++++++++ ui/src/components/AgentView.tsx | 13 +++++++++++ 3 files changed, 55 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index ab99bac..07d4486 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "llama-vscode", - "version": "0.0.45", + "version": "0.0.47", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "llama-vscode", - "version": "0.0.45", + "version": "0.0.47", "hasInstallScript": true, "dependencies": { "axios": "^1.1.2", @@ -35,7 +35,7 @@ "webpack-cli": "^4.10.0" }, "engines": { - "vscode": "^1.100.0" + "vscode": "^1.109.0" } }, "node_modules/@babel/helper-string-parser": { diff --git a/src/llama-webview-provider.ts b/src/llama-webview-provider.ts index 73cc866..b9086a4 100644 --- a/src/llama-webview-provider.ts +++ b/src/llama-webview-provider.ts @@ -57,6 +57,9 @@ export class LlamaWebviewProvider implements vscode.WebviewViewProvider { case 'showChatsHistory': this.app.chatService.selectChatFromList(); break; + case 'deleteCurrentChat': + await this.deleteCurrentChat(webviewView); + break; case 'configureTools': await this.app.tools.selectTools() break; @@ -371,6 +374,42 @@ export class LlamaWebviewProvider implements vscode.WebviewViewProvider { }); } + private async deleteCurrentChat(webviewView: vscode.WebviewView) { + const currentChat = this.app.getChat(); + if (!currentChat || !currentChat.id) { + vscode.window.showInformationMessage("No chat to delete. Start a new conversation first."); + return; + } + + let chatsList = this.app.persistence.getChats(); + if (!chatsList || chatsList.length === 0) { + vscode.window.showInformationMessage("No saved chats to delete."); + return; + } + + // Show confirmation dialog with action buttons + const confirmed = await vscode.window.showWarningMessage( + `Delete chat "${currentChat.name || 'Untitled'}"?`, + { modal: true }, + "Delete" + ); + + if (confirmed === "Delete") { + // Find and remove the current chat from the list + const chatIndex = chatsList.findIndex((chat: any) => chat.id === currentChat.id); + if (chatIndex !== -1) { + chatsList.splice(chatIndex, 1); + await this.app.persistence.setChats(chatsList); + + // Clear the UI after deletion + await this.clearChatText(webviewView); + vscode.window.showInformationMessage(`Chat "${currentChat.name || 'Untitled'}" has been deleted.`); + } else { + vscode.window.showWarningMessage("Could not find the chat to delete."); + } + } + } + public addEditAgent(agent: Agent) { this.app.agentService.resetEditedAgentTools(); agent.tools?.map(tool => this.app.agentService.addEditedAgentTools(tool, "")); diff --git a/ui/src/components/AgentView.tsx b/ui/src/components/AgentView.tsx index 4505f13..0660162 100644 --- a/ui/src/components/AgentView.tsx +++ b/ui/src/components/AgentView.tsx @@ -211,6 +211,12 @@ const AgentView: React.FC = ({ }); }; + const handleDeleteCurrentChat = () => { + vscode.postMessage({ + command: 'deleteCurrentChat' + }); + }; + const handleFileSelect = (fileLongName: string) => { // Send the selected file to the extension setShowFileSelector(false); @@ -362,6 +368,13 @@ const AgentView: React.FC = ({ > Chats History + +