@@ -125,6 +125,10 @@ export function initializeTerminalComponent() {
125
125
if ( this . term ) this . term . reset ( ) ;
126
126
this . terminalActive = false ;
127
127
this . message = '(sorry, something went wrong, please try again)' ;
128
+ } else if ( event . data === 'pty-exited' ) {
129
+ this . terminalActive = false ;
130
+ this . term . reset ( ) ;
131
+ this . commandBuffer = '' ;
128
132
} else {
129
133
this . pendingWrites ++ ;
130
134
this . term . write ( event . data , this . flowControlCallback . bind ( this ) ) ;
@@ -136,9 +140,12 @@ export function initializeTerminalComponent() {
136
140
if ( this . pendingWrites > this . MAX_PENDING_WRITES && ! this . paused ) {
137
141
this . paused = true ;
138
142
this . socket . send ( JSON . stringify ( { pause : true } ) ) ;
139
- } else if ( this . pendingWrites <= this . MAX_PENDING_WRITES && this . paused ) {
143
+ return ;
144
+ }
145
+ if ( this . pendingWrites <= this . MAX_PENDING_WRITES && this . paused ) {
140
146
this . paused = false ;
141
147
this . socket . send ( JSON . stringify ( { resume : true } ) ) ;
148
+ return ;
142
149
}
143
150
} ,
144
151
@@ -147,15 +154,7 @@ export function initializeTerminalComponent() {
147
154
148
155
this . term . onData ( ( data ) => {
149
156
this . socket . send ( JSON . stringify ( { message : data } ) ) ;
150
- // Handle CTRL + D or exit command
151
- if ( data === '\x04' || ( data === '\r' && this . stripAnsiCommands ( this . commandBuffer ) . trim ( ) . includes ( 'exit' ) ) ) {
152
- this . checkIfProcessIsRunningAndKillIt ( ) ;
153
- setTimeout ( ( ) => {
154
- this . terminalActive = false ;
155
- this . term . reset ( ) ;
156
- } , 500 ) ;
157
- this . commandBuffer = '' ;
158
- } else if ( data === '\r' ) {
157
+ if ( data === '\r' ) {
159
158
this . commandBuffer = '' ;
160
159
} else {
161
160
this . commandBuffer += data ;
@@ -183,10 +182,6 @@ export function initializeTerminalComponent() {
183
182
} ) ;
184
183
} ,
185
184
186
- stripAnsiCommands ( input ) {
187
- return input . replace ( / \x1b \[ [ 0 - 9 ; ] * [ a - z A - Z ] / g, '' ) ;
188
- } ,
189
-
190
185
keepAlive ( ) {
191
186
if ( this . socket && this . socket . readyState === WebSocket . OPEN ) {
192
187
this . socket . send ( JSON . stringify ( { ping : true } ) ) ;
0 commit comments