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

@@ -83,12 +83,21 @@ export class SerialTabComponent extends BaseTerminalTabComponent<SerialProfile>
this.session?.resize(this.size.columns, this.size.rows)
})
this.attachSessionHandler(this.session!.destroyed$, () => {
this.write(this.translate.instant(_('Press any key to reconnect')) + '\r\n')
this.input$.pipe(first()).subscribe(() => {
if (!this.session?.open) {
if (this.frontend) {
// Session was closed abruptly
this.write('\r\n' + colors.black.bgWhite(' SERIAL ') + ` session closed\r\n`)
if (this.profile.behaviorOnSessionEnd === 'reconnect') {
this.reconnect()
} else if (this.profile.behaviorOnSessionEnd === 'keep' || this.profile.behaviorOnSessionEnd === 'auto' && !this.isSessionExplicitlyTerminated()) {
this.write(this.translate.instant(_('Press any key to reconnect')) + '\r\n')
this.input$.pipe(first()).subscribe(() => {
if (!this.session?.open) {
this.reconnect()
}
})
}
})
}
})
super.attachSessionHandlers()
}
@@ -117,4 +126,10 @@ export class SerialTabComponent extends BaseTerminalTabComponent<SerialProfile>
this.session?.serial?.update({ baudRate: rate })
this.profile.options.baudrate = rate
}
protected isSessionExplicitlyTerminated (): boolean {
return super.isSessionExplicitlyTerminated() ||
this.recentInputs.endsWith('close\r') ||
this.recentInputs.endsWith('quit\r')
}
}