Skip to content

Implement wtcli, an application to query details about an existing Terminal instance - #20461

Open
PankajBhojwani wants to merge 13 commits into
mainfrom
dev/pabhoj/wtcli
Open

Implement wtcli, an application to query details about an existing Terminal instance#20461
PankajBhojwani wants to merge 13 commits into
mainfrom
dev/pabhoj/wtcli

Conversation

@PankajBhojwani

@PankajBhojwani PankajBhojwani commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

Summary of the Pull Request

Implements wtcli, a new command-line client for Windows Terminal Protocol: a local COM control surface that lets external processes inspect and drive a running Windows Terminal instance. It provides a tmux-style command vocabulary for the terminal.

wtcli currently exposes 10 commands:

  • Inspect: list-windows (lsw), list-tabs (lst), list-panes
    (lsp), active-pane, pane-status
  • Read output: capture-pane (capturep) — including --last-prompt to
    grab the most recent completed shell command via OSC 133 shell integration
  • Mutate: new-tab (neww), split-pane (splitw), kill-pane
    (killp), focus-pane (focusp)

Every command supports --json for machine-readable output, otherwise results are rendered as human-readable tables.

References and Relevant Issues

Detailed Description of the Pull Request / Additional comments

A client activates the server directly with CoCreateInstance using a per-brand CLSID (Release/Preview/Canary/Dev, selected at compile time), and issues typed commands.

Components:
1. wtcli.exe: the CLI client (src/tools/wtcli/)
The user-facing tool. Parses subcommands, activates the protocol server via WT_COM_CLSID, and calls the interface methods.

2. ITerminalProtocol: the classic-COM interface (src/host/proxy/ITerminalProtocol.idl)
The contract between client and Terminal. A classic-COM interface marshaled by the MIDL proxy/stub in OpenConsoleProxy.dll (registered per-brand in the app manifests). Scalar arguments stay typed; every complex result crosses the boundary as a JSON BSTR.

3. TerminalProtocolComServer: the in-proc server (src/cascadia/WindowsTerminal/)
Implements ITerminalProtocol inside WindowsTerminal.exe.

4. TerminalPage protocol bridge (src/cascadia/TerminalApp/TerminalPage.Protocol.cpp)
The UI-thread methods that actually query and mutate live terminal state (windows, tabs, panes, process status, pane output) and return typed results.

5. TerminalProtocol shared library (src/cascadia/TerminalProtocol/)
Hosts the shared WinRT struct types (WindowInfo, TabInfo, PaneInfo, etc) consumed in-process by both the page bridge and the server. Also provides ProtocolParsing.h, a header of parsing helpers (ParseSplitDirection, ClassifyPaneOutputSource) shared by the server and the fuzzer.

6. Protocol fuzzer (src/cascadia/TerminalProtocol/ft_fuzzer/)
A LibFuzzer harness targeting the parsing functions (ParseSplitDirection, ClassifyPaneOutputSource).

Validation Steps Performed

In a dev build of terminal, all 10 of the commands work

PR Checklist

  • Closes #xxx
  • Tests added/passed
  • Documentation updated
    • If checked, please file a pull request on our docs repo and link it here: #xxx
  • Schema updated (if necessary)

@github-advanced-security github-advanced-security AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

check-spelling found more than 20 potential problems in the proposed changes. Check the Files changed tab for more details.

@github-actions

This comment has been minimized.

@PankajBhojwani
PankajBhojwani marked this pull request as ready for review July 23, 2026 17:46
@github-actions

Copy link
Copy Markdown

check-spelling-bot Report

⚠️ Dictionary not found

Problems were encountered retrieving check dictionaries (cspell:cpp/src/compiler-gcc.txt cspell:ruby/dict/ruby.txt cspell:monkeyc/src/monkeyc_keywords.txt cspell:cpp/src/compiler-clang-attributes.txt cspell:ada/dict/ada.txt cspell:cpp/src/stdlib-cerrno.txt cspell:haskell/dict/haskell.txt cspell:fullstack/dict/fullstack.txt cspell:lua/dict/lua.txt cspell:svelte/dict/svelte.txt cspell:java/src/java-terms.txt cspell:cpp/src/people.txt cspell:cpp/src/stdlib-cpp.txt cspell:django/dict/django.txt cspell:scala/dict/scala.txt cspell:html/dict/html.txt cspell:java/src/java.txt cspell:sql/src/tsql.txt cspell:python/src/python/python.txt cspell:cpp/src/stdlib-cmath.txt cspell:software-terms/dict/webServices.txt cspell:dart/src/dart.txt cspell:swift/src/swift.txt cspell:cpp/src/ecosystem.txt cspell:cpp/src/compiler-msvc.txt cspell:public-licenses/src/generated/public-licenses.txt cspell:cpp/src/lang-jargon.txt cspell:php/dict/php.txt cspell:shell/dict/shell-all-words.txt cspell:r/src/r.txt cspell:python/src/common/extra.txt cspell:redis/dict/redis.txt cspell:cpp/src/stdlib-c.txt cspell:node/dict/node.txt cspell:k8s/dict/k8s.txt cspell:npm/dict/npm.txt cspell:public-licenses/src/additional-licenses.txt cspell:docker/src/docker-words.txt cspell:gaming-terms/dict/gaming-terms.txt cspell:cpp/src/template-strings.txt cspell:elixir/dict/elixir.txt cspell:software-terms/dict/softwareTerms.txt cspell:python/src/additional_words.txt cspell:sql/src/sql.txt cspell:css/dict/css.txt cspell:golang/dict/go.txt cspell:typescript/dict/typescript.txt cspell:powershell/dict/powershell.txt cspell:rust/dict/rust.txt cspell:python/src/python/python-lib.txt cspell:clojure/src/clojure.txt cspell:dotnet/dict/dotnet.txt cspell:cpp/src/lang-keywords.txt cspell:latex/dict/latex.txt).

⚠️ For more information, see check-dictionary-not-found.

🔴 Please review

See the 📂 files view, the 📜action log, 👼 SARIF report, or 📝 job summary for details.

Unrecognized words (15)
capturep
combase
CWin
DFX
focusp
killp
lsp
lsw
MBM
neww
splitw
submittable
wta
wtcli
yeelam
These words are not needed and should be removed NODEFAULT notif SND

To accept these unrecognized words as correct and remove the previously acknowledged and now absent words, you could run the following commands

... in a clone of the git@github.com:microsoft/terminal.git repository
on the dev/pabhoj/wtcli branch (ℹ️ how do I use this?):

curl -s -S -L 'https://raw.githubusercontent.com/check-spelling/check-spelling/cfb6f7e75bbfc89c71eaa30366d0c166f1bd9c8c/apply.pl' |
perl - 'https://github.com/microsoft/terminal/actions/runs/30030838668/attempts/1' &&
git commit -m 'Update check-spelling metadata'
Available 📚 dictionaries could cover words (expected and unrecognized) not in the 📘 dictionary

This includes both expected items (2016) from .github/actions/spelling/expect/alphabet.txt .github/actions/spelling/expect/expect.txt .github/actions/spelling/expect/web.txt and unrecognized words (15)

Dictionary Entries Covers Uniquely
cspell:csharp/csharp.txt 32 2 2
cspell:aws/aws.txt 232 2 2
cspell:fonts/fonts.txt 536 1 1

Consider adding to the extra_dictionaries array (in the .github/actions/spelling/config.json file):

    "cspell:csharp/csharp.txt",
    "cspell:aws/aws.txt",
    "cspell:fonts/fonts.txt",

To stop checking additional dictionaries, put (in the .github/actions/spelling/config.json file):

"check_extra_dictionaries": []
Errors and Warnings ❌ (2)

See the 📂 files view, the 📜action log, 👼 SARIF report, or 📝 job summary for details.

❌ Errors and Warnings Count
⚠️ check-dictionary-not-found 54
❌ check-file-path 6

See ❌ Event descriptions for more information.

✏️ Contributor please read this

By default the command suggestion will generate a file named based on your commit. That's generally ok as long as you add the file to your commit. Someone can reorganize it later.

If the listed items are:

  • ... misspelled, then please correct them instead of using the command.
  • ... names, please add them to .github/actions/spelling/allow/names.txt.
  • ... APIs, you can add them to a file in .github/actions/spelling/allow/.
  • ... just things you're using, please add them to an appropriate file in .github/actions/spelling/expect/.
  • ... tokens you only need in one place and shouldn't generally be used, you can add an item in an appropriate file in .github/actions/spelling/patterns/.

See the README.md in each directory for more information.

🔬 You can test your commits without appending to a PR by creating a new branch with that extra change and pushing it to your fork. The check-spelling action will run in response to your push -- it doesn't require an open pull request. By using such a branch, you can limit the number of typos your peers see you make. 😉

If the flagged items are 🤯 false positives

If items relate to a ...

  • binary file (or some other file you wouldn't want to check at all).

    Please add a file path to the excludes.txt file matching the containing file.

    File paths are Perl 5 Regular Expressions - you can test yours before committing to verify it will match your files.

    ^ refers to the file's path from the root of the repository, so ^README\.md$ would exclude README.md (on whichever branch you're using).

  • well-formed pattern.

    If you can write a pattern that would match it,
    try adding it to the patterns.txt file.

    Patterns are Perl 5 Regular Expressions - you can test yours before committing to verify it will match your lines.

    Note that patterns can't match multiline strings.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants