Skip to content

fix(tui): proactive mouse disable on ConPTY + /mouse toggle command#15488

Merged
OutThisLife merged 1 commit into
NousResearch:mainfrom
kevin-ho:fix/tui-mouse-toggle
Apr 25, 2026
Merged

fix(tui): proactive mouse disable on ConPTY + /mouse toggle command#15488
OutThisLife merged 1 commit into
NousResearch:mainfrom
kevin-ho:fix/tui-mouse-toggle

Conversation

@kevin-ho

Copy link
Copy Markdown

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/ ?1003h DECSET codes. The TUI enters alt screen on startup; the classic CLI does not.

The HERMES_TUI_DISABLE_MOUSE env 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:

  1. ConPTY fix — Proactively send DISABLE_MOUSE_TRACKING after entering the alternate screen when mouse tracking is off (AlternateScreen.tsx). This cancels ConPTY's implicit enable immediately.

  2. Runtime toggle — Add /mouse [on|off|toggle] slash command with config persistence (display.tui_mouse). The env var HERMES_TUI_DISABLE_MOUSE continues to work as the initial default but can now be overridden at runtime. Config persistence means the setting survives restarts.

  3. 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

File Change
ui-tui/packages/hermes-ink/src/ink/components/AlternateScreen.tsx Send DISABLE_MOUSE_TRACKING on mount when tracking is off
ui-tui/packages/hermes-ink/src/ink/ink.tsx Add setAltScreenMouseTracking() for runtime toggle
ui-tui/src/app/slash/commands/core.ts Add /mouse slash command
ui-tui/src/app/interfaces.ts Add mouseTracking to UiState
ui-tui/src/app/uiStore.ts Initialize mouseTracking from env var
ui-tui/src/app/useConfigSync.ts Hydrate from display.tui_mouse config
ui-tui/src/app.tsx Wire reactive mouseTracking from store
ui-tui/src/gatewayTypes.ts Add tui_mouse to config type
tui_gateway/server.py Add config.set/get mouse

Credits

Concept inspired by @OutThisLife's PR #13716 which addressed the same root issue.

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
@OutThisLife OutThisLife merged commit 6407b3d into NousResearch:main Apr 25, 2026
@alt-glitch alt-glitch added type/bug Something isn't working P2 Medium — degraded but workaround exists comp/tui Terminal UI (ui-tui/ + tui_gateway/) labels Apr 25, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

Supersedes #13716 (runtime /mouse toggle). May close #4064 (mouse support config toggle).

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/tui Terminal UI (ui-tui/ + tui_gateway/) P2 Medium — degraded but workaround exists type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants