resolves Eugeny/tabby#7751, Eugeny/tabby#8062, Eugeny/tabby#6617 add behavior when session ends

This commit is contained in:
Clem
2023-04-23 10:50:39 +02:00
parent f2a62413da
commit b1acfe2519
8 changed files with 95 additions and 33 deletions

View File

@@ -49,14 +49,20 @@ export class TelnetTabComponent extends BaseTerminalTabComponent<TelnetProfile>
this.attachSessionHandler(session.destroyed$, () => {
if (this.frontend) {
// Session was closed abruptly
if (!this.reconnectOffered) {
this.reconnectOffered = true
this.write(this.translate.instant(_('Press any key to reconnect')) + '\r\n')
this.input$.pipe(first()).subscribe(() => {
if (!this.session?.open && this.reconnectOffered) {
this.reconnect()
}
})
this.write('\r\n' + colors.black.bgWhite(' TELNET ') + ` ${this.session?.profile.options.host}: session closed\r\n`)
if (this.profile.behaviorOnSessionEnd === 'reconnect') {
this.reconnect()
} else if (this.profile.behaviorOnSessionEnd === 'keep' || this.profile.behaviorOnSessionEnd === 'auto' && !this.isSessionExplicitlyTerminated()) {
if (!this.reconnectOffered) {
this.reconnectOffered = true
this.write(this.translate.instant(_('Press any key to reconnect')) + '\r\n')
this.input$.pipe(first()).subscribe(() => {
if (!this.session?.open && this.reconnectOffered) {
this.reconnect()
}
})
}
}
}
})
@@ -121,4 +127,11 @@ export class TelnetTabComponent extends BaseTerminalTabComponent<TelnetProfile>
},
)).response === 0
}
protected isSessionExplicitlyTerminated (): boolean {
return super.isSessionExplicitlyTerminated() ||
this.recentInputs.endsWith('close\r') ||
this.recentInputs.endsWith('quit\r')
}
}