Skip to content

feat: capture PTY terminal sessions - #176

Merged
konard merged 14 commits into
mainfrom
issue-841-722d23014d4b
Jul 24, 2026
Merged

feat: capture PTY terminal sessions#176
konard merged 14 commits into
mainfrom
issue-841-722d23014d4b

Conversation

@konard

@konard konard commented Jul 24, 2026

Copy link
Copy Markdown
Member

Closes #175. Supplies the reusable terminal-capture layer needed by link-assistant/formal-ai#841 in both JavaScript and Rust.

Reproduction

The previous API only spawned pipe-based commands. It could not assign or resize a PTY, retain scrolled-off terminal states, or emit replay artifacts. The new tests reproduce interactive input, control keys, resize observation, full-screen repaint, scrollback, repeated-state preservation, timeout diagnostics, premature PTY-host exits, and platform-specific terminal shutdown.

Changes

  • run interactive commands in a real pseudoterminal (node-pty in JavaScript, portable-pty in Rust)
  • model terminal state with maintained emulators (@xterm/headless and vt100), with no custom VT parser
  • drive text, control-key, and resize interactions
  • retain consecutive-deduplicated settled frames and an ordered unrolled transcript
  • preserve lines after they scroll outside the visible terminal
  • record asciicast v2 output/input/resize events and provide readers in both languages
  • write transcript, frame JSON, static SVG, and animated SVG artifacts
  • retain and persist partial captures on timeout
  • expose opt-in JavaScript tracing while keeping normal pipe/pipeline behavior unchanged
  • provision a Node PTY host for Bun and use official node-pty prebuilds across Linux, macOS, and Windows

Verification

JavaScript:

  • PATH=/tmp/formal-ai-841-bin:$PATH bun run test: 780 pass, 5 skip, 0 fail
  • focused terminal suite repeated 10 times
  • bun run lint
  • bun run format:check
  • bun run check:duplication
  • CI: Bun on Ubuntu, macOS, and Windows; Node 20/22/24 on Ubuntu

Rust:

  • red test first: unresolved command_stream::terminal
  • focused terminal suite repeated 10 times
  • cargo test --all-features
  • cargo test --doc --all-features
  • cargo clippy --all-targets --all-features
  • cargo fmt --all -- --check
  • cargo package --allow-dirty
  • CI: Ubuntu, macOS, and Windows

Cross-language source parity also passes.

@konard konard changed the title feat(js): capture PTY terminal sessions feat: capture PTY terminal sessions Jul 24, 2026
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.

PTY-backed execution, terminal emulation, and TUI frame capture with unrolling (text snapshot + image/animation)

1 participant