@@ -29,7 +29,7 @@ export const checkpoints_command = (params: {
2929 websites_provider : WebsitesProvider
3030 panel_provider : PanelProvider
3131} ) : vscode . Disposable [ ] => {
32- let activeDeleteOperation : {
32+ let active_delete_operation : {
3333 finalize : ( ) => Promise < void >
3434 timestamp : number
3535 } | null = null
@@ -53,14 +53,16 @@ export const checkpoints_command = (params: {
5353 params . websites_provider
5454 )
5555 if ( checkpoint ) {
56- vscode . commands . executeCommand ( 'codeWebChat.checkpoints' )
56+ vscode . commands . executeCommand ( 'codeWebChat.checkpoints' , {
57+ highlight_checkpoint : checkpoint
58+ } )
5759 }
5860 }
5961 )
6062
6163 const checkpoints_command = vscode . commands . registerCommand (
6264 'codeWebChat.checkpoints' ,
63- async ( ) => {
65+ async ( args ?: { highlight_checkpoint ?: Checkpoint } ) => {
6466 if (
6567 ! vscode . workspace . workspaceFolders ||
6668 vscode . workspace . workspaceFolders . length == 0
@@ -72,6 +74,7 @@ export const checkpoints_command = (params: {
7274 }
7375
7476 const show_quick_pick = async ( ) => {
77+ let checkpoint_to_highlight = args ?. highlight_checkpoint
7578 const quick_pick = vscode . window . createQuickPick <
7679 vscode . QuickPickItem & { id ?: string ; checkpoint ?: Checkpoint }
7780 > ( )
@@ -196,6 +199,17 @@ export const checkpoints_command = (params: {
196199 }
197200
198201 update_view ( )
202+ if ( checkpoint_to_highlight ) {
203+ const item = quick_pick . items . find (
204+ ( i ) =>
205+ ( i as any ) . checkpoint ?. timestamp ===
206+ checkpoint_to_highlight ?. timestamp
207+ )
208+ if ( item ) {
209+ quick_pick . activeItems = [ item ]
210+ checkpoint_to_highlight = undefined
211+ }
212+ }
199213 quick_pick . busy = false
200214 }
201215
@@ -214,7 +228,9 @@ export const checkpoints_command = (params: {
214228 params . websites_provider
215229 )
216230 if ( checkpoint ) {
217- vscode . commands . executeCommand ( 'codeWebChat.checkpoints' )
231+ vscode . commands . executeCommand ( 'codeWebChat.checkpoints' , {
232+ highlight_checkpoint : checkpoint
233+ } )
218234 }
219235 } else if ( selected . id == 'revert-last' ) {
220236 quick_pick . hide ( )
@@ -271,6 +287,7 @@ export const checkpoints_command = (params: {
271287 )
272288
273289 if ( confirmation == 'Clear All' ) {
290+ active_delete_operation = null
274291 await clear_all_checkpoints ( params . context , params . panel_provider )
275292 vscode . window . showInformationMessage (
276293 dictionary . information_message . ALL_CHECKPOINTS_CLEARED
@@ -318,6 +335,7 @@ export const checkpoints_command = (params: {
318335 if ( e . button . tooltip == 'Edit Description' ) {
319336 notification_count ++
320337 const new_description = await vscode . window . showInputBox ( {
338+ title : 'Description' ,
321339 prompt : 'Enter a description for the checkpoint' ,
322340 value : item . checkpoint . description || '' ,
323341 placeHolder : 'e.g. Before refactoring the main component'
@@ -353,8 +371,8 @@ export const checkpoints_command = (params: {
353371 }
354372
355373 if ( e . button . tooltip == 'Delete' ) {
356- if ( activeDeleteOperation ) {
357- await activeDeleteOperation . finalize ( )
374+ if ( active_delete_operation ) {
375+ await active_delete_operation . finalize ( )
358376 }
359377
360378 const deleted_checkpoint = item . checkpoint
@@ -398,7 +416,7 @@ export const checkpoints_command = (params: {
398416 }
399417 }
400418 }
401- activeDeleteOperation = currentOperation
419+ active_delete_operation = currentOperation
402420
403421 notification_count ++
404422 const choice = await vscode . window . showInformationMessage (
@@ -410,16 +428,22 @@ export const checkpoints_command = (params: {
410428 notification_count --
411429
412430 if (
413- activeDeleteOperation &&
414- activeDeleteOperation . timestamp === currentOperation . timestamp
431+ active_delete_operation &&
432+ active_delete_operation . timestamp === currentOperation . timestamp
415433 ) {
416434 if ( choice == 'Undo' ) {
417435 // Restore to state and UI
418- checkpoints . splice (
419- real_index_in_state ,
420- 0 ,
421- original_checkpoint_from_state
422- )
436+ const current_checkpoints =
437+ params . context . workspaceState . get < Checkpoint [ ] > (
438+ CHECKPOINTS_STATE_KEY ,
439+ [ ]
440+ ) ?? [ ]
441+
442+ current_checkpoints . push ( original_checkpoint_from_state )
443+ current_checkpoints . sort ( ( a , b ) => b . timestamp - a . timestamp )
444+
445+ checkpoints = current_checkpoints
446+
423447 await params . context . workspaceState . update (
424448 CHECKPOINTS_STATE_KEY ,
425449 checkpoints
@@ -434,10 +458,20 @@ export const checkpoints_command = (params: {
434458 notification_count --
435459 } )
436460 update_view ( )
461+ const restored_item = quick_pick . items . find (
462+ ( i ) =>
463+ ( i as any ) . checkpoint ?. timestamp ==
464+ original_checkpoint_from_state . timestamp
465+ )
466+ if ( restored_item ) {
467+ quick_pick . activeItems = [ restored_item ]
468+ }
469+ quick_pick . show ( )
437470 } else {
438471 await currentOperation . finalize ( )
472+ quick_pick . dispose ( )
439473 }
440- activeDeleteOperation = null
474+ active_delete_operation = null
441475 } else if ( choice === 'Undo' ) {
442476 notification_count ++
443477 vscode . window
@@ -448,9 +482,9 @@ export const checkpoints_command = (params: {
448482 . then ( ( ) => {
449483 notification_count --
450484 } )
485+ quick_pick . show ( )
451486 }
452487
453- quick_pick . show ( )
454488 return
455489 }
456490 } )
0 commit comments