@@ -200,6 +200,7 @@ export class ChatInputPart extends Disposable implements IHistoryNavigationWidge
200
200
201
201
readonly inputUri = URI . parse ( `${ ChatInputPart . INPUT_SCHEME } :input-${ ChatInputPart . _counter ++ } ` ) ;
202
202
203
+ private readonly _chatEditsActionsDisposables = this . _register ( new DisposableStore ( ) ) ;
203
204
private readonly _chatEditsDisposables = this . _register ( new DisposableStore ( ) ) ;
204
205
private _chatEditsProgress : ProgressBar | undefined ;
205
206
private _chatEditsListPool : CollapsibleListPool ;
@@ -866,49 +867,55 @@ export class ChatInputPart extends Disposable implements IHistoryNavigationWidge
866
867
: localize ( 'chatEditingSessionOverview' , "{0} files changed" , numberOfEditedEntries ) ;
867
868
}
868
869
869
- // Chat editing session actions
870
- let actionsContainer = overviewRegion . querySelector ( '.chat-editing-session-actions' ) as HTMLElement ;
871
- const actions = [ ] ;
872
- if ( ! actionsContainer && chatEditingSession . entries . get ( ) . find ( ( e ) => e . state . get ( ) === ModifiedFileEntryState . Undecided ) ) {
873
- // Don't show Accept All / Discard All actions if user already selected Accept All / Discard All
874
- actionsContainer = dom . append ( overviewRegion , $ ( '.chat-editing-session-actions' ) ) ;
875
- actions . push (
876
- {
877
- command : ChatEditingShowChangesAction . ID ,
878
- label : ChatEditingShowChangesAction . LABEL ,
879
- isSecondary : true
880
- } ,
881
- {
882
- command : ChatEditingDiscardAllAction . ID ,
883
- label : ChatEditingDiscardAllAction . LABEL ,
884
- isSecondary : true
885
- } ,
886
- {
887
- command : ChatEditingAcceptAllAction . ID ,
888
- label : ChatEditingAcceptAllAction . LABEL ,
889
- isSecondary : false
870
+ //#region Chat editing session actions
871
+ {
872
+ const actionsContainer = overviewRegion . querySelector ( '.chat-editing-session-actions' ) as HTMLElement ?? dom . append ( overviewRegion , $ ( '.chat-editing-session-actions' ) ) ;
873
+ // Clear out the previous actions (if any)
874
+ this . _chatEditsActionsDisposables . clear ( ) ;
875
+ dom . clearNode ( actionsContainer ) ;
876
+
877
+ if ( chatEditingSession . entries . get ( ) . find ( ( e ) => e . state . get ( ) === ModifiedFileEntryState . Undecided ) ) {
878
+ // Don't show Accept All / Discard All actions if user already selected Accept All / Discard All
879
+ const actions = [ ] ;
880
+ actions . push (
881
+ {
882
+ command : ChatEditingShowChangesAction . ID ,
883
+ label : ChatEditingShowChangesAction . LABEL ,
884
+ isSecondary : true
885
+ } ,
886
+ {
887
+ command : ChatEditingDiscardAllAction . ID ,
888
+ label : ChatEditingDiscardAllAction . LABEL ,
889
+ isSecondary : true
890
+ } ,
891
+ {
892
+ command : ChatEditingAcceptAllAction . ID ,
893
+ label : ChatEditingAcceptAllAction . LABEL ,
894
+ isSecondary : false
895
+ }
896
+ ) ;
897
+
898
+ for ( const action of actions ) {
899
+ const button = this . _chatEditsActionsDisposables . add ( new Button ( actionsContainer , {
900
+ supportIcons : false ,
901
+ secondary : action . isSecondary
902
+ } ) ) ;
903
+ button . label = action . label ;
904
+ this . _chatEditsActionsDisposables . add ( button . onDidClick ( ( ) => {
905
+ this . commandService . executeCommand ( action . command ) ;
906
+ } ) ) ;
907
+ dom . append ( actionsContainer , button . element ) ;
890
908
}
891
- ) ;
892
-
893
- for ( const action of actions ) {
894
- const button = this . _chatEditsDisposables . add ( new Button ( actionsContainer , {
895
- supportIcons : false ,
896
- secondary : action . isSecondary
897
- } ) ) ;
898
- button . label = action . label ;
899
- this . _chatEditsDisposables . add ( button . onDidClick ( ( ) => {
900
- this . commandService . executeCommand ( action . command ) ;
901
- } ) ) ;
902
- dom . append ( actionsContainer , button . element ) ;
903
909
}
904
910
905
- const clearButton = this . _chatEditsDisposables . add ( new Button ( actionsContainer , { supportIcons : true } ) ) ;
911
+ const clearButton = this . _chatEditsActionsDisposables . add ( new Button ( actionsContainer , { supportIcons : true } ) ) ;
906
912
clearButton . icon = Codicon . close ;
907
- this . _chatEditsDisposables . add ( clearButton . onDidClick ( ( e ) => {
913
+ this . _chatEditsActionsDisposables . add ( clearButton . onDidClick ( ( e ) => {
908
914
void chatEditingSession . stop ( ) ;
909
915
} ) ) ;
910
916
dom . append ( actionsContainer , clearButton . element ) ;
911
917
}
918
+ //#endregion
912
919
913
920
if ( ! this . _chatEditsProgress && chatEditingSession . state . get ( ) === ChatEditingSessionState . StreamingEdits ) {
914
921
this . _chatEditsProgress = new ProgressBar ( innerContainer ) ;
0 commit comments