-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Enable ConPTY by default in terminals on Windows #44468
Merged
Merged
Changes from 7 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
814567d
Add `terminal.windowsUseConpty` config option
gzdunek c63b463
Calculate `windowsPty` options
gzdunek ae1c6cb
Pass `useConpty` to node-pty
gzdunek 3ff3ade
Pass `windowsPty` to xterm
gzdunek 6294749
Fix test
gzdunek 99e3c17
Replace `terminal.windowsUseConpty` with `terminal.windowsBackend`, p…
gzdunek 2ae7285
Wait for pty processes to exit before closing the app
gzdunek b5996ad
Simplify `Array.from`
gzdunek 4abd7cc
`GRACEFUL_KILL_MESSAGE` -> `TERMINATE_MESSAGE`
gzdunek 9189a20
Adjust callsites to async `dispose`
gzdunek d26bf33
Add `winpty` to ignored words in `cspell.json`
gzdunek File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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; | ||
} |
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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about
TERMINATE_MESSAGE
instead? SIGKILL just ends a process with no hesitation, the graceful version of it has a name and it's SIGTERM. ;)Also, please add a JSDoc explaining what the message signals.