mirror of
https://github.com/cline/cline.git
synced 2025-06-03 03:59:07 +00:00
[PROTOBUS] Move deleteTasksWithIds to protobus (#3282)
* deleteTasksWithIDs protobus migration * Moved deleteTasksWithIds to dedicated message type * Created common StringArrayRequest * Delete webview-ui/.vite-port
This commit is contained in:
parent
a953f6e768
commit
cb7234f967
@ -19,6 +19,11 @@ message StringRequest {
|
|||||||
string value = 2;
|
string value = 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
message StringArrayRequest {
|
||||||
|
Metadata metadata = 1;
|
||||||
|
repeated string value = 2;
|
||||||
|
}
|
||||||
|
|
||||||
message String {
|
message String {
|
||||||
string value = 1;
|
string value = 1;
|
||||||
}
|
}
|
||||||
|
@ -11,6 +11,8 @@ service TaskService {
|
|||||||
rpc cancelTask(EmptyRequest) returns (Empty);
|
rpc cancelTask(EmptyRequest) returns (Empty);
|
||||||
// Clears the current task
|
// Clears the current task
|
||||||
rpc clearTask(EmptyRequest) returns (Empty);
|
rpc clearTask(EmptyRequest) returns (Empty);
|
||||||
|
// Deletes multiple tasks with the given IDs
|
||||||
|
rpc deleteTasksWithIds(StringArrayRequest) returns (Empty);
|
||||||
// Creates a new task with the given text and optional images
|
// Creates a new task with the given text and optional images
|
||||||
rpc newTask(NewTaskRequest) returns (Empty);
|
rpc newTask(NewTaskRequest) returns (Empty);
|
||||||
}
|
}
|
||||||
|
@ -336,9 +336,6 @@ export class Controller {
|
|||||||
case "showTaskWithId":
|
case "showTaskWithId":
|
||||||
this.showTaskWithId(message.text!)
|
this.showTaskWithId(message.text!)
|
||||||
break
|
break
|
||||||
case "deleteTasksWithIds":
|
|
||||||
this.deleteTasksWithIds(message.text!)
|
|
||||||
break
|
|
||||||
case "exportTaskWithId":
|
case "exportTaskWithId":
|
||||||
this.exportTaskWithId(message.text!)
|
this.exportTaskWithId(message.text!)
|
||||||
break
|
break
|
||||||
@ -1757,12 +1754,6 @@ Here is the project's README to help you get started:\n\n${mcpDetails.readmeCont
|
|||||||
this.refreshTotalTasksSize()
|
this.refreshTotalTasksSize()
|
||||||
}
|
}
|
||||||
|
|
||||||
async deleteTasksWithIds(ids: string) {
|
|
||||||
for (const id of JSON.parse(ids) as string[]) {
|
|
||||||
await this.deleteTaskWithId(id)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
async deleteTaskFromState(id: string) {
|
async deleteTaskFromState(id: string) {
|
||||||
// Remove the task from history
|
// Remove the task from history
|
||||||
const taskHistory = ((await getGlobalState(this.context, "taskHistory")) as HistoryItem[] | undefined) || []
|
const taskHistory = ((await getGlobalState(this.context, "taskHistory")) as HistoryItem[] | undefined) || []
|
||||||
|
23
src/core/controller/task/deleteTasksWithIds.ts
Normal file
23
src/core/controller/task/deleteTasksWithIds.ts
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
import { Controller } from ".."
|
||||||
|
import { Empty, StringArrayRequest } from "../../../shared/proto/common"
|
||||||
|
import { TaskMethodHandler } from "./index"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Deletes tasks with the specified IDs
|
||||||
|
* @param controller The controller instance
|
||||||
|
* @param request The request containing an array of task IDs to delete
|
||||||
|
* @returns Empty response
|
||||||
|
* @throws Error if operation fails
|
||||||
|
*/
|
||||||
|
export const deleteTasksWithIds: TaskMethodHandler = async (
|
||||||
|
controller: Controller,
|
||||||
|
request: StringArrayRequest,
|
||||||
|
): Promise<Empty> => {
|
||||||
|
if (!request.value || request.value.length === 0) {
|
||||||
|
throw new Error("Missing task IDs")
|
||||||
|
}
|
||||||
|
|
||||||
|
await Promise.all(request.value.map((value) => controller.deleteTaskWithId(value)))
|
||||||
|
|
||||||
|
return Empty.create()
|
||||||
|
}
|
@ -5,6 +5,7 @@
|
|||||||
import { registerMethod } from "./index"
|
import { registerMethod } from "./index"
|
||||||
import { cancelTask } from "./cancelTask"
|
import { cancelTask } from "./cancelTask"
|
||||||
import { clearTask } from "./clearTask"
|
import { clearTask } from "./clearTask"
|
||||||
|
import { deleteTasksWithIds } from "./deleteTasksWithIds"
|
||||||
import { newTask } from "./newTask"
|
import { newTask } from "./newTask"
|
||||||
|
|
||||||
// Register all task service methods
|
// Register all task service methods
|
||||||
@ -12,5 +13,6 @@ export function registerAllMethods(): void {
|
|||||||
// Register each method with the registry
|
// Register each method with the registry
|
||||||
registerMethod("cancelTask", cancelTask)
|
registerMethod("cancelTask", cancelTask)
|
||||||
registerMethod("clearTask", clearTask)
|
registerMethod("clearTask", clearTask)
|
||||||
|
registerMethod("deleteTasksWithIds", deleteTasksWithIds)
|
||||||
registerMethod("newTask", newTask)
|
registerMethod("newTask", newTask)
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,6 @@ export interface WebviewMessage {
|
|||||||
| "selectImages"
|
| "selectImages"
|
||||||
| "exportCurrentTask"
|
| "exportCurrentTask"
|
||||||
| "showTaskWithId"
|
| "showTaskWithId"
|
||||||
| "deleteTasksWithIds"
|
|
||||||
| "exportTaskWithId"
|
| "exportTaskWithId"
|
||||||
| "resetState"
|
| "resetState"
|
||||||
| "requestOllamaModels"
|
| "requestOllamaModels"
|
||||||
|
@ -22,6 +22,11 @@ export interface StringRequest {
|
|||||||
value: string
|
value: string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface StringArrayRequest {
|
||||||
|
metadata?: Metadata | undefined
|
||||||
|
value: string[]
|
||||||
|
}
|
||||||
|
|
||||||
export interface String {
|
export interface String {
|
||||||
value: string
|
value: string
|
||||||
}
|
}
|
||||||
@ -275,6 +280,83 @@ export const StringRequest: MessageFns<StringRequest> = {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function createBaseStringArrayRequest(): StringArrayRequest {
|
||||||
|
return { metadata: undefined, value: [] }
|
||||||
|
}
|
||||||
|
|
||||||
|
export const StringArrayRequest: MessageFns<StringArrayRequest> = {
|
||||||
|
encode(message: StringArrayRequest, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {
|
||||||
|
if (message.metadata !== undefined) {
|
||||||
|
Metadata.encode(message.metadata, writer.uint32(10).fork()).join()
|
||||||
|
}
|
||||||
|
for (const v of message.value) {
|
||||||
|
writer.uint32(18).string(v!)
|
||||||
|
}
|
||||||
|
return writer
|
||||||
|
},
|
||||||
|
|
||||||
|
decode(input: BinaryReader | Uint8Array, length?: number): StringArrayRequest {
|
||||||
|
const reader = input instanceof BinaryReader ? input : new BinaryReader(input)
|
||||||
|
let end = length === undefined ? reader.len : reader.pos + length
|
||||||
|
const message = createBaseStringArrayRequest()
|
||||||
|
while (reader.pos < end) {
|
||||||
|
const tag = reader.uint32()
|
||||||
|
switch (tag >>> 3) {
|
||||||
|
case 1: {
|
||||||
|
if (tag !== 10) {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
|
||||||
|
message.metadata = Metadata.decode(reader, reader.uint32())
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
case 2: {
|
||||||
|
if (tag !== 18) {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
|
||||||
|
message.value.push(reader.string())
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ((tag & 7) === 4 || tag === 0) {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
reader.skip(tag & 7)
|
||||||
|
}
|
||||||
|
return message
|
||||||
|
},
|
||||||
|
|
||||||
|
fromJSON(object: any): StringArrayRequest {
|
||||||
|
return {
|
||||||
|
metadata: isSet(object.metadata) ? Metadata.fromJSON(object.metadata) : undefined,
|
||||||
|
value: globalThis.Array.isArray(object?.value) ? object.value.map((e: any) => globalThis.String(e)) : [],
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
toJSON(message: StringArrayRequest): unknown {
|
||||||
|
const obj: any = {}
|
||||||
|
if (message.metadata !== undefined) {
|
||||||
|
obj.metadata = Metadata.toJSON(message.metadata)
|
||||||
|
}
|
||||||
|
if (message.value?.length) {
|
||||||
|
obj.value = message.value
|
||||||
|
}
|
||||||
|
return obj
|
||||||
|
},
|
||||||
|
|
||||||
|
create<I extends Exact<DeepPartial<StringArrayRequest>, I>>(base?: I): StringArrayRequest {
|
||||||
|
return StringArrayRequest.fromPartial(base ?? ({} as any))
|
||||||
|
},
|
||||||
|
fromPartial<I extends Exact<DeepPartial<StringArrayRequest>, I>>(object: I): StringArrayRequest {
|
||||||
|
const message = createBaseStringArrayRequest()
|
||||||
|
message.metadata =
|
||||||
|
object.metadata !== undefined && object.metadata !== null ? Metadata.fromPartial(object.metadata) : undefined
|
||||||
|
message.value = object.value?.map((e) => e) || []
|
||||||
|
return message
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
function createBaseString(): String {
|
function createBaseString(): String {
|
||||||
return { value: "" }
|
return { value: "" }
|
||||||
}
|
}
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
/* eslint-disable */
|
/* eslint-disable */
|
||||||
import { BinaryReader, BinaryWriter } from "@bufbuild/protobuf/wire"
|
import { BinaryReader, BinaryWriter } from "@bufbuild/protobuf/wire"
|
||||||
import { Empty, EmptyRequest, Metadata } from "./common"
|
import { Empty, EmptyRequest, Metadata, StringArrayRequest } from "./common"
|
||||||
|
|
||||||
export const protobufPackage = "cline"
|
export const protobufPackage = "cline"
|
||||||
|
|
||||||
@ -133,6 +133,15 @@ export const TaskServiceDefinition = {
|
|||||||
responseStream: false,
|
responseStream: false,
|
||||||
options: {},
|
options: {},
|
||||||
},
|
},
|
||||||
|
/** Deletes multiple tasks with the given IDs */
|
||||||
|
deleteTasksWithIds: {
|
||||||
|
name: "deleteTasksWithIds",
|
||||||
|
requestType: StringArrayRequest,
|
||||||
|
requestStream: false,
|
||||||
|
responseType: Empty,
|
||||||
|
responseStream: false,
|
||||||
|
options: {},
|
||||||
|
},
|
||||||
/** Creates a new task with the given text and optional images */
|
/** Creates a new task with the given text and optional images */
|
||||||
newTask: {
|
newTask: {
|
||||||
name: "newTask",
|
name: "newTask",
|
||||||
|
@ -10,6 +10,7 @@ import { vscode } from "@/utils/vscode"
|
|||||||
import Thumbnails from "@/components/common/Thumbnails"
|
import Thumbnails from "@/components/common/Thumbnails"
|
||||||
import { normalizeApiConfiguration } from "@/components/settings/ApiOptions"
|
import { normalizeApiConfiguration } from "@/components/settings/ApiOptions"
|
||||||
import { validateSlashCommand } from "@/utils/slash-commands"
|
import { validateSlashCommand } from "@/utils/slash-commands"
|
||||||
|
import { TaskServiceClient } from "@/services/grpc-client"
|
||||||
|
|
||||||
interface TaskHeaderProps {
|
interface TaskHeaderProps {
|
||||||
task: ClineMessage
|
task: ClineMessage
|
||||||
@ -669,7 +670,7 @@ const DeleteButton: React.FC<{
|
|||||||
}> = ({ taskSize, taskId }) => (
|
}> = ({ taskSize, taskId }) => (
|
||||||
<VSCodeButton
|
<VSCodeButton
|
||||||
appearance="icon"
|
appearance="icon"
|
||||||
onClick={() => vscode.postMessage({ type: "deleteTasksWithIds", text: JSON.stringify([taskId]) })}
|
onClick={() => taskId && TaskServiceClient.deleteTasksWithIds({ value: [taskId] })}
|
||||||
style={{ padding: "0px 0px" }}>
|
style={{ padding: "0px 0px" }}>
|
||||||
<div
|
<div
|
||||||
style={{
|
style={{
|
||||||
|
@ -4,6 +4,7 @@ import { vscode } from "@/utils/vscode"
|
|||||||
import { Virtuoso } from "react-virtuoso"
|
import { Virtuoso } from "react-virtuoso"
|
||||||
import { memo, useMemo, useState, useEffect, useCallback } from "react"
|
import { memo, useMemo, useState, useEffect, useCallback } from "react"
|
||||||
import Fuse, { FuseResult } from "fuse.js"
|
import Fuse, { FuseResult } from "fuse.js"
|
||||||
|
import { TaskServiceClient } from "@/services/grpc-client"
|
||||||
import { formatLargeNumber } from "@/utils/format"
|
import { formatLargeNumber } from "@/utils/format"
|
||||||
import { formatSize } from "@/utils/format"
|
import { formatSize } from "@/utils/format"
|
||||||
import { ExtensionMessage } from "@shared/ExtensionMessage"
|
import { ExtensionMessage } from "@shared/ExtensionMessage"
|
||||||
@ -61,12 +62,12 @@ const HistoryView = ({ onDone }: HistoryViewProps) => {
|
|||||||
}, [])
|
}, [])
|
||||||
|
|
||||||
const handleDeleteHistoryItem = useCallback((id: string) => {
|
const handleDeleteHistoryItem = useCallback((id: string) => {
|
||||||
vscode.postMessage({ type: "deleteTasksWithIds", text: JSON.stringify([id]) })
|
TaskServiceClient.deleteTasksWithIds({ value: [id] })
|
||||||
}, [])
|
}, [])
|
||||||
|
|
||||||
const handleDeleteSelectedHistoryItems = useCallback((ids: string[]) => {
|
const handleDeleteSelectedHistoryItems = useCallback((ids: string[]) => {
|
||||||
if (ids.length > 0) {
|
if (ids.length > 0) {
|
||||||
vscode.postMessage({ type: "deleteTasksWithIds", text: JSON.stringify(ids) })
|
TaskServiceClient.deleteTasksWithIds({ value: ids })
|
||||||
setSelectedItems([])
|
setSelectedItems([])
|
||||||
}
|
}
|
||||||
}, [])
|
}, [])
|
||||||
|
Loading…
Reference in New Issue
Block a user