Repository navigation
Description
Summary
Cross-checking libvt (#2, #8, #17) against Ghostty (11ed660d9 / vt-1.0.1), xterm (xterm-412), and live tmux 3.8a (17c016750) uncovered five universal VT bugs and five profile-specific divergences: _bce_pair() stamps active OSC 8 hyperlinks onto erased blank cells; SU (CSI Ps S) discards scrolled-off lines instead of pushing to primary scrollback when top == 0 and full-width; 0x7F (DEL) in GROUND fails to flush incomplete multi-byte UTF-8 sequences (gluing b"\xe2\x7f\x82\xac" into '€'); non-m CSI sequences with : subparameters execute instead of dropping; Formatter(OutputFormat.VT) emits IRM/DECOM/DECLRMM before drawing cells and omits wrapped=True row padding; and DECSTR, ?69, CSI 5;10 s, DECSTBM top > 0 history, and DECSC/?1049h cursor save slots differ between DEFAULT_PROFILE/XTERM_PROFILE and TMUX_PROFILE.
Reproduction
- Run the four minimal probes (
BCEwith activeOSC 8,CSI 1 Son primary screen,0x7Finside€UTF-8 bytes, andESC 7+?1049h/?1049l+ESC 8underTMUX_PROFILE):
uv run python -c 'from libvt import TMUX_PROFILE, Terminal; a = Terminal(rows=2, cols=8); a.feed(b"\x1b]8;;https://example.com\x07\x1b[42m\x1b[K\x1b]8;;\x07"); b = Terminal(rows=2, cols=8, scrollback=10); b.feed(b"rowA\r\nrowB\x1b[1S"); c = Terminal(rows=2, cols=8); c.feed(b"\xe2\x7f\x82\xac"); d = Terminal(rows=4, cols=8, profile=TMUX_PROFILE); d.feed(b"\x1b[3;1H\x1b7\x1b[3;3H\x1b[?1049h\x1b[?1049l\x1b8"); print("bce_link:", a[0, 3].hyperlink, "su_hist:", len(b.history), "del_utf8:", repr(c.lines[0]), "tmux_decsc:", (d.cursor.row, d.cursor.col))'
Expected
bce_linkisNone(BCEcarries background color only, neverOSC 8hyperlinks).su_histis1('rowA'saved to primary scrollback whentop == 0and horizontal margins are full-width, matchingGhosttyTerminal.zigscrollUpandtmux 3.8a).del_utf8is'\ufffd\ufffd\ufffd'(0x7FDELflushes incompleteâasU+FFFDbefore ignoringDEL), non-mCSIsequences containing:subparameters are ignored,DECSLRMpartial scroll preserves wide glyphs wholly within[left, right]withtext_used <= used, andFormatter(OutputFormat.VT)restoresIRM/DECOM/DECLRMMafter rendering cells while paddingwrapped=Truerows tocols.- On
DEFAULT_PROFILEandXTERM_PROFILE,DECSTR(CSI ! p) resets only the VT510 soft-reset set (IRM,DECOM,DECAWMon,DECTCEMon,DECSTBM/DECSLRM,SGR/pen/DECSCA,G0–G3/GL/SS,pending_wrap, saved cursor, keeping?1000–?1006/?2004mouse and paste modes intact perGhosttysoftReset), and primaryDECSCshares the primary save slot with?1049hwhile the alternate screen keeps its own separateDECSCslot (saving_single_shifttoo). - On
TMUX_PROFILE,?69(DECLRMM) is disabled (CSI 5;10 sexecutes cursor saveSCOSC),DECSTRremains a no-op,LF/IND/SUatbottompushDECSTBMtopinto primary history even whentop > 0(matchingtmuxscreen-write.c), andDECSC(ESC 7) uses a separate save slot from?1049hsotmux_decscprints(2, 0).
Actual
bce_link: Hyperlink(uri='https://example.com', id='') su_hist: 0 del_utf8: '€' tmux_decsc: (2, 2).
Environment
Versions
libvt:#2(0.1.0a0)- Python:
3.15.1 - Reference
tmux:3.8a(17c016750) - Reference
Ghostty:11ed660d9(vt-1.0.1) - OS: Linux
x86_64
Proposal
Invariants
The invariants below are load-bearing; everything under Intent is open.
BCEerases (ED,EL,ECH,ICH,DCH,IL,DL,SU,SD, scroll linefeeds) never attachHyperlinkmetadata to blanked cells.Formatter(OutputFormat.VT).format_snapshot(snap)round-trips into a freshTerminalof matching dimensions whenIRM,DECOM,DECLRMM, orwrapped=Trueshort/BCE rows are active.- Profile switches on
Profilecleanly separateDEFAULT_PROFILE/XTERM_PROFILE(Ghostty/xtermsemantics) fromTMUX_PROFILE(tmuxinner-pane semantics).
Intent (non-binding)
- Add
declrmm_enabled: bool = True,top_margin_scrolls_to_history: bool = False, andseparate_alt_save_cursor: bool = False(naming open to match existingProfilefields) toProfile, withProfile.tmux()configuringdeclrmm_enabled=False,top_margin_scrolls_to_history=True, and separateDECSCvs?1049hprimary cursor slots.
Not doing
- Enabling
DECLRMM(?69) onTMUX_PROFILE(tmuxdoes not implement left/right margin mode).
References
- Core(feat[vt]): Add sans-I/O VT engine, RLE grid, OSC 7501, input, and ADRs #2
- Fix
DECSLRMscrolltext_used,REPreset, and?7lVS16width #8 - Align
Profile.tmuxonDECSTR, primaryED 2history, andnext-3.9#17 Ghosttysrc/terminal/Terminal.zig(scrollUp,softReset,switchScreenMode) at11ed660d9tmuxscreen.c(screen_alternate_ons->saved_cx) at17c016750
Activity
terminal(fix[vt]): Fix BCE, SU, DEL, profiles (#25)