Repository navigation
Description
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.
Activity
j4james commentedon 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 commentedon Feb 6, 2021
James Holderness (@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:
What do you think?
skyline75489 commentedon Feb 6, 2021
This is what Mike Griese (@zadjii-msft) is recently working on.
awakecoding commentedon Feb 6, 2021
Got a link to a branch or related issue with the WIP code? 😲
skyline75489 commentedon Feb 6, 2021
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 commentedon Feb 6, 2021
Oh sorry about it. Didn’t noticed James already mentioned #8898. I was merely want to summon Mike Griese (@zadjii-msft). Bet he has something to say about this issue.
zadjii-msft commentedon Feb 8, 2021
Hey thanks for the great write up here. I think for the majority of cases, the
wt.exesommandline 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