Repository navigation
Description
The pointer rung of the #90 control surface, terminal half: let a caller place
a mouse event inside a session's terminal, the way run_in_session places
text there.
Why
Two gaps, and the second is the one that blocks work today.
- The act→wait→observe loop has no pointer.
press_keysandrun_action
drive termherd's own keyboard;run_in_sessiontypes into a PTY. Nothing
can click. Every mouse-mode TUI a session hosts — Claude Code's/diffand
/resume, lazygit, fzf, vim — is therefore unreachable to an agent, even
though its keyboard is not. - Mouse clicks are never forwarded to the child process (Claude Code /diff, vim, lazygit…) #155 cannot be verified by the agent that fixes it. That bug is the
mouse button is never encoded to the child. Its whole contract is a
pointer gesture, and no test in the tree can produce one: a unit test can
pinsgr_bytes(...)inpty, but the path click → pane →core→ PTY →
child stays a human check. Shipping the encoder blind is how a
platform-conditional or mode-gated mistake lands green.
Shape
One tool, cell-addressed — terminals are a grid, and a grid is what the SGR
report carries:
mouse_in_session(session, kind, col, row, button?, modifiers?)
kind: "press" | "release" | "click" | "drag" | "move"
col/roware 0-based cells in the visible screen, bounded by the pane's
reported geometry; out of range rejects the whole call, as a malformed chord
does forpress_keys.- The answer reports what the pane did with it, in the spirit of
press_keys'ran/inert/typed:forwarded(the child had mouse
reporting on and received a report),selection(reporting off, so it drove
local text selection),rejected(out of bounds). A caller must be able to
tell "the child ignored my click" from "termherd never sent one" — those
need opposite responses, exactly asinert'sreasondoes.
Ordering with #155
They share one seam and should not be built twice. This ticket introduces the
pointer event path — a core::Event carrying cell coordinates and button
state, through the shell to the focused pane — and exposes it over MCP; #155
introduces the SGR encoder in pty and the mode gate that decides between
forwarding and local selection, consuming that path. So this lands first (or
in the same PR, as its first commit), and #155 becomes verifiable at the
moment it is written rather than three merges later.
Local selection is the observable behaviour before #155 lands: a drag over
text that a subsequent copy action can read back. That is a real assertion,
so this rung has a test even standing alone.
Out of scope
The pointer at termherd's own chrome — sidebar rows, tab bar, split
gutters. Same family, different coordinate frame (pixels, not cells), and it
blocks nothing. Filed separately.
Activity
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 …
bastien-gallay commentedon Sep 16, 2026
Plan
Seam. The pointer path mirrors the wheel's, end to end: a cell-addressed
core::Event→Effect→PtyHostport method → the per-session terminalthread, which owns the grid and the mode. Nothing pixel-shaped enters
core.core::PointerEvent { kind, col, row, button, modifiers }—kindispress | release | click | drag | move;col/roware 0-based visiblecells (the tool's frame). The pty converts to a grid line with its live
display_offset, not a snapshot's.core::pointer_select(&PointerEvent, display_offset) -> Option<SelectOp>, decides what a pointer does locally: left press →Start,left drag →
Update, left click →Clear(a bare click drops thehighlight, as the canvas does), release / move / other buttons → nothing. The
pty applies it; the shell consults the same function to answer the caller —
so the outcome cannot drift from the behaviour.
Screen(
col < cols && row < rows); out of range, or a session not yet rendered,rejects the whole call before anything applies, as a malformed chord
does for
press_keys.{ focused_handle, pointer: "selection" | "ignored" }.forwardedis not produced by this rung — it arrives with Mouse clicks are never forwarded to the child process (Claude Code /diff, vim, lazygit…) #155, whichadds the mode gate and the SGR/X10 press encoder inside the same
TermCmd::Pointerarm, besidewheel_bytes. Adding the variant now would bea value nothing emits.
word, shift-extend, link click depend on screen content and pixel side); Mouse clicks are never forwarded to the child process (Claude Code /diff, vim, lazygit…) #155
routes its bare press/drag/release through the new path when the gate lands.
Tests (red first).
core:TerminalPointeron a live session yields oneTerminalPointereffect, on an unknown session none;
pointer_selecttable for everykind × button; property: the grid line is alwaysrow − display_offsetand the column is preserved, for any offset.
pty:TermCmd::Pointerpress+drag over a real grid leaves a selectionthat
CopySelectionreads back as the dragged text; a click clears it.orchestrate): unknown handle rejected, nothing forwarded; out ofbounds rejected naming the geometry, nothing forwarded; in-bounds press
forwards exactly one pointer to the PTY and answers
selection; amoveanswers
ignored; a press thencopyaction reads the selection throughthe existing chord path.
mcp/handler:mouse_in_sessionbuildsAction::Pointerfrom its args;an unknown
kind/buttonrejects before the bridge; the tool joins therouter-derived sweeps (structured content is an object) without an
exemption.
Book:
docs/src/mcp/live-bridge.mdgains the tool and loses the #300 row ofits open-gaps table; the roadmap entry flips when #155 follows.
[-]MCP: place a mouse event inside a session's terminal (cell-addressed) — blocks #155[/-][+]MCP: place a mouse event inside a session's terminal (cell-addressed)[/+]docs: the README and the book's tool count catch up with the pointer …