Repository navigation
Done
Labels
enhancementNew feature or request
Description
Summary
Downstream consumers migrating from pyte (docs, PyPI) and integrating with libtmux (repo, PyPI, libtmux#886) lack four ergonomic building blocks on #2: coordinate-versioned per-row change tracking for live renderers, an executable pyte-to-libvt migration guide covering HistoryScreen paging and Char quirks, libtmux send-keys / tmux -CC %output / OSC 133 command-block helpers, and cross-platform CI verification matching pyproject.toml claims.
Motivation
- Live UI renderers and multiplexers cannot safely use a
pyte-style caller-clearedscreen.dirty: set[int]when multiple consumers (wait_forpredicates, recorders, and UI painters) observe oneTerminal, whileSnapshot.generationalone forces scanning all rows on 1-cell updates. libtmuxcallers passtmuxkey names ("C-c","M-a","BSpace","PPage","BTab"), receive octal-escaped%output/%extended-outputlines (\xxx) intmux -CCcontrol mode, and inspect command/output blocks delimited byOSC 133PromptZonemarkers.src/libvt/terminal.pycurrently combinesTerminal,Snapshot,Formatter, andFlightRecorderin one large module, and.github/workflows/tests.yml(7a72ae8) runs onlyubuntu-latestCPython3.12–3.15without a portable Windows core leg or an experimental PyPy3.12(8.0.1beta) leg.
Proposal
Invariants
The invariants below are load-bearing; everything under Intent is open.
- Change tracking is multi-consumer safe (never requiring a caller to mutate or
.clear()sharedTerminalstate) and accounts for vertical scrolling,resize(), alternate-screen switches, cursor/visibility changes, and?2026synchronized commits. - Core
libvttypes (Terminal,Screen,Snapshot,Cell,Style) remain free ofpytelegacy quirks ("brown"ANSI color 3, bare 6-hex RGB strings,Screen(columns, lines)vsresize(lines, columns)transposed parameter order, wide-glyph""trailing cells shorteningdisplaystring length, and mutatingHistoryScreenpagination). - Splitting
Snapshot,Formatter, andFlightRecorderinto dedicated modules preserves top-levelfrom libvt import ...imports. - Portable
import libvton Windows never importspty,termios, orfcntl, and documentation scopeslibvt.aio.open_pty()explicitly to POSIX (Linux, plus macOS tracked in Verifyopen_pty()TIOCSCTTYcontrolling-TTY behavior on macOS #3).
Intent (non-binding)
- Stamp monotonic per-row generations on
_Rowand exposeSnapshot.row_generations: tuple[int, ...]plusTerminal.changes_since(token)returning(new_token, changed_rows, cursor_changed, full_refresh). - Add
docs/topics/migrating-from-pyte.mdwith a runnable mapping guide and a pure viewport-offsetHistoryScreenadapter recipe (_scroll_offsetover append-onlyhistory + lines), promoting it to an isolatedlibvt.compat.pytemodule only if migratinglibtmux's screen tests from a builtlibvtwheel demonstrates clear boilerplate reduction. - Add
KeyEvent.from_tmux()(translatingtmuxsend-keyschord names),unescape_tmux_control_output()(decodingtmux -CCoctal escapes), andSnapshot.command_blocks()(pairingOSC 133A/B/C/Dzones acrosshistoryandscreeninto command, output, andexit_coderecords). - Add a
windows-latestportable-core job and anallow-failurepypy3.12job in.github/workflows/tests.yml, and validatelibtmux's screen test suite against an installedlibvtwheel in a clean virtual environment (paired with a deliberate failing screen assertion) before freezing1.0.
Not doing
- Baking mutating
prev_page()/next_page()deques intoScreen. - Wrapping Win32
ConPTY(pywinpty) inlibvt.
Alternatives
- A
pyte-style mutableTerminal.dirty: set[int]was weighed and rejected as the primary API because clearing it from one observer hides dirty rows from concurrent observers (wait_for, logger, renderer); single-consumer callers can derive adirtyset in 5 lines fromchanges_since(token).
References
- Core(feat[vt]): Add sans-I/O VT engine, RLE grid, OSC 7501, input, and ADRs #2
- Verify
open_pty()TIOCSCTTYcontrolling-TTY behavior on macOS #3 - libtmux#886
pyproject.toml(7a72ae8): https://github.com/tmux-python/libvt/blob/7a72ae8/pyproject.toml.github/workflows/tests.yml(7a72ae8): https://github.com/tmux-python/libvt/blob/7a72ae8/.github/workflows/tests.yml- PyPy v8.0.1 release notes
Metadata
Metadata
Assignees
Labels
enhancementNew feature or request
Activity
terminal(feat[sync]): Add deltas and graphics hooks (#13)
tony commentedon Nov 23, 2026
Pre-
0.1.0contract refinementsFollow-up review narrows three items from this tracking issue into dedicated issues:
SyncTokenopacity (private watermark fields and per-Terminalcounters replacing_GLOBAL_ROW_GEN) plus structural_Rowwrite-barrier generation bumps fixingDCHleft ofDECLRMMare tracked in MakeSyncTokenopaque perTerminaland guard_Rowmutations with write barriers #22.PyPy 3.12compatibility certification is split out to0.2.0in CertifyPyPy 3.12compatibility acrossOSErrorreduction andarray('Q')grids #32, whilewindows-latestportable-core CI and read-onlylibtmuxwheel validation proceed for0.1.0a0.