mirror of
https://github.com/cline/cline.git
synced 2026-10-29 17:42:34 +08:00
[PROTOBUS] Move showTaskWithID to protobus (#3283)
* showTaskWithID protobus migration * replaced ShowTaskWithIdRequest with generic stringRequest * prettier
This commit is contained in:
@@ -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);
|
||||
// Shows a task with the specified ID
|
||||
rpc showTaskWithId(StringRequest) returns (Empty);
|
||||
// Exports a task with the given ID to markdown
|
||||
rpc exportTaskWithId(StringRequest) returns (Empty);
|
||||
}
|
||||
@@ -25,3 +27,4 @@ message NewTaskRequest {
|
||||
string text = 2;
|
||||
repeated string images = 3;
|
||||
}
|
||||
|
||||
|
||||
@@ -329,9 +329,6 @@ export class Controller {
|
||||
images,
|
||||
})
|
||||
break
|
||||
case "showTaskWithId":
|
||||
this.showTaskWithId(message.text!)
|
||||
break
|
||||
case "resetState":
|
||||
await this.resetState()
|
||||
break
|
||||
|
||||
@@ -8,6 +8,7 @@ import { clearTask } from "./clearTask"
|
||||
import { deleteTasksWithIds } from "./deleteTasksWithIds"
|
||||
import { exportTaskWithId } from "./exportTaskWithId"
|
||||
import { newTask } from "./newTask"
|
||||
import { showTaskWithId } from "./showTaskWithId"
|
||||
|
||||
// Register all task service methods
|
||||
export function registerAllMethods(): void {
|
||||
@@ -17,4 +18,5 @@ export function registerAllMethods(): void {
|
||||
registerMethod("deleteTasksWithIds", deleteTasksWithIds)
|
||||
registerMethod("exportTaskWithId", exportTaskWithId)
|
||||
registerMethod("newTask", newTask)
|
||||
registerMethod("showTaskWithId", showTaskWithId)
|
||||
}
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
import { Controller } from ".."
|
||||
import { Empty, StringRequest } from "../../../shared/proto/common"
|
||||
|
||||
/**
|
||||
* Shows a task with the specified ID
|
||||
* @param controller The controller instance
|
||||
* @param request The request containing the task ID
|
||||
* @returns Empty response
|
||||
*/
|
||||
export async function showTaskWithId(controller: Controller, request: StringRequest): Promise<Empty> {
|
||||
try {
|
||||
await controller.showTaskWithId(request.value)
|
||||
return Empty.create()
|
||||
} catch (error) {
|
||||
throw error
|
||||
}
|
||||
}
|
||||
@@ -16,7 +16,6 @@ export interface WebviewMessage {
|
||||
| "askResponse"
|
||||
| "didShowAnnouncement"
|
||||
| "selectImages"
|
||||
| "showTaskWithId"
|
||||
| "resetState"
|
||||
| "openInBrowser"
|
||||
| "openMention"
|
||||
|
||||
@@ -151,6 +151,15 @@ export const TaskServiceDefinition = {
|
||||
responseStream: false,
|
||||
options: {},
|
||||
},
|
||||
/** Shows a task with the specified ID */
|
||||
showTaskWithId: {
|
||||
name: "showTaskWithId",
|
||||
requestType: StringRequest,
|
||||
requestStream: false,
|
||||
responseType: Empty,
|
||||
responseStream: false,
|
||||
options: {},
|
||||
},
|
||||
/** Exports a task with the given ID to markdown */
|
||||
exportTaskWithId: {
|
||||
name: "exportTaskWithId",
|
||||
|
||||
@@ -2,6 +2,7 @@ import { VSCodeButton } from "@vscode/webview-ui-toolkit/react"
|
||||
import { useExtensionState } from "@/context/ExtensionStateContext"
|
||||
import { vscode } from "@/utils/vscode"
|
||||
import { memo } from "react"
|
||||
import { TaskServiceClient } from "@/services/grpc-client"
|
||||
import { formatLargeNumber } from "@/utils/format"
|
||||
|
||||
type HistoryPreviewProps = {
|
||||
@@ -11,7 +12,7 @@ type HistoryPreviewProps = {
|
||||
const HistoryPreview = ({ showHistoryView }: HistoryPreviewProps) => {
|
||||
const { taskHistory } = useExtensionState()
|
||||
const handleHistorySelect = (id: string) => {
|
||||
vscode.postMessage({ type: "showTaskWithId", text: id })
|
||||
TaskServiceClient.showTaskWithId({ value: id }).catch((error) => console.error("Error showing task:", error))
|
||||
}
|
||||
|
||||
const formatDate = (timestamp: number) => {
|
||||
|
||||
@@ -48,7 +48,7 @@ const HistoryView = ({ onDone }: HistoryViewProps) => {
|
||||
}, [searchQuery, sortOption, lastNonRelevantSort])
|
||||
|
||||
const handleShowTaskWithId = useCallback((id: string) => {
|
||||
vscode.postMessage({ type: "showTaskWithId", text: id })
|
||||
TaskServiceClient.showTaskWithId({ value: id }).catch((error) => console.error("Error showing task:", error))
|
||||
}, [])
|
||||
|
||||
const handleHistorySelect = useCallback((itemId: string, checked: boolean) => {
|
||||
|
||||
Reference in New Issue
Block a user