lib/termInputGuard.ts

agentglass · web/src/lib/termInputGuard.ts · typescript · MIT
ui, tag:embed-classified

Filters terminal mouse input to avoid sending invalid reports.

// Source: https://github.com/SirAllap/agentglass | License: MIT | Copyright 2026 David Pallares (SirAllap)
// Provided via justclaw.it.com; keep this notice with the code.
/**
 * Keep a mouse report that was never a real one out of the shell.
 *
 * Measured in headless Chrome against the xterm this app ships: press inside a
 * terminal in mouse mode, take the terminal out of the document, release. The
 * press goes out as `ESC [ < 0 ; 3 ; 1 M` and the release as
 * `ESC [ < 0 ; NaN ; NaN m`. xterm reads the element's padding with
 * `parseInt(getComputedStyle(el).paddingLeft)`, and a detached element has no
 * computed style, so the answer is `NaN` and nothing downstream checks it.
 *
 * In the app that is a click on a link in the terminal that opens the card in
 * another view: the view 

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key