# Changelog

## libvt 0.0.1a2 (Yet to be released)

<!-- KEEP THIS PLACEHOLDER - DO NOT REMOVE OR MODIFY THIS LINE -->
_Notes on the upcoming release will go here._
<!-- END PLACEHOLDER - ADD NEW CHANGELOG ENTRIES BELOW THIS LINE -->

## libvt 0.0.1a1 (2026-11-24)

`libvt` 0.0.1a1 adds `OSC 4` and `OSC 10`–`12` palette and dynamic color
queries, `XTMODKEYS` and `?1007` alternate-scroll input encoding,
cell-calibrated `?1016` pixel mouse coordinates, and chained `tmux` capture
bundles (`-N -T -F`). It also buffers outbound POSIX PTY writes above kernel
`TTYHOG` limits, expires stalled `?2026` holds on `EOF` and close, retains
`SIXEL` and Kitty graphics across `DECSTBM` scrolls and resize reflow, and
isolates per-terminal {class}`~libvt.terminal.SyncToken` watermarks. See
{doc}`topics/protocols-and-input`, {doc}`topics/sync-and-asyncio`, and
{doc}`migration` for upgrade details.

### Breaking changes

#### Cell-calibrated `MouseEvent.pixel_x` and `pixel_y` defaults (#26)

{attr}`~libvt.input.MouseEvent.pixel_x` and
{attr}`~libvt.input.MouseEvent.pixel_y` now default to `None`
(`int | None = None`) instead of `0` so `?1016` SGR-Pixel encoding derives
cell-center pixel coordinates from `row`, `col`, and
{class}`~libvt.config.Profile` cell geometry unless explicit pixel coordinates
are supplied:

```python
# Before
ev = MouseEvent(button=MouseButton.LEFT, action=MouseAction.PRESS, row=2, col=3)
assert (ev.pixel_x, ev.pixel_y) == (0, 0)

# After
ev = MouseEvent(button=MouseButton.LEFT, action=MouseAction.PRESS, row=2, col=3)
assert (ev.pixel_x, ev.pixel_y) == (None, None)  # encodes cell center (28, 40)
```

#### Scoped `CSI 5:3 m` overline decoding (#18)

{func}`~libvt.parser.parse_sgr` and live {meth}`~libvt.terminal.Terminal.feed`
ignore `CSI 5:3 m` (`5` with colon subparameter `3`, neither enabling overline
nor blink), matching `tmux` and `Ghostty` input parsing, while
{func}`~libvt.tmux.decode_tmux_capture` continues decoding `tmux`
`grid_string_cells_code`'s `5:3m` overline serialization:

```python
# Before
style = parse_sgr(CsiParams((5, 3), colon_mask=0b10))  # overline=True

# After
style = parse_sgr(CsiParams((53,)))  # standard SGR 53 overline
res = decode_tmux_capture(["\x1b[5:3mOV\x1b[0m"], rows=1, cols=4)
```

#### Opaque per-terminal sync watermarks (#22)

{class}`~libvt.terminal.SyncToken` keeps its watermark state private, disallows
direct instantiation, and renders a compact `repr()`. Read snapshot state from
{attr}`~libvt.terminal.ScreenDelta.snapshot` rather than inspecting token
attributes directly:

```python
# Before
cur = tok.cursor

# After
delta = term.changes_since(tok)
cur = delta.snapshot.cursor
```

### What's new

#### `OSC 4`/`12` queries, `XTMODKEYS`, `?1007`, and pixel `?1016` (#26)

{class}`~libvt.terminal.Terminal` answers `OSC 4` / `OSC 104` 256-palette
overrides and queries, semicolon-chained `OSC 10`–`12` / `OSC 110`–`112`
foreground, background, and cursor color queries
({attr}`~libvt.config.Profile.cursor_rgb`), `DECRQM` across all ANSI and DEC
modes, `XTSMGRAPHICS` (`CSI ? Pi ; Pa ; Pv S` returning `\x1b[?{pi};3S`), and
`XTMODKEYS` (`CSI > 4 ; pv m` and `CSI ? 4 m` via
{attr}`~libvt.terminal.Terminal.modify_other_keys` and
{attr}`~libvt.screen.Screen.modify_other_keys`), while consuming `OSC 9`,
`OSC 99`, and `OSC 777` notifications silently.
{func}`~libvt.input.encode_input` and {meth}`~libvt.terminal.Terminal.encode`
encode `XTMODKEYS` levels `1` and `2`, default-enabled `?1007`
({attr}`~libvt.modes.Mode.ALTERNATE_SCROLL`) wheel-to-arrow presses on the
alternate screen, and cell-calibrated `?1016`
({attr}`~libvt.input.MouseEvent.pixel_x` /
{attr}`~libvt.input.MouseEvent.pixel_y`) mouse coordinates, while
{meth}`~libvt.terminal.Terminal.resize`, {func}`~libvt.aio.open_pty`, and
{meth}`~libvt.aio.PtySession.resize` report pixel dimensions in `?2048` and
`TIOCSWINSZ`.

#### Chained `tmux` capture bundles and `-N -T -F` wide-wrap decoding (#18)

{func}`~libvt.tmux.build_tmux_capture_command` and
{class}`~libvt.tmux.TmuxCaptureCommand` construct single-invocation `tmux`
command chains bracketing `capture-pane -S - -E - -e -p -N -T -F` (`-e -p -N
-T` + `-e -p -J` on `3.4`–`3.7`, `-e -p -N` + `-e -p -J` on `3.3a`) with
`display-message` metadata headers and footers so pane output cannot drift
mid-capture and trailing blank viewport lines survive line-splitting wrappers.
{func}`~libvt.tmux.decode_tmux_capture`,
{meth}`~libvt.terminal.Terminal.from_tmux_capture`, and
{meth}`~libvt.terminal.Snapshot.from_tmux_capture` accept `trim_trailing=True`
to preserve explicit trailing spaces and disambiguate `GRID_FLAG_PADDING`
wide-wrap spacers in a single pass.

### Fixes

#### `BCE` hyperlinks, `SU` scrollback, `DEL` UTF-8 flush, and profiles (#25)

{class}`~libvt.terminal.Terminal` strips `OSC 8` hyperlinks from `BCE` blank
fills, pushes primary-screen `SU` (`CSI Ps S`) lines into scrollback when
unbounded horizontally, ignores non-`m` `CSI` sequences carrying `:`
subparameters while restricting {func}`~libvt.parser.parse_sgr` colons to
well-formed `4`/`38`/`48`/`58` groups, and flushes incomplete multi-byte UTF-8
sequences on `0x7F` (`DEL`) in {class}`~libvt.parser.Parser`. `DECSLRM` partial
scrolls preserve wide glyphs wholly inside `[left, right]`, and
{class}`~libvt.terminal.Formatter` restores `IRM`, `DECOM`, `DECLRMM`, and
`DECSCUSR` after rendering cells while padding `wrapped=True` rows to `cols`.
{class}`~libvt.config.Profile` splits {data}`~libvt.config.DEFAULT_PROFILE` and
{data}`~libvt.config.XTERM_PROFILE` (VT510 `DECSTR` mode set, shared primary
`DECSC`/`?1049h` save slot with isolated alternate `DECSC` slot, and
`SS2`/`SS3` single-shift preservation) from {data}`~libvt.config.TMUX_PROFILE`
({attr}`~libvt.config.Profile.declrmm_enabled` `False` so `CSI 5;10 s` saves
the cursor, {attr}`~libvt.config.Profile.top_margin_scrolls_to_history` `True`,
and {attr}`~libvt.config.Profile.separate_alt_save_cursor` `True`).

#### Buffered PTY writes, `?2026` EOF expiry, and frame-commit wakeups (#24)

{class}`~libvt.aio.PtySession` queues synchronous
{meth}`~libvt.aio.PtySession.send`, {meth}`~libvt.aio.PtySession.paste`, and
terminal query auto-replies onto a single bounded FIFO drained via
`loop.add_writer` with {meth}`~libvt.aio.PtySession.drain` high-water
backpressure, keeping bracketed pastes atomic above kernel `TTYHOG` limits
while flushing `?2048` replies inside {meth}`~libvt.aio.PtySession.resize` and
closing `master_fd` inside non-awaiting `finally` guards.
{class}`~libvt.aio.AsyncTerminalStream` and {class}`~libvt.aio.PtySession`
drive {meth}`~libvt.aio.AsyncTerminalStream.wait_for` and
{meth}`~libvt.aio.PtySession.wait_for` from
{attr}`~libvt.terminal.Terminal.committed_generation` and expire unclosed
`?2026` holds on `EOF`, {meth}`~libvt.aio.AsyncTerminalStream.aclose`, and
{meth}`~libvt.aio.PtySession.aclose`.

#### Bounded ASCII integer parsing and UTF-8 event accounting (#23)

{class}`~libvt.parser.Parser`, {class}`~libvt.terminal.Terminal`,
{mod}`libvt.graphics`, {mod}`libvt.status`, and {mod}`libvt.tmux` parse numeric
parameters strictly from ASCII digits `0`–`9` with bounded accumulators
(`<= 65535` for `OSC` command codes, unsigned 32-bit Kitty `i=` / `I=` / `p=` /
`P=` / `Q=` identifiers, and signed 32-bit `OSC 133;D` exit codes), while
{meth}`~libvt.terminal.Terminal.feed` isolates malformed `OSC 7` / `OSC 9;9`
URIs and non-hex `OSC 10` / `OSC 11` color specs without raising `ValueError`.
Event retention limits charge UTF-8 payload bytes across every `Event` variant
in {mod}`libvt.events` under {attr}`~libvt.config.Limits.max_event_bytes`.

#### Per-terminal sync isolation and horizontal-margin edits (#22)

{meth}`~libvt.terminal.Terminal.sync_token` and
{meth}`~libvt.terminal.Terminal.changes_since` isolate row-mutation watermarks
per {class}`~libvt.terminal.Terminal` instance and report every cell,
soft-wrap, and direct {attr}`~libvt.terminal.Terminal.screen` mutation in
{attr}`~libvt.terminal.ScreenDelta.dirty_rows`, while `ICH` and `DCH` outside
`DECLRMM` horizontal margins leave soft-wrapped rows intact.

#### Graphics retention, `DECSTBM` `SIXEL` masking, and streaming reflow (#21)

{meth}`~libvt.graphics.GraphicsTracker.on_region_scroll` preserves `SIXEL`
visibility masks and scrollback-bound placements when `DECSTBM` top-zero
margins advance scrollback history. {meth}`~libvt.terminal.Terminal.resize`
and {meth}`~libvt.screen.Screen.resize` retain stored images and placements
across reflow and non-reflow resizes, stream unwrapped scrollback lines that
fit within `cols` in `O(1)` per row without reallocating history blocks,
preserve monotonic {attr}`~libvt.terminal.Snapshot.scrolled_total`
continuity, and remap {class}`~libvt.events.PromptZone` and cell-anchored
Kitty {class}`~libvt.graphics.ImagePlacement` `(abs_row, col)` pins.

### Development

#### macOS PTY and Windows portable-core CI (#3)

GitHub Actions exercises Darwin {func}`~libvt.aio.open_pty` (`TIOCSCTTY`,
`TTYHOG` write queueing, and fast-exiting child drain) on `macos-latest` and
portable sans-I/O and {class}`~libvt.aio.AsyncTerminalStream` tests plus `ty`
checks on `windows-latest`, alongside the `Operating System :: Microsoft ::
Windows` classifier.

## libvt 0.0.1a0 (2026-11-22)

Initial pre-alpha release of `libvt`: a pure-Python, zero-dependency virtual
terminal emulator, streaming VT500 byte parser, mode-aware input encoder,
`asyncio` POSIX PTY adapter, and `pytest` plugin.

### What's new

#### Sans-I/O terminal core, two-tier RLE grid, and Unicode 17 width (#2)

{class}`~libvt.terminal.Terminal`, {class}`~libvt.screen.Screen`, and
{class}`~libvt.terminal.Snapshot` emulate primary and `?1049` alternate
screens with zero-based `(row, col)` coordinates, lazy 64-bit inline
viewport attributes, run-length-encoded scrollback history, and
primary-screen soft-wrap resize reflow. Top-level
{func}`~libvt.terminal.render`, {func}`~libvt.terminal.strip`, and
{func}`~libvt.codec.explain` helpers handle common rendering, stripping,
and sequence disassembly tasks, backed by `python -m libvt` CLI
subcommands.

{class}`~libvt.parser.Parser` decodes incremental UTF-8, colon-delimited
ITU T.416 SGR subparameters (`4:3`, `38:2::R:G:B`, `58:5:idx`), `G0`–`G3`
character-set designations (`ESC ( 0` DEC Special Graphics, `SO`/`SI`,
`SS2`/`SS3`), `HPR`/`VPR` (`CSI a` / `CSI e`), `CBT`/`CHT`,
`DECSCA`/`DECSED`/`DECSEL`, `CSI 3 J` / `CSI 22 J`, and `DCS tmux;`
passthrough framing while isolating UTF-8 `0x9C` and `U+009B` bytes from
8-bit `C1` controls (with optional `encoding="latin-1"` 8-bit wire mode).
SHA-256-pinned Unicode 17.0.0 two-stage tables drive East Asian width and
DEC `?2027` UAX #29 grapheme clustering across ZWJ emoji, Regional
Indicator flag pairs, Indic conjuncts, Hangul jamo, and `VS15` / `VS16`
emoji variation sequences. See {doc}`topics/architecture` for details.

#### Synchronized output stepping, Rex `OSC 7501`, and host queries (#2)

{meth}`~libvt.terminal.Terminal.committed`,
{meth}`~libvt.terminal.Terminal.feed_until`, and
{meth}`~libvt.terminal.Terminal.expire_synchronized_output` provide
lazy copy-on-write frame holds and generation-tagged timeout recovery
for DEC mode `?2026` synchronized updates.
{class}`~libvt.terminal.Formatter` exports snapshots to plain text, VT
escape sequences, and span-coalesced HTML with URI scheme allowlisting.

{class}`~libvt.status.ProgramStatusStore` and
{class}`~libvt.status.ProgramStatus` implement the Rex `OSC 7501`
Program Status specification, including hierarchical task identifiers,
ancestor `app` inheritance, urgency ranking, base64 `title`/`msg`
validation, profile- and policy-gated `OSC 7501 ; ?` capability replies,
`OSC 9;4` fallback, and lifecycle pruning alongside `OSC 133` prompt zones,
`OSC 7` RFC 8089 working directory updates, `OSC 52` clipboard writes,
`OSC 10`/`11` and `OSC 110`/`111` dynamic colors, `tmux` `ESC k` window
renames ({class}`~libvt.events.WindowRenamed`), `DA1`/`DA2`, `DSR`,
`DECRQM`, `DECRQSS`, `XTVERSION`, `XTGETTCAP`, and `?2031`/`?996n`
color-scheme queries. Configuration splits cleanly across {class}`~libvt.config.Profile`
(including versioned {meth}`~libvt.config.Profile.tmux` phantom-column
and resize compatibility profiles), {class}`~libvt.config.Policy`, and
{class}`~libvt.config.Limits`. See {doc}`topics/protocols-and-input` for
details.

#### Mode-aware input encoding, `asyncio` PTY bridge, and pytest plugin (#2)

{class}`~libvt.input.KeyEvent`, {class}`~libvt.input.MouseEvent`,
{class}`~libvt.input.FocusEvent`, and {class}`~libvt.input.PasteEvent`
encode outbound PTY bytes against active terminal modes, including
per-screen Kitty `CSI u` keyboard stacks (`>u`, `<u`, `=u`, `?u`), `SGR`
and `SGR-Pixel` mouse tracking (`?1006`, `?1016`), and fail-closed
bracketed paste validation raising {exc}`~libvt.exc.UnsafePasteError`.

{class}`~libvt.aio.AsyncTerminalStream` and {func}`~libvt.aio.open_pty`
connect sans-I/O terminals to `asyncio` streams and controlling POSIX
pseudo-terminals (`TIOCSCTTY` and `tty_mode`) without importing `asyncio`
or `pty` on `import libvt`. The `pytest11` plugin provides
protocol-typed `vt_terminal`, `vt_factory`, `vt_parser`, `vt_recorder`,
and `vt_pty` fixtures alongside {func}`~libvt.testing.assert_screen`,
{func}`~libvt.testing.assert_screen_box`,
{exc}`~libvt.exc.TerminalTimeoutError` stream diagnostics, and
{class}`~libvt.terminal.FlightRecorder` ring buffers. See
{doc}`topics/sync-and-asyncio` for details.

#### Incremental sync deltas, `tmux` capture reconstruction, and graphics (#13–#20)

{meth}`~libvt.terminal.Terminal.sync_token` and
{meth}`~libvt.terminal.Terminal.changes_since` emit non-destructive
multi-consumer {class}`~libvt.terminal.ScreenDelta` updates across both
`"committed"` (`?2026`-held) and `"working"` views, paired with
{meth}`~libvt.terminal.ScreenDelta.apply_lines`,
{meth}`~libvt.terminal.ScreenDelta.apply_rows`, and `O(1)` copy-on-write
{attr}`~libvt.terminal.Snapshot.history` sequence views.

{func}`~libvt.tmux.decode_tmux_capture`,
{class}`~libvt.tmux.TmuxPaneMetadata`, and
{func}`~libvt.tmux.unescape_tmux_control_output` reconstruct live
{class}`~libvt.terminal.Terminal` and {class}`~libvt.terminal.Snapshot`
state from `tmux capture-pane` (handling bare `SO`/`SI` ACS borders,
`GRID_FLAG_TAB` tabstops, `-F` / `-J` soft wraps, phantom-column
`pending_wrap`, and `-a` saved primary screens).
{mod}`libvt.graphics` tracks zero-dependency `SIXEL` and Kitty `APC G`
image metadata ({class}`~libvt.graphics.ImageMeta`) and monotonic
`abs_row` grid placements ({class}`~libvt.graphics.ImagePlacement` and
{meth}`~libvt.graphics.ImagePlacement.occupies_abs`) resolved alongside
{class}`~libvt.events.PromptZone` anchors via
{meth}`~libvt.terminal.Snapshot.at_abs` and
{meth}`~libvt.terminal.Snapshot.viewport_row`.
{exc}`~libvt.exc.TerminalTimeoutError` attaches multi-line viewport and
flight-recorder diagnostics via PEP 678 `__notes__` while keeping
`str(exc)` single-line.

### Documentation

- Add Architecture Decision Records `0001`–`0010` documenting clean-room
  provenance, sans-I/O layering, two-tier RLE storage, Unicode 17
  clustering, protocol semantics, input safety, and `asyncio`/pytest
  boundaries in {doc}`project/adr/index` (#2).
