From f8a7b563aaeebed696de2a359030f090ab5a267c Mon Sep 17 00:00:00 2001 From: Toshii <94262432+0xToshii@users.noreply.github.com> Date: Mon, 12 May 2025 15:35:31 -0700 Subject: [PATCH] PROTO refactor reportbug (#3485) * protos report bug * changeset --- .changeset/rude-cameras-approve.md | 5 ++++ proto/build-proto.js | 1 + proto/slash.proto | 13 ++++++++++ src/core/controller/grpc-service-config.ts | 5 ++++ src/core/controller/index.ts | 3 --- src/core/controller/slash/index.ts | 22 ++++++++++++++++ src/core/controller/slash/methods.ts | 12 +++++++++ src/core/controller/slash/reportBug.ts | 10 ++++++++ src/core/task/index.ts | 2 +- src/shared/proto/slash.ts | 28 +++++++++++++++++++++ webview-ui/src/components/chat/ChatView.tsx | 7 ++---- webview-ui/src/services/grpc-client.ts | 3 +++ 12 files changed, 102 insertions(+), 9 deletions(-) create mode 100644 .changeset/rude-cameras-approve.md create mode 100644 proto/slash.proto create mode 100644 src/core/controller/slash/index.ts create mode 100644 src/core/controller/slash/methods.ts create mode 100644 src/core/controller/slash/reportBug.ts create mode 100644 src/shared/proto/slash.ts diff --git a/.changeset/rude-cameras-approve.md b/.changeset/rude-cameras-approve.md new file mode 100644 index 0000000000..0c30af0cf1 --- /dev/null +++ b/.changeset/rude-cameras-approve.md @@ -0,0 +1,5 @@ +--- +"claude-dev": patch +--- + +move slash report bug to protos / grpc diff --git a/proto/build-proto.js b/proto/build-proto.js index a0ebfeee75..9ddf636b23 100755 --- a/proto/build-proto.js +++ b/proto/build-proto.js @@ -29,6 +29,7 @@ const serviceNameMap = { task: "cline.TaskService", web: "cline.WebService", models: "cline.ModelsService", + slash: "cline.SlashService", // Add new services here - no other code changes needed! } const serviceDirs = Object.keys(serviceNameMap).map((serviceKey) => path.join(ROOT_DIR, "src", "core", "controller", serviceKey)) diff --git a/proto/slash.proto b/proto/slash.proto new file mode 100644 index 0000000000..9bb30aa388 --- /dev/null +++ b/proto/slash.proto @@ -0,0 +1,13 @@ +syntax = "proto3"; + +package cline; +option java_package = "bot.cline.proto"; +option java_multiple_files = true; + +import "common.proto"; + +// SlashService provides methods for managing slash +service SlashService { + // Sends button click message + rpc reportBug(StringRequest) returns (Empty); +} diff --git a/src/core/controller/grpc-service-config.ts b/src/core/controller/grpc-service-config.ts index 48aff02389..82af03f13d 100644 --- a/src/core/controller/grpc-service-config.ts +++ b/src/core/controller/grpc-service-config.ts @@ -12,6 +12,7 @@ import { handleStateServiceRequest, handleStateServiceStreamingRequest } from ". import { handleTaskServiceRequest, handleTaskServiceStreamingRequest } from "./task/index" import { handleWebServiceRequest, handleWebServiceStreamingRequest } from "./web/index" import { handleModelsServiceRequest, handleModelsServiceStreamingRequest } from "./models/index" +import { handleSlashServiceRequest, handleSlashServiceStreamingRequest } from "./slash/index" /** * Configuration for a service handler @@ -67,4 +68,8 @@ export const serviceHandlers: Record = { requestHandler: handleModelsServiceRequest, streamingHandler: handleModelsServiceStreamingRequest, }, + "cline.SlashService": { + requestHandler: handleSlashServiceRequest, + streamingHandler: handleSlashServiceStreamingRequest, + }, } diff --git a/src/core/controller/index.ts b/src/core/controller/index.ts index aa393a8087..67ea48f5fe 100644 --- a/src/core/controller/index.ts +++ b/src/core/controller/index.ts @@ -274,9 +274,6 @@ export class Controller { case "condense": this.task?.handleWebviewAskResponse("yesButtonClicked") break - case "reportBug": - this.task?.handleWebviewAskResponse("yesButtonClicked") - break case "apiConfiguration": if (message.apiConfiguration) { await updateApiConfiguration(this.context, message.apiConfiguration) diff --git a/src/core/controller/slash/index.ts b/src/core/controller/slash/index.ts new file mode 100644 index 0000000000..dd4b3f53e7 --- /dev/null +++ b/src/core/controller/slash/index.ts @@ -0,0 +1,22 @@ +// AUTO-GENERATED FILE - DO NOT MODIFY DIRECTLY +// Generated by proto/build-proto.js + +import { createServiceRegistry, ServiceMethodHandler, StreamingMethodHandler } from "../grpc-service" +import { StreamingResponseHandler } from "../grpc-handler" +import { registerAllMethods } from "./methods" + +// Create slash service registry +const slashService = createServiceRegistry("slash") + +// Export the method handler types and registration function +export type SlashMethodHandler = ServiceMethodHandler +export type SlashStreamingMethodHandler = StreamingMethodHandler +export const registerMethod = slashService.registerMethod + +// Export the request handlers +export const handleSlashServiceRequest = slashService.handleRequest +export const handleSlashServiceStreamingRequest = slashService.handleStreamingRequest +export const isStreamingMethod = slashService.isStreamingMethod + +// Register all slash methods +registerAllMethods() diff --git a/src/core/controller/slash/methods.ts b/src/core/controller/slash/methods.ts new file mode 100644 index 0000000000..bb656c3c4d --- /dev/null +++ b/src/core/controller/slash/methods.ts @@ -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 { reportBug } from "./reportBug" + +// Register all slash service methods +export function registerAllMethods(): void { + // Register each method with the registry + registerMethod("reportBug", reportBug) +} diff --git a/src/core/controller/slash/reportBug.ts b/src/core/controller/slash/reportBug.ts new file mode 100644 index 0000000000..ecc86d2af8 --- /dev/null +++ b/src/core/controller/slash/reportBug.ts @@ -0,0 +1,10 @@ +import { Controller } from ".." +import { StringRequest, Empty } from "../../../shared/proto/common" + +/** + * Report bug slash command logic + */ +export async function reportBug(controller: Controller, request: StringRequest): Promise { + await controller.task?.handleWebviewAskResponse("yesButtonClicked") + return Empty.create() +} diff --git a/src/core/task/index.ts b/src/core/task/index.ts index ed3a02c4c4..fba6cbb91e 100644 --- a/src/core/task/index.ts +++ b/src/core/task/index.ts @@ -3259,7 +3259,7 @@ export class Task { await this.say("user_feedback", text ?? "", images) pushToolResult( formatResponse.toolResult( - `The user provided feedback on the Github issue generated:\n\n${text}\n`, + `The user did not submit the bug, and provided feedback on the Github issue generated instead:\n\n${text}\n`, images, ), ) diff --git a/src/shared/proto/slash.ts b/src/shared/proto/slash.ts new file mode 100644 index 0000000000..1f36eea54e --- /dev/null +++ b/src/shared/proto/slash.ts @@ -0,0 +1,28 @@ +// Code generated by protoc-gen-ts_proto. DO NOT EDIT. +// versions: +// protoc-gen-ts_proto v2.7.0 +// protoc v3.19.1 +// source: slash.proto + +/* eslint-disable */ +import { Empty, StringRequest } from "./common" + +export const protobufPackage = "cline" + +/** SlashService provides methods for managing slash */ +export type SlashServiceDefinition = typeof SlashServiceDefinition +export const SlashServiceDefinition = { + name: "SlashService", + fullName: "cline.SlashService", + methods: { + /** Sends button click message */ + reportBug: { + name: "reportBug", + requestType: StringRequest, + requestStream: false, + responseType: Empty, + responseStream: false, + options: {}, + }, + }, +} as const diff --git a/webview-ui/src/components/chat/ChatView.tsx b/webview-ui/src/components/chat/ChatView.tsx index 879de5abab..987ac74a0a 100644 --- a/webview-ui/src/components/chat/ChatView.tsx +++ b/webview-ui/src/components/chat/ChatView.tsx @@ -18,7 +18,7 @@ import { combineCommandSequences } from "@shared/combineCommandSequences" import { getApiMetrics } from "@shared/getApiMetrics" import { useExtensionState } from "@/context/ExtensionStateContext" import { vscode } from "@/utils/vscode" -import { TaskServiceClient } from "@/services/grpc-client" +import { TaskServiceClient, SlashServiceClient } from "@/services/grpc-client" import HistoryPreview from "@/components/history/HistoryPreview" import { normalizeApiConfiguration } from "@/components/settings/ApiOptions" import Announcement from "@/components/chat/Announcement" @@ -562,10 +562,7 @@ const ChatView = ({ isHidden, showAnnouncement, hideAnnouncement, showHistoryVie }) break case "report_bug": - vscode.postMessage({ - type: "reportBug", - text: lastMessage?.text, - }) + await SlashServiceClient.reportBug({ value: lastMessage?.text }).catch((err) => console.error(err)) break } setSendingDisabled(true) diff --git a/webview-ui/src/services/grpc-client.ts b/webview-ui/src/services/grpc-client.ts index 6f29f2fd23..d5e83aa591 100644 --- a/webview-ui/src/services/grpc-client.ts +++ b/webview-ui/src/services/grpc-client.ts @@ -11,6 +11,7 @@ import { StateServiceDefinition } from "@shared/proto/state" import { TaskServiceDefinition } from "@shared/proto/task" import { WebServiceDefinition } from "@shared/proto/web" import { ModelsServiceDefinition } from "@shared/proto/models" +import { SlashServiceDefinition } from "@shared/proto/slash" const AccountServiceClient = createGrpcClient(AccountServiceDefinition) const BrowserServiceClient = createGrpcClient(BrowserServiceDefinition) @@ -21,6 +22,7 @@ const StateServiceClient = createGrpcClient(StateServiceDefinition) const TaskServiceClient = createGrpcClient(TaskServiceDefinition) const WebServiceClient = createGrpcClient(WebServiceDefinition) const ModelsServiceClient = createGrpcClient(ModelsServiceDefinition) +const SlashServiceClient = createGrpcClient(SlashServiceDefinition) export { AccountServiceClient, @@ -32,4 +34,5 @@ export { TaskServiceClient, WebServiceClient, ModelsServiceClient, + SlashServiceClient, }