Repository navigation
Closed
Labels
bugSomething isn't working
Description
Summary
Formatter in src/libvt/terminal.py (#2) drops background-color-erase (BCE) trailing spans in OutputFormat.VT and omits 16-color AnsiColor, 256-color IndexedColor, reverse, and text-decoration styles in OutputFormat.HTML, while AsyncTerminalStream.wait_for() in src/libvt/aio.py (#2) raises TerminalTimeoutError without parser_state or FlightRecorder tail bytes.
Reproduction
- Export a green-BCE
EL 0bar (CSI 42 m HI CSI K) throughFormatter(OutputFormat.VT)and replay it into a secondTerminal, and export an ANSI-colored row throughFormatter(OutputFormat.HTML):
$ uv run python -c 'from libvt import Formatter, OutputFormat, Terminal; a = Terminal(rows=2, cols=10); a.feed(b"\x1b[42mHI\x1b[K\x1b[31;4m!"); vt_bytes = Formatter(OutputFormat.VT).format_terminal(a).encode(); b = Terminal(rows=2, cols=10); b.feed(vt_bytes); print("col5 bg after roundtrip:", b[0, 5].style.bg); print("html:", Formatter(OutputFormat.HTML).format_terminal(a))'Expected
- Replaying
OutputFormat.VToutput preservesAnsiColor.GREENbackground across columns2..9(row.used), matchingtmux capture-pane -e. OutputFormat.HTMLemits CSS color, background-color,reverseswap, andtext-decorationrules forAnsiColorandIndexedColorin addition toRgbColor.TerminalTimeoutErrorraised bywait_for()exposes structured attributes (parser_state,screen_text,recent_bytes) and includesparser_state(for exampleParserState.OSC_STRINGwhen a child hangs in an unterminatedOSCsequence) plus recentFlightRecordertail bytes in its message.
Actual
col5 bg after roundtrip: NonebecauseFormatter._format_vt()stops atlimit = row.used if row.wrapped else row.text_used.OutputFormat.HTMLchecks onlyisinstance(style.fg, RgbColor)andisinstance(style.bg, RgbColor), rendering 16-color and 256-color cells unstyled.TerminalTimeoutErrorformats onlyterminal.text.
Environment
libvt:#2(feat/v2-architecture,0.1.0a0)- Python:
3.15.0(unicodedata17.0.0) - Reference
tmux:3.8a(tmux -f /dev/null) - OS: Linux
x86_64
Proposal
Invariants
The invariants below are load-bearing; everything under Intent is open.
- Feeding
Formatter(OutputFormat.VT).format_snapshot(snap).encode()into a freshTerminalof equal dimensions reproduces visible glyphs and cellStyleattributes across0..row.used - 1. Formatter(OutputFormat.HTML)escapes text and restricts hyperlink schemes perPolicy.allow_unsafe_uriswhile renderingAnsiColor,IndexedColor,RgbColor,reverse,bold,dim,italic,underline,strikethrough, andoverline.TerminalTimeoutErrorremains a subclass of bothLibVtErrorand builtinTimeoutError.
Intent (non-binding)
- Iterate up to
row.usedin_format_vt()so styled trailing blanks fromEL/ED/ECHsurvive round-trips. - Resolve
AnsiColorandIndexedColorthrough a standard 256-color palette table onFormatter(respectingProfile.fg_rgb/Profile.bg_rgbonreverse). - Attach
parser_state: ParserState,screen_text: str, andrecent_bytes: bytestoTerminalTimeoutErrorwhenrecorderis present.
Not doing
- Adding external CSS/HTML templating dependencies.
References
- Core(feat[vt]): Add sans-I/O VT engine, RLE grid, OSC 7501, input, and ADRs #2
tmuxgrid.cgrid_string_cells(72c20dc/3.8): https://github.com/tmux/tmux/blob/72c20dc/grid.c
Metadata
Metadata
Assignees
Labels
bugSomething isn't working
Activity
Format(fix[export]): Keep VT BCE and timeout info (#9)
Format(fix[export]): Keep VT BCE and timeout info (#9)
tony commentedon Nov 23, 2026
Resolved in #2 (
0c7ee41).