Skip to content

aio(feat[session]): Add mode-aware send_line() - #214

Merged
tony merged 1 commit into
masterfrom
feat/121-send-line
Dec 5, 2026
Merged

tony merged 1 commit into
masterfrom
feat/121-send-line

Conversation

@tony

@tony tony commented Dec 5, 2026

Copy link
Copy Markdown
Contributor

Summary

Add a mode-aware send_line(text, /, *, sanitize=False) method to AsyncSession, AsyncTerminalStream, PtySession, and synchronous TerminalProcess.

Changes

  • Factor shared paste control-character checks into libvt.input._is_disallowed_paste_cp() and add _encode_line_payload() to wrap non-empty payloads in ?2004 brackets when active, omit empty brackets when empty or sanitized to empty, and always reject embedded CR/LF and unsafe controls with UnsafePasteError unless sanitize=True.
  • Add send_line(text, /, *, sanitize=False) to AsyncSession and _SessionCore (inherited by AsyncTerminalStream and PtySession), encoding the line payload and KeyEvent("enter") atomically onto the single-FIFO outbound write queue so buffer overflow raises BufferError without queuing partial bytes.
  • Add TerminalProcess.send_line(text, /, *, sanitize=False) in libvt.contrib.subprocess delegating to the underlying session (POSIX PTY and Windows ConPTY).
  • Add unit, stream, POSIX PTY, and subprocess tests (including is_safe_paste, exact split-write buffer boundaries, Kitty >8u/>31u, and concurrent aclose() ECANCELED cancellation), docs updates, and a CHANGES entry.

Fixes #121

why:
Line-oriented terminal prompts had to coordinate paste() and
send_key("enter") separately, risking partial writes under buffer limits
or hardcoded carriage returns that break ?2004 and Kitty keyboard modes.

what:
- Add _encode_line_payload() in libvt.input sharing paste control checks
  while rejecting embedded CR/LF unless sanitize=True and omitting empty
  ?2004 brackets.
- Add send_line(text, /, *, sanitize=False) to AsyncSession,
  _SessionCore (AsyncTerminalStream, PtySession), and TerminalProcess,
  encoding text and Enter atomically onto the outbound write queue.
- Add stream, POSIX PTY, and subprocess tests, update
  docs/topics/sync-and-asyncio.md and docs/api/contrib/subprocess.md,
  and record the entry in CHANGES.

Fixes #121
@tony
tony merged commit 2d7a53e into master Dec 5, 2026
9 checks passed
@tony
tony deleted the feat/121-send-line branch December 5, 2026 18:46
@tony tony mentioned this pull request Dec 5, 2026
35 of 38 tasks

This branch was successfully deployed

1 active deployment
docs — 98e44257 Deployed Dec 5, 2026 by tony via build (3.14) #535
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add a mode-aware send_line() for line-oriented terminal prompts

1 participant