Repository navigation
Description
Summary
A raw flight recorder can retain every incoming byte and still lack enough information to reproduce the final screen. Two runs below share starting and ending dimensions and identical complete byte streams but show X in different cells.
Motivation
Raw input bytes carry the program’s cursor moves but cannot capture the external window width in effect when they arrived. A simulator replaying those bytes therefore needs a second source for geometry.
From the tagged libvt checkout, install the locked development dependencies with uv sync --frozen --python 3.14 --all-groups --all-extras. Use the checkout root as the working directory.
Save the following as case.py at the checkout root and run uv run --no-sync python case.py.
from libvt import Terminal
from libvt.terminal import FlightRecorder
def record(narrow):
recorder = FlightRecorder()
term = Terminal(rows=2, cols=8, recorder=recorder)
if narrow:
term.resize(rows=2, cols=4, reflow=False)
term.feed(b"\x1b[1;7HX")
if narrow:
term.resize(rows=2, cols=8, reflow=False)
return recorder.tail(), term.committed
plain, first = record(False)
resized, second = record(True)
print("same bytes:", plain == resized, "same final dimensions:", (first.rows, first.cols) == (second.rows, second.cols))
print("unchanged width:", first.lines[0])
print("narrow while drawing:", second.lines[0])Evidence
CPython 3.14.6 on Linux under WSL2 ARM64. Identical output on release v0.0.1a4 (09611e5) and trunk (0864aa2).
Observed output
same bytes: True same final dimensions: True
unchanged width: X
narrow while drawing: X
Proposal
Keep the small raw-byte debugging recorder and offer an opt-in replay format that interleaves resize and input-byte records. Test a shrink, drawing while narrow, restoration, and replay at different chunk sizes.
- Developer experience — A downstream recorder does not need to invent its own timestamp and resize ordering format.
- Immediate benefit — Preserves geometry-dependent cursor and layout results in replayed failures.
- Longer-term benefit — Enables portable recorded fixtures and comparable results across interactive subprocess backends.
- End-user experience — A saved terminal test reproduces what the user actually saw after resizing the window.
Activity
tony commentedon Dec 3, 2026
The local pytest fixture recorded feed bytes and caller resizes in order. Replaying a width change byte by byte produced the same visible rows and cursor. This establishes the fixture/CLI scope. A resize-aware recorder for callers outside pytest remains a separate part of this issue. Related PR #139