From 4d7ced7e1517c75523e7325fa0d01fe8dbdfd9f7 Mon Sep 17 00:00:00 2001 From: Andrei Eternal Date: Fri, 6 Jun 2025 18:46:31 -0700 Subject: [PATCH] [Protobus] migrate executeQuickWin (#4088) * protobuf executeQuickWin * whitespaces --------- Co-authored-by: Andrei Eternal --- proto/task.proto | 9 ++++++ src/core/controller/index.ts | 7 ----- src/core/controller/task/executeQuickWin.ts | 35 +++++++++++++++++++++ src/shared/WebviewMessage.ts | 3 -- 4 files changed, 44 insertions(+), 10 deletions(-) create mode 100644 src/core/controller/task/executeQuickWin.ts diff --git a/proto/task.proto b/proto/task.proto index 0f74cacc..cd8b1db3 100644 --- a/proto/task.proto +++ b/proto/task.proto @@ -33,6 +33,8 @@ service TaskService { rpc taskFeedback(StringRequest) returns (Empty); // Shows task completion changes diff in a view rpc taskCompletionViewChanges(Int64Request) returns (Empty); + // Executes a quick win task with command and title + rpc executeQuickWin(ExecuteQuickWinRequest) returns (Empty); } // Request message for creating a new task @@ -107,3 +109,10 @@ message AskResponseRequest { repeated string images = 4; repeated string files = 5; } + +// Request for executing a quick win task +message ExecuteQuickWinRequest { + Metadata metadata = 1; + string command = 2; + string title = 3; +} diff --git a/src/core/controller/index.ts b/src/core/controller/index.ts index 2db549bb..909ec07a 100644 --- a/src/core/controller/index.ts +++ b/src/core/controller/index.ts @@ -316,13 +316,6 @@ export class Controller { } break } - case "executeQuickWin": - if (message.payload) { - const { command, title } = message.payload - this.outputChannel.appendLine(`Received executeQuickWin: command='${command}', title='${title}'`) - await this.initTask(title) - } - break // Add more switch case statements here as more webview message commands // are created within the webview context (i.e. inside media/main.js) diff --git a/src/core/controller/task/executeQuickWin.ts b/src/core/controller/task/executeQuickWin.ts new file mode 100644 index 00000000..580c9abe --- /dev/null +++ b/src/core/controller/task/executeQuickWin.ts @@ -0,0 +1,35 @@ +import { ExecuteQuickWinRequest } from "@shared/proto/task" +import { Empty } from "@shared/proto/common" +import type { Controller } from "../index" + +/** + * Executes a quick win task with command and title + * @param controller The controller instance + * @param request The execute quick win request + * @returns Empty response + * + * @example + * // Usage from webview: + * import { TaskServiceClient } from "@/services/grpc-client" + * import { ExecuteQuickWinRequest } from "@shared/proto/task" + * + * const request: ExecuteQuickWinRequest = { + * command: "npm install", + * title: "Install dependencies" + * } + * + * TaskServiceClient.executeQuickWin(request) + * .then(() => console.log("Quick win executed successfully")) + * .catch(error => console.error("Failed to execute quick win:", error)) + */ +export async function executeQuickWin(controller: Controller, request: ExecuteQuickWinRequest): Promise { + try { + const { command, title } = request + console.log(`Received executeQuickWin: command='${command}', title='${title}'`) + await controller.initTask(title) + return Empty.create({}) + } catch (error) { + console.error("Failed to execute quick win:", error) + throw error + } +} diff --git a/src/shared/WebviewMessage.ts b/src/shared/WebviewMessage.ts index 0fdddce2..dda79231 100644 --- a/src/shared/WebviewMessage.ts +++ b/src/shared/WebviewMessage.ts @@ -20,7 +20,6 @@ export interface WebviewMessage { | "grpc_request" | "grpc_request_cancel" | "toggleWorkflow" - | "executeQuickWin" text?: string disabled?: boolean @@ -71,8 +70,6 @@ export interface WebviewMessage { enabled?: boolean filename?: string - payload?: { command: string; title: string } - offset?: number shellIntegrationTimeout?: number terminalReuseEnabled?: boolean