[PROTOBUS] Move exportTaskWithId to protobus (#3285)

* exportTaskWithId protobus migration

* rebase fixes
This commit is contained in:
canvrno 2025-05-06 11:06:37 -07:00 committed by GitHub
parent 7084e74372
commit 94fc619196
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 37 additions and 13 deletions

View File

@ -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

View File

@ -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

View File

@ -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<Empty> => {
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
}
}

View File

@ -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)
}

View File

@ -16,9 +16,7 @@ export interface WebviewMessage {
| "askResponse"
| "didShowAnnouncement"
| "selectImages"
| "exportCurrentTask"
| "showTaskWithId"
| "exportTaskWithId"
| "resetState"
| "requestLmStudioModels"
| "openInBrowser"

View File

@ -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

View File

@ -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))
}}>
<div style={{ fontSize: "11px", fontWeight: 500, opacity: 1 }}>EXPORT</div>
</VSCodeButton>