termreply

package
v1.9.30 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 22, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Active

func Active() bool

Active reports whether terminal replies should currently be discarded.

func Clear

func Clear()

Clear removes any active quarantine window. Intended for tests.

func QuarantineFor

func QuarantineFor(duration time.Duration)

QuarantineFor drops terminal reply traffic until the later of the existing deadline or now+duration.

Types

type Filter

type Filter struct {
	// contains filtered or unexported fields
}

Filter strips terminal-generated control replies from a byte stream while preserving ordinary keyboard input. It is stateful so replies split across reads are discarded without relying on terminal-specific payload strings.

func (*Filter) Active

func (f *Filter) Active() bool

Active reports whether the filter is carrying parser state across read boundaries.

func (*Filter) Consume

func (f *Filter) Consume(src []byte, armed bool, final bool) []byte

Consume filters a chunk of bytes. Escape-string replies (OSC/DCS/APC/PM/SOS) are discarded unconditionally — they have no keyboard overlap, so a human cannot produce them, and leaking them to the inner PTY has real-world failure modes (see #731: iTerm2 XTVERSION DCS leaking as `TERM2 3.6.10n` input into the wrapped agent).

CSI sequences are handled by final-byte whitelist:

  • Keyboard/mouse CSIs (arrows, Home/End, backtab, ~ keys, kitty CSI u, mouse M/m) always pass through so user input is never corrupted.
  • DA/DSR replies (final bytes c/n/R) always pass through so tmux can negotiate modifyOtherKeys with the host terminal (see #738: @Clean-Cole identified that swallowing DA1 collapsed Shift+Enter to bare CR in iTerm2 default profile).
  • Anything else is gated by armed: discarded during the quarantine window, preserved outside it.

If a reply started in a previous chunk, it continues to be discarded until it terminates even if armed is now false.

If final is true, any incomplete pending escape/CSI/SS3 sequence is flushed as literal input, while an incomplete discarded escape-string reply is dropped.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL