diff --git a/package-lock.json b/package-lock.json index 3ea880e57..93e9eafa3 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@continuedev/cli", - "version": "1.0.1", + "version": "1.1.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@continuedev/cli", - "version": "1.0.1", + "version": "1.1.0", "license": "Apache-2.0", "dependencies": { "@continuedev/openai-adapters": "^1.0.18", diff --git a/src/slashCommands.ts b/src/slashCommands.ts index 5e2117a9a..b9f04f4ce 100644 --- a/src/slashCommands.ts +++ b/src/slashCommands.ts @@ -14,6 +14,7 @@ export function handleSlashCommands( output?: string; exit?: boolean; newInput?: string; + clear?: boolean; } | null { if (input.startsWith("/")) { const [command, ...args] = input.slice(1).split(" "); @@ -22,6 +23,7 @@ export function handleSlashCommands( const helpMessage = [ "Available commands:", "/help - Show this help message", + "/clear - Clear the chat history", "/exit - Exit the chat", "/login - Authenticate with your account", "/logout - Sign out of your current session", @@ -39,6 +41,8 @@ export function handleSlashCommands( "None" }`, }; + case "clear": + return { clear: true, output: "Chat history cleared." }; case "exit": return { exit: true, output: "Goodbye!" }; case "login": diff --git a/src/ui/SlashCommandUI.tsx b/src/ui/SlashCommandUI.tsx index 3f03bf8fb..5cb26d433 100644 --- a/src/ui/SlashCommandUI.tsx +++ b/src/ui/SlashCommandUI.tsx @@ -25,6 +25,7 @@ const SlashCommandUI: React.FC = ({ const getSlashCommands = (): SlashCommand[] => { const systemCommands: SlashCommand[] = [ { name: "help", description: "Show help message", category: "system" }, + { name: "clear", description: "Clear the chat history", category: "system" }, { name: "exit", description: "Exit the chat", category: "system" }, { name: "login", diff --git a/src/ui/TUIChat.tsx b/src/ui/TUIChat.tsx index 25db23d85..be3625c11 100644 --- a/src/ui/TUIChat.tsx +++ b/src/ui/TUIChat.tsx @@ -65,6 +65,24 @@ const TUIChat: React.FC = ({ return; } + if (commandResult.clear) { + // Clear chat history but keep system message + const systemMessage = chatHistory.find(msg => msg.role === "system"); + const newHistory = systemMessage ? [systemMessage] : []; + setChatHistory(newHistory); + setMessages([]); + + // Add command output to messages + if (commandResult.output) { + setMessages([{ + role: "system", + content: commandResult.output!, + messageType: "system", + }]); + } + return; + } + // Add command output to messages if (commandResult.output) { setMessages((prev) => [