Skip to content
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

Support for terminal profiles. #12066

Merged
merged 4 commits into from
Jan 19, 2023

Conversation

tsmaeder
Copy link
Contributor

What it does

Adds support for terminal profiles.

Fixes #11503

  • UI and service to manage terminal profiles
  • Handle profiles in preferences according to VS Code schema
  • API and contribution markup for contributing profiles and activation event handling

contributed on behalf of STMicroelectronics

How to test

This PR adds two new items under the "Terminal" menu: "New Terminal...", which allows to select a profile and use it to open a terminal and "Choose Default Profile", which selects the profile to be used when selecting "New Terminal" from the menu.
Some profiles are added by default ("cmd" by default on windows), but they can also be contributed by plugins or defined in the preferences.
Here are two extensions that can be used to test contributed terminals:

plugins.zip

One contributes a shell terminal profile ("JavaScript Debug Terminal") and the other a pseudo-pty terminal ("My Extension Terminal").

Adding profiles via terminals is described here:

https://code.visualstudio.com/docs/terminal/profiles

Note that terminal "source"s have not been implemented. Theia will accept the syntax, but the resulting profiles will not work.

Review checklist

Reminder for reviewers

Copy link
Member

@vince-fugnitto vince-fugnitto left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems that there are conflicts, do you mind rebasing?

packages/core/i18n/nls.de.json Outdated Show resolved Hide resolved
Comment on lines +83 to +91
export const PROFILE_NEW = Command.toLocalizedCommand({
id: 'terminal:new:profile',
category: TERMINAL_CATEGORY,
label: 'Create New Integrated Terminal from a Profile'
});
export const PROFILE_DEFAULT = Command.toLocalizedCommand({
id: 'terminal:profile:default',
category: TERMINAL_CATEGORY,
label: 'Choose the default Terminal Profile'
});
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These commands do not seem to be present in VS Code, and are not added to the terminal main-menu.
I do see the command 'Create New Terminal (With Profile)' however.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

terminal-frontend-contribution.ts L 653-668?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mean, these commands do not exist in VS Code, are they necessary?
Instead we should probably implement Create New Terminal (With Profile) which is present in VS Code and likely achieves what we are attempting here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, the UI (in particular choosing the default profile) is very different from what VS Code does. As for the "Create New Terminal (With Profile)", I would argue that my solution is superior: the "..." at the end of "New Profile" is a well established UI pattern indicating that the user will face a dialog to do some configuration or selection before running the action.
Remember that "do the same as VS Code" is not a strategic goal of the project anymore.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

However in this case it adds entries in the terminal menu that downstream applications might not be expecting since in general we do follow the default implementation of VS Code. Moreover, plugins may attempt to trigger the workbench.action.terminal.newWithProfile command but it does not exist.

If we want to keep the commands that you've added on top of VS Code I'd maybe suggest we move them out of the terminal menu.

Copy link
Contributor Author

@tsmaeder tsmaeder Jan 17, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

However in this case it adds entries in the terminal menu that downstream applications might not be expecting

Having the same menu structure as VS Code is not a promise I think we are making to our adopters. If downstream apps rely on that, we have a problem. Our UI with terminals and profiles is very different (no tabbed terminals, for example) and I feel it's a bit of a kludge in VS Code. It would be wrong to strive for visual compatibility in this respect, IMO.

Moreover, plugins may attempt to trigger the workbench.action.terminal.newWithProfile command but it does not exist.

That's the question I'm asking: is this command id VS Code published API we should support? I don't think it is.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's the question I'm asking: is this command id VS Code published API we should support? I don't think it is.

I believe it is the main reason that command ids follow VS Code, since they can be ultimately executed from plugins.
In the case that we do not match their id, we have a mapping performed in the plugin system, for example:

I understand you might be referring to builtin commands, but the page also describes "common commands" and such commands are also accessible by plugins.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Having a look at the broader picture here: all the other terminal-related commands do not have the same command ids as in VS Code (e.g. terminal:new instead of workbench.action.terminal.new. So having just the two new one's aligned seems odd. In this PR, the command ids are consistent with the rest of the terminal commands. If we want to align the command ids with VS Code, it should be done in a separate PR that covers all terminal-related command ids.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've opened an issue: #12084

packages/terminal/src/browser/terminal-preferences.ts Outdated Show resolved Hide resolved
@vince-fugnitto vince-fugnitto added terminal issues related to the terminal vscode issues related to VSCode compatibility labels Jan 13, 2023
Copy link
Member

@msujew msujew left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I noticed a few issues when the frontend OS isn't the same as the backend OS. The preferences don't match up well.

- UI and service to manage terminal profiles
- Handle profiles in preferences according to VS Code schema
- API and contribution markup for contributing profiles and activation
event handling

contributed on behalf of STMicroelectronics

Signed-off-by: Thomas Mäder <[email protected]>
Copy link
Member

@msujew msujew left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The changes look good to me. I would wait to merge until @vince-fugnitto has given his approval as well 👍

Copy link
Member

@vince-fugnitto vince-fugnitto left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The changes work well for me when I verified the functionality, I only have a minor comment regarding the new menu item.

Signed-off-by: Thomas Mäder <[email protected]>
Copy link
Member

@vince-fugnitto vince-fugnitto left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The latest updates look good to me 👍
I confirmed that the functionality works well and as expected, and the new API is marked as supported.

throw new Error('There are not profiles registered');
}
if (profile instanceof ShellTerminalProfile) {
profile = profile.modify({ rootURI: cwd });
Copy link
Contributor

@colin-grant-work colin-grant-work Feb 17, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tsmaeder, I believe this should have just been modify({cwd}). rootURI is not a recognized field when these options are eventually passed into the TerminalWidgetFactory. As a consequence, running the new terminal command in a multi-root workspace ignores the user's selection of root and just goes with the first root no matter what. Alternatively, it should be converted to cwd when the widget is created.

Comment on lines +37 to +39
modify(options: IShellTerminalServerOptions): TerminalProfile {
return new ShellTerminalProfile(this.terminalService, { ...this.options, ...options });
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This operation is mostly bogus, because IShellTerminalServerOptions (the function arg) and TerminalWidgetOptions (the constructor argument type) have very little in common.

@tsmaeder
Copy link
Contributor Author

I think this is a leftover from prototype I did where I separated the code paths for shell terminals and other terminals (Pseudoterminal).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
terminal issues related to the terminal vscode issues related to VSCode compatibility
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[vscode] Support TerminalProfileProvider
5 participants