@@ -885,6 +885,16 @@ export class AiAssistancePanel extends UI.Panel.Panel {
885885 steps : [ ] ,
886886 } ;
887887 let step : Step = { isLoading : true } ;
888+
889+ /**
890+ * Commits the step to props only if necessary.
891+ */
892+ function commitStep ( ) : void {
893+ if ( systemMessage . steps . at ( - 1 ) !== step ) {
894+ systemMessage . steps . push ( step ) ;
895+ }
896+ }
897+
888898 this . #viewProps. isLoading = true ;
889899 for await ( const data of generator ) {
890900 step . sideEffect = undefined ;
@@ -913,24 +923,18 @@ export class AiAssistancePanel extends UI.Panel.Panel {
913923 step . title = data . title ;
914924 step . contextDetails = data . details ;
915925 step . isLoading = false ;
916- if ( systemMessage . steps . at ( - 1 ) !== step ) {
917- systemMessage . steps . push ( step ) ;
918- }
926+ commitStep ( ) ;
919927 break ;
920928 }
921929 case ResponseType . TITLE : {
922930 step . title = data . title ;
923- if ( systemMessage . steps . at ( - 1 ) !== step ) {
924- systemMessage . steps . push ( step ) ;
925- }
931+ commitStep ( ) ;
926932 break ;
927933 }
928934 case ResponseType . THOUGHT : {
929935 step . isLoading = false ;
930936 step . thought = data . thought ;
931- if ( systemMessage . steps . at ( - 1 ) !== step ) {
932- systemMessage . steps . push ( step ) ;
933- }
937+ commitStep ( ) ;
934938 break ;
935939 }
936940 case ResponseType . SIDE_EFFECT : {
@@ -939,19 +943,15 @@ export class AiAssistancePanel extends UI.Panel.Panel {
939943 step . sideEffect = {
940944 onAnswer : data . confirm ,
941945 } ;
942- if ( systemMessage . steps . at ( - 1 ) !== step ) {
943- systemMessage . steps . push ( step ) ;
944- }
946+ commitStep ( ) ;
945947 break ;
946948 }
947949 case ResponseType . ACTION : {
948950 step . isLoading = false ;
949951 step . code = data . code ;
950952 step . output = data . output ;
951953 step . canceled = data . canceled ;
952- if ( systemMessage . steps . at ( - 1 ) !== step ) {
953- systemMessage . steps . push ( step ) ;
954- }
954+ commitStep ( ) ;
955955 break ;
956956 }
957957 case ResponseType . ANSWER : {
@@ -984,14 +984,17 @@ export class AiAssistancePanel extends UI.Panel.Panel {
984984 }
985985 }
986986
987- void this . doUpdate ( ) ;
987+ // Commit update intermediated step when not
988+ // in read only mode.
989+ if ( ! this . #viewProps. isReadOnly ) {
990+ void this . doUpdate ( ) ;
988991
989- // This handles scrolling to the bottom for live conversations when:
990- // * User submits the query & the context step is shown.
991- // * There is a side effect dialog shown.
992- if ( ! this . #viewProps . isReadOnly &&
993- ( data . type === ResponseType . CONTEXT || data . type === ResponseType . SIDE_EFFECT ) ) {
994- this . #viewOutput . chatView ?. scrollToBottom ( ) ;
992+ // This handles scrolling to the bottom for live conversations when:
993+ // * User submits the query & the context step is shown.
994+ // * There is a side effect dialog shown.
995+ if ( data . type === ResponseType . CONTEXT || data . type === ResponseType . SIDE_EFFECT ) {
996+ this . #viewOutput . chatView ?. scrollToBottom ( ) ;
997+ }
995998 }
996999 }
9971000
0 commit comments