@@ -3,7 +3,11 @@ import type { HistoryItem } from "@roo-code/types"
33
44import { Task } from "../../task/Task"
55import { ClineProvider } from "../ClineProvider"
6- import { ConversationRewindError , TaskNotRestartedError } from "../../checkpoints/ConversationRewindError"
6+ import {
7+ ConversationPartlyRewoundError ,
8+ ConversationRewindError ,
9+ TaskNotRestartedError ,
10+ } from "../../checkpoints/ConversationRewindError"
711import { handleCheckpointRestoreOperation , type CheckpointRestoreConfig } from "../checkpointRestoreHandler"
812import { PendingEditOperationStore } from "../PendingEditOperationStore"
913import { saveTaskMessages } from "../../task-persistence"
@@ -408,6 +412,43 @@ describe("checkpointRestoreHandler", () => {
408412 expect ( vscode . window . showErrorMessage ) . toHaveBeenCalledOnce ( )
409413 } )
410414
415+ it ( "does not offer to restart a deleted task whose conversation is only partly rewound, and hands an edit back" , async ( ) => {
416+ fixture . taskDouble . abort = true
417+ const partly = new ConversationRewindError ( new ConversationPartlyRewoundError ( "only partly rewound" ) , {
418+ error : new Error ( "the task was not started again" ) ,
419+ } )
420+ fixture . taskDouble . checkpointRestore . mockRejectedValueOnce ( partly )
421+
422+ await expect ( handleCheckpointRestoreOperation ( fixture . config ) ) . rejects . toBe ( partly )
423+
424+ // The failure is reported, and no restart is offered: it would load turns that the user cannot see.
425+ expect ( vscode . window . showErrorMessage ) . toHaveBeenCalledOnce ( )
426+ expect ( showWarningMessage ) . not . toHaveBeenCalled ( )
427+ expect ( fixture . providerDouble . restartTaskIfCurrent ) . not . toHaveBeenCalled ( )
428+ } )
429+
430+ it ( "hands an edit back, and offers no restart, after a partly rewound conversation of an edit" , async ( ) => {
431+ fixture . taskDouble . abort = true
432+ fixture . taskDouble . checkpointRestore . mockRejectedValueOnce (
433+ new ConversationRewindError ( new ConversationPartlyRewoundError ( "only partly rewound" ) , {
434+ error : new Error ( "the task was not started again" ) ,
435+ } ) ,
436+ )
437+
438+ await expect (
439+ handleCheckpointRestoreOperation ( {
440+ ...fixture . config ,
441+ operation : "edit" ,
442+ editData : { editedContent : "Edited prompt" , apiConversationHistoryIndex : 0 } ,
443+ } ) ,
444+ ) . rejects . toMatchObject ( { restarted : false } )
445+
446+ expect ( fixture . providerDouble . postMessageToWebview ) . toHaveBeenCalledWith (
447+ expect . objectContaining ( { invoke : "setChatBoxMessage" , text : "Edited prompt" } ) ,
448+ )
449+ expect ( showWarningMessage ) . not . toHaveBeenCalled ( )
450+ } )
451+
411452 it ( "offers to restart a deleted task, since nothing started it" , async ( ) => {
412453 fixture . taskDouble . abort = true
413454 fixture . taskDouble . checkpointRestore . mockRejectedValueOnce ( notRestarted ( ) )
0 commit comments