@@ -474,6 +474,61 @@ registerAction2(class RestoreCheckpointAction extends Action2 {
474
474
}
475
475
} ) ;
476
476
477
+ registerAction2 ( class RestoreLastCheckpoint extends Action2 {
478
+ constructor ( ) {
479
+ super ( {
480
+ id : 'workbench.action.chat.restoreLastCheckpoint' ,
481
+ title : localize2 ( 'chat.restoreLastCheckpoint.label' , "Restore to last checkpoint" ) ,
482
+ f1 : false ,
483
+ category : CHAT_CATEGORY ,
484
+ icon : Codicon . arrowUp ,
485
+ menu : [
486
+ {
487
+ id : MenuId . ChatMessageFooter ,
488
+ group : 'navigation' ,
489
+ order : 3 ,
490
+ when : ContextKeyExpr . and ( ContextKeyExpr . in ( ChatContextKeys . itemId . key , ChatContextKeys . lastItemId . key ) , ContextKeyExpr . equals ( `config.${ ChatConfiguration . CheckpointsEnabled } ` , true ) ) ,
491
+ }
492
+ ]
493
+ } ) ;
494
+ }
495
+
496
+ async run ( accessor : ServicesAccessor , ...args : any [ ] ) {
497
+ let item : ChatTreeItem | undefined = args [ 0 ] ;
498
+ const chatWidgetService = accessor . get ( IChatWidgetService ) ;
499
+ const chatService = accessor . get ( IChatService ) ;
500
+ const widget = chatWidgetService . lastFocusedWidget ;
501
+ if ( ! isResponseVM ( item ) && ! isRequestVM ( item ) ) {
502
+ item = widget ?. getFocus ( ) ;
503
+ }
504
+
505
+ if ( ! item ) {
506
+ return ;
507
+ }
508
+
509
+ const chatModel = chatService . getSession ( item . sessionId ) ;
510
+ if ( ! chatModel ) {
511
+ return ;
512
+ }
513
+
514
+ const session = chatModel . editingSession ;
515
+ if ( ! session ) {
516
+ return ;
517
+ }
518
+
519
+ await restoreSnapshotWithConfirmation ( accessor , item ) ;
520
+
521
+ if ( isResponseVM ( item ) ) {
522
+ widget ?. viewModel ?. model . setCheckpoint ( item . requestId ) ;
523
+ const request = chatModel . getRequests ( ) . find ( request => request . id === item . requestId ) ;
524
+ if ( request ) {
525
+ widget ?. focusInput ( ) ;
526
+ widget ?. input . setValue ( request . message . text , false ) ;
527
+ }
528
+ }
529
+ }
530
+ } ) ;
531
+
477
532
registerAction2 ( class EditAction extends Action2 {
478
533
constructor ( ) {
479
534
super ( {
0 commit comments