|
1 | 1 | import React, { useState, useRef, forwardRef, useCallback } from "react" |
2 | 2 | import Thumbnails from "@/components/common/Thumbnails" |
3 | 3 | import { highlightText } from "./TaskHeader" |
4 | | -import { vscode } from "@/utils/vscode" |
5 | 4 | import DynamicTextArea from "react-textarea-autosize" |
6 | 5 | import { useExtensionState } from "@/context/ExtensionStateContext" |
| 6 | +import { CheckpointsServiceClient } from "@/services/grpc-client" |
| 7 | +import { ClineCheckpointRestore } from "@shared/WebviewMessage" |
7 | 8 |
|
8 | 9 | interface UserMessageProps { |
9 | 10 | text?: string |
@@ -35,24 +36,27 @@ const UserMessage: React.FC<UserMessageProps> = ({ text, images, messageTs, send |
35 | 36 | } |
36 | 37 | }, [isEditing]) |
37 | 38 |
|
38 | | - const handleRestoreWorkspace = (type: string) => { |
| 39 | + const handleRestoreWorkspace = async (type: ClineCheckpointRestore) => { |
39 | 40 | const delay = type === "task" ? 500 : 1000 // Delay for task and workspace restore |
40 | 41 | setIsEditing(false) |
41 | 42 |
|
42 | 43 | if (text === editedText) { |
43 | 44 | return |
44 | 45 | } |
45 | 46 |
|
46 | | - vscode.postMessage({ |
47 | | - type: "checkpointRestore", |
48 | | - number: messageTs, |
49 | | - text: type, |
50 | | - offset: 1, |
51 | | - }) |
52 | | - |
53 | | - setTimeout(() => { |
54 | | - sendMessageFromChatRow?.(editedText, images || []) |
55 | | - }, delay) |
| 47 | + try { |
| 48 | + await CheckpointsServiceClient.checkpointRestore({ |
| 49 | + number: messageTs, |
| 50 | + restoreType: type, |
| 51 | + offset: 1, |
| 52 | + }) |
| 53 | + |
| 54 | + setTimeout(() => { |
| 55 | + sendMessageFromChatRow?.(editedText, images || []) |
| 56 | + }, delay) |
| 57 | + } catch (err) { |
| 58 | + console.error("Checkpoint restore error:", err) |
| 59 | + } |
56 | 60 | } |
57 | 61 |
|
58 | 62 | const handleBlur = (e: React.FocusEvent<HTMLTextAreaElement>) => { |
@@ -146,10 +150,10 @@ const UserMessage: React.FC<UserMessageProps> = ({ text, images, messageTs, send |
146 | 150 |
|
147 | 151 | // Reusable button component for restore actions |
148 | 152 | interface RestoreButtonProps { |
149 | | - type: string |
| 153 | + type: ClineCheckpointRestore |
150 | 154 | label: string |
151 | 155 | isPrimary: boolean |
152 | | - onClick: (type: string) => void |
| 156 | + onClick: (type: ClineCheckpointRestore) => void |
153 | 157 | title?: string |
154 | 158 | } |
155 | 159 |
|
|
0 commit comments