diff --git a/proto/task.proto b/proto/task.proto index 783497954..20bc8942d 100644 --- a/proto/task.proto +++ b/proto/task.proto @@ -15,6 +15,8 @@ service TaskService { rpc deleteTasksWithIds(StringArrayRequest) returns (Empty); // Creates a new task with the given text and optional images rpc newTask(NewTaskRequest) returns (Empty); + // Exports a task with the given ID to markdown + rpc exportTaskWithId(StringRequest) returns (Empty); } // Request message for creating a new task diff --git a/src/core/controller/index.ts b/src/core/controller/index.ts index 11ae63183..8309b6229 100644 --- a/src/core/controller/index.ts +++ b/src/core/controller/index.ts @@ -327,18 +327,9 @@ export class Controller { images, }) break - case "exportCurrentTask": - const currentTaskId = this.task?.taskId - if (currentTaskId) { - this.exportTaskWithId(currentTaskId) - } - break case "showTaskWithId": this.showTaskWithId(message.text!) break - case "exportTaskWithId": - this.exportTaskWithId(message.text!) - break case "resetState": await this.resetState() break diff --git a/src/core/controller/task/exportTaskWithId.ts b/src/core/controller/task/exportTaskWithId.ts new file mode 100644 index 000000000..479e8dcb4 --- /dev/null +++ b/src/core/controller/task/exportTaskWithId.ts @@ -0,0 +1,22 @@ +import { Controller } from ".." +import { Empty, StringRequest } from "@shared/proto/common" +import { TaskMethodHandler } from "./index" + +/** + * Exports a task with the given ID to markdown + * @param controller The controller instance + * @param request The request containing the task ID in the value field + * @returns Empty response + */ +export const exportTaskWithId: TaskMethodHandler = async (controller: Controller, request: StringRequest): Promise => { + try { + if (request.value) { + await controller.exportTaskWithId(request.value) + } + return Empty.create() + } catch (error) { + // Log the error but allow it to propagate for proper gRPC error handling + console.error(`Error exporting task with ID ${request.value}:`, error) + throw error + } +} diff --git a/src/core/controller/task/methods.ts b/src/core/controller/task/methods.ts index 209f1cb40..409a0fc91 100644 --- a/src/core/controller/task/methods.ts +++ b/src/core/controller/task/methods.ts @@ -6,6 +6,7 @@ import { registerMethod } from "./index" import { cancelTask } from "./cancelTask" import { clearTask } from "./clearTask" import { deleteTasksWithIds } from "./deleteTasksWithIds" +import { exportTaskWithId } from "./exportTaskWithId" import { newTask } from "./newTask" // Register all task service methods @@ -14,5 +15,6 @@ export function registerAllMethods(): void { registerMethod("cancelTask", cancelTask) registerMethod("clearTask", clearTask) registerMethod("deleteTasksWithIds", deleteTasksWithIds) + registerMethod("exportTaskWithId", exportTaskWithId) registerMethod("newTask", newTask) } diff --git a/src/shared/WebviewMessage.ts b/src/shared/WebviewMessage.ts index de649e9a3..c70799b28 100644 --- a/src/shared/WebviewMessage.ts +++ b/src/shared/WebviewMessage.ts @@ -16,9 +16,7 @@ export interface WebviewMessage { | "askResponse" | "didShowAnnouncement" | "selectImages" - | "exportCurrentTask" | "showTaskWithId" - | "exportTaskWithId" | "resetState" | "requestLmStudioModels" | "openInBrowser" diff --git a/src/shared/proto/task.ts b/src/shared/proto/task.ts index 60a12e673..ebb1bbd54 100644 --- a/src/shared/proto/task.ts +++ b/src/shared/proto/task.ts @@ -6,7 +6,7 @@ /* eslint-disable */ import { BinaryReader, BinaryWriter } from "@bufbuild/protobuf/wire" -import { Empty, EmptyRequest, Metadata, StringArrayRequest } from "./common" +import { Empty, EmptyRequest, Metadata, StringArrayRequest, StringRequest } from "./common" export const protobufPackage = "cline" @@ -151,6 +151,15 @@ export const TaskServiceDefinition = { responseStream: false, options: {}, }, + /** Exports a task with the given ID to markdown */ + exportTaskWithId: { + name: "exportTaskWithId", + requestType: StringRequest, + requestStream: false, + responseType: Empty, + responseStream: false, + options: {}, + }, }, } as const diff --git a/webview-ui/src/components/history/HistoryView.tsx b/webview-ui/src/components/history/HistoryView.tsx index 1c7e137ca..5bf722c8f 100644 --- a/webview-ui/src/components/history/HistoryView.tsx +++ b/webview-ui/src/components/history/HistoryView.tsx @@ -563,7 +563,7 @@ const ExportButton = ({ itemId }: { itemId: string }) => ( appearance="icon" onClick={(e) => { e.stopPropagation() - vscode.postMessage({ type: "exportTaskWithId", text: itemId }) + TaskServiceClient.exportTaskWithId({ value: itemId }).catch((err) => console.error("Failed to export task:", err)) }}>
EXPORT