@@ -110,9 +110,9 @@ export const webviewMessageHandler = async (
110
110
const { messageIndex } = findMessageIndices ( messageTs , currentCline )
111
111
if ( messageIndex !== - 1 ) {
112
112
// Find the last checkpoint before this message
113
- const checkpoints = currentCline . clineMessages
114
- . filter ( ( msg ) => msg . say === "checkpoint_saved" && msg . ts < messageTs )
115
- . sort ( ( a , b ) => b . ts - a . ts )
113
+ const checkpoints = currentCline . clineMessages . filter (
114
+ ( msg ) => msg . say === "checkpoint_saved" && msg . ts > messageTs ,
115
+ )
116
116
117
117
hasCheckpoint = checkpoints . length > 0
118
118
} else {
@@ -153,19 +153,19 @@ export const webviewMessageHandler = async (
153
153
// If checkpoint restoration is requested, find and restore to the last checkpoint before this message
154
154
if ( restoreCheckpoint ) {
155
155
// Find the last checkpoint before this message
156
- const checkpoints = currentCline . clineMessages
157
- . filter ( ( msg ) => msg . say === "checkpoint_saved" && msg . ts < messageTs )
158
- . sort ( ( a , b ) => b . ts - a . ts )
156
+ const checkpoints = currentCline . clineMessages . filter (
157
+ ( msg ) => msg . say === "checkpoint_saved" && msg . ts > messageTs ,
158
+ )
159
159
160
- const lastCheckpoint = checkpoints [ 0 ]
160
+ const nextCheckpoint = checkpoints [ 0 ]
161
161
162
- if ( lastCheckpoint && lastCheckpoint . text ) {
162
+ if ( nextCheckpoint && nextCheckpoint . text ) {
163
163
await handleCheckpointRestoreOperation ( {
164
164
provider,
165
165
currentCline,
166
166
messageTs : targetMessage . ts ! ,
167
167
messageIndex,
168
- checkpoint : { hash : lastCheckpoint . text } ,
168
+ checkpoint : { hash : nextCheckpoint . text } ,
169
169
operation : "delete" ,
170
170
} )
171
171
} else {
@@ -221,9 +221,9 @@ export const webviewMessageHandler = async (
221
221
const { messageIndex } = findMessageIndices ( messageTs , currentCline )
222
222
if ( messageIndex !== - 1 ) {
223
223
// Find the last checkpoint before this message
224
- const checkpoints = currentCline . clineMessages
225
- . filter ( ( msg ) => msg . say === "checkpoint_saved" && msg . ts < messageTs )
226
- . sort ( ( a , b ) => b . ts - a . ts )
224
+ const checkpoints = currentCline . clineMessages . filter (
225
+ ( msg ) => msg . say === "checkpoint_saved" && msg . ts > messageTs ,
226
+ )
227
227
228
228
hasCheckpoint = checkpoints . length > 0
229
229
} else {
@@ -274,19 +274,19 @@ export const webviewMessageHandler = async (
274
274
// If checkpoint restoration is requested, find and restore to the last checkpoint before this message
275
275
if ( restoreCheckpoint ) {
276
276
// Find the last checkpoint before this message
277
- const checkpoints = currentCline . clineMessages
278
- . filter ( ( msg ) => msg . say === "checkpoint_saved" && msg . ts < messageTs )
279
- . sort ( ( a , b ) => b . ts - a . ts )
277
+ const checkpoints = currentCline . clineMessages . filter (
278
+ ( msg ) => msg . say === "checkpoint_saved" && msg . ts > messageTs ,
279
+ )
280
280
281
- const lastCheckpoint = checkpoints [ 0 ]
281
+ const nextCheckpoint = checkpoints [ 0 ]
282
282
283
- if ( lastCheckpoint && lastCheckpoint . text ) {
283
+ if ( nextCheckpoint && nextCheckpoint . text ) {
284
284
await handleCheckpointRestoreOperation ( {
285
285
provider,
286
286
currentCline,
287
287
messageTs : targetMessage . ts ! ,
288
288
messageIndex,
289
- checkpoint : { hash : lastCheckpoint . text } ,
289
+ checkpoint : { hash : nextCheckpoint . text } ,
290
290
operation : "edit" ,
291
291
editData : {
292
292
editedContent,
0 commit comments