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

Add protocol handler to open new tab in existing Windows Terminal #9061

Closed
awakecoding opened this issue Feb 6, 2021 · 8 comments
Closed
Labels
Issue-Feature Complex enough to require an in depth planning process and actual budgeted, scheduled work. Resolution-Duplicate There's another issue on the tracker that's pretty much the same thing.

Comments

@awakecoding
Copy link

awakecoding commented Feb 6, 2021

Description of the new feature/enhancement

Add a protocol handler (winterm://) to allow opening a new tab inside the existing Windows Terminal, instead of opening a new Windows Terminal. The current "Open in Windows Terminal" contextual menu option unfortunately always open a new Windows Terminal, instead of adding a new tab to the current one. The goal is to make it easier for third-party programs to implement richer "Open in Windows Terminal" functionality, where a new tab with a special profile is opened with an initial command injected. In our case, we intend to launch PowerShell remoting sessions from Remote Desktop Manager inside Windows Terminal. We currently supported embedded tabs inside Remote Desktop Manager, or we can launch the old boring blue PowerShell terminal externally. Since the old PowerShell terminal doesn't support tabs anyway, it has never been an issue.

Proposed technical implementation details

Regardless of the final name for the protocol handler (I suggest winterm://) the implementation is relatively simple: on startup, you check for the presence of an existing Windows Terminal instance. If there is one, you send the URL string passed through the protocol handler to the other process, and terminate. The receiving instance receives the URL and processes it to open a new tab with the specified profile id. We have implemented something like this to open new connections in our remote desktop program.

the URL string should contain at a bare minimum a profile id, and accept additional parameters following the same format found in settings.json:

winterm://34a13805-9b56-5e89-9234-f02de44bd971?name=Name?command=Command

Since addition parameters like the name and the command will likely contain characters causing trouble, I suggest that we either URL-encode them, or define them to always be encoded as UTF-8 base64url strings, whichever feels best.

The ideal solution would be to support temporary profiles, such that if the profile id doesn't exist, it could be created on-the-fly with all the parameters passed. This would be very useful as external programs could inject meaningful names, and even give a path to an icon file to use. In our case, system administrators can manage thousands of entries in Remote Desktop Manager, so everything that makes it easier to give identifying or distinctive information is a big win.

If we can have such a mechanism in place, we have everything we need for a possible integration, and nothing prevents other vendors from offering similar integration with relatively little effort. The good news is that it would also be relatively decoupled from Windows Terminal.

@awakecoding awakecoding added the Issue-Feature Complex enough to require an in depth planning process and actual budgeted, scheduled work. label Feb 6, 2021
@ghost ghost added Needs-Triage It's a new issue that the core contributor team needs to triage at the next triage meeting Needs-Tag-Fix Doesn't match tag requirements labels Feb 6, 2021
@j4james
Copy link
Collaborator

j4james commented Feb 6, 2021

This is very similar to issue #8898. Did you specifically require this implemented as a protocol handler, or would the solution proposed in #8898 be adequate?

@awakecoding
Copy link
Author

@j4james very interesting, it looks like the other issue is very similar to this one, with the exception of the protocol handler. I wouldn't mark it as duplicate, because the protocol handler would be usable to open a new tab from a browser-based password manager (we have those as well), but then the requirements are different, and we'd have to see how to properly handle security for the dynamic command injection.

I suggest we modify this feature request to be the protocol handler built on top of the other issue #8898, rather than the entire feature by itself. The goal would be to securely expose the same functionality but through a protocol handler instead.

I have a few ideas how security could be handled:

  • the profile could be preconfigured with a hard-coded command, and the profile id would need to be known in advance
  • a security warning could be shown to the user and the entire command presented in a dialog box before running it
  • the command could be signed by a certificate using something very similar to .rdp file signatures. A modern variant would be a JWT

What do you think?

@skyline75489
Copy link
Collaborator

This is what @zadjii-msft is recently working on.

@awakecoding
Copy link
Author

This is what @zadjii-msft is recently working on.

Got a link to a branch or related issue with the WIP code? 😲

@skyline75489
Copy link
Collaborator

There’s a bunch of related issues. For PR there’s #8898 , which may not be exact what you asked by is part of a grand plan.

@skyline75489
Copy link
Collaborator

Oh sorry about it. Didn’t noticed James already mentioned #8898. I was merely want to summon @zadjii-msft. Bet he has something to say about this issue.

@zadjii-msft
Copy link
Member

Hey thanks for the great write up here. I think for the majority of cases, the wt.exe sommandline args to invoke existing windows is going to be sufficient. However, you've got a great point about invoking the terminal from a browser window.

We've actually already started the discussion of a protocol handler over in #4842, so I'm gonna close this discussion as a dupe. I am going to make sure to call this thread out though, because it's got some great points. Thanks!

/dup #4842

@ghost
Copy link

ghost commented Feb 8, 2021

Hi! We've identified this issue as a duplicate of another one that already exists on this Issue Tracker. This specific instance is being closed in favor of tracking the concern over on the referenced thread. Thanks for your report!

@ghost ghost closed this as completed Feb 8, 2021
@ghost ghost added Resolution-Duplicate There's another issue on the tracker that's pretty much the same thing. and removed Needs-Triage It's a new issue that the core contributor team needs to triage at the next triage meeting Needs-Tag-Fix Doesn't match tag requirements labels Feb 8, 2021
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Issue-Feature Complex enough to require an in depth planning process and actual budgeted, scheduled work. Resolution-Duplicate There's another issue on the tracker that's pretty much the same thing.
Projects
None yet
Development

No branches or pull requests

4 participants