From f423be15100329aa7a244bd8f124f1e236a805f9 Mon Sep 17 00:00:00 2001 From: Clem Date: Sat, 22 Apr 2023 14:36:43 +0200 Subject: [PATCH] Revert "resolves Eugeny/tabby#7751, Eugeny/tabby#8062, Eugeny/tabby#6617 add configurable behavior when session ends" This reverts commit 268af8806cefc8dba071ead3a03870acdcf39a8e. --- tabby-core/src/configDefaults.yaml | 1 - .../src/components/terminalTab.component.ts | 8 ++-- .../src/components/serialTab.component.ts | 21 ++--------- tabby-ssh/src/components/sshTab.component.ts | 37 +++++++++---------- .../src/components/telnetTab.component.ts | 25 ++++--------- .../terminalSettingsTab.component.pug | 18 --------- tabby-terminal/src/config.ts | 1 - 7 files changed, 32 insertions(+), 79 deletions(-) diff --git a/tabby-core/src/configDefaults.yaml b/tabby-core/src/configDefaults.yaml index 3b829ab1..fd51a672 100644 --- a/tabby-core/src/configDefaults.yaml +++ b/tabby-core/src/configDefaults.yaml @@ -25,7 +25,6 @@ terminal: paneResizeStep: 0.1 focusFollowsMouse: false identification: null - behaviorOnSessionEnds: 'keep-open' hotkeys: profile: __nonStructural: true diff --git a/tabby-local/src/components/terminalTab.component.ts b/tabby-local/src/components/terminalTab.component.ts index 5fb09beb..325264d8 100644 --- a/tabby-local/src/components/terminalTab.component.ts +++ b/tabby-local/src/components/terminalTab.component.ts @@ -28,6 +28,7 @@ export class TerminalTabComponent extends BaseTerminalTabComponent this.sessionOptions = this.profile.options this.logger = this.log.create('terminalTab') + this.session = new Session(this.injector) const isConPTY = isWindowsBuild(WIN_BUILD_CONPTY_SUPPORTED) && this.config.store.terminal.useConPTY @@ -55,9 +56,6 @@ export class TerminalTabComponent extends BaseTerminalTabComponent } initializeSession (columns: number, rows: number): void { - - const session = new Session(this.injector) - if (this.profile.options.runAsAdministrator && this.uac?.isAvailable) { this.profile = { ...this.profile, @@ -65,13 +63,13 @@ export class TerminalTabComponent extends BaseTerminalTabComponent } } - session.start({ + this.session!.start({ ...this.profile.options, width: columns, height: rows, }) - this.setSession(session, this.config.store.terminal.behaviorOnSessionEnds.endsWith('close')) + this.attachSessionHandlers(true) this.recoveryStateChangedHint.next() } diff --git a/tabby-serial/src/components/serialTab.component.ts b/tabby-serial/src/components/serialTab.component.ts index 944df11b..d648dac4 100644 --- a/tabby-serial/src/components/serialTab.component.ts +++ b/tabby-serial/src/components/serialTab.component.ts @@ -82,25 +82,12 @@ export class SerialTabComponent extends BaseTerminalTabComponent this.session?.resize(this.size.columns, this.size.rows) }) this.attachSessionHandler(this.session!.destroyed$, () => { - if (this.frontend) { - // Session was closed abruptly - if (this.config.store.terminal.behaviorOnSessionEnds == 'close') { - // Close the tab - this.destroy() - } else if (this.config.store.terminal.behaviorOnSessionEnds.startsWith('reconnect-or-')) { - // Automatically reconnect the session + this.write(this.translate.instant(_('Press any key to reconnect')) + '\r\n') + this.input$.pipe(first()).subscribe(() => { + if (!this.session?.open) { this.reconnect() - } else { - // Reconnect Offer - 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() } diff --git a/tabby-ssh/src/components/sshTab.component.ts b/tabby-ssh/src/components/sshTab.component.ts index 14296ad5..11af1368 100644 --- a/tabby-ssh/src/components/sshTab.component.ts +++ b/tabby-ssh/src/components/sshTab.component.ts @@ -157,27 +157,24 @@ export class SSHTabComponent extends BaseTerminalTabComponent implem protected attachSessionHandlers (): void { const session = this.session! this.attachSessionHandler(session.destroyed$, () => { - if (this.frontend) { - + if ( + // Ctrl-D + this.recentInputs.charCodeAt(this.recentInputs.length - 1) === 4 || + this.recentInputs.endsWith('exit\r') + ) { + // User closed the session + this.destroy() + } else if (this.frontend) { + // Session was closed abruptly this.write('\r\n' + colors.black.bgWhite(' SSH ') + ` ${this.sshSession?.profile.options.host}: session closed\r\n`) - - if (this.config.store.terminal.behaviorOnSessionEnds == 'close') { - // Close the tab - this.destroy() - } else if (this.config.store.terminal.behaviorOnSessionEnds.startsWith('reconnect-or-')) { - // Automatically reconnect the session - this.reconnect() - } else { - // Reconnect Offer - 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() - } - }) - } + 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() + } + }) } } }) diff --git a/tabby-telnet/src/components/telnetTab.component.ts b/tabby-telnet/src/components/telnetTab.component.ts index 58e4e7fe..440e3432 100644 --- a/tabby-telnet/src/components/telnetTab.component.ts +++ b/tabby-telnet/src/components/telnetTab.component.ts @@ -48,23 +48,14 @@ export class TelnetTabComponent extends BaseTerminalTabComponent this.attachSessionHandler(session.destroyed$, () => { if (this.frontend) { // Session was closed abruptly - if (this.config.store.terminal.behaviorOnSessionEnds == 'close') { - // Close the tab - this.destroy() - } else if (this.config.store.terminal.behaviorOnSessionEnds.startsWith('reconnect-or-')) { - // Automatically reconnect the session - this.reconnect() - } else { - // Reconnect Offer - 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() - } - }) - } + 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() + } + }) } } }) diff --git a/tabby-terminal/src/components/terminalSettingsTab.component.pug b/tabby-terminal/src/components/terminalSettingsTab.component.pug index b0265c6d..9005f12b 100644 --- a/tabby-terminal/src/components/terminalSettingsTab.component.pug +++ b/tabby-terminal/src/components/terminalSettingsTab.component.pug @@ -225,24 +225,6 @@ div.mt-4 (ngModelChange)='config.save()', ) -.mt-4 - h3(translate) Closing - - .form-line - .header - .title(translate) Tab's behavior when session ends - .description(*ngIf='config.store.terminal.behaviorOnSessionEnds.startsWith("reconnect-or")', translate) Automatically reconnect the Serial, Telnet or SSH session - - select.form-control( - [(ngModel)]='config.store.terminal.behaviorOnSessionEnds', - (ngModelChange)='config.save()' - ) - option(ngValue='keep-open', translate) Keep open - option(ngValue='reconnect-or-keep-open', translate) Reconnect, otherwise keep open - option(ngValue='reconnect-or-close', translate) Reconnect, otherwise close - option(ngValue='close', translate) Close - - div.mt-4(*ngIf='hostApp.platform === Platform.Windows') h3(translate) Windows diff --git a/tabby-terminal/src/config.ts b/tabby-terminal/src/config.ts index 35bd77ca..8c4276b0 100644 --- a/tabby-terminal/src/config.ts +++ b/tabby-terminal/src/config.ts @@ -24,7 +24,6 @@ export class TerminalConfigProvider extends ConfigProvider { hideCloseButton: false, hideTabOptionsButton: false, rightClick: 'menu', - behaviorOnSessionEnds: 'keep-open', pasteOnMiddleClick: true, copyOnSelect: false, copyAsHTML: true,