Summary
Tessera already supports emitting ED3 (CSI 3 J) via:
.eraseInDisplay(.allAndScrollback)
and tests both the exact encoding and Ghostty behavior. However, TerminalCapabilities does not currently expose whether scrollback erase is advertised/supported.
This came up while reviewing OMP's new tui.resizeScrollback behavior, where ED3 is used for rebuilding terminal scrollback after width changes. It highlighted that Tessera has the primitive, but not capability metadata for deciding when it is appropriate to rely on.
Current state
EraseMode.allAndScrollback maps to ED3 (CSI 3 J).
ANSIEncoderTests verifies the exact bytes.
- A Ghostty-backed virtual-terminal test verifies that ED3 purges scrollback without clearing visible cells.
TerminalCapabilities tracks modern protocol support, terminal identity, nesting, underline declarations, etc., but has no ED3/scrollback-erase field.
TerminfoDatabase already parses ncurses extended string capabilities, currently for Smulx and Setulc.
Suggestion
Extend the existing terminfo declaration infrastructure to inspect the ncurses E3 capability and surface it as advisory metadata.
For example, either generalize the existing underline-specific declaration structure:
public struct TerminfoDeclarations: Equatable, Sendable {
public var extendedUnderlineStyle: TerminfoCapabilityDeclaration
public var underlineColor: TerminfoCapabilityDeclaration
public var eraseScrollback: TerminfoCapabilityDeclaration
}
or add an equivalent narrowly scoped field while preserving the current API shape.
E3 should map to the same declaration states Tessera already uses:
.declared
.notDeclared
.unknown
I would avoid treating TERM_PROGRAM=Ghostty, TERM=xterm-*, etc. as proof of ED3 support. Tessera's existing capability philosophy is appropriately conservative: terminal identity is diagnostic/advisory metadata, not protocol-native proof. Terminfo E3 is a better fit because it records an explicit host declaration without overclaiming runtime behavior.
Important nuance
An underlying terminal may support ED3 while an intervening host or multiplexer changes or ignores its effect on scrollback. OMP's recent resize-scrollback work is a useful example: tmux, screen, Zellij, direct terminals, and herdr can behave differently.
So this capability should probably mean roughly:
The current terminfo entry declares an erase-scrollback (E3) sequence.
—not:
Tessera has proven that clearing scrollback will work end-to-end in this environment.
A future stronger signal could distinguish advertised support from confirmed host behavior if that ever becomes detectable.
Acceptance ideas
- Parse
E3 from extended terminfo string capabilities.
- Expose the declaration in Tessera's capability metadata.
- Add deterministic terminfo parser tests for declared / missing / unavailable
E3.
- Keep
.eraseInDisplay(.allAndScrollback) unchanged as the semantic operation.
- Document that
E3 is advisory and may be affected by multiplexers/hosts.
Summary
Tessera already supports emitting ED3 (
CSI 3 J) via:and tests both the exact encoding and Ghostty behavior. However,
TerminalCapabilitiesdoes not currently expose whether scrollback erase is advertised/supported.This came up while reviewing OMP's new
tui.resizeScrollbackbehavior, where ED3 is used for rebuilding terminal scrollback after width changes. It highlighted that Tessera has the primitive, but not capability metadata for deciding when it is appropriate to rely on.Current state
EraseMode.allAndScrollbackmaps to ED3 (CSI 3 J).ANSIEncoderTestsverifies the exact bytes.TerminalCapabilitiestracks modern protocol support, terminal identity, nesting, underline declarations, etc., but has no ED3/scrollback-erase field.TerminfoDatabasealready parses ncurses extended string capabilities, currently forSmulxandSetulc.Suggestion
Extend the existing terminfo declaration infrastructure to inspect the ncurses
E3capability and surface it as advisory metadata.For example, either generalize the existing underline-specific declaration structure:
or add an equivalent narrowly scoped field while preserving the current API shape.
E3should map to the same declaration states Tessera already uses:I would avoid treating
TERM_PROGRAM=Ghostty,TERM=xterm-*, etc. as proof of ED3 support. Tessera's existing capability philosophy is appropriately conservative: terminal identity is diagnostic/advisory metadata, not protocol-native proof. TerminfoE3is a better fit because it records an explicit host declaration without overclaiming runtime behavior.Important nuance
An underlying terminal may support ED3 while an intervening host or multiplexer changes or ignores its effect on scrollback. OMP's recent resize-scrollback work is a useful example: tmux, screen, Zellij, direct terminals, and herdr can behave differently.
So this capability should probably mean roughly:
—not:
A future stronger signal could distinguish advertised support from confirmed host behavior if that ever becomes detectable.
Acceptance ideas
E3from extended terminfo string capabilities.E3..eraseInDisplay(.allAndScrollback)unchanged as the semantic operation.E3is advisory and may be affected by multiplexers/hosts.