From d88c07c932797dfc3c30e2b65f63226cbbbe5ff7 Mon Sep 17 00:00:00 2001 From: Toshii <94262432+0xToshii@users.noreply.github.com> Date: Mon, 12 May 2025 16:41:13 -0700 Subject: [PATCH] PROTO refactor condense tool (#3489) * proto for condense * changeset * condense text --- .changeset/brown-dots-sip.md | 5 +++++ proto/slash.proto | 1 + src/core/controller/index.ts | 3 --- src/core/controller/slash/condense.ts | 10 ++++++++++ src/core/controller/slash/methods.ts | 2 ++ src/shared/proto/slash.ts | 8 ++++++++ webview-ui/src/components/chat/ChatView.tsx | 5 +---- 7 files changed, 27 insertions(+), 7 deletions(-) create mode 100644 .changeset/brown-dots-sip.md create mode 100644 src/core/controller/slash/condense.ts diff --git a/.changeset/brown-dots-sip.md b/.changeset/brown-dots-sip.md new file mode 100644 index 0000000000..de94adfebc --- /dev/null +++ b/.changeset/brown-dots-sip.md @@ -0,0 +1,5 @@ +--- +"claude-dev": patch +--- + +convert condense command to use grpc diff --git a/proto/slash.proto b/proto/slash.proto index 9bb30aa388..db0590a6b5 100644 --- a/proto/slash.proto +++ b/proto/slash.proto @@ -10,4 +10,5 @@ import "common.proto"; service SlashService { // Sends button click message rpc reportBug(StringRequest) returns (Empty); + rpc condense(StringRequest) returns (Empty); } diff --git a/src/core/controller/index.ts b/src/core/controller/index.ts index 67ea48f5fe..8a357008ac 100644 --- a/src/core/controller/index.ts +++ b/src/core/controller/index.ts @@ -271,9 +271,6 @@ export class Controller { // initializing new instance of Cline will make sure that any agentically running promises in old instance don't affect our new task. this essentially creates a fresh slate for the new task await this.initTask(message.text, message.images) break - case "condense": - this.task?.handleWebviewAskResponse("yesButtonClicked") - break case "apiConfiguration": if (message.apiConfiguration) { await updateApiConfiguration(this.context, message.apiConfiguration) diff --git a/src/core/controller/slash/condense.ts b/src/core/controller/slash/condense.ts new file mode 100644 index 0000000000..aa40763a0b --- /dev/null +++ b/src/core/controller/slash/condense.ts @@ -0,0 +1,10 @@ +import { Controller } from ".." +import { StringRequest, Empty } from "../../../shared/proto/common" + +/** + * Command slash command logic + */ +export async function condense(controller: Controller, request: StringRequest): Promise { + await controller.task?.handleWebviewAskResponse("yesButtonClicked") + return Empty.create() +} diff --git a/src/core/controller/slash/methods.ts b/src/core/controller/slash/methods.ts index bb656c3c4d..9bfdb098c3 100644 --- a/src/core/controller/slash/methods.ts +++ b/src/core/controller/slash/methods.ts @@ -3,10 +3,12 @@ // Import all method implementations import { registerMethod } from "./index" +import { condense } from "./condense" import { reportBug } from "./reportBug" // Register all slash service methods export function registerAllMethods(): void { // Register each method with the registry + registerMethod("condense", condense) registerMethod("reportBug", reportBug) } diff --git a/src/shared/proto/slash.ts b/src/shared/proto/slash.ts index 1f36eea54e..811768704d 100644 --- a/src/shared/proto/slash.ts +++ b/src/shared/proto/slash.ts @@ -24,5 +24,13 @@ export const SlashServiceDefinition = { responseStream: false, options: {}, }, + condense: { + name: "condense", + requestType: StringRequest, + requestStream: false, + responseType: Empty, + responseStream: false, + options: {}, + }, }, } as const diff --git a/webview-ui/src/components/chat/ChatView.tsx b/webview-ui/src/components/chat/ChatView.tsx index 987ac74a0a..56890080a5 100644 --- a/webview-ui/src/components/chat/ChatView.tsx +++ b/webview-ui/src/components/chat/ChatView.tsx @@ -556,10 +556,7 @@ const ChatView = ({ isHidden, showAnnouncement, hideAnnouncement, showHistoryVie }) break case "condense": - vscode.postMessage({ - type: "condense", - text: lastMessage?.text, - }) + await SlashServiceClient.condense({ value: lastMessage?.text }).catch((err) => console.error(err)) break case "report_bug": await SlashServiceClient.reportBug({ value: lastMessage?.text }).catch((err) => console.error(err))