mirror of
https://github.com/Eugeny/tabby.git
synced 2025-06-16 01:19:58 +00:00
ref(connectable tab) on session destroyed
This commit is contained in:
parent
2b5976f202
commit
312b365851
@ -83,21 +83,18 @@ export class SerialTabComponent extends ConnectableTerminalTabComponent<SerialPr
|
|||||||
this.write(`\r\n${colors.black.bgWhite(' Serial ')} ${msg}\r\n`)
|
this.write(`\r\n${colors.black.bgWhite(' Serial ')} ${msg}\r\n`)
|
||||||
this.session?.resize(this.size.columns, this.size.rows)
|
this.session?.resize(this.size.columns, this.size.rows)
|
||||||
})
|
})
|
||||||
this.attachSessionHandler(this.session!.destroyed$, () => {
|
|
||||||
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.offerReconnection()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
super.attachSessionHandlers()
|
super.attachSessionHandlers()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected onSessionDestroyed() {
|
||||||
|
if (this.frontend) {
|
||||||
|
// Session was closed abruptly
|
||||||
|
this.write('\r\n' + colors.black.bgWhite(' SERIAL ') + ` session closed\r\n`)
|
||||||
|
|
||||||
|
super.onSessionDestroyed()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
async getRecoveryToken (options?: GetRecoveryTokenOptions): Promise<any> {
|
async getRecoveryToken (options?: GetRecoveryTokenOptions): Promise<any> {
|
||||||
return {
|
return {
|
||||||
type: 'app:serial-tab',
|
type: 'app:serial-tab',
|
||||||
|
@ -148,21 +148,13 @@ export class SSHTabComponent extends ConnectableTerminalTabComponent<SSHProfile>
|
|||||||
return session
|
return session
|
||||||
}
|
}
|
||||||
|
|
||||||
protected attachSessionHandlers (): void {
|
protected onSessionDestroyed() {
|
||||||
const session = this.session!
|
if (this.frontend) {
|
||||||
this.attachSessionHandler(session.destroyed$, () => {
|
// Session was closed abruptly
|
||||||
if (this.frontend) {
|
this.write('\r\n' + colors.black.bgWhite(' SSH ') + ` ${this.sshSession?.profile.options.host}: session closed\r\n`)
|
||||||
// Session was closed abruptly
|
|
||||||
this.write('\r\n' + colors.black.bgWhite(' SSH ') + ` ${this.sshSession?.profile.options.host}: session closed\r\n`)
|
|
||||||
|
|
||||||
if (this.profile.behaviorOnSessionEnd === 'reconnect') {
|
super.onSessionDestroyed()
|
||||||
this.reconnect()
|
}
|
||||||
} else if (this.profile.behaviorOnSessionEnd === 'keep' || this.profile.behaviorOnSessionEnd === 'auto' && !this.isSessionExplicitlyTerminated()) {
|
|
||||||
this.offerReconnection()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
super.attachSessionHandlers()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private async initializeSessionMaybeMultiplex (multiplex = true): Promise<void> {
|
private async initializeSessionMaybeMultiplex (multiplex = true): Promise<void> {
|
||||||
|
@ -42,21 +42,13 @@ export class TelnetTabComponent extends ConnectableTerminalTabComponent<TelnetPr
|
|||||||
super.onFrontendReady()
|
super.onFrontendReady()
|
||||||
}
|
}
|
||||||
|
|
||||||
protected attachSessionHandlers (): void {
|
protected onSessionDestroyed() {
|
||||||
const session = this.session!
|
if (this.frontend) {
|
||||||
this.attachSessionHandler(session.destroyed$, () => {
|
// Session was closed abruptly
|
||||||
if (this.frontend) {
|
this.write('\r\n' + colors.black.bgWhite(' TELNET ') + ` ${this.session?.profile.options.host}: session closed\r\n`)
|
||||||
// Session was closed abruptly
|
|
||||||
this.write('\r\n' + colors.black.bgWhite(' TELNET ') + ` ${this.session?.profile.options.host}: session closed\r\n`)
|
|
||||||
|
|
||||||
if (this.profile.behaviorOnSessionEnd === 'reconnect') {
|
super.onSessionDestroyed()
|
||||||
this.reconnect()
|
}
|
||||||
} else if (this.profile.behaviorOnSessionEnd === 'keep' || this.profile.behaviorOnSessionEnd === 'auto' && !this.isSessionExplicitlyTerminated()) {
|
|
||||||
this.offerReconnection()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
super.attachSessionHandlers()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async initializeSession (): Promise<void> {
|
async initializeSession (): Promise<void> {
|
||||||
|
@ -784,7 +784,7 @@ export class BaseTerminalTabComponent<P extends BaseTerminalProfile> extends Bas
|
|||||||
})
|
})
|
||||||
|
|
||||||
this.attachSessionHandler(this.session.destroyed$, () => {
|
this.attachSessionHandler(this.session.destroyed$, () => {
|
||||||
this.setSession(null)
|
this.onSessionDestroyed()
|
||||||
})
|
})
|
||||||
|
|
||||||
this.attachSessionHandler(this.session.oscProcessor.copyRequested$, content => {
|
this.attachSessionHandler(this.session.oscProcessor.copyRequested$, content => {
|
||||||
@ -793,6 +793,13 @@ export class BaseTerminalTabComponent<P extends BaseTerminalProfile> extends Bas
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Method called when session is destroyed. Set the session to null
|
||||||
|
*/
|
||||||
|
protected onSessionDestroyed() {
|
||||||
|
this.setSession(null)
|
||||||
|
}
|
||||||
|
|
||||||
protected detachSessionHandlers (): void {
|
protected detachSessionHandlers (): void {
|
||||||
this.sessionHandlers.cancelAll()
|
this.sessionHandlers.cancelAll()
|
||||||
}
|
}
|
||||||
|
@ -32,6 +32,21 @@ export abstract class ConnectableTerminalTabComponent<P extends BaseTerminalProf
|
|||||||
async initializeSession (): Promise<void> {
|
async initializeSession (): Promise<void> {
|
||||||
this.reconnectOffered = false
|
this.reconnectOffered = false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Method called when session is destroyed. Handle the tab behavior on session end for connectable tab
|
||||||
|
*/
|
||||||
|
protected onSessionDestroyed() {
|
||||||
|
super.onSessionDestroyed()
|
||||||
|
|
||||||
|
if (this.frontend) {
|
||||||
|
if (this.profile.behaviorOnSessionEnd === 'reconnect') {
|
||||||
|
this.reconnect()
|
||||||
|
} else if (this.profile.behaviorOnSessionEnd === 'keep' || this.profile.behaviorOnSessionEnd === 'auto' && !this.isSessionExplicitlyTerminated()) {
|
||||||
|
this.offerReconnection()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Offering reconnection to the user if it hasn't been done yet.
|
* Offering reconnection to the user if it hasn't been done yet.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user