MCPcopy Create free account
hub / github.com/Zoo-Code-Org/Zoo-Code / handleEditMessageConfirm

Function handleEditMessageConfirm

src/core/webview/webviewMessageHandler.ts:404–537  ·  view source on GitHub ↗
(
		messageTs: number,
		editedContent: string,
		restoreCheckpoint?: boolean,
		images?: string[],
	)

Source from the content-addressed store, hash-verified

402 * Handles confirmed message editing from webview dialog
403 */
404 const handleEditMessageConfirm = async (
405 messageTs: number,
406 editedContent: string,
407 restoreCheckpoint?: boolean,
408 images?: string[],
409 ): Promise<void> => {
410 const currentCline = provider.getCurrentTask()
411 if (!currentCline) {
412 console.error("[handleEditMessageConfirm] No current cline available")
413 return
414 }
415
416 // Use findMessageIndices to find messages based on timestamp
417 const { messageIndex, apiConversationHistoryIndex } = findMessageIndices(messageTs, currentCline)
418
419 if (messageIndex === -1) {
420 const errorMessage = t("common:errors.message.message_not_found", { messageTs })
421 console.error("[handleEditMessageConfirm]", errorMessage)
422 await vscode.window.showErrorMessage(errorMessage)
423 return
424 }
425
426 try {
427 const targetMessage = currentCline.clineMessages[messageIndex]
428
429 // If checkpoint restoration is requested, find and restore to the last checkpoint before this message
430 if (restoreCheckpoint) {
431 // Find the last checkpoint before this message
432 const checkpoints = currentCline.clineMessages.filter(
433 (msg) => msg.say === "checkpoint_saved" && msg.ts > messageTs,
434 )
435
436 const nextCheckpoint = checkpoints[0]
437
438 if (nextCheckpoint && nextCheckpoint.text) {
439 await handleCheckpointRestoreOperation({
440 provider,
441 currentCline,
442 messageTs: targetMessage.ts!,
443 messageIndex,
444 checkpoint: { hash: nextCheckpoint.text },
445 operation: "edit",
446 editData: {
447 editedContent,
448 images,
449 apiConversationHistoryIndex,
450 },
451 })
452 // The task will be cancelled and reinitialized by checkpointRestore
453 // The pending edit will be processed in the reinitialized task
454 return
455 } else {
456 // No checkpoint found before this message
457 console.log("[handleEditMessageConfirm] No checkpoint found before message")
458 vscode.window.showWarningMessage("No checkpoint found before this message")
459 // Continue with non-checkpoint edit
460 }
461 }

Callers 1

webviewMessageHandlerFunction · 0.85

Calls 15

tFunction · 0.90
saveTaskMessagesFunction · 0.90
findMessageIndicesFunction · 0.85
showWarningMessageMethod · 0.80
rewindToTimestampMethod · 0.80
getCurrentTaskMethod · 0.65
errorMethod · 0.65
logMethod · 0.65
setMethod · 0.65
postStateToWebviewMethod · 0.65

Tested by

no test coverage detected