[PR #12938] [CLOSED] Add support for running the terminal core as a content process #29310

Open
opened 2026-01-31 09:34:10 +00:00 by claunia · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/microsoft/terminal/pull/12938
Author: @zadjii-msft
Created: 4/19/2022
Status: Closed

Base: mainHead: dev/migrie/oop/2/infinity-war


📝 Commits (10+)

  • e168413 I think this merges the-whole-thing into this branch. The remote control doesn't render right, but I think that's because the actual HEAD of all this work is in connection-factory
  • bb49d50 I believe this merges the buisness of connection-factory, though there are many issues.
  • 7731f59 Some comments because everything is hard
  • 996c71a Add a signal that the content can use to tell the window it's ready
  • 2f23e1f A close button, and more logging
  • c3a9445 some short-circuits for these inits, to make them more stable
  • 7e792b2 You know, there's 0% chance that this is the right pattern for this, but it works
  • 5a07282 Add a kill button for manually killing the content
  • 3d15b09 This works to kill the content and have the app live
  • ea9d3cb a fix for a crash when closing

📊 Changes

48 files changed (+1896 additions, -728 deletions)

View changed files

📝 .github/actions/spelling/README.md (+1 -0)
📝 .github/actions/spelling/advice.md (+1 -1)
📝 .github/actions/spelling/allow/allow.txt (+10 -2)
📝 .github/actions/spelling/allow/apis.txt (+5 -4)
.github/actions/spelling/candidate.patterns (+523 -0)
📝 .github/actions/spelling/excludes.txt (+27 -11)
📝 .github/actions/spelling/expect/alphabet.txt (+0 -7)
📝 .github/actions/spelling/expect/expect.txt (+90 -607)
📝 .github/actions/spelling/expect/web.txt (+0 -2)
📝 .github/actions/spelling/line_forbidden.patterns (+28 -2)
📝 .github/actions/spelling/patterns/patterns.txt (+56 -1)
📝 .github/actions/spelling/reject.txt (+4 -23)
📝 .github/workflows/spelling2.yml (+96 -8)
📝 scratch/ScratchIslandApp/Package/Package.wapproj (+2 -2)
📝 scratch/ScratchIslandApp/SampleApp/MyPage.cpp (+214 -2)
📝 scratch/ScratchIslandApp/SampleApp/MyPage.h (+8 -1)
📝 scratch/ScratchIslandApp/SampleApp/MyPage.xaml (+32 -6)
📝 scratch/ScratchIslandApp/SampleApp/SampleAppLib.vcxproj (+2 -2)
📝 scratch/ScratchIslandApp/SampleApp/dll/SampleApp.vcxproj (+2 -2)
📝 scratch/ScratchIslandApp/WindowExe/SampleIslandWindow.cpp (+2 -2)

...and 28 more files

📄 Description

Summary of the Pull Request

This is 1000% WIP work. This PR, however, can go in now before the rest of tear out is ready. It's gated behind a new velocity flag that only enables it for Dev builds. Terminal the app also provides no way to leverage this quite yet, but it is hooked up for the sample app.

Adds an undocumented --content parameter to wt which allows you to pass a content GUID on the commandline. When you do that, wt will start up as a content process, instead of as a window process. WT will serve a singular terminal control instance, which can be accessed with

winrt::create_instance<winrt::Microsoft::Terminal::Control::ContentProcess>(contentGuid, CLSCTX_LOCAL_SERVER);

This content process will hang around until the last outstanding reference to it is closed.

PR Checklist

Detailed Description of the Pull Request / Additional comments

Multiple different clients can access the same content process by simply communicating the GUID. That's obviously not recommended to do simultaneously, cause you'd have to keep the controls exactly the same size, but it's something that's possible.

Theoretically, we need to gate access to _interactivity and to _core behind some sort of safer accessor that won't just throw when the content process has died unexpectedly. A prototype was started in dev/migrie/oop/2/cptn-marvel, but that can definitely wait. Best to get this section of the merge conflicts done with now.

  • We've added a Control.ContentProcess class, which is responsible for owning a single ControlInteractivity bound to a GUID. You can use ContentProcess.RequestSwapChainHandle to get the swapchain of that content process.
    • this includes the TermControlContentManagement.cpp, which handles the TermControl side of connecting to one of these.
  • We've had to re-wire some InteractivityAutomationPeer methods, because we couldn't have a XAML AutomationPeer in the content process without XAML. I've checked that this still works in narrator and accessibility insights.
  • There's another file in WindowsTerminal for ContentProcessMain, for handling all the weird lifetime semantics of the content process.

Validation Steps Performed

It works pretty cool in the scratch sln.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/microsoft/terminal/pull/12938 **Author:** [@zadjii-msft](https://github.com/zadjii-msft) **Created:** 4/19/2022 **Status:** ❌ Closed **Base:** `main` ← **Head:** `dev/migrie/oop/2/infinity-war` --- ### 📝 Commits (10+) - [`e168413`](https://github.com/microsoft/terminal/commit/e168413e9fdf4313af208fee2d7f15afc1c781a6) I think this merges `the-whole-thing` into this branch. The remote control doesn't render right, but I think that's because the actual HEAD of all this work is in `connection-factory` - [`bb49d50`](https://github.com/microsoft/terminal/commit/bb49d5086c589f5a9dcc921308d8fafe55702190) I believe this merges the buisness of `connection-factory`, though there are many issues. - [`7731f59`](https://github.com/microsoft/terminal/commit/7731f5943ace5dd964a82b923ab40b3d5d084565) Some comments because everything is hard - [`996c71a`](https://github.com/microsoft/terminal/commit/996c71a93317581258b9991f799cb8aa84856f9a) Add a signal that the content can use to tell the window it's ready - [`2f23e1f`](https://github.com/microsoft/terminal/commit/2f23e1fc0c5369dfcbfd5a1a90e27e3418731c37) A close button, and more logging - [`c3a9445`](https://github.com/microsoft/terminal/commit/c3a94454e0952f0532c85e492dc20b3f17af6eb7) some short-circuits for these inits, to make them more stable - [`7e792b2`](https://github.com/microsoft/terminal/commit/7e792b2b5e8eced4b4f611fbeb82126a147bbde2) You know, there's 0% chance that this is the right pattern for this, but it _works_ - [`5a07282`](https://github.com/microsoft/terminal/commit/5a07282d19fc4fcfb14d187697f9c47399bd0948) Add a kill button for manually killing the content - [`3d15b09`](https://github.com/microsoft/terminal/commit/3d15b097b772262113f02fbbbfc6d81c1fbf5926) This works to kill the content and have the app live - [`ea9d3cb`](https://github.com/microsoft/terminal/commit/ea9d3cb5f7358fd9efac09038de9532eee2745c2) a fix for a crash when closing ### 📊 Changes **48 files changed** (+1896 additions, -728 deletions) <details> <summary>View changed files</summary> 📝 `.github/actions/spelling/README.md` (+1 -0) 📝 `.github/actions/spelling/advice.md` (+1 -1) 📝 `.github/actions/spelling/allow/allow.txt` (+10 -2) 📝 `.github/actions/spelling/allow/apis.txt` (+5 -4) ➕ `.github/actions/spelling/candidate.patterns` (+523 -0) 📝 `.github/actions/spelling/excludes.txt` (+27 -11) 📝 `.github/actions/spelling/expect/alphabet.txt` (+0 -7) 📝 `.github/actions/spelling/expect/expect.txt` (+90 -607) 📝 `.github/actions/spelling/expect/web.txt` (+0 -2) 📝 `.github/actions/spelling/line_forbidden.patterns` (+28 -2) 📝 `.github/actions/spelling/patterns/patterns.txt` (+56 -1) 📝 `.github/actions/spelling/reject.txt` (+4 -23) 📝 `.github/workflows/spelling2.yml` (+96 -8) 📝 `scratch/ScratchIslandApp/Package/Package.wapproj` (+2 -2) 📝 `scratch/ScratchIslandApp/SampleApp/MyPage.cpp` (+214 -2) 📝 `scratch/ScratchIslandApp/SampleApp/MyPage.h` (+8 -1) 📝 `scratch/ScratchIslandApp/SampleApp/MyPage.xaml` (+32 -6) 📝 `scratch/ScratchIslandApp/SampleApp/SampleAppLib.vcxproj` (+2 -2) 📝 `scratch/ScratchIslandApp/SampleApp/dll/SampleApp.vcxproj` (+2 -2) 📝 `scratch/ScratchIslandApp/WindowExe/SampleIslandWindow.cpp` (+2 -2) _...and 28 more files_ </details> ### 📄 Description ## Summary of the Pull Request This is 1000% WIP work. This PR, however, can go in now before the rest of tear out is ready. It's gated behind a new velocity flag that only enables it for Dev builds. Terminal the app also provides no way to leverage this quite yet, but it is hooked up for the sample app. Adds an undocumented `--content` parameter to `wt` which allows you to pass a content GUID on the commandline. When you do that, `wt` will start up as a **content process**, instead of as a **window process**. WT will serve a singular terminal control instance, which can be accessed with ```c++ winrt::create_instance<winrt::Microsoft::Terminal::Control::ContentProcess>(contentGuid, CLSCTX_LOCAL_SERVER); ``` This content process will hang around until the last outstanding reference to it is closed. ## PR Checklist * [x] See #5000 * [x] I work here * [ ] Tests - probably should, yea. * [n/a] Requires documentation to be updated ## Detailed Description of the Pull Request / Additional comments Multiple different clients can access the same content process by simply communicating the GUID. That's obviously not recommended to do simultaneously, cause you'd have to keep the controls exactly the same size, but it's something that's possible. Theoretically, we need to gate access to `_interactivity` and to `_core` behind some sort of safer accessor that won't just throw when the content process has died unexpectedly. A prototype was started in `dev/migrie/oop/2/cptn-marvel`, but that can definitely wait. Best to get this section of the merge conflicts done with now. * We've added a `Control.ContentProcess` class, which is responsible for owning a single `ControlInteractivity` bound to a GUID. You can use `ContentProcess.RequestSwapChainHandle` to get the swapchain of that content process. - this includes the `TermControlContentManagement.cpp`, which handles the `TermControl` side of connecting to one of these. * We've had to re-wire some `InteractivityAutomationPeer` methods, because we couldn't have a XAML `AutomationPeer` in the content process _without XAML_. I've checked that this still works in narrator and accessibility insights. * There's another file in `WindowsTerminal` for `ContentProcessMain`, for handling all the weird lifetime semantics of the content process. ## Validation Steps Performed It works pretty cool in the scratch sln. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
claunia added the pull-request label 2026-01-31 09:34:10 +00:00
Sign in to join this conversation.
No Label pull-request
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#29310