Skip to content

fix: wire terminal query responses (DSR/CPR) back to child PTY#18

Open
aannoo wants to merge 1 commit intopproenca:masterfrom
aannoo:fix/wire-dsr-cpr-writeback
Open

fix: wire terminal query responses (DSR/CPR) back to child PTY#18
aannoo wants to merge 1 commit intopproenca:masterfrom
aannoo:fix/wire-dsr-cpr-writeback

Conversation

@aannoo
Copy link

@aannoo aannoo commented Feb 20, 2026

Summary

  • The virtual terminal used io::sink() as the wezterm writer, silently discarding all terminal-to-application responses (DSR/CPR, DA1, etc.)
  • This broke TUI apps that query cursor position — notably ratatui's Viewport::Inline mode, which sends \x1b[6n on init and expects a CPR response
  • Wires the PTY master writer into VirtualTerminal via an ArcWriter adapter so wezterm's responses flow back to the child process

Changes

  • pty.rs: Add writer_handle() to expose a clone of the Arc<Mutex<...>> PTY writer
  • pty_session.rs: Pass through writer_handle()
  • vterm.rs: Accept a Box<dyn Write + Send> writer parameter instead of using io::sink()
  • terminal_state.rs: Forward the writer to VirtualTerminal
  • session.rs: Add ArcWriter adapter struct; wire PTY writer into VirtualTerminal during session creation

Test plan

  • just ready passes (fmt, clippy, architecture, 451 tests, version check)
  • New test_dsr_cursor_position_response unit test verifies CPR flows through the writer
  • E2E: Python raw-mode test confirms \x1b[1;1R arrives on child stdin
  • E2E: ratatui Viewport::Inline TUI app renders correctly under agent-tui (previously failed)

The virtual terminal emulator used io::sink() as the wezterm writer,
which discarded terminal-to-application responses. This broke TUI apps
that query cursor position — notably ratatui's Viewport::Inline mode,
which sends \x1b[6n during init and expects a CPR response.

Wire the PTY master writer into VirtualTerminal so wezterm's CPR
responses flow back to the child process via an ArcWriter adapter
that shares the existing PTY writer handle.
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.

1 participant