mirror of
https://github.com/cline/cline.git
synced 2025-06-03 03:59:07 +00:00
checkpointDiff --> protobuf (#2980)
* Checkpoints diff protobuf * Requested changes to checkpointDiff protobuf
This commit is contained in:
parent
ba6dcb5bc9
commit
0d38381573
@ -93,6 +93,7 @@ async function generateMethodRegistrations() {
|
||||
|
||||
const serviceDirs = [
|
||||
path.join(ROOT_DIR, "src", "core", "controller", "browser"),
|
||||
path.join(ROOT_DIR, "src", "core", "controller", "checkpoints"),
|
||||
// Add more service directories here as needed
|
||||
]
|
||||
|
||||
|
10
proto/checkpoints.proto
Normal file
10
proto/checkpoints.proto
Normal file
@ -0,0 +1,10 @@
|
||||
syntax = "proto3";
|
||||
|
||||
package cline;
|
||||
|
||||
import "common.proto";
|
||||
|
||||
service CheckpointsService {
|
||||
rpc checkpointDiff(Int64Request) returns (Empty);
|
||||
}
|
||||
|
9
src/core/controller/checkpoints/checkpointDiff.ts
Normal file
9
src/core/controller/checkpoints/checkpointDiff.ts
Normal file
@ -0,0 +1,9 @@
|
||||
import { Controller } from ".."
|
||||
import { Empty, Int64Request } from "../../../shared/proto/common"
|
||||
|
||||
export async function checkpointDiff(controller: Controller, request: Int64Request): Promise<Empty> {
|
||||
if (request.value) {
|
||||
await controller.task?.presentMultifileDiff(request.value, false)
|
||||
}
|
||||
return Empty
|
||||
}
|
15
src/core/controller/checkpoints/index.ts
Normal file
15
src/core/controller/checkpoints/index.ts
Normal file
@ -0,0 +1,15 @@
|
||||
import { createServiceRegistry, ServiceMethodHandler } from "../grpc-service"
|
||||
import { registerAllMethods } from "./methods"
|
||||
|
||||
// Create checkpoints service registry
|
||||
const checkpointsService = createServiceRegistry("checkpoints")
|
||||
|
||||
// Export the method handler type and registration function
|
||||
export type CheckpointsMethodHandler = ServiceMethodHandler
|
||||
export const registerMethod = checkpointsService.registerMethod
|
||||
|
||||
// Export the request handler
|
||||
export const handleCheckpointsDiffServiceRequest = checkpointsService.handleRequest
|
||||
|
||||
// Register all checkpoints methods
|
||||
registerAllMethods()
|
12
src/core/controller/checkpoints/methods.ts
Normal file
12
src/core/controller/checkpoints/methods.ts
Normal file
@ -0,0 +1,12 @@
|
||||
// AUTO-GENERATED FILE - DO NOT MODIFY DIRECTLY
|
||||
// Generated by proto/build-proto.js
|
||||
|
||||
// Import all method implementations
|
||||
import { registerMethod } from "./index"
|
||||
import { checkpointDiff } from "./checkpointDiff"
|
||||
|
||||
// Register all checkpoints service methods
|
||||
export function registerAllMethods(): void {
|
||||
// Register each method with the registry
|
||||
registerMethod("checkpointDiff", checkpointDiff)
|
||||
}
|
@ -1,6 +1,7 @@
|
||||
import { Controller } from "./index"
|
||||
import { handleBrowserServiceRequest } from "./browser/index"
|
||||
import { ExtensionMessage } from "../../shared/ExtensionMessage"
|
||||
import { handleCheckpointsDiffServiceRequest } from "./checkpoints"
|
||||
|
||||
/**
|
||||
* Handles gRPC requests from the webview
|
||||
@ -27,15 +28,20 @@ export class GrpcHandler {
|
||||
request_id: string
|
||||
}> {
|
||||
try {
|
||||
// Handle BrowserService requests
|
||||
if (service === "cline.BrowserService") {
|
||||
return {
|
||||
message: await handleBrowserServiceRequest(this.controller, method, message),
|
||||
request_id: requestId,
|
||||
}
|
||||
switch (service) {
|
||||
case "cline.BrowserService":
|
||||
return {
|
||||
message: await handleBrowserServiceRequest(this.controller, method, message),
|
||||
request_id: requestId,
|
||||
}
|
||||
case "cline.CheckpointsService":
|
||||
return {
|
||||
message: await handleCheckpointsDiffServiceRequest(this.controller, method, message),
|
||||
request_id: requestId,
|
||||
}
|
||||
default:
|
||||
throw new Error(`Unknown service: ${service}`)
|
||||
}
|
||||
|
||||
throw new Error(`Unknown service: ${service}`)
|
||||
} catch (error) {
|
||||
return {
|
||||
error: error instanceof Error ? error.message : String(error),
|
||||
|
@ -483,12 +483,6 @@ export class Controller {
|
||||
case "openMention":
|
||||
openMention(message.text)
|
||||
break
|
||||
case "checkpointDiff": {
|
||||
if (message.number) {
|
||||
await this.task?.presentMultifileDiff(message.number, false)
|
||||
}
|
||||
break
|
||||
}
|
||||
case "checkpointRestore": {
|
||||
await this.cancelTask() // we cannot alter message history say if the task is active, as it could be in the middle of editing a file or running a command, which expect the ask to be responded to rather than being superseded by a new message eg add deleted_api_reqs
|
||||
// cancel task waits for any open editor to be reverted and starts a new cline instance
|
||||
|
@ -43,7 +43,6 @@ export interface WebviewMessage {
|
||||
| "discoverBrowser"
|
||||
| "browserRelaunchResult"
|
||||
| "togglePlanActMode"
|
||||
| "checkpointDiff"
|
||||
| "checkpointRestore"
|
||||
| "taskCompletionViewChanges"
|
||||
| "openExtensionSettings"
|
||||
|
26
src/shared/proto/checkpoints.ts
Normal file
26
src/shared/proto/checkpoints.ts
Normal file
@ -0,0 +1,26 @@
|
||||
// Code generated by protoc-gen-ts_proto. DO NOT EDIT.
|
||||
// versions:
|
||||
// protoc-gen-ts_proto v2.7.0
|
||||
// protoc v6.30.1
|
||||
// source: checkpoints.proto
|
||||
|
||||
/* eslint-disable */
|
||||
import { Empty, Int64Request } from "./common"
|
||||
|
||||
export const protobufPackage = "cline"
|
||||
|
||||
export type CheckpointsServiceDefinition = typeof CheckpointsServiceDefinition
|
||||
export const CheckpointsServiceDefinition = {
|
||||
name: "CheckpointsService",
|
||||
fullName: "cline.CheckpointsService",
|
||||
methods: {
|
||||
checkpointDiff: {
|
||||
name: "checkpointDiff",
|
||||
requestType: Int64Request,
|
||||
requestStream: false,
|
||||
responseType: Empty,
|
||||
responseStream: false,
|
||||
options: {},
|
||||
},
|
||||
},
|
||||
} as const
|
@ -2,6 +2,7 @@ import { useCallback, useRef, useState, useEffect } from "react"
|
||||
import { useEvent } from "react-use"
|
||||
import styled from "styled-components"
|
||||
import { ExtensionMessage } from "@shared/ExtensionMessage"
|
||||
import { CheckpointsServiceClient } from "@/services/grpc-client"
|
||||
import { vscode } from "@/utils/vscode"
|
||||
import { CODE_BLOCK_BG_COLOR } from "@/components/common/CodeBlock"
|
||||
import { VSCodeButton } from "@vscode/webview-ui-toolkit/react"
|
||||
@ -138,12 +139,17 @@ export const CheckmarkControl = ({ messageTs, isCheckpointCheckedOut }: Checkmar
|
||||
$isCheckedOut={isCheckpointCheckedOut}
|
||||
disabled={compareDisabled}
|
||||
style={{ cursor: compareDisabled ? "wait" : "pointer" }}
|
||||
onClick={() => {
|
||||
onClick={async () => {
|
||||
setCompareDisabled(true)
|
||||
vscode.postMessage({
|
||||
type: "checkpointDiff",
|
||||
number: messageTs,
|
||||
})
|
||||
try {
|
||||
await CheckpointsServiceClient.checkpointDiff({
|
||||
value: messageTs,
|
||||
})
|
||||
} catch (err) {
|
||||
console.error("CheckpointDiff error:", err)
|
||||
} finally {
|
||||
setCompareDisabled(false)
|
||||
}
|
||||
}}>
|
||||
Compare
|
||||
</CustomButton>
|
||||
|
@ -3,6 +3,7 @@ import { useCallback, useRef, useState } from "react"
|
||||
import { useClickAway, useEvent } from "react-use"
|
||||
import styled from "styled-components"
|
||||
import { ExtensionMessage } from "@shared/ExtensionMessage"
|
||||
import { CheckpointsServiceClient } from "@/services/grpc-client"
|
||||
import { vscode } from "@/utils/vscode"
|
||||
import { CODE_BLOCK_BG_COLOR } from "@/components/common/CodeBlock"
|
||||
import { ClineCheckpointRestore } from "@shared/WebviewMessage"
|
||||
@ -110,12 +111,17 @@ export const CheckpointOverlay = ({ messageTs }: CheckpointOverlayProps) => {
|
||||
appearance="secondary"
|
||||
disabled={compareDisabled}
|
||||
style={{ cursor: compareDisabled ? "wait" : "pointer" }}
|
||||
onClick={() => {
|
||||
onClick={async () => {
|
||||
setCompareDisabled(true)
|
||||
vscode.postMessage({
|
||||
type: "checkpointDiff",
|
||||
number: messageTs,
|
||||
})
|
||||
try {
|
||||
await CheckpointsServiceClient.checkpointDiff({
|
||||
value: messageTs,
|
||||
})
|
||||
} catch (err) {
|
||||
console.error("CheckpointDiff error:", err)
|
||||
} finally {
|
||||
setCompareDisabled(false)
|
||||
}
|
||||
}}>
|
||||
<i className="codicon codicon-diff-multiple" style={{ position: "absolute" }} />
|
||||
</VSCodeButton>
|
||||
|
@ -1,6 +1,7 @@
|
||||
import { vscode } from "../utils/vscode"
|
||||
import { v4 as uuidv4 } from "uuid"
|
||||
import { BrowserServiceDefinition } from "@shared/proto/browser"
|
||||
import { CheckpointsServiceDefinition } from "@shared/proto/checkpoints"
|
||||
import { EmptyRequest } from "@shared/proto/common"
|
||||
|
||||
// Generic type for any protobuf service definition
|
||||
@ -92,9 +93,7 @@ function createGrpcClient<T extends ProtoService>(service: T): GrpcClientType<T>
|
||||
return client
|
||||
}
|
||||
|
||||
// Create the Browser Service Client singleton with inferred types
|
||||
// No need for manual interface definition - types are inferred from the service definition
|
||||
const BrowserServiceClient = createGrpcClient(BrowserServiceDefinition)
|
||||
const CheckpointsServiceClient = createGrpcClient(CheckpointsServiceDefinition)
|
||||
|
||||
// Export the Browser Service Client as a static object
|
||||
export { BrowserServiceClient }
|
||||
export { BrowserServiceClient, CheckpointsServiceClient }
|
||||
|
Loading…
Reference in New Issue
Block a user