Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,13 @@ _Notes on the upcoming release will go here._
Concurrent foreground waits and direct reads now share one input read.
Closing the stream releases that reader before a successor consumes input.

#### Observe consecutive synchronized frames in one read (#192)

A wait on {class}`~libvt.aio.AsyncTerminalStream` or
{class}`~libvt.aio.PtySession` now observes each committed frame when
one read contains several synchronized updates. A transient prompt can
match before the next update replaces it.

## libvt 0.0.1a5 (2026-11-30)

`libvt` 0.0.1a5 adds rectangular grid blitting, display-column text writes, and
Expand Down
27 changes: 22 additions & 5 deletions docs/topics/sync-and-asyncio.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,11 @@ into a terminal and drives outbound input over an optional writer.

{meth}`AsyncTerminalStream.wait_for() <libvt.aio.AsyncTerminalStream.wait_for>`
and {meth}`PtySession.wait_for() <libvt.aio.PtySession.wait_for>` test a
substring or `Callable[[Snapshot], bool]` predicate each time
{attr}`~libvt.terminal.Terminal.committed_generation` advances, expiring
unclosed `?2026` frames after `sync_timeout` seconds. On timeout or premature
`EOF`, both raise {exc}`~libvt.exc.TerminalTimeoutError` with the boxed screen
and recent decoded input attached via `__notes__`:
substring or callable predicate against the current committed snapshot,
then at synchronized frame and read boundaries. An unclosed `?2026` hold
expires after `sync_timeout` seconds. On timeout or premature EOF, both
raise {exc}`~libvt.exc.TerminalTimeoutError` with the boxed screen and
recent decoded input attached via `__notes__`:

```python
>>> import asyncio
Expand All @@ -81,6 +81,14 @@ and recent decoded input attached via `__notes__`:
'Prompt>'
```

A pending wait can match a committed redraw even when the next redraw
arrives in the same stream read or PTY write. It returns the first matching
snapshot. A wait started after both redraws sees the current frame.
Predicates run in their waiting tasks and can read or set the callers'
`ContextVar` values. The transport advances through bounded batches of
committed snapshots while waits are active. It reports EOF after
delivering the pending batch.

Concurrent {meth}`~libvt.aio.AsyncTerminalStream.wait_for` and
{meth}`~libvt.aio.AsyncTerminalStream.pump_once` calls can share a stream
before or after {meth}`~libvt.aio.AsyncTerminalStream.start`. Each chunk
Expand Down Expand Up @@ -111,6 +119,9 @@ window size via `TIOCSWINSZ`, resizes `session.terminal`, and queues any

### Cleanup

Closing an asyncio stream feeds the remaining bytes from its current
read. Input still buffered in the `StreamReader` belongs to the caller.

Leaving `async with` or calling
{meth}`AsyncTerminalStream.aclose() <libvt.aio.AsyncTerminalStream.aclose>` /
{meth}`PtySession.aclose() <libvt.aio.PtySession.aclose>` expires any active
Expand All @@ -119,6 +130,12 @@ Leaving `async with` or calling
master descriptor, closes it, and calls
{meth}`~libvt.terminal.Terminal.notify_process_exit`.

Concurrent stream close calls share delivery of frames already received.
Wait for close to finish before restarting the stream. Concurrent PTY
close calls share process cleanup and the final frame drain. A caller
cancelled during that drain receives {exc}`asyncio.CancelledError` when
the drain finishes.

## `tmux` control mode (`-C` / `-CC`)

{class}`~libvt.contrib.tmux.control.TmuxControlParser` frames raw `tmux -C` /
Expand Down
Loading
Loading