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

[DefApp] Document how it works #9462

Open
3 tasks
Tracked by #15065 ...
miniksa opened this issue Mar 12, 2021 · 26 comments
Open
3 tasks
Tracked by #15065 ...

[DefApp] Document how it works #9462

miniksa opened this issue Mar 12, 2021 · 26 comments
Labels
Area-DefApp Area-Server Down in the muck of API call servicing, interprocess communication, eventing, etc. Issue-Docs It's a documentation issue that really should be on MicrosoftDocs/Console-Docs Priority-2 A description (P2) Product-Conhost For issues in the Console codebase Product-Terminal The new Windows Terminal.
Milestone

Comments

@miniksa
Copy link
Member

miniksa commented Mar 12, 2021

@miniksa and @cinnamon-msft to document how this works.

_Originally posted by @miniksa in #7489

Tasks

@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 Mar 12, 2021
@miniksa miniksa self-assigned this Mar 12, 2021
@miniksa miniksa added Issue-Docs It's a documentation issue that really should be on MicrosoftDocs/Console-Docs Issue-Task It's a feature request, but it doesn't really need a major design. Product-Conhost For issues in the Console codebase Product-Terminal The new Windows Terminal. labels Mar 12, 2021
@miniksa miniksa added this to the Terminal v2.0 milestone Mar 12, 2021
@miniksa miniksa added Area-Server Down in the muck of API call servicing, interprocess communication, eventing, etc. and removed Issue-Task It's a feature request, but it doesn't really need a major design. labels Mar 12, 2021
@ghost ghost removed the Needs-Tag-Fix Doesn't match tag requirements label Mar 12, 2021
@miniksa miniksa removed the Needs-Triage It's a new issue that the core contributor team needs to triage at the next triage meeting label Mar 12, 2021
@driver1998
Copy link

driver1998 commented Mar 16, 2021

Implements the default application behavior and handoff mechanisms between console and terminal. The inbox portion is done already.

Could you hint us about what Windows version will support this feature?

@zadjii-msft
Copy link
Member

Windows 11? 🤣

I'm kidding, it'll probably be something above build 21336, but that's about as sure as we can be right now. Build numbers can change a lot as a feature makes its way up the source tree. This feature needs a lot more testing still, and we still need to finish the Terminal side of things before it will do anything. I'm sure when it's ready for folks to try out, you'll know 😉

DHowett pushed a commit that referenced this issue Mar 26, 2021
- Implements the default application behavior and handoff mechanisms
  between console and terminal. The inbox portion is done already. This
  adds the ability for our OpenConsole.exe to accept the incoming server
  connection from the Windows OS, stand up a PTY session, start the
  Windows Terminal as a listener for an incoming connection, and then
  send it the incoming PTY connection for it to launch a tab.
- The tab is launched with default settings at the moment.
- You must configure the default application using the `conhost.exe`
  propsheet or with the registry keys. Finishing the setting inside
  Windows Terminal will be a todo after this is complete. The OS
  Settings panel work to surface this setting is a dependency delivered
  by another team and you will not see it here.

## Validation Steps Performed
- [x] Manual adjust of registry keys to the delegation conhost/terminal
  behavior
- [x] Adjustment of the delegation options with the propsheet
- [x] Launching things from the run box manually and watching them show
  in Terminal
- [x] Launching things from shortcuts and watching them show in the
  Terminal   

Documentation on how it works will be a TODO post completion in #9462

References #7414 - Default Terminal spec

Closes #492
ghost pushed a commit that referenced this issue Apr 28, 2021
Implement dropdown menu for choosing a default terminal application from inside the Windows Terminal Settings UI

## PR Checklist
* [x] Closes #9463 
* [x] I work here.
* [x] Manual tests passed
* [x] MicrosoftDocs/terminal#314 (and cross reference #9462)

## Detailed Description of the Pull Request / Additional comments
- Adds dropdown menu and a template card for displaying the available default applications (using the same lookup code as the console property sheet `console.dll`)
- Adds model to TSM for adapting the data for display and binding on XAML
- Lookup occurs on every page reload. Persistence only happens on Save Changes.
- Manifest changed for Terminal to add capability to opt-out of registry redirection so we can edit this setting

## Validation Steps Performed
- [x] Flipped the menu and pressed Save Changes and launched cmd from run box... it moved between the two.
- [x] Flipped system theme from light to dark and ensured secondary color looked good
- [x] Flipped the status with a different mechanism (conhost propsheet) and then reopened settings page and confirmed it loaded the updated status
@just1a-person
Copy link

yes Windows 11

@LuanVSO
Copy link
Contributor

LuanVSO commented Jun 27, 2021

he wasn't kidding after all

@MatejKafka
Copy link

