From 433c7d33d9a393c409c1ec6ba374539c893b16a2 Mon Sep 17 00:00:00 2001 From: Eugene Pankov Date: Wed, 8 Dec 2021 21:45:58 +0100 Subject: [PATCH] fixed tab title recovery for split tabs - fixes #4810 --- app/lib/pty.ts | 8 ++++++-- tabby-core/src/components/appRoot.component.ts | 6 +++--- tabby-core/src/components/splitTab.component.ts | 1 + tabby-core/src/services/app.service.ts | 11 ++++------- tabby-local/src/session.ts | 10 ++++------ 5 files changed, 18 insertions(+), 18 deletions(-) diff --git a/app/lib/pty.ts b/app/lib/pty.ts index 426e49ed..0d30e1ec 100644 --- a/app/lib/pty.ts +++ b/app/lib/pty.ts @@ -90,6 +90,7 @@ class PTYDataQueue { export class PTY { private pty: nodePTY.IPty private outputQueue: PTYDataQueue + exited = false constructor (private id: string, private app: Application, ...args: any[]) { this.pty = (nodePTY as any).spawn(...args) @@ -101,7 +102,10 @@ export class PTY { setImmediate(() => this.emit('data', data)) }) - this.pty.on('data', data => this.outputQueue.push(Buffer.from(data))) + this.pty.onData(data => this.outputQueue.push(Buffer.from(data))) + this.pty.onExit(() => { + this.exited = true + }) } getPID (): number { @@ -144,7 +148,7 @@ export class PTYManager { }) ipcMain.on('pty:exists', (event, id) => { - event.returnValue = !!this.ptys[id] + event.returnValue = !this.ptys[id]?.exited }) ipcMain.on('pty:get-pid', (event, id) => { diff --git a/tabby-core/src/components/appRoot.component.ts b/tabby-core/src/components/appRoot.component.ts index 2f1403cd..40a694cd 100644 --- a/tabby-core/src/components/appRoot.component.ts +++ b/tabby-core/src/components/appRoot.component.ts @@ -108,13 +108,13 @@ export class AppRootComponent { if (hotkey === 'move-tab-right') { this.app.moveSelectedTabRight() } - if (hotkey === 'reopen-tab') { - this.app.reopenLastTab() - } if (hotkey === 'duplicate-tab') { this.app.duplicateTab(this.app.activeTab) } } + if (hotkey === 'reopen-tab') { + this.app.reopenLastTab() + } if (hotkey === 'toggle-fullscreen') { hostWindow.toggleFullscreen() } diff --git a/tabby-core/src/components/splitTab.component.ts b/tabby-core/src/components/splitTab.component.ts index b9b7393e..04badbfd 100644 --- a/tabby-core/src/components/splitTab.component.ts +++ b/tabby-core/src/components/splitTab.component.ts @@ -306,6 +306,7 @@ export class SplitTabComponent extends BaseTabComponent implements AfterViewInit async ngAfterViewInit (): Promise { if (this._recoveredState) { await this.recoverContainer(this.root, this._recoveredState, this._recoveredState.duplicate) + this.updateTitle() this.layout() setTimeout(() => { if (this.hasFocus) { diff --git a/tabby-core/src/services/app.service.ts b/tabby-core/src/services/app.service.ts index b0c4d927..a0d699ba 100644 --- a/tabby-core/src/services/app.service.ts +++ b/tabby-core/src/services/app.service.ts @@ -102,13 +102,6 @@ export class AppService { }) hostWindow.windowFocused$.subscribe(() => this._activeTab?.emitFocused()) - - this.tabClosed$.subscribe(async tab => { - const token = await tabRecovery.getFullRecoveryToken(tab) - if (token) { - this.closedTabsStack.push(token) - } - }) } addTabRaw (tab: BaseTabComponent, index: number|null = null): void { @@ -317,6 +310,10 @@ export class AppService { if (checkCanClose && !await tab.canClose()) { return } + const token = await this.tabRecovery.getFullRecoveryToken(tab) + if (token) { + this.closedTabsStack.push(token) + } tab.destroy() } diff --git a/tabby-local/src/session.ts b/tabby-local/src/session.ts index 19fb7618..da4ec3e6 100644 --- a/tabby-local/src/session.ts +++ b/tabby-local/src/session.ts @@ -295,18 +295,16 @@ export class Session extends BaseSession { } else { await new Promise((resolve) => { this.kill('SIGTERM') - setImmediate(() => { + setTimeout(() => { try { process.kill(this.pty!.getPID(), 0) // still alive - setTimeout(() => { - this.kill('SIGKILL') - resolve() - }, 1000) + this.kill('SIGKILL') + resolve() } catch { resolve() } - }) + }, 500) }) } }