Skip to content

Commit

Permalink
Revert "resolves Eugeny#7751, Eugeny#8062, Eugeny#6617 add configurab…
Browse files Browse the repository at this point in the history
…le behavior when session ends"

This reverts commit 268af88.
  • Loading branch information
Clem-Fern committed Apr 22, 2023
1 parent 8cb75e1 commit f423be1
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 79 deletions.
1 change: 0 additions & 1 deletion tabby-core/src/configDefaults.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ terminal:
paneResizeStep: 0.1
focusFollowsMouse: false
identification: null
behaviorOnSessionEnds: 'keep-open'
hotkeys:
profile:
__nonStructural: true
Expand Down
8 changes: 3 additions & 5 deletions tabby-local/src/components/terminalTab.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export class TerminalTabComponent extends BaseTerminalTabComponent<LocalProfile>
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

Expand Down Expand Up @@ -55,23 +56,20 @@ export class TerminalTabComponent extends BaseTerminalTabComponent<LocalProfile>
}

initializeSession (columns: number, rows: number): void {

const session = new Session(this.injector)

if (this.profile.options.runAsAdministrator && this.uac?.isAvailable) {
this.profile = {
...this.profile,
options: this.uac.patchSessionOptionsForUAC(this.profile.options),
}
}

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()
}

Expand Down
21 changes: 4 additions & 17 deletions tabby-serial/src/components/serialTab.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,25 +82,12 @@ export class SerialTabComponent extends BaseTerminalTabComponent<SerialProfile>
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()
}
Expand Down
37 changes: 17 additions & 20 deletions tabby-ssh/src/components/sshTab.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,27 +157,24 @@ export class SSHTabComponent extends BaseTerminalTabComponent<SSHProfile> 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()
}
})
}
}
})
Expand Down
25 changes: 8 additions & 17 deletions tabby-telnet/src/components/telnetTab.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,23 +48,14 @@ export class TelnetTabComponent extends BaseTerminalTabComponent<TelnetProfile>
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()
}
})
}
}
})
Expand Down
18 changes: 0 additions & 18 deletions tabby-terminal/src/components/terminalSettingsTab.component.pug
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
1 change: 0 additions & 1 deletion tabby-terminal/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ export class TerminalConfigProvider extends ConfigProvider {
hideCloseButton: false,
hideTabOptionsButton: false,
rightClick: 'menu',
behaviorOnSessionEnds: 'keep-open',
pasteOnMiddleClick: true,
copyOnSelect: false,
copyAsHTML: true,
Expand Down

0 comments on commit f423be1

Please sign in to comment.