Quick question, is there a way to set a custom terminal by just setting a path to a binary in HKCU/Console/%%Startup (or somewhere else), or does the terminal emulator have to implement a COM server?

Using just a path would be nice for portable apps (not installed system-wide), and simplify adding support even for installed apps (currently, at least Alacritty seems unlikely to implement support due to the added complexity of a COM server (alacritty/alacritty#6036)).

@DHowett
Copy link
Member

DHowett commented May 30, 2023

The original mockups for "default terminal" config actually had two parts: "What console handles these requests?" "What terminal does it send them to?" and that's actually still how it works internally.

@CrendKing
Copy link

It'd be nice if we can use the portable Windows Terminal installation as default terminal. I suppose all the necessary components are already there on the disk, but only the "COM registration" part is missing.

@ysc3839
Copy link
Contributor

ysc3839 commented Sep 20, 2024

It looks like OpenConsoleProxy.dll is required to do marshaling.
If I implement terminal handoff in my app, and register OpenConsoleProxy.dll in HKEY_CLASSES_ROOT, would it conflict with the one in Windows Terminal?

@lhecker lhecker added the Needs-Discussion Something that requires a team discussion before we can proceed label Sep 23, 2024
@feeas
Copy link

feeas commented Oct 4, 2024

On a Windows 11 computer that does not have any version of Windows Terminal installed, is there a simple way to set the portable version of Windows Terminal as the Default Terminal?

@ysc3839
Copy link
Contributor

ysc3839 commented Oct 4, 2024

@feeas Yes. By modifying registry manually.

@feeas
Copy link

feeas commented Oct 4, 2024

@ysc3839 Can you further explain how to do it? I know that I may need to modify HKEY_CURRENT_USER\Console%%Startup, but the value inside does not point to an exe path.

@ysc3839
Copy link
Contributor

ysc3839 commented Oct 10, 2024

@feeas
Use this reg file to register COM components:

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\CLSID\{2EACA947-7F5F-4CFA-BA87-8F7FBEEFBE69}\LocalServer32]
@="C:\\terminal-1.21.2361.0\\OpenConsole.exe"

[HKEY_CLASSES_ROOT\CLSID\{E12CFF52-A866-4C77-9A90-F570A7AA2C6B}\LocalServer32]
@="C:\\terminal-1.21.2361.0\\WindowsTerminal.exe"

[HKEY_CLASSES_ROOT\CLSID\{3171DE52-6EFA-4AEF-8A9F-D02BD67E7A4F}\InprocServer32]
@="C:\\terminal-1.21.2361.0\\OpenConsoleProxy.dll"

[HKEY_CLASSES_ROOT\Interface\{59D55CCE-FC8A-48B4-ACE8-0A9286C6557F}\ProxyStubClsid32]
@="{3171DE52-6EFA-4AEF-8A9F-D02BD67E7A4F}"

[HKEY_CLASSES_ROOT\Interface\{746E6BC0-AB05-4E38-AB14-71E86763141F}\ProxyStubClsid32]
@="{3171DE52-6EFA-4AEF-8A9F-D02BD67E7A4F}"

[HKEY_CLASSES_ROOT\Interface\{AA6B364F-4A50-4176-9002-0AE755E7B5EF}\ProxyStubClsid32]
@="{3171DE52-6EFA-4AEF-8A9F-D02BD67E7A4F}"

[HKEY_CLASSES_ROOT\Interface\{E686C757-9A35-4A1C-B3CE-0BCC8B5C69F4}\ProxyStubClsid32]
@="{3171DE52-6EFA-4AEF-8A9F-D02BD67E7A4F}"

Note that you need to modify the file location.

Use this to unregister:

Windows Registry Editor Version 5.00

[-HKEY_CLASSES_ROOT\CLSID\{2EACA947-7F5F-4CFA-BA87-8F7FBEEFBE69}]

[-HKEY_CLASSES_ROOT\CLSID\{E12CFF52-A866-4C77-9A90-F570A7AA2C6B}]

[-HKEY_CLASSES_ROOT\CLSID\{3171DE52-6EFA-4AEF-8A9F-D02BD67E7A4F}]

[-HKEY_CLASSES_ROOT\Interface\{59D55CCE-FC8A-48B4-ACE8-0A9286C6557F}]

[-HKEY_CLASSES_ROOT\Interface\{746E6BC0-AB05-4E38-AB14-71E86763141F}]

[-HKEY_CLASSES_ROOT\Interface\{AA6B364F-4A50-4176-9002-0AE755E7B5EF}]

[-HKEY_CLASSES_ROOT\Interface\{E686C757-9A35-4A1C-B3CE-0BCC8B5C69F4}]

Use this to set default terminal for current user:

Windows Registry Editor Version 5.00

[HKEY_CURRENT_USER\Console\%%Startup]
"DelegationConsole"="{2EACA947-7F5F-4CFA-BA87-8F7FBEEFBE69}"
"DelegationTerminal"="{E12CFF52-A866-4C77-9A90-F570A7AA2C6B}"

@feeas
Copy link

feeas commented Oct 11, 2024

@ysc3839 Have you tested this reg file? I tested it on two PCs, but both failed. I can see Windows Command Processor and OpenConsole running in Task Manager, but no WindowsTerminal.exe is started. I can launch WindowsTerminal.exe directly, and I’ve confirmed that my path is correct.

edited: I resolved the issue by downgrading from version v1.22.2702.0 to v1.21.2701.0. Is this a problem with the new version of Windows Terminal? It's really strange.
No more issues now. Thank you very much for your registry. It was really helpful and also solved the issue with administrator scripts being unable to invoke Windows Terminal.

@CrendKing
Copy link

CrendKing commented Oct 11, 2024

Thank you @ysc3839 ! Those registry works for me. More interestingly, when I open a .cmd or .ps1 file, even though Windows Terminal shows up, from the task manager I can see there is still a cmd.exe there. So it seems like there is some proxying happened.

Also, Settings -> System -> For developers -> Terminal doesn't have Windows Terminal as a selectable.

@DHowett
Copy link
Member

DHowett commented Oct 11, 2024

I can see there is still a cmd.exe there

cmd.exe is the Command Prompt. You should only see it when you launch a .cmd file or Windows Command Prompt.

I suspect you are mixing up cmd (the shell) and conhost (the console).

Conhost is usually in charge of the window and the keyboard input. In the "default terminal" case, conhost is still running (there are some annoying reasons for this today) but it hands off to another instance of itself called OpenConsole. OpenConsole talks to Terminal.

@CrendKing
Copy link

I'm sorry I probably misremembered the case before. There is nothing weird about the registry method. Everything works as expected.

Is there any chance we can make it more official than a comment in an issue? I'm sure we can include this in the Scoop manifest and make the portable installation more smooth.

@ysc3839
Copy link
Contributor

ysc3839 commented Oct 11, 2024

@feeas Version 1.22 uses a new COM interface, I didn't add its interface id to the reg file.

@CrendKing The default terminal selection list requires packaged app (AppX or MSIX).

@CrendKing
Copy link

Do you mean we need a new reg for future versions?

@DHowett
Copy link
Member

DHowett commented Oct 12, 2024

You just need another interface entry,

{6F23DA90-15C5-4203-9DB0-64E73F1B1B00}

@CrendKing
Copy link

Thanks for the info. But this doesn't seem to be very future-proof. How to expect a normal user to find out all these obscure interface IDs, let alone to put them in registry? And one day there might be another new interface.

I feel this should be treated the same level as how portable mode is treated. The latter at least has a dedicated document page section to explain how it works. If a user is able to create a ".portable" file, surely they can run a "register_windows_terminal_as_default.ps1" if it is provided and maintained by the WT team, right?

@ysc3839
Copy link
Contributor

ysc3839 commented Oct 12, 2024

@CrendKing This is for third-party terminal developers to implement a "register as default terminal" function. It's not for end users.

@CrendKing
Copy link

I'm sorry if I sounded as it is for end user. I was talking about third-party package maintainers.
If I maintain the Scoop Windows Terminal manifest, I'd love to have official information on how to register the installed terminal as default, which is, as you can see, lacking in that manifest. It only contains creating the .portable file.

@feeas
Copy link

feeas commented Oct 12, 2024

@DHowett Could you tell me if adding this will make it work in version 1.22? I tried but it didn't work.

Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\Interface\{6F23DA90-15C5-4203-9DB0-64E73F1B1B00}\ProxyStubClsid32]
@="{3171DE52-6EFA-4AEF-8A9F-D02BD67E7A4F}"

@ysc3839
Copy link
Contributor

ysc3839 commented Oct 12, 2024

@feeas Currently 1.22 is Preview, its CLSID is different from normal version.

@carlos-zamora carlos-zamora added Priority-2 A description (P2) and removed Needs-Discussion Something that requires a team discussion before we can proceed Priority-1 A description (P1) labels Oct 21, 2024
@carlos-zamora carlos-zamora modified the milestones: Terminal v1.22, Backlog Oct 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-DefApp Area-Server Down in the muck of API call servicing, interprocess communication, eventing, etc. Issue-Docs It's a documentation issue that really should be on MicrosoftDocs/Console-Docs Priority-2 A description (P2) Product-Conhost For issues in the Console codebase Product-Terminal The new Windows Terminal.
Projects
None yet
Development

No branches or pull requests