Skip to content

Commit ca3cf18

Browse files
authored
[PROTOBUS] Move showTaskWithID to protobus (RooCodeInc#3283)
* showTaskWithID protobus migration * replaced ShowTaskWithIdRequest with generic stringRequest * prettier
1 parent a02bf11 commit ca3cf18

File tree

8 files changed

+34
-6
lines changed

8 files changed

+34
-6
lines changed

proto/task.proto

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ service TaskService {
1515
rpc deleteTasksWithIds(StringArrayRequest) returns (Empty);
1616
// Creates a new task with the given text and optional images
1717
rpc newTask(NewTaskRequest) returns (Empty);
18+
// Shows a task with the specified ID
19+
rpc showTaskWithId(StringRequest) returns (Empty);
1820
// Exports a task with the given ID to markdown
1921
rpc exportTaskWithId(StringRequest) returns (Empty);
2022
}
@@ -25,3 +27,4 @@ message NewTaskRequest {
2527
string text = 2;
2628
repeated string images = 3;
2729
}
30+

src/core/controller/index.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -329,9 +329,6 @@ export class Controller {
329329
images,
330330
})
331331
break
332-
case "showTaskWithId":
333-
this.showTaskWithId(message.text!)
334-
break
335332
case "resetState":
336333
await this.resetState()
337334
break

src/core/controller/task/methods.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { clearTask } from "./clearTask"
88
import { deleteTasksWithIds } from "./deleteTasksWithIds"
99
import { exportTaskWithId } from "./exportTaskWithId"
1010
import { newTask } from "./newTask"
11+
import { showTaskWithId } from "./showTaskWithId"
1112

1213
// Register all task service methods
1314
export function registerAllMethods(): void {
@@ -17,4 +18,5 @@ export function registerAllMethods(): void {
1718
registerMethod("deleteTasksWithIds", deleteTasksWithIds)
1819
registerMethod("exportTaskWithId", exportTaskWithId)
1920
registerMethod("newTask", newTask)
21+
registerMethod("showTaskWithId", showTaskWithId)
2022
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import { Controller } from ".."
2+
import { Empty, StringRequest } from "../../../shared/proto/common"
3+
4+
/**
5+
* Shows a task with the specified ID
6+
* @param controller The controller instance
7+
* @param request The request containing the task ID
8+
* @returns Empty response
9+
*/
10+
export async function showTaskWithId(controller: Controller, request: StringRequest): Promise<Empty> {
11+
try {
12+
await controller.showTaskWithId(request.value)
13+
return Empty.create()
14+
} catch (error) {
15+
throw error
16+
}
17+
}

src/shared/WebviewMessage.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ export interface WebviewMessage {
1616
| "askResponse"
1717
| "didShowAnnouncement"
1818
| "selectImages"
19-
| "showTaskWithId"
2019
| "resetState"
2120
| "openInBrowser"
2221
| "openMention"

src/shared/proto/task.ts

Lines changed: 9 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

webview-ui/src/components/history/HistoryPreview.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { VSCodeButton } from "@vscode/webview-ui-toolkit/react"
22
import { useExtensionState } from "@/context/ExtensionStateContext"
33
import { vscode } from "@/utils/vscode"
44
import { memo } from "react"
5+
import { TaskServiceClient } from "@/services/grpc-client"
56
import { formatLargeNumber } from "@/utils/format"
67

78
type HistoryPreviewProps = {
@@ -11,7 +12,7 @@ type HistoryPreviewProps = {
1112
const HistoryPreview = ({ showHistoryView }: HistoryPreviewProps) => {
1213
const { taskHistory } = useExtensionState()
1314
const handleHistorySelect = (id: string) => {
14-
vscode.postMessage({ type: "showTaskWithId", text: id })
15+
TaskServiceClient.showTaskWithId({ value: id }).catch((error) => console.error("Error showing task:", error))
1516
}
1617

1718
const formatDate = (timestamp: number) => {

webview-ui/src/components/history/HistoryView.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ const HistoryView = ({ onDone }: HistoryViewProps) => {
4848
}, [searchQuery, sortOption, lastNonRelevantSort])
4949

5050
const handleShowTaskWithId = useCallback((id: string) => {
51-
vscode.postMessage({ type: "showTaskWithId", text: id })
51+
TaskServiceClient.showTaskWithId({ value: id }).catch((error) => console.error("Error showing task:", error))
5252
}, [])
5353

5454
const handleHistorySelect = useCallback((itemId: string, checked: boolean) => {

0 commit comments

Comments
 (0)