[PR #14825] Split AppLogic into "App logic" and "Window logic" #30270

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

Original Pull Request: https://github.com/microsoft/terminal/pull/14825

State: closed
Merged: Yes


followed by: #14843

Map

And so begins the first chapter in the epic tale of the Terminal's tab tear-out. This commit, though humble in its nature, shall mark the beginning of a grand journey.
This initial offering, though small in its scope, doth serve to divide the code that currently resides within TerminalPage and AppLogic, moving it unto a new entity known as TerminalWindow. In the ages to come, these classes shall take on separate responsibilities, each with their own purpose.
The AppLogic shall hold sway over the entire process, shared among all Terminal windows, while the AppHost, TerminalWindow, and TerminalPage shall rule over each individual window.
This pull request prepares the way for the future, moving state that pertains to the individual windows into the TerminalWindow. This is a task of great labor, for it requires moving much code, but the end result shall bring greater organization to the codebase.
And so the stage is set, for in the next pull request, the Process Model v3 shall be revealed, unifying all Terminal windows into a single process, a grand accomplishment indeed.

courtesy of G.P.T. Tolkien

Or, as I wrote it originally.

This is the first of the commits in the long saga which will culminate in tab tear-out for the Terminal.

This the most functionally trivial of the PRs. It mostly just splits up code that's currently in TerminalPage & AppLogic, and moves it into a new class TerminalWindow. In the future, these classes will separate responsibility as such:

  • There will be one AppLogic per process, shared across all Terminal windows.
  • There will be one AppHost, TerminalWindow, and TerminalPage for each individual window in the process.

This PR prepares for that by moving some state that's applicable to individual windows into TerminalWindow. This is almost exclusively a code moving PR. There should be minimal functional changes.

In the next PR, we'll introduce the actual "Process Model v3", merging all Terminal windows into a single terminal process.

Related to #5000. See https://github.com/Microsoft/terminal/issues/5000#issuecomment-1407110045 for my current todo list.
Related to #1256.

These commits are all artificially broken down pieces. Honestly, I don't want to really merge them till they're all ready, so we know that the work e2e. This my feigned attempt to break it into digestable PRs.

Lightly manually tested, things seem to still all work? Most of this code was actually written in deeper branches, it was only today I realized it all needed to come back to this branch.

  • The window persistence fishy-ness of the subsequent PR isn't present here. So that's something.
  • Localtests still pass

Detailed description

Q: Does AppLogic not keep track of its windows?

Sure doesn't! I didn't think that was something it needed to know.

Q: Why does TerminalWindow (per-window) have access to the commandline args (per-process)

It's because it's not per process. Commandline args are per-window. Consider - you launch the Terminal, then run a wt -w -1 -- foo. That makes its own window. In this process, yes. But that new window has its own commandline args, separate from the ones that started the original process.

**Original Pull Request:** https://github.com/microsoft/terminal/pull/14825 **State:** closed **Merged:** Yes --- _followed by: #14843_ <sub> **Map** * [ ] #14825 &lt;---- **YOU ARE HERE** * [ ] #14843 * [ ] #14851 * [ ] #14866 * [ ] #14901 * [ ] #14935 </sub> _And so begins the first chapter in the epic tale of the Terminal's tab tear-out. This commit, though humble in its nature, shall mark the beginning of a grand journey._ _This initial offering, though small in its scope, doth serve to divide the code that currently resides within TerminalPage and AppLogic, moving it unto a new entity known as TerminalWindow. In the ages to come, these classes shall take on separate responsibilities, each with their own purpose._ _The AppLogic shall hold sway over the entire process, shared among all Terminal windows, while the AppHost, TerminalWindow, and TerminalPage shall rule over each individual window._ _This pull request prepares the way for the future, moving state that pertains to the individual windows into the TerminalWindow. This is a task of great labor, for it requires moving much code, but the end result shall bring greater organization to the codebase._ _And so the stage is set, for in the next pull request, the Process Model v3 shall be revealed, unifying all Terminal windows into a single process, a grand accomplishment indeed._ _courtesy of G.P.T. Tolkien_ <details> <summary>Or, as I wrote it originally. </summary> This is the first of the commits in the long saga which will culminate in tab tear-out for the Terminal. This the most functionally trivial of the PRs. It mostly just splits up code that's currently in TerminalPage & AppLogic, and moves it into a new class `TerminalWindow`. In the future, these classes will separate responsibility as such: * There will be one `AppLogic` per process, shared across all Terminal windows. * There will be one `AppHost`, `TerminalWindow`, and `TerminalPage` for each individual window in the process. This PR prepares for that by moving some state that's applicable to _individual windows_ into `TerminalWindow`. This is almost exclusively a code moving PR. There should be minimal functional changes. </details> In the next PR, we'll introduce the actual "Process Model v3", merging all Terminal windows into a single terminal process. Related to #5000. See https://github.com/Microsoft/terminal/issues/5000#issuecomment-1407110045 for my current todo list. Related to #1256. These commits are all artificially broken down pieces. Honestly, I don't want to really merge them till they're all ready, so we know that the work e2e. This my feigned attempt to break it into digestable PRs. Lightly manually tested, things seem to still all work? Most of this code was actually written in deeper branches, it was only today I realized it all needed to come back to this branch. * [x] The window persistence fishy-ness of the subsequent PR isn't present here. So that's something. * [x] Localtests still pass ### Detailed description > Q: Does `AppLogic` not keep track of its windows? Sure doesn't! I didn't think that was something it needed to know. >Q: Why does `TerminalWindow` (per-window) have access to the commandline args (per-process) It's because it's _not_ per process. Commandline args _are_ per-window. Consider - you launch the Terminal, then run a `wt -w -1 -- foo`. That makes its own window. In this process, yes. But that new window has its own commandline args, separate from the ones that started the original process.
claunia added the pull-request label 2026-01-31 09:39:41 +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#30270