Skip to content

Commit ba7b9fa

Browse files
committed
docs(control-mode): Document errors, queue drops, env reqs, sandbox
1 parent 367e1b3 commit ba7b9fa

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed

docs/topics/control_mode.md

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,3 +148,44 @@ print(server.list_sessions()) # legacy behavior
148148
metadata (``exit_status``, ``cmd_id``, ``tmux_time``) is attached.
149149
- Notifications are queued; drops are counted when consumers fall behind.
150150
- Timeouts raise ``ControlModeTimeout`` and restart the control client.
151+
152+
## Errors, timeouts, and retries
153+
154+
- ``ControlModeTimeout`` — command block did not finish before
155+
``command_timeout``. The engine closes and restarts the control client.
156+
- ``ControlModeConnectionError`` — control socket died (EOF/broken pipe). The
157+
engine restarts and replays the pending command once.
158+
- ``ControlModeProtocolError`` — malformed ``%begin/%end/%error`` framing; the
159+
client is marked dead and must be restarted.
160+
- ``SubprocessTimeout`` — subprocess fallback exceeded its timeout.
161+
162+
## Notifications and backpressure
163+
164+
- Notifications are enqueued in a bounded queue (default 4096). When the queue
165+
fills, additional notifications are dropped and the drop counter is reported
166+
via :class:`~libtmux._internal.engines.base.EngineStats`.
167+
- Consume notifications via :meth:`ControlModeEngine.iter_notifications` to
168+
avoid drops; use a small timeout (e.g., 0.1s) for non-blocking loops.
169+
170+
## Environment propagation requirements
171+
172+
- tmux **3.2 or newer** is required for ``-e KEY=VAL`` on ``new-session``,
173+
``new-window``, and ``split-window``. Older tmux versions ignore ``-e``; the
174+
library emits a warning and tests skip these cases.
175+
- Environment tests and examples may wait briefly after ``send-keys`` so the
176+
shell prompt/output reaches the pane before capture.
177+
178+
## Capture-pane normalization
179+
180+
- Control mode trims trailing *whitespace-only* lines from ``capture-pane`` to
181+
match subprocess behaviour. If you request explicit ranges (``-S/-E``) or use
182+
``-N/-J``, output is left untouched.
183+
- In control mode, the first capture after ``send-keys`` can race the shell;
184+
libtmux retries briefly to ensure the prompt/output is visible.
185+
186+
## Control sandbox (tests/diagnostics)
187+
188+
The pytest fixture ``control_sandbox`` provides an isolated control-mode tmux
189+
server with a unique socket, HOME/TMUX_TMPDIR isolation, and automatic cleanup.
190+
It is used by the regression suite and can be reused in custom tests when you
191+
need a hermetic control-mode client.

0 commit comments

Comments
 (0)