[PR #9820] [MERGED] Split TermControl into a Core, Interactivity, and Control layer #27780

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

📋 Pull Request Information

Original PR: https://github.com/microsoft/terminal/pull/9820
Author: @zadjii-msft
Created: 4/14/2021
Status: Merged
Merged: 4/27/2021
Merged by: @undefined

Base: mainHead: dev/migrie/oop-core-interactivity-control


📝 Commits (10+)

  • 0bd30c2 Move everything to a fresh branch
  • b0f1fa4 fix some build breaks, because I was only playing in TerminalControl
  • 243867a Merge remote-tracking branch 'origin/main' into dev/migrie/oop-tear-apart-control
  • acf84f1 hey look it launches. But there's definitely a good amount of broken features O.o
  • 5e655ef I wasn't the murderer after all
  • 2402c59 Hokay, so that gets the control as a lib/dll split
  • 24765d7 its-all-coming-together.gif
  • 54f443b can I get a big woop woop from all my homies
  • 322d511 Fix the tests
  • 8f8cf59 Rename Microsoft.Terminal.TerminalControl to just Microsoft.Terminal.Control

📊 Changes

43 files changed (+3740 additions, -1711 deletions)

View changed files

📝 .github/actions/spelling/dictionary/apis.txt (+4 -0)
📝 .vscode/settings.json (+14 -1)
📝 .vscode/tasks.json (+4 -3)
📝 OpenConsole.sln (+2 -0)
📝 build/pipelines/templates/build-console-steps.yml (+3 -3)
📝 src/cascadia/TerminalApp/Pane.h (+1 -2)
📝 src/cascadia/TerminalApp/SettingsTab.h (+0 -2)
📝 src/cascadia/TerminalApp/TabManagement.cpp (+5 -0)
📝 src/cascadia/TerminalApp/TerminalPage.cpp (+36 -25)
📝 src/cascadia/TerminalApp/TerminalPage.h (+2 -2)
📝 src/cascadia/TerminalApp/TerminalTab.cpp (+59 -35)
📝 src/cascadia/TerminalApp/TerminalTab.h (+3 -0)
src/cascadia/TerminalControl/ControlCore.cpp (+1372 -0)
src/cascadia/TerminalControl/ControlCore.h (+240 -0)
src/cascadia/TerminalControl/ControlCore.idl (+16 -0)
src/cascadia/TerminalControl/ControlInteractivity.cpp (+531 -0)
src/cascadia/TerminalControl/ControlInteractivity.h (+142 -0)
src/cascadia/TerminalControl/ControlInteractivity.idl (+17 -0)
📝 src/cascadia/TerminalControl/EventArgs.cpp (+1 -0)
📝 src/cascadia/TerminalControl/EventArgs.h (+22 -17)

...and 23 more files

📄 Description

Summary of the Pull Request

Brace yourselves, it's finally here. This PR does the dirty work of splitting the monolithic TermControl into three components. These components are:

  • ControlCore: This encapsulates the Terminal instance, the DxEngine and Renderer, and the Connection. This is intended to everything that someone might need to stand up a terminal instance in a control, but without any regard for how the UX works.
  • ControlInteractivity: This is a wrapper for the ControlCore, which holds the logic for things like double-click, right click copy/paste, selection, etc. This is intended to be a UI framework-independent abstraction. The methods this layer exposes can be called the same from both the WinUI TermControl and the WPF control.
  • TermControl: This is the UWP control. It's got a Core and Interactivity inside it, which it uses for the actual logic of the terminal itself. TermControl's main responsibility is now

By splitting into smaller pieces, it will enable us to

  • write unit tests for the Core and Interactivity bits, which we desparately need
  • Combine ControlCore and ControlInteractivity in an out-of-proc core process in the future, to enable tab tearout.

However, we're not doing that work quite yet. There's still lots of work to be done to enable that, thought this is likely the biggest portion.

Ideally, this would just be methods moved wholesale from one file to another. Unfortunately, there are a bunch of cases where that didn't work as well as expected. Especially when trying to better enforce the boundary between the classes.

We've got a couple tests here that I've added. These are partially examples, and partially things I ran into while implementing this. A bunch of things from #7001 can go in now that we have this.

This PR is gonna be a huge pain to review - 38 files with 3,730 additions and 1,661 deletions is nothing to scoff at. It will also conflict 100% with anything that's targeting TermControl. I'm hoping we can review this over the course of the next week and just be done with it, and leave plenty of runway for 1.9 bugs in post.

References

PR Checklist

Detailed Description of the Pull Request / Additional comments

  • I don't love the names ControlCore and ControlInteractivity. Open to other names.
  • I added a ICoreState interface for "properties that come from the ControlCore, but consumers of the TermControl need to know". In the future, these will all need to be handled specially, because they might involve an RPC call to retrieve the info from the core (or cache it) in the window process.
  • I've added more EventArgs to make more events proper TypedEvents.
  • I've changed how the TerminalApp layer requests updated TaskbarProgress state. It doesn't need to pump TermControl to raise a new event anymore.
  • Something that snuck into this branch in the very long history is the switch to DCompositionCreateSurfaceHandle for the DxEngine. @miniksa wrote this originally in 30b8335, I'm just finally committing it here. We'll need that in the future for the out-of-proc stuff.
    • I reverted this in c113b65d9. We can revert that commit when we want to come back to it.
  • I've changed the acrylic handler a decent amount. But added tests!
  • All the ThrottledFunc things are left in TermControl. Some might be able to move down into core/interactivity, but once we figure out how to use a different kind of Dispatcher (because a UI thread won't necessarily exist for those components).
  • I've undoubtably messed up the merging of the locking around the appearance config stuff recently

Validation Steps Performed

I've got a rolling list in https://github.com/microsoft/terminal/issues/6842#issuecomment-810990460 that I'm updating as I go.


🔄 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/9820 **Author:** [@zadjii-msft](https://github.com/zadjii-msft) **Created:** 4/14/2021 **Status:** ✅ Merged **Merged:** 4/27/2021 **Merged by:** [@undefined](undefined) **Base:** `main` ← **Head:** `dev/migrie/oop-core-interactivity-control` --- ### 📝 Commits (10+) - [`0bd30c2`](https://github.com/microsoft/terminal/commit/0bd30c2a7a0d5ae2094432ee02adac78ef0019d8) Move everything to a fresh branch - [`b0f1fa4`](https://github.com/microsoft/terminal/commit/b0f1fa4d64d10924bcc8ab6013df503c3a0ec239) fix some build breaks, because I was only playing in TerminalControl - [`243867a`](https://github.com/microsoft/terminal/commit/243867aadc72d79d2a0ddce9788008886921391c) Merge remote-tracking branch 'origin/main' into dev/migrie/oop-tear-apart-control - [`acf84f1`](https://github.com/microsoft/terminal/commit/acf84f188fa9a41ebc6ae265de1b6bd97e609cba) hey look it launches. But there's definitely a good amount of broken features O.o - [`5e655ef`](https://github.com/microsoft/terminal/commit/5e655ef2d851fd9506486d5f91570428d9ff608d) I wasn't the murderer after all - [`2402c59`](https://github.com/microsoft/terminal/commit/2402c59f3da0062e2e297ef269affb93539d697a) Hokay, so that gets the control as a lib/dll split - [`24765d7`](https://github.com/microsoft/terminal/commit/24765d708a437c2c952cd300a0715cc716975cdf) its-all-coming-together.gif - [`54f443b`](https://github.com/microsoft/terminal/commit/54f443b17f29b89b80ef5db0e83cfce1a27116f7) can I get a big woop woop from all my homies - [`322d511`](https://github.com/microsoft/terminal/commit/322d511034ae4cb73ba740db6e37714a97b5787f) Fix the tests - [`8f8cf59`](https://github.com/microsoft/terminal/commit/8f8cf5996eb216c53cf9bc9e8eeda34078ef59b2) Rename Microsoft.Terminal.TerminalControl to just Microsoft.Terminal.Control ### 📊 Changes **43 files changed** (+3740 additions, -1711 deletions) <details> <summary>View changed files</summary> 📝 `.github/actions/spelling/dictionary/apis.txt` (+4 -0) 📝 `.vscode/settings.json` (+14 -1) 📝 `.vscode/tasks.json` (+4 -3) 📝 `OpenConsole.sln` (+2 -0) 📝 `build/pipelines/templates/build-console-steps.yml` (+3 -3) 📝 `src/cascadia/TerminalApp/Pane.h` (+1 -2) 📝 `src/cascadia/TerminalApp/SettingsTab.h` (+0 -2) 📝 `src/cascadia/TerminalApp/TabManagement.cpp` (+5 -0) 📝 `src/cascadia/TerminalApp/TerminalPage.cpp` (+36 -25) 📝 `src/cascadia/TerminalApp/TerminalPage.h` (+2 -2) 📝 `src/cascadia/TerminalApp/TerminalTab.cpp` (+59 -35) 📝 `src/cascadia/TerminalApp/TerminalTab.h` (+3 -0) ➕ `src/cascadia/TerminalControl/ControlCore.cpp` (+1372 -0) ➕ `src/cascadia/TerminalControl/ControlCore.h` (+240 -0) ➕ `src/cascadia/TerminalControl/ControlCore.idl` (+16 -0) ➕ `src/cascadia/TerminalControl/ControlInteractivity.cpp` (+531 -0) ➕ `src/cascadia/TerminalControl/ControlInteractivity.h` (+142 -0) ➕ `src/cascadia/TerminalControl/ControlInteractivity.idl` (+17 -0) 📝 `src/cascadia/TerminalControl/EventArgs.cpp` (+1 -0) 📝 `src/cascadia/TerminalControl/EventArgs.h` (+22 -17) _...and 23 more files_ </details> ### 📄 Description ## Summary of the Pull Request Brace yourselves, it's finally here. This PR does the dirty work of splitting the monolithic `TermControl` into three components. These components are: * `ControlCore`: This encapsulates the `Terminal` instance, the `DxEngine` and `Renderer`, and the `Connection`. This is intended to everything that someone might need to stand up a terminal instance in a control, but without any regard for how the UX works. * `ControlInteractivity`: This is a wrapper for the `ControlCore`, which holds the logic for things like double-click, right click copy/paste, selection, etc. This is intended to be a UI framework-independent abstraction. The methods this layer exposes can be called the same from both the WinUI TermControl and the WPF control. * `TermControl`: This is the UWP control. It's got a Core and Interactivity inside it, which it uses for the actual logic of the terminal itself. TermControl's main responsibility is now By splitting into smaller pieces, it will enable us to * write unit tests for the `Core` and `Interactivity` bits, which we desparately need * Combine `ControlCore` and `ControlInteractivity` in an out-of-proc core process in the future, to enable tab tearout. However, we're not doing that work quite yet. There's still lots of work to be done to enable that, thought this is likely the biggest portion. Ideally, this would just be methods moved wholesale from one file to another. Unfortunately, there are a bunch of cases where that didn't work as well as expected. Especially when trying to better enforce the boundary between the classes. We've got a couple tests here that I've added. These are partially examples, and partially things I ran into while implementing this. A bunch of things from #7001 can go in now that we have this. This PR is gonna be a huge pain to review - 38 files with 3,730 additions and 1,661 deletions is nothing to scoff at. It will also conflict 100% with anything that's targeting `TermControl`. I'm hoping we can review this over the course of the next week and just be done with it, and leave plenty of runway for 1.9 bugs in post. ## References * In pursuit of #1256 * Proc Model: #5000 * https://github.com/microsoft/terminal/projects/5 ## PR Checklist * [x] Closes #6842 * [x] Closes https://github.com/microsoft/terminal/projects/5#card-50760249 * [x] Closes https://github.com/microsoft/terminal/projects/5#card-50760258 * [x] I work here * [x] Tests added/passed * [n/a] Requires documentation to be updated ## Detailed Description of the Pull Request / Additional comments * I don't love the names `ControlCore` and `ControlInteractivity`. Open to other names. * I added a `ICoreState` interface for "properties that come from the `ControlCore`, but consumers of the `TermControl` need to know". In the future, these will all need to be handled specially, because they might involve an RPC call to retrieve the info from the core (or cache it) in the window process. * I've added more `EventArgs` to make more events proper `TypedEvent`s. * I've changed how the TerminalApp layer requests updated TaskbarProgress state. It doesn't need to pump TermControl to raise a new event anymore. * ~~Something that snuck into this branch in the very long history is the switch to `DCompositionCreateSurfaceHandle` for the `DxEngine`. @miniksa wrote this originally in 30b8335, I'm just finally committing it here. We'll need that in the future for the out-of-proc stuff.~~ * I reverted this in c113b65d9. We can revert _that_ commit when we want to come back to it. * I've changed the acrylic handler a decent amount. But added tests! * All the `ThrottledFunc` things are left in `TermControl`. Some might be able to move down into core/interactivity, but once we figure out how to use a different kind of Dispatcher (because a UI thread won't necessarily exist for those components). * I've undoubtably messed up the merging of the locking around the appearance config stuff recently ## Validation Steps Performed I've got a rolling list in https://github.com/microsoft/terminal/issues/6842#issuecomment-810990460 that I'm updating as I go. --- <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:24:12 +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#27780