@@ -1352,19 +1352,11 @@ describe("ClineProvider", () => {
13521352 text : "Edited message content" ,
13531353 } )
13541354
1355- // Verify correct messages were kept (only messages before the edited one)
1356- expect ( mockCline . overwriteClineMessages ) . toHaveBeenCalledWith ( [
1357- mockMessages [ 0 ] ,
1358- mockMessages [ 1 ] ,
1359- mockMessages [ 2 ] ,
1360- ] )
1355+ // Verify correct messages were kept - delete from the preceding user message to truly replace it
1356+ expect ( mockCline . overwriteClineMessages ) . toHaveBeenCalledWith ( [ ] )
13611357
1362- // Verify correct API messages were kept (only messages before the edited one)
1363- expect ( mockCline . overwriteApiConversationHistory ) . toHaveBeenCalledWith ( [
1364- mockApiHistory [ 0 ] ,
1365- mockApiHistory [ 1 ] ,
1366- mockApiHistory [ 2 ] ,
1367- ] )
1358+ // Verify correct API messages were kept
1359+ expect ( mockCline . overwriteApiConversationHistory ) . toHaveBeenCalledWith ( [ ] )
13681360
13691361 // The new flow calls webviewMessageHandler recursively with askResponse
13701362 // We need to verify the recursive call happened by checking if the handler was called again
@@ -3112,7 +3104,7 @@ describe("ClineProvider - Comprehensive Edit/Delete Edge Cases", () => {
31123104 mockCline . apiConversationHistory = [ { ts : 1000 } , { ts : 2000 } , { ts : 3000 } ] as any [ ]
31133105 mockCline . overwriteClineMessages = vi . fn ( )
31143106 mockCline . overwriteApiConversationHistory = vi . fn ( )
3115- mockCline . handleWebviewAskResponse = vi . fn ( )
3107+ mockCline . submitUserMessage = vi . fn ( )
31163108
31173109 await provider . addClineToStack ( mockCline )
31183110 ; ( provider as any ) . getTaskWithId = vi . fn ( ) . mockResolvedValue ( {
@@ -3142,9 +3134,11 @@ describe("ClineProvider - Comprehensive Edit/Delete Edge Cases", () => {
31423134 text : "Edited message with preserved images" ,
31433135 } )
31443136
3145- // Verify messages were edited correctly - messages up to the edited message should remain
3146- expect ( mockCline . overwriteClineMessages ) . toHaveBeenCalledWith ( [ mockMessages [ 0 ] , mockMessages [ 1 ] ] )
3147- expect ( mockCline . overwriteApiConversationHistory ) . toHaveBeenCalledWith ( [ { ts : 1000 } , { ts : 2000 } ] )
3137+ // Verify messages were edited correctly - the ORIGINAL user message and all subsequent messages are removed
3138+ expect ( mockCline . overwriteClineMessages ) . toHaveBeenCalledWith ( [ mockMessages [ 0 ] ] )
3139+ expect ( mockCline . overwriteApiConversationHistory ) . toHaveBeenCalledWith ( [ { ts : 1000 } ] )
3140+ // Verify submitUserMessage was called with the edited content
3141+ expect ( mockCline . submitUserMessage ) . toHaveBeenCalledWith ( "Edited message with preserved images" , undefined )
31483142 } )
31493143
31503144 test ( "handles editing messages with file attachments" , async ( ) => {
@@ -3166,7 +3160,7 @@ describe("ClineProvider - Comprehensive Edit/Delete Edge Cases", () => {
31663160 mockCline . apiConversationHistory = [ { ts : 1000 } , { ts : 2000 } , { ts : 3000 } ] as any [ ]
31673161 mockCline . overwriteClineMessages = vi . fn ( )
31683162 mockCline . overwriteApiConversationHistory = vi . fn ( )
3169- mockCline . handleWebviewAskResponse = vi . fn ( )
3163+ mockCline . submitUserMessage = vi . fn ( )
31703164
31713165 await provider . addClineToStack ( mockCline )
31723166 ; ( provider as any ) . getTaskWithId = vi . fn ( ) . mockResolvedValue ( {
@@ -3197,11 +3191,7 @@ describe("ClineProvider - Comprehensive Edit/Delete Edge Cases", () => {
31973191 } )
31983192
31993193 expect ( mockCline . overwriteClineMessages ) . toHaveBeenCalled ( )
3200- expect ( mockCline . handleWebviewAskResponse ) . toHaveBeenCalledWith (
3201- "messageResponse" ,
3202- "Edited message with file attachment" ,
3203- undefined ,
3204- )
3194+ expect ( mockCline . submitUserMessage ) . toHaveBeenCalledWith ( "Edited message with file attachment" , undefined )
32053195 } )
32063196 } )
32073197
@@ -3293,7 +3283,7 @@ describe("ClineProvider - Comprehensive Edit/Delete Edge Cases", () => {
32933283 await messageHandler ( { type : "editMessageConfirm" , messageTs : 2000 , text : "Edited message" } )
32943284
32953285 // The error should be caught and shown
3296- expect ( vscode . window . showErrorMessage ) . toHaveBeenCalledWith ( "Error editing message: Connection lost " )
3286+ expect ( vscode . window . showErrorMessage ) . toHaveBeenCalledWith ( "errors. message.error_editing_message " )
32973287 } )
32983288 } )
32993289
@@ -3416,7 +3406,7 @@ describe("ClineProvider - Comprehensive Edit/Delete Edge Cases", () => {
34163406 text : "Edited message" ,
34173407 } )
34183408
3419- expect ( vscode . window . showErrorMessage ) . toHaveBeenCalledWith ( "Error editing message: Unauthorized " )
3409+ expect ( vscode . window . showErrorMessage ) . toHaveBeenCalledWith ( "errors. message.error_editing_message " )
34203410 } )
34213411
34223412 describe ( "Malformed Requests and Invalid Formats" , ( ) => {
@@ -3640,7 +3630,7 @@ describe("ClineProvider - Comprehensive Edit/Delete Edge Cases", () => {
36403630
36413631 // Verify cleanup was attempted before failure
36423632 expect ( cleanupSpy ) . toHaveBeenCalled ( )
3643- expect ( vscode . window . showErrorMessage ) . toHaveBeenCalledWith ( "Error editing message: Operation failed " )
3633+ expect ( vscode . window . showErrorMessage ) . toHaveBeenCalledWith ( "errors. message.error_editing_message " )
36443634 } )
36453635
36463636 test ( "validates proper cleanup during failed delete operations" , async ( ) => {
@@ -3680,9 +3670,7 @@ describe("ClineProvider - Comprehensive Edit/Delete Edge Cases", () => {
36803670
36813671 // Verify cleanup was attempted before failure
36823672 expect ( cleanupSpy ) . toHaveBeenCalled ( )
3683- expect ( vscode . window . showErrorMessage ) . toHaveBeenCalledWith (
3684- "Error deleting message: Delete operation failed" ,
3685- )
3673+ expect ( vscode . window . showErrorMessage ) . toHaveBeenCalledWith ( "errors.message.error_deleting_message" )
36863674 } )
36873675 } )
36883676
@@ -3705,7 +3693,7 @@ describe("ClineProvider - Comprehensive Edit/Delete Edge Cases", () => {
37053693 mockCline . apiConversationHistory = [ { ts : 1000 } , { ts : 2000 } ] as any [ ]
37063694 mockCline . overwriteClineMessages = vi . fn ( )
37073695 mockCline . overwriteApiConversationHistory = vi . fn ( )
3708- mockCline . handleWebviewAskResponse = vi . fn ( )
3696+ mockCline . submitUserMessage = vi . fn ( )
37093697
37103698 await provider . addClineToStack ( mockCline )
37113699 ; ( provider as any ) . getTaskWithId = vi . fn ( ) . mockResolvedValue ( {
@@ -3734,11 +3722,7 @@ describe("ClineProvider - Comprehensive Edit/Delete Edge Cases", () => {
37343722 await messageHandler ( { type : "editMessageConfirm" , messageTs : 2000 , text : largeEditedContent } )
37353723
37363724 expect ( mockCline . overwriteClineMessages ) . toHaveBeenCalled ( )
3737- expect ( mockCline . handleWebviewAskResponse ) . toHaveBeenCalledWith (
3738- "messageResponse" ,
3739- largeEditedContent ,
3740- undefined ,
3741- )
3725+ expect ( mockCline . submitUserMessage ) . toHaveBeenCalledWith ( largeEditedContent , undefined )
37423726 } )
37433727
37443728 test ( "handles deleting messages with large payloads" , async ( ) => {
@@ -3918,7 +3902,7 @@ describe("ClineProvider - Comprehensive Edit/Delete Edge Cases", () => {
39183902 ] as any [ ]
39193903 mockCline . overwriteClineMessages = vi . fn ( )
39203904 mockCline . overwriteApiConversationHistory = vi . fn ( )
3921- mockCline . handleWebviewAskResponse = vi . fn ( )
3905+ mockCline . submitUserMessage = vi . fn ( )
39223906
39233907 await provider . addClineToStack ( mockCline )
39243908 ; ( provider as any ) . getTaskWithId = vi . fn ( ) . mockResolvedValue ( {
@@ -3951,7 +3935,7 @@ describe("ClineProvider - Comprehensive Edit/Delete Edge Cases", () => {
39513935
39523936 // Should handle future timestamps correctly
39533937 expect ( mockCline . overwriteClineMessages ) . toHaveBeenCalled ( )
3954- expect ( mockCline . handleWebviewAskResponse ) . toHaveBeenCalled ( )
3938+ expect ( mockCline . submitUserMessage ) . toHaveBeenCalled ( )
39553939 } )
39563940 } )
39573941 } )
0 commit comments