Files
tai/research/shell-multiplexer-auto-attach/libtmux-pane-interaction.md
T

49 lines
2.3 KiB
Markdown
Raw Normal View History

# Pane Interaction — libtmux docs
## Metadata
| Field | Value |
|---|---|
| Institute | Molodetz Institute — Research & Retrieval Division |
| Subject | shell-multiplexer-auto-attach |
| Document type | Source Dossier |
| Tier | 1 |
| Source title | Pane Interaction - libtmux 0.53.0 documentation |
| Source URL | https://libtmux.git-pull.com/topics/pane_interaction.html |
| Source publisher / author | libtmux project |
| Source type | vendor docs |
| Source date (published) | Unknown — not stated |
| Date researched | 2026-10-09 |
| Researched by | tai (agent), model: Claude Sonnet 5, on behalf of retoor |
| Research method | web search synthesis |
| Confidence | High |
| Status | Active |
## Summary
libtmux's own documentation for the send-keys/capture-pane automation pattern: spawn or attach a session, send keystrokes with `send_keys`, read the rendered screen back with `capture_pane` (optionally the full scrollback via `-S -`), and loop until the expected state appears.
## Key findings
- The canonical "drive and poll" loop: `send_keys()` then `capture_pane()`, waiting briefly for output to catch up before reading.
- A documented, easy-to-miss gotcha: a command is **not executed** unless `Enter` is sent as its own, separate key event — typing the text alone leaves it sitting unexecuted in the prompt.
- Output can lag behind the command that produced it, so libtmux's own examples add short sleeps before capturing.
## Pros / strengths
- Comes from a maintained Python wrapper library that has clearly hit these exact gotchas in practice — the Enter-must-be-separate warning in particular is the kind of thing that silently breaks automation until someone documents it.
## Cons / limitations / caveats
- The send+capture+sleep loop is inherently a polling approach with a race condition (how long is "briefly"?) — it's not real event-driven I/O the way control-mode notifications are.
## Relevance to tai
This is the baseline implementation for the proposal's "write/type at a position" and "read pane content" commands when NOT using control mode — and the Enter-as-separate-key gotcha must be built into the design from day one, not discovered via a bug report later.
## Changelog
| Date | Change |
|---|---|
| 2026-10-09 | Initial dossier created. |