Repository navigation
Description
Blocked by #300 — the MCP pointer rung. The encoder half unit-tests today
the waywheel_bytesalready does inpty::input; what nothing in the tree
can produce is the gesture itself against a real child, which is the half
that decides whether a TUI actually responds. #300 introduces the pointer
event path this encoder consumes.
What
Mouse clicks (and drag/motion) are never forwarded to the child process, so
mouse-mode apps like vim / less can't position the cursor on click.
Root cause
Only wheel notches are encoded to the PTY — wheel_bytes
(crates/pty/src/input.rs:146) handles SGR/X10 wheel reporting and
alternate-scroll. Button press/release/drag/motion are not encoded at all:
a left-press is consumed locally for text selection
(crates/app/src/shell/terminal/canvas.rs, around the SelectOp::Start arm)
and never reaches the child. So an app that enabled mouse reporting
(MOUSE_REPORT_CLICK / SGR_MOUSE in TermMode) gets wheel events but no
clicks.
Fix direction
- Extend
wheel_bytes' SGR/X10 encoder inpty::inputto press, release,
drag and motion. Do not write a second encoder beside it. - Gate on the app's mouse-reporting mode — reuse the existing
mode.intersects(MOUSE_REPORT_CLICK | MOUSE_MOTION | MOUSE_DRAG)gate rather
than adding another: when the child has mouse reporting on, forward
click/drag to the PTY and bypass local text selection; when off, keep the
current local-selection behaviour. - Extend the existing cell-addressed pointer path with button state — it is
not new.Event::ScrollViewportalready carries aScrollTarget::Wheel { col, row, lines }andSelectOpalready carries grid coordinates, both in
crates/core/src/app.rs. The risk here is a second copy, not a missing one.
Blast radius: not just vim (2026-09-05)
Re-read of crates/pty/src/input.rs: wheel_bytes (line 146) is still the
only mouse encoder in the tree. There is no press / release / drag / motion
encoding at all, on any path.
So the defect is not "vim clicks don't work" — it is the mouse button is
never reported to the child, ever. Every TUI that enables mouse reporting
gets wheel notches and nothing else:
| Surface | What breaks |
|---|---|
Claude Code /diff, /resume, and its menus |
clicking an entry does nothing |
| vim / neovim | cursor placement, clicking a split |
| lazygit, gitui, tig | pane and entry selection |
| less, man, fzf, htop | click-to-select |
tmux with mouse on |
pane click, drag-resize |
The Claude Code row is the one that matters for this product: termherd exists
to host Claude Code sessions, and one of Claude Code's own panels is
unusable with the mouse inside it. That is a stronger case for the severity
than the vim example the title carries.
Title updated accordingly; the fix direction below is unchanged.
Body corrected 2026-09-07 during a wrap pass. Four things: the blocked-by note
overstated what cannot be tested (the encoder half is unit-testable today); the
fix direction called the pointer event path new when it already exists and
needs extending; wheel_bytes was cited at crates/pty/src/lib.rs:834, which
#172 moved to crates/pty/src/input.rs:146, and shell/terminal.rs became a
directory in #168; and the What / Root cause / Fix direction sections were
stored with literal \n escapes, so they rendered as one run-on paragraph.
Activity
bastien-gallay commentedon Jul 11, 2026
Refactor prerequisites: #168 (C1
terminal/canvas.rs— mouse dispatch) and #172 (Dinput.rs— mouse-protocol encoding to the PTY).chore(planning): close the two gaps a merged board left open (#235)
[-]Vim mouse click not forwarded to the child process[/-][+]Mouse clicks are never forwarded to the child process (Claude Code /diff, vim, lazygit…)[/+]bastien-gallay commentedon Sep 5, 2026
Blocked by #300: the SGR encoder here consumes the pointer event path that ticket introduces, and #300 is also what makes this fix verifiable end to end rather than only at the
ptyunit level. #301 is the sibling chrome-pointer rung and blocks nothing here.docs: reconcile the follow-up count and the pointer seam with the code
docs: the MCP surface has six follow-ups, and #155 was never about vim (
The docs catch up with the pointer gap, and one type name that never …
feat(mcp): a pointer event reaches a session's terminal by cell (#311)
bastien-gallay commentedon Sep 16, 2026
Unblocked: #300 merged (#311). Starting on
fix+155-mouse-forward.Root cause, re-read against
mainat 9bed9b6pty::input::wheel_bytesis still the only mouse encoder; it gates onMOUSE_REPORT_CLICK | MOUSE_MOTION | MOUSE_DRAGand encodes buttons 64/65 only.TermCmd::Pointer(MCP: place a mouse event inside a session's terminal (cell-addressed) #300) reaches the terminal thread but goes straight toapply_pointer→ local selection; the child is never consulted.Message::Selectunconditionally,so even once the terminal thread forwards, a GUI click would still select locally.
Screenexposesbracketed_pastebut no mouse-mode bit, so neither the canvas nor theMCP shell can tell whether the child reads the mouse.
Shape of the fix
One predicate, three readers.
core::app::pointergainsMouseReporting { Click, Drag, Motion }(what the child asked for) andPointerEvent::route(Option<MouseReporting>) -> PointerRoute { Forward, Select(LocalGesture), Nothing }— the whole whether-rule, including "under any mouse mode the mouse belongs to the child,
so a bare drag selects nothing".
pty::input::mouse_reporting(TermMode)maps the modebits once;
Screen.mouse_reportingcarries it;wheel_byteskeeps its gate through it.wheel_bytes' SGR/X10 body becomes a sharedmouse_reportalso used bymouse_bytes(mode, PointerEvent)— press / release / drag / move,Click= press+release.No second encoder.
TermCmd::Pointerroutes with the live mode:Forward→ writebytes;
Select→pointer_selectwith the live offset;Nothing→ nothing.PointerOutcome::ForwardedbesideSelection/Ignored, read off thesession's last
Screen(same lag class as the bounds check).Message::TermPointer→Event::TerminalPointerwhen the route isForward; shift keeps the localselection (the xterm override), and the content-dependent gestures (double-click word,
shift-extend, link click) stay where they are.
Out of scope, noted for later: modifier bits in the report (no
modifierson theevent since #311's cleanup; comes back as one shared type when something needs it), and
folding the wheel into
PointerKind(its three-way scrollback / alt-scroll fallback hasno pointer equivalent).
Tests (red first)
core::app::pointerClickmode → press/release/click forward, drag/move nothing;Drag→ +drag;Motion→ everything. PBT: under any reporting,routeis neverSelect.pty::input\e[<0;5;3M, release\e[<0;5;3m, middle 1, right 2, drag 32+button, move 35, click = pair; X10\e[M+ biased bytes, release code 3; existingwheel_bytescases unchanged.pty::gridsnapshotreportsNone/Click/Drag/Motionafter DECSET 1000 / 1002 / 1003;apply_pointerunder mouse mode leaves the selection alone.app::shellpointer_action_*:forwardedunder a mouse-mode screen,ignoredfor a drag under click-only mode, selection unchanged when off.app::mcp::handlerpointer_str/ sweep case carriesforwarded.canvasTermPointernotSelect; shift+press still selects; drag underDrag, move underMotion, release all forward; right press forwards instead of pasting. Off: every existing test unchanged.