Repository navigation
Description
Summary
The capture builder accepts a native version, but cmd.parse(raw) defaults to a different profile. Creating an explicit profile also drops the patch letter from version replies.
Reproduction
-
From the tagged
libvtcheckout, install the locked development dependencies withuv sync --frozen --python 3.14 --all-groups --all-extras. Use the checkout root as the working directory. Use tmux 3.6b for the transcript below. SetTMUX_BINto its executable if another tmux comes first on your search path. -
Save the following as
case.pyat the checkout root.
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)
with pane() as (tm, write, capture, argv, version):
bundle = build_tmux_capture_command("%0", tmux_version=version)
raw = tm(*bundle.argv)
implicit = bundle.parse(raw)
explicit = bundle.parse(raw, profile=tmux_profile(version))
print("native", version, "profile", tmux_profile(version).identity.xtversion)
print("implicit", implicit.terminal.profile.identity.xtversion, "explicit", explicit.terminal.profile.identity.xtversion)
for name, result in (("implicit", implicit), ("explicit", explicit)):
result.terminal.feed(b"\x1b[>0q")
print(name, "reply", repr(result.terminal.drain_replies()))- Run the case.
$ uv run --no-sync python case.pyExpected
A bundle built for a native version retains that identity by default. A version string with a patch letter can be reported faithfully.
Actual
On tmux 3.6b the implicit profile replies with tmux 3.8 and the explicit profile replies with tmux 3.6. With tmux 3.4, the same example replies with tmux 3.8 and tmux 3.4, respectively.
Environment
Tested versions
libvt v0.0.1a4 and trunk 0864aa2, Linux ARM64 on WSL2, CPython 3.14.6, and tmux 3.6b and 3.4.
Evidence
Observed output
native tmux 3.6b profile tmux 3.6
implicit tmux 3.8 explicit tmux 3.6
implicit reply b'\x1bP>|tmux 3.8\x1b\\'
explicit reply b'\x1bP>|tmux 3.6\x1b\\'
Proposal
Store the resolved version/profile on the capture command. Keep the original normalized native identity for replies alongside the major/minor tuple used for capability selection. Preserve explicit profile overrides.
- Developer experience — The caller only supplies the server version once.
- Immediate benefit — Remove a silent version change at parse time and retain the release suffix.
- Longer-term benefit — Keep capability decisions separate from the exact terminal identity an application observes.
- End-user experience — Applications that branch on the terminal version can choose the same behavior inside and outside a recorded pane.
Activity
tony commentedon Dec 3, 2026
Capture and attach use the selected server's full version for terminal replies. In a native 32×4 pane on tmux 3.6b, the version query returned
ESC P >|tmux 3.6b ESC \with the suffix intact. An explicit profile keeps precedence. PR #158