CodeVetter
← All unpacks
CodeVetter · Repo Unpack evidence

microsoft/terminal

Scanned commit 7c92ecd037 dated 2026-09-18 — last upstream commit. Generated by codevetter 1.12.0 on 2026-09-22.

github.com/microsoft/terminal ↗ · 2428 files · 23.2 MB

Welcome to the Windows Terminal, Console and Command-Line repo Table of Contents - Installing and running Windows Terminal - [Microsoft Store \[Recommended\]](#microsoft-store-recommended) - Other install methods - Via GitHub - Via Windows Package Manager CLI

Deep analysis by swe-2 via the devin CLI on 2026-09-22 (runtime not recorded) — every claim below links to its cited source files.

Overview

This is the microsoft/terminal monorepo: it builds the Windows Terminal application (a WinUI 3 / C++/WinRT tabbed terminal emulator), the classic Windows console host (conhost.exe), and the shared components between them (VT parser, text buffer, renderers, types). Windows Terminal spawns client command-line apps through ConPTY pseudoconsoles, parses their VT output through a state machine into a text buffer, and renders with a Direct2D/Direct3D 'Atlas' engine. Distinctive aspects include a single-instance 'WindowEmperor' process model with WM_COPYDATA command-line handoff, a heavily layered JSON settings model with dynamic profile generators and third-party fragments, and an X-macro-driven action/keybinding system.

System map

The repo is one MSBuild workspace (OpenConsole.slnx) producing several binaries: WindowsTerminal.exe (the packaged terminal app, entrypoint in src/cascadia/WindowsTerminal/main.cpp), conhost.exe/OpenConsole.exe (src/host/exe), a wt.exe CLI shim, a shell extension, and many DLL/LIB components under src/cascadia and src/terminal. The terminal app is a Win32 process hosting WinUI 3 XAML islands; a single-instance 'WindowEmperor' owns all windows. Terminal functionality is layered: TerminalConnection (process/pipe IO) -> TerminalControl/ControlCore (XAML + renderer glue) -> TerminalCore (buffer + VT state machine) -> renderer/atlas (D3D text rendering). The conhost side lives under src/host and src/server and talks to the ConDrv driver. Build is MSBuild via tools/razzle.cmd + bcz.cmd or the OpenConsole.psm1 module; CI is Azure Pipelines (build/pipelines), with GitHub Actions only for release publishing and spell-checking.

All 14 system map claims →

Feature catalog

Windows Terminal's user-facing surface is a tabbed, split-pane terminal with profiles, color schemes, themes, keybindings ('actions'), a command palette, search, a GUI settings editor, a wt command line, session persistence, quake-mode summon, global hotkeys, and deep shell/OS integration (default-terminal handoff, 'Open in Terminal' explorer extension, jump lists, elevated tabs). The settings model supports dynamic profile generators (WSL, PowerShell, Azure Cloud Shell, Visual Studio, SSH hosts) and third-party JSON fragments/app-extensions. VT features include Sixel graphics, scroll marks, and custom HLSL pixel shaders in the Atlas renderer.

All 15 feature catalog claims →

Data flow

The core data path is bidirectional ConPTY pipes. Outbound: keystrokes travel XAML -> TermControl/ControlCore -> ITerminalConnection::WriteInput (UTF-16 to UTF-8, overlapped WriteFile on the ConPTY input pipe). Inbound: ConptyConnection's dedicated _OutputThread ReadFile's the output pipe and raises the TerminalOutput event; ControlCore::_connectionOutputHandler takes the terminal write lock and calls Terminal::Write -> StateMachine::ProcessString -> OutputStateMachineEngine -> ITermDispatch handlers that mutate TextBuffer rows; the Atlas renderer then paints the buffer. Settings flow from settings.json + inbox defaults.json + dynamic generators + fragments through SettingsLoader's layered ParsedSettings into CascadiaSettings, with a directory watcher triggering throttled reloads. Command lines flow through CLI11 parsing into ActionAndArgs vectors executed by ShortcutActionDispatch; between processes, whole invocations are serialized into WM_COPYDATA blobs.

All 13 data flow claims →

Behavior traces

Three load-bearing flows were traced end-to-end. (1) Process startup: wWinMain -> WindowEmperor::HandleCommandlineArgs does mutex-or-WM_COPYDATA handoff, loads settings via AppLogic::ReloadSettings -> CascadiaSettings::LoadAll, restores persisted windows, dispatches the command line into AppHost windows, then pumps a single message loop. (2) New tab: an action (keybinding/menu/CLI) reaches ShortcutActionDispatch::DoAction -> TerminalPage handlers -> _MakePane -> _CreateConnectionFromSettings (ConptyConnection) -> TermControl::_InitializeTerminal -> connection.Start() -> ConPTY + CreateProcessW -> _OutputThread -> TerminalOutput -> Terminal::Write. (3) Settings persistence: a wil::FolderChangeReader on the settings directory triggers ReloadSettingsThrottled -> _TryLoadSettings -> SettingsChanged event, which WindowEmperor and TerminalPage subscribe to for hot-reload of hotkeys, themes, and profiles.

Testing signals

Tests are TAEF-based C++ unit tests (TEST_CLASS/TEST_METHOD) plus WexTaef te.exe for the settings model, feature tests, a fuzzing harness, and a small C# WinAppDriver UIA suite. tools/runut.cmd enumerates the unit test DLLs: Conhost.Unit.Tests, TextBuffer.Unit.Tests, Terminal.Core.Unit.Tests, ConParser/ConAdapter.Unit.Tests, Types, til.unit.tests, Terminal.App.Unit.Tests, Control.Unit.Tests, TerminalApp.LocalTests, and SettingsModel.Unit.Tests. CI (Azure Pipelines) gates on code formatting and runs tests per-platform. Coverage is strong for settings serialization, the parser/adapter, buffer, and control core; the Win32 windowing layer (WindowEmperor/AppHost/IslandWindow) and remoting have no dedicated unit tests.

Risk map

The riskiest areas are cross-process trust boundaries and lifecycle races. The WM_COPYDATA handoff sends the entire environment block (potentially containing secrets) to an existing instance and parses a remote buffer — bounds-checked, but a real IPC attack surface. ConPTY spawn uses raw CreateProcessW with expanded environment and user-controlled profile commandlines. The defterm COM handoff accepts duplicated handles from other processes. The codebase repeatedly documents fragile threading invariants (STA-before-XAML, recursive ticket lock, output-thread join on Close, XAML islands quirks) — these are blast-radius hotspots. Telemetry (TraceLogging with Microsoft telemetry options) is pervasive and warrants privacy review on changes.

All 13 risk map claims →

Extension points

The codebase is built around explicit extension surfaces: the ALL_SHORTCUT_ACTIONS X-macro generates dispatch for every bindable action; ACTION_ARGS_STRUCT macros synthesize args classes with JSON keys; NewTabMenuEntry variants compose the new-tab menu; IDynamicProfileGenerator feeds discovered profiles; ITerminalConnection abstracts transports; IStateMachineEngine/ITermDispatch decouple the VT parser from its consumer; renderers are swappable behind the renderer/base interface; settings fragments + app extensions let third parties inject configuration; and features.xml adds staged feature flags. HwndTerminal/WpfTerminalControl expose the terminal as an embeddable control.

Contributor handoff

This is a Windows-only C++/WinRT + WinUI 3 codebase; you cannot build or run it on Linux/macOS. Read AGENTS.md first: the project has a strict AI-usage policy that bans most AI-authored public contributions and Co-authored-by AI credits. Build with tools/razzle.cmd + bcz (or OpenConsole.psm1 Invoke-OpenConsoleBuild), test with tools/runut.cmd (TAEF). Conventions: wil RAII + THROW_IF_*/RETURN_IF_* macros, til:: types, fmt, .idl files generate .g.cpp via cppwinrt (never edit generated files), settings changes follow doc/AddASetting.md, new actions go through the ALL_SHORTCUT_ACTIONS X-macro. Key traps: STA must precede XAML creation, don't hold static refs to ApplicationState in callbacks, first tab must be created synchronously, and WindowsTerminal.exe can't just be double-clicked when packaged.

Languages

LanguageFilesShare of source
C++67756%
C42935%
Markdown125docs/config
C#978%
JSON21docs/config
YAML9docs/config
Python50%
HTML2docs/config

Start reading here

Probable source entrypoint: src/ — inferred from the directory tree and manifest, not the upstream docs.

Source roots

src/ (2002 files)

Repository structure

Top-level pathFiles
src/2002
doc/101
scratch/73
samples/63
tools/41
oss/37
.github/33
dep/31

Docs found: AGENTS.mdCLAUDE.mdCONTRIBUTING.mdREADME.md

CI & config entrypoints

Structural health signals

Average score 7.8/10 across 96 analyzed source files; 18 hotspots surfaced.

These are deterministic review leads — size, churn, and structural signals — not proof of a bug in this project.

Recent history