Repository navigation
Description
Summary
A configured terminal can read a Latin-1 job and retain its Bell event. The PTY and size-based factories reject the same settings before a caller can observe that child.
Motivation
The child can write its first byte before a session user obtains the terminal. Replaying raw output through a separately configured terminal requires a complete recording.
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.
import asyncio
import os
import sys
from libvt import Terminal
from libvt.aio import open_pty
wire = b"caf\xe9\x07"
correct = Terminal(rows=2, cols=20, encoding="latin-1", record_events=True)
correct.feed(wire)
print("explicit terminal:", correct.lines[0], [type(e).__name__ for e in correct.drain_events()])
for key, value in [("encoding", "latin-1"), ("record_events", True)]:
for name, make in [("from_size", lambda: Terminal.from_size(os.terminal_size((20, 2)), **{key: value})),
("open_pty", lambda: open_pty([sys.executable], **{key: value}))]:
try:
make()
except TypeError:
print(name, "rejects", key)
async def main():
child = [sys.executable, "-c", "import os; os.write(1, " + repr(wire) + ")"]
async with open_pty(child, rows=2, cols=20) as session:
await session.wait_for(lambda _: session.eof, timeout=4)
print("PTY default:", session.terminal.lines[0], list(session.terminal.drain_events()))
asyncio.run(main())Evidence
CPython 3.14.6 on Linux under WSL2 ARM64. Identical output on release v0.0.1a4 (09611e5) and trunk (0864aa2).
Observed output
explicit terminal: café ['Bell']
from_size rejects encoding
open_pty rejects encoding
from_size rejects record_events
open_pty rejects record_events
PTY default: caf� []
Proposal
Forward encoding and record_events through Terminal.from_size, open_pty and relevant pytest factories. Keep current defaults and test the first byte and event from a real guest.
- Developer experience — Tests use identical settings on pipe-backed and PTY-backed applications without replaying the stream.
- Immediate benefit — Makes startup options accessible where applications create terminal sessions.
- Longer-term benefit — Prevents configuration drift between emulator construction, transport wrappers and test fixtures.
- End-user experience — Legacy tools display their actual text and progress signals from the first screen.
Activity
tony commentedon Dec 3, 2026
Startup options now reach the terminal before the first PTY read. In the Linux probe a child writes green Latin-1
caféand BEL, then exits. The frame has four green cells and cursor (0, 4), and the opted-in event log contains one Bell. PR #164aio(feat[pty]): Configure parser before launch