Repository navigation
Description
Summary
Native plain capture works on tmux 3.1c while the pause-based attachment command is rejected. The resulting usage error does not tell a caller whether one-shot capture remains practical. The original streaming design set a tmux 3.3a floor.
Motivation
On 3.1c capture-pane -p returns ONLINE; the first refresh-client -A barrier fails with a native usage error. The unchanged witness reaches live on 3.4.
From the tagged libvt checkout, install the locked development dependencies with uv sync --frozen --python 3.14 --all-groups --all-extras. Use the checkout root as the working directory. Use the tmux version recorded below and set TMUX_BIN to its executable.
Save the following as case.py at the checkout root and run uv run --no-sync python case.py.
import contextlib
import os
import subprocess
import tempfile
import time
from pathlib import Path
from libvt.contrib.tmux import build_tmux_capture_command, tmux_profile
def until(read, check):
end = time.monotonic() + 6
while True:
value = read()
if check(value):
return value
if time.monotonic() >= end:
raise AssertionError(f"native wait expired at {value!r}")
time.sleep(0.02)
@contextlib.contextmanager
def pane(width=24, height=6):
binary = os.environ.get("TMUX_BIN", "tmux")
version = subprocess.check_output([binary, "-V"], text=True).strip()
with tempfile.TemporaryDirectory() as tmp:
pipe = Path(tmp) / "log"
os.mkfifo(pipe)
argv = [binary, "-u", "-S", tmp + "/socket", "-f", "/dev/null"]
def tm(*args):
return subprocess.check_output([*argv, *args], timeout=6, stderr=subprocess.PIPE)
def capture():
bundle = build_tmux_capture_command("%0", tmux_version=version)
return bundle.parse(tm(*bundle.argv), profile=tmux_profile(version))
tm("new-session", "-d", "-x", str(width), "-y", str(height), "-s", "desk", "cat", str(pipe))
try:
tm("set", "-g", "status", "off")
tm("set", "-w", "window-size", "manual")
tm("resize-window", "-t", "%0", "-x", str(width), "-y", str(height))
with pipe.open("wb", buffering=0) as feed:
yield tm, feed.write, capture, argv, version
finally:
subprocess.run([*argv, "kill-server"], capture_output=True, check=False)
import select
from libvt.contrib.tmux import TmuxControlParser, TmuxPaneSync, TmuxNotification
@contextlib.contextmanager
def observer(argv, version):
parser = TmuxControlParser()
sync = TmuxPaneSync("%0", tmux_version=version)
proc = subprocess.Popen([*argv, "-C", "attach-session", "-t", "desk"],
stdin=subprocess.PIPE, stdout=subprocess.PIPE)
def send(command):
proc.stdin.write(command.encode() + b"\n")
proc.stdin.flush()
def pump(check):
deadline = time.monotonic() + 6
while time.monotonic() < deadline:
if not select.select([proc.stdout], [], [], max(0, deadline - time.monotonic()))[0]:
break
data = os.read(proc.stdout.fileno(), 65536)
if not data:
raise EOFError("tmux client stopped")
matched = False
for event in parser.feed(data):
response = sync.handle_event(event)
if response:
send(response)
matched = check(event) or matched
if matched:
return
raise TimeoutError("tmux control event")
try:
pump(lambda e: isinstance(e, TmuxNotification) and e.name == "session-changed")
send(sync.begin_attach())
pump(lambda e: sync.phase.value == "live")
yield sync, send, pump
finally:
proc.stdin.close()
try:
proc.wait(timeout=3)
except subprocess.TimeoutExpired:
proc.terminate()
proc.wait(timeout=3)
proc.stdout.close()
from libvt.exc import ProtocolError
with pane() as (tm, write, capture, argv, version):
write(b"ONLINE")
until(lambda: tm("capture-pane", "-p"), lambda b: b"ONLINE" in b)
print("native plain capture", tm("capture-pane", "-p").decode().strip(), "server", version)
try:
with observer(argv, version) as (sync, send, pump):
print("observer", sync.phase.value)
except ProtocolError as error:
print(type(error).__name__, str(error))Evidence
libvt v0.0.1a4 and trunk 0864aa2, Linux ARM64 on WSL2, tmux 3.1c, CPython 3.12.3. Set TMUX_BIN to the installed tmux 3.1c binary to exercise the boundary. The same code reaches live on tmux 3.4.
Observed output
native plain capture ONLINE server tmux 3.1c
ProtocolError tmux pause failed for %0: parse error: usage: refresh-client [-cDlLRSU] [-C XxY] [-F flags] [-t target-client] [adjustment]
Proposal
Document separately the minimum exercised versions for basic capture flags, pause/continue and extended format fields. Offer an explicit non-streaming fallback for callers who can use a point-in-time snapshot.
- Developer experience — Integrations can select features by the server capability instead of interpreting a multi-line usage error.
- Immediate benefit — Give a precise setup error and a usable attainable alternative.
- Longer-term benefit — Treat tmux compatibility as a versioned capability contract.
- End-user experience — A user on an older terminal multiplexer can still read a pane with an understood level of fidelity.
Activity
tony commentedon Dec 3, 2026
The guide now documents the tmux 3.2 boundary for pause-based pane attach. Native tmux 3.1c supported one-shot pane capture and rejected pause-based attach before entering the attach state. The same probe reached live attach on 3.2a. PR #158