fix(tui): proactive mouse disable on ConPTY + /mouse toggle command#15488
Merged
Conversation
On Windows WSL2, ConPTY implicitly enables mouse event injection when the alternate screen buffer (DEC 1049) is entered, causing raw escape sequences to appear in the transcript as ghost characters. Fix (two parts): 1. ConPTY fix: send DISABLE_MOUSE_TRACKING immediately after entering alt screen when mouse tracking is off (AlternateScreen.tsx) 2. Runtime toggle: add /mouse [on|off|toggle] slash command with config persistence (display.tui_mouse) so users can manage this at runtime The env var HERMES_TUI_DISABLE_MOUSE continues to work as the initial default, but can now be overridden via /mouse and persisted to config. Closes: upstream ConPTY mouse injection issue Credits: OutThisLife / PR NousResearch#13716 for the toggle concept
Collaborator
ulasbilgen
pushed a commit
to ulasbilgen/hermes-adhd-agent
that referenced
this pull request
May 1, 2026
fix(tui): proactive mouse disable on ConPTY + /mouse toggle command
02356abc
pushed a commit
to 02356abc/hermes-agent
that referenced
this pull request
May 14, 2026
fix(tui): proactive mouse disable on ConPTY + /mouse toggle command
dannyJ848
pushed a commit
to dannyJ848/hermes-agent
that referenced
this pull request
May 17, 2026
fix(tui): proactive mouse disable on ConPTY + /mouse toggle command
gweeteve
pushed a commit
to gweeteve/hermes-agent
that referenced
this pull request
Jun 2, 2026
fix(tui): proactive mouse disable on ConPTY + /mouse toggle command
Egavasyug
pushed a commit
to Egavasyug/hermes-agent
that referenced
this pull request
Jun 10, 2026
fix(tui): proactive mouse disable on ConPTY + /mouse toggle command
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
On Windows WSL2, moving the mouse or using the scroll wheel while the Hermes TUI is active injects raw escape sequences (e.g.
<35;col;row M>) into the chat transcript as ghost characters. This is reproducible in any terminal that uses ConPTY for WSL2 (Windows Terminal, Termius, etc.).Root Cause
ConPTY implicitly enables mouse event injection when the alternate screen buffer (DEC 1049) is entered, even without explicit
?1000h/?1003hDECSET codes. The TUI enters alt screen on startup; the classic CLI does not.The
HERMES_TUI_DISABLE_MOUSEenv var correctly prevents Hermes from sending mouse enable sequences, but since ConPTY's implicit enable is never explicitly countered, the injection still occurs.Fix
Two parts:
ConPTY fix — Proactively send
DISABLE_MOUSE_TRACKINGafter entering the alternate screen when mouse tracking is off (AlternateScreen.tsx). This cancels ConPTY's implicit enable immediately.Runtime toggle — Add
/mouse [on|off|toggle]slash command with config persistence (display.tui_mouse). The env varHERMES_TUI_DISABLE_MOUSEcontinues to work as the initial default but can now be overridden at runtime. Config persistence means the setting survives restarts.Runtime Ink API — Added
setAltScreenMouseTracking(enabled)to the Ink instance so the toggle can update the terminal immediately mid-session (not just on next alt screen entry).Files Changed
ui-tui/packages/hermes-ink/src/ink/components/AlternateScreen.tsxui-tui/packages/hermes-ink/src/ink/ink.tsxui-tui/src/app/slash/commands/core.tsui-tui/src/app/interfaces.tsui-tui/src/app/uiStore.tsui-tui/src/app/useConfigSync.tsui-tui/src/app.tsxui-tui/src/gatewayTypes.tstui_gateway/server.pyCredits
Concept inspired by @OutThisLife's PR #13716 which addressed the same root issue.