-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* Add `terminal.windowsUseConpty` config option * Calculate `windowsPty` options * Pass `useConpty` to node-pty * Pass `windowsPty` to xterm * Fix test * Replace `terminal.windowsUseConpty` with `terminal.windowsBackend`, pass boolean all the way through * Wait for pty processes to exit before closing the app * Simplify `Array.from` * `GRACEFUL_KILL_MESSAGE` -> `TERMINATE_MESSAGE` * Adjust callsites to async `dispose` * Add `winpty` to ignored words in `cspell.json` (cherry picked from commit 981aed6)
- Loading branch information
Showing
28 changed files
with
311 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -951,6 +951,7 @@ | |
"winadj", | ||
"windowsaccountname", | ||
"windowsdesktop", | ||
"winpty", | ||
"winscp", | ||
"winserver", | ||
"workgroups", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
61 changes: 61 additions & 0 deletions
61
web/packages/teleterm/src/services/pty/ptyHost/windowsPty.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
/** | ||
* Teleport | ||
* Copyright (C) 2024 Gravitational, Inc. | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Affero General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Affero General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Affero General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
import { makeRuntimeSettings } from 'teleterm/mainProcess/fixtures/mocks'; | ||
|
||
import { getWindowsPty } from './windowsPty'; | ||
|
||
test.each([ | ||
{ | ||
name: 'uses conpty on supported Windows version', | ||
platform: 'win32' as const, | ||
osVersion: '10.0.22621', | ||
terminalOptions: { windowsBackend: 'auto' as const }, | ||
expected: { useConpty: true, buildNumber: 22621 }, | ||
}, | ||
{ | ||
name: 'uses winpty on unsupported Windows version', | ||
platform: 'win32' as const, | ||
osVersion: '10.0.18308', | ||
terminalOptions: { windowsBackend: 'auto' as const }, | ||
expected: { useConpty: false, buildNumber: 18308 }, | ||
}, | ||
{ | ||
name: 'uses winpty when Windows version is supported, but conpty is disabled in options', | ||
platform: 'win32' as const, | ||
osVersion: '10.0.22621', | ||
terminalOptions: { windowsBackend: 'winpty' as const }, | ||
expected: { useConpty: false, buildNumber: 22621 }, | ||
}, | ||
{ | ||
name: 'undefined on non-Windows OS', | ||
platform: 'darwin' as const, | ||
osVersion: '23.5.0', | ||
terminalOptions: { windowsBackend: 'auto' as const }, | ||
expected: undefined, | ||
}, | ||
])('$name', ({ platform, osVersion, terminalOptions, expected }) => { | ||
const pty = getWindowsPty( | ||
makeRuntimeSettings({ | ||
platform, | ||
osVersion, | ||
}), | ||
terminalOptions | ||
); | ||
expect(pty).toEqual(expected); | ||
}); |
49 changes: 49 additions & 0 deletions
49
web/packages/teleterm/src/services/pty/ptyHost/windowsPty.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/** | ||
* Teleport | ||
* Copyright (C) 2024 Gravitational, Inc. | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Affero General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Affero General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Affero General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
import { RuntimeSettings } from 'teleterm/mainProcess/types'; | ||
|
||
import { TerminalOptions, WindowsPty } from '../types'; | ||
|
||
export const WIN_BUILD_STABLE_CONPTY = 18309; | ||
|
||
export function getWindowsPty( | ||
runtimeSettings: RuntimeSettings, | ||
terminalOptions: TerminalOptions | ||
): WindowsPty { | ||
if (runtimeSettings.platform !== 'win32') { | ||
return undefined; | ||
} | ||
|
||
const buildNumber = getWindowsBuildNumber(runtimeSettings.osVersion); | ||
const useConpty = | ||
terminalOptions.windowsBackend === 'auto' && | ||
buildNumber >= WIN_BUILD_STABLE_CONPTY; | ||
return { | ||
useConpty, | ||
buildNumber, | ||
}; | ||
} | ||
|
||
function getWindowsBuildNumber(osVersion: string): number { | ||
const parsedOsVersion = /(\d+)\.(\d+)\.(\d+)/g.exec(osVersion); | ||
if (parsedOsVersion?.length === 4) { | ||
return parseInt(parsedOsVersion[3]); | ||
} | ||
return 0; | ||
} |
Oops, something went wrong.