Skip to content

Enable Passthrough for VT Input Mode in ConPty - #4856

Merged
2 commits merged into
masterfrom
dev/cazamor/vtmm/dispatch-and-engine-changes
Mar 10, 2020
Merged

2 commits merged into
masterfrom
dev/cazamor/vtmm/dispatch-and-engine-changes

Conversation

@carlos-zamora

@carlos-zamora Carlos Zamora (carlos-zamora) commented Mar 9, 2020 •

Copy link
Copy Markdown

This commit enables passthrough mode for VT Input Mode in ConPty. This
will be used to pass VT Input from Mouse Mode directly to the app on the
other side.

References

#545 - VT Mouse Mode (Terminal)
#376 - VT Mouse Mode (ConPty)

Detailed Description of the Pull Request / Additional comments

ConHost

  • Set the callback for the InputEngine.
  • Retrieve IsInVirtualTerminalInputMode from the InputBuffer

Adapter (Dispatch)

Retrieve VTInputMode setting from ConHost

Parser

  • Add a callback to passthrough unknown input sequences directly to the
    input queue.
  • If we're in VTInputMode, use the callback

Validation Steps Performed

Tests should still pass.

@ghost ghost added the Needs-Author-Feedback The original author of the issue/PR needs to come back and respond to something label Mar 9, 2020

@zadjii-msft Mike Griese (zadjii-msft) left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

  1. I'm largely blocking on the same thing Dustin is
  2. We still need a function in conhost for "I'm in conpty mode, and the client app turned off VT input mode, I need to reset the Terminal's input mode", right?

@ghost ghost removed the Needs-Author-Feedback The original author of the issue/PR needs to come back and respond to something label Mar 10, 2020
if (isPty)
{
return false;
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

god, this API is needlessly verbose ;)

i hope when somebody fixes IsConsolePty to return a bool, they come fix all of these

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This same infrastructure is tested w/ statemachine and OSME; I am comfortable shipping this without a test. Mike?

@DHowett-MSFT Dustin L. Howett (MSFT) (DHowett-MSFT) added the AutoMerge Marked for automatic merge by the bot when requirements are met label Mar 10, 2020
@ghost

Copy link
Copy Markdown

Hello Dustin L. Howett (MSFT) (@DHowett-MSFT)!

Because this pull request has the AutoMerge label, I will be glad to assist with helping to merge this pull request once all check-in policies pass.

p.s. you can customize the way I help with merging this pull request, such as holding this pull request until a specific person approves. Simply @mention me (@msftbot) and give me an instruction to get started! Learn more here.

@ghost
ghost merged commit a5297fa into master Mar 10, 2020
@ghost
ghost deleted the dev/cazamor/vtmm/dispatch-and-engine-changes branch March 10, 2020 22:07
Abhijeet Viswam (abhijeetviswam) pushed a commit to abhijeetviswam/terminal that referenced this pull request Mar 12, 2020
This commit enables passthrough mode for VT Input Mode in ConPty. This
will be used to pass VT Input from Mouse Mode directly to the app on the
other side.

## References
microsoft#545 - VT Mouse Mode (Terminal)
microsoft#376 - VT Mouse Mode (ConPty)

## Detailed Description of the Pull Request / Additional comments

### ConHost
- Set the callback for the InputEngine.
- Retrieve `IsInVirtualTerminalInputMode` from the InputBuffer

### Adapter (Dispatch)
Retrieve `VTInputMode` setting from ConHost

### Parser
- Add a callback to passthrough unknown input sequences directly to the
  input queue.
- If we're in VTInputMode, use the callback

## Validation Steps Performed
Tests should still pass.
Dustin L. Howett (MSFT) (DHowett-MSFT) pushed a commit that referenced this pull request Mar 13, 2020
## Summary of the Pull Request
Make TerminalControl synthesize mouse events and Terminal send them to
the TerminalInput's MouseInput module.

The implementation here takes significant inspiration from how we handle
KeyEvents.

## References
Closes #545 - VT Mouse Mode (Terminal)
References #376 - VT Mouse Mode (ConPty)

### TerminalControl
- `_TrySendMouseEvent` attempts to send a mouse event via TermInput.
  Similar to `_TrySendKeyEvent`
- Use the above function to try and send the mouse event _before_
  deciding to modify the selection

### TerminalApi
- Hookup (re)setting the various modes to handle VT Input
- Terminal is _always_ in VT Input mode (important for #4856)

### TerminalDispatch
- Hookup (re)setting the various modes to handle VT Input

### TerminalInput
- Convert the mouse input position from viewport position to buffer
  position
- Then send it over to the MouseInput in TerminalInput to actually do it
  (#4848)

## Validation Steps Performed
Tests should still pass.
ghost pushed a commit that referenced this pull request Apr 1, 2020
…e's a problem in Win32 quite yet. (#5208)

## Summary of the Pull Request

When conpty is in VT input mode, we pass through all the input we receive. This includes all the other `Action*Dispatch` methods, but missed this one.

## References
* Missed during #4856 
* Discovered during the course of the #4192 review
* #5205 Also investigated part of the issue, but found a different bug.

## PR Checklist
* [x] Doesn't close anything, just related to above things.
* [x] I work here
* [ ] Tests added/passed
* [n/a] Requires documentation to be updated

## Detailed Description of the Pull Request / Additional comments
This will fix the <kbd>ctrl+alt+space</kbd> in the Terminal thing mentioned in #4192, but doesn't actually resolve the root cause of that bug (which is tracked in #5205).
Alistair Smith (alistair-bot) pushed a commit to oven-sh/bun that referenced this pull request Sep 20, 2026
…43457)

### Problem
- A child spawned with `Bun.spawn({ terminal })` on Windows 10 or
Windows Server 2019 writes `\x1b[?1000h\x1b[?1006h` and the sequences
never reach the `data` callback. The outer terminal never reports mouse
events, so the child never sees a click. Fixes #43450.
- The cause is the inbox ConPTY (conhost build 17763 through 19045). It
predates
[microsoft/terminal#4856](microsoft/terminal#4856),
the change that passes VT input mode enables through to the host. Bun
calls the kernel32 `CreatePseudoConsole`
(`src/runtime/api/bun/Terminal.rs:1170`) and has no way to swap the
console host.

### Fix
- This PR documents the gap and adds a test. It does not bundle
`conpty.dll` and does not add a `conptyDllPath` option. Every Windows
channel ships exactly `bun.exe`, and a public option that points at a
third-party DLL pair Bun does not ship is a permanent API surface for
one reporter. The repo's pattern for conhost 17763 quirks is a
build-scoped docs bullet plus a platform gap test, so this PR follows
it.
- Docs: one bullet in the Platform differences list of
`docs/runtime/child-process.mdx`. It names the affected versions, links
the upstream change, and notes that Windows 11 and Server 2022 relay the
sequences only after the child enables VT input mode
(`process.stdin.setRawMode(true)`) before it writes them.
- Test: `test/js/bun/terminal/terminal-platform-gaps.test.ts` gains a
test that spawns a child that enables raw mode, writes the two DECSET
sequences, and asserts they reach the `data` callback. It is a todo on
Windows builds before 20348 (Server 2022), so the Server 2019 lane skips
it and the Windows 11 lane checks the ordering claim in the docs.
- Verified: the test passes on Linux with the debug build and on Windows
11 (build 26100). On Windows Server 2019 (build 17763) it is todo, and
with `--todo` its body fails. Ran all of
`terminal-platform-gaps.test.ts` on all three.

### Background
- ConPTY is the Windows pseudo console. It renders the child's output to
a virtual screen inside conhost and emits VT sequences that describe the
result. It does not pass bytes through. A DECSET the child writes only
reaches the host if conhost chooses to forward it.
- Mouse tracking works by a handshake. The child writes `ESC[?1000h`
(report clicks) and `ESC[?1006h` (SGR encoding). The outer terminal then
writes mouse events to the child's stdin as `ESC[<b;x;yM`. If the enable
never reaches the outer terminal, no events flow.
- Windows 10 and Server 2019 share the 17763 to 19045 conhost line.
microsoft/terminal#4856 merged in March 2020 and shipped in Windows 11
and Server 2022 (build 20348 and later).

<details><summary>Notes</summary>

Probe on Windows 11 (build 26100, bun 1.4.3): with the child calling
`setRawMode(true)` before the DECSET, both sequences reach the `data`
callback. Without it, neither does. So the ordering note in the docs is
required, and the reporter's `child.mjs` (which writes the DECSET before
`setRawMode`) would fail on Windows 11 too.

Probe on Windows Server 2019 (build 17763): the sequences are absent in
both orderings. `ESC[?25l` (cursor hide) from the same child does
arrive, so the drop is specific to the input mode enables.

The todo threshold is build 20348 (Server 2022), the first inbox conhost
line that carries the upstream change. Windows 10 builds 19041 through
19045 share the older conhost and stay todo.

</details>
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area-VT Virtual Terminal sequence support AutoMerge Marked for automatic merge by the bot when requirements are met Product-Conpty For console issues specifically related to conpty

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants