Update 'restart connection' action to reset internal state (#19971)
## Summary of the Pull Request I was becoming frustrated with getting in a state where a CLI app (i.e. Copilot CLI) enters some VT state (like mouse mode) then doesn't unset it when it accidentally exits. I normally use "Restart connection" to keep the buffer and connect again. Problem is, "restart connection" didn't actually reset the internal state! So I would type and get a bunch of lingering VT escape sequences. This bug is tracked over in #18425 in a more generic way. This fixes that bug by doing the following: - update `ITermDispatch::HardReset()` -->`HardReset(bool erase)` - `erase=true` does what `HardReset()` already did - `erase=false` skips over clearing the screen and resetting the cursor position - expose `HardReset(false)` as `HardResetWithoutErase()` by piping it up through `Terminal` --> `ControlCore` --> `TermControl` - update the restart connection handler - `TerminalPage::_restartPaneConnection()` now calls `HardResetWithoutErase()` before setting the new connection - this is also the same route for the "Enter to restart connection" scenario (text displayed when connection ends) Relevant notes from PR discussion: - `PSEUDOCONSOLE_INHERIT_CURSOR` is passed into the new connection via `_restartPaneConnection()` --> `_duplicateConnectionForRestart()` --> `_CreateConnectionFromSettings(profile, *controlSettings.DefaultSettings(), true)` ## Validation Steps Performed - Used this to enter mouse tracking mode: `Write-Host -NoNewline "`e[?1003h`e[?1006h"` - mouse selection doesn't work as usual (expected) - invoke "restart connection" action - mouse selection works as usual Closes #18425
C
Carlos Zamora committed
ec939aabda58b84b448cdd4589adbd8596b95f75
Parent: be5dcf8
Committed by GitHub <noreply@github.com>
on 3/30/2026, 11:25:12 PM