From c7f54e9254d06f4c870e0dde1e879e8af622909f Mon Sep 17 00:00:00 2001 From: Tony Narlock Date: Wed, 2 Dec 2026 19:29:10 -0600 Subject: [PATCH 1/2] tmux(fix[scope]): Detect panes outside session why: A moved pane can stop sending bytes while its observer stays live. what: - Confirm pane membership in the control client's session. - Retain the last screen and allow same-handle resync. - Cover moved, linked and closed panes. Fixes #76 --- MIGRATION | 7 ++ docs/topics/sync-and-asyncio.md | 10 +- src/libvt/contrib/tmux/control.py | 181 ++++++++++++++++++++++-------- tests/test_tmux.py | 125 ++++++++++++++++++--- 4 files changed, 259 insertions(+), 64 deletions(-) diff --git a/MIGRATION b/MIGRATION index fcb0c660..8454f94d 100644 --- a/MIGRATION +++ b/MIGRATION @@ -142,6 +142,13 @@ until the coordinator returns to `LIVE`. Read the new geometry from the same terminal after that checkpoint. Check its {ref}`bookmark epoch ` before reusing an absolute row. +### `TmuxPaneSync` session scope (#76) + +Handle `OUT_OF_SCOPE` alongside `LIVE` and `FAILED` when awaiting an +attachment. `terminal` holds the last screen when the pane moves away and +is `None` when the pane was never attached. Send `resync()` through a control +client attached to a session that contains the pane. + ## libvt 0.0.1a2 (2026-11-28) ### Curated PEP 562 `libvt` root exports (#43) diff --git a/docs/topics/sync-and-asyncio.md b/docs/topics/sync-and-asyncio.md index 0b28c9ff..ead55bb0 100644 --- a/docs/topics/sync-and-asyncio.md +++ b/docs/topics/sync-and-asyncio.md @@ -201,7 +201,7 @@ two-phase `refresh-client -A '%N:pause'` barrier and atomic `capture-pane` + >>> parser.feed(b"%output %0 hello\\015\\012\n") [TmuxOutput(pane_id='%0', data=b'hello\r\n')] >>> sync = TmuxPaneSync("%0") ->>> "refresh-client -A '%0:pause'" in sync.begin_attach(), sync.phase +>>> "list-panes -s" in sync.begin_attach(), sync.phase (True, ) ``` @@ -242,6 +242,14 @@ other tasks also write to the client. Catch {meth}`~libvt.contrib.tmux.control.TmuxPaneSync.handle_event` call so that the other panes receive the same event. +An attach checks the control client's session before pausing or capturing the +pane. A sync can enter `CHECKING_SCOPE` while it confirms whether the pane +still belongs to the session. If the pane moves outside that session, the +sync enters `OUT_OF_SCOPE` and retains the last observed screen. To follow +the pane, use a control client attached to a session containing it and send +the result of +{meth}`~libvt.contrib.tmux.control.TmuxPaneSync.resync` on that client. + ### Follow pane process replacement Tmux keeps the pane ID when a new child takes over after `respawn-pane`. diff --git a/src/libvt/contrib/tmux/control.py b/src/libvt/contrib/tmux/control.py index dc29c8ca..217c83e4 100644 --- a/src/libvt/contrib/tmux/control.py +++ b/src/libvt/contrib/tmux/control.py @@ -30,6 +30,11 @@ re.ASCII, ) _MAX_LAYOUT_DIM = 10_000 +_SESSION_PANES = ( + "list-panes -s -F '#{pane_id} #{window_id} #{pane_height} #{pane_width}'" +) + +type _BatchStage = t.Literal["locate", "pause", "capture", "scope"] def _search_v2_layout_node(node: object, pane_id: str) -> tuple[int, int] | None: @@ -789,14 +794,16 @@ class TmuxAttachPhase(enum.StrEnum): CAPTURING = "capturing" LIVE = "live" PAUSED = "paused" + CHECKING_SCOPE = "checking-scope" + OUT_OF_SCOPE = "out-of-scope" FAILED = "failed" class TmuxPaneSync: r"""Sans-I/O two-phase ``tmux -C`` / ``-CC`` pane-attachment coordinator. - Implements a pause barrier (``refresh-client -A '%N:pause'`` followed by - pane ID verification) and a single atomic + Checks membership in the control client's session, then implements a + pause barrier and a single atomic ``capture-pane`` + ``capture-pane -P -p -C`` + ``refresh-client -A '%N:continue'`` command batch so ``tmux`` executes capture and resume in one ``cmdq_next`` turn without dropping live PTY bytes. @@ -805,6 +812,12 @@ class TmuxPaneSync: returned string in one write followed by a newline. The two lines identify the reply owner and submit its command batch. + A topology change can put a live pane into + :attr:`TmuxAttachPhase.CHECKING_SCOPE` while the session query runs. + If the pane leaves the client's session, :attr:`phase` becomes + :attr:`TmuxAttachPhase.OUT_OF_SCOPE` and ``terminal`` retains its last view. + Call :meth:`resync` from a control client whose session contains the pane. + Parameters ---------- pane_id : str @@ -854,7 +867,7 @@ class TmuxPaneSync: -------- >>> from libvt.contrib.tmux.control import TmuxAttachPhase, TmuxPaneSync >>> sync = TmuxPaneSync("%0") - >>> "refresh-client -A '%0:pause'" in sync.begin_attach() + >>> "list-panes -s" in sync.begin_attach() True >>> sync.phase == TmuxAttachPhase.PAUSING True @@ -862,6 +875,7 @@ class TmuxPaneSync: __slots__ = ( "_batch_marker", + "_batch_stage", "_capture_cmd", "_capture_process_changed", "_collected_blocks", @@ -872,6 +886,7 @@ class TmuxPaneSync: "_process_identity", "_process_subscription", "_profile", + "_window_id", "capture_result", "history_lines", "pane_id", @@ -920,6 +935,8 @@ def __init__( self._limits = limits self._phase = TmuxAttachPhase.UNATTACHED self._batch_marker: bytes | None = None + self._batch_stage: _BatchStage | None = None + self._window_id: str | None = None self._expected_blocks = 0 self._collected_blocks: list[TmuxCommandBlock] = [] self._capture_cmd: TmuxCaptureCommand | None = None @@ -931,7 +948,7 @@ def __init__( @property def phase(self) -> TmuxAttachPhase: - """Return current :class:`TmuxAttachPhase`. + """Return current :class:`TmuxAttachPhase` including scope checks. Examples -------- @@ -939,15 +956,17 @@ def phase(self) -> TmuxAttachPhase: >>> TmuxPaneSync("%0").phase.value 'unattached' """ + if self._batch_stage == "scope": + return TmuxAttachPhase.CHECKING_SCOPE return self._phase def begin_attach(self) -> str: - r"""Start the pause barrier and return the control-client input. + r"""Check session membership before pausing and capturing the pane. Returns ------- str - Reply marker and pause batch. Append ``\n`` and write both lines + Reply marker and membership query. Append ``\n`` and write both lines together to the control client's stdin. Raises @@ -958,7 +977,7 @@ def begin_attach(self) -> str: Examples -------- >>> from libvt.contrib.tmux.control import TmuxPaneSync - >>> "refresh-client -A '%2:pause'" in TmuxPaneSync("%2").begin_attach() + >>> "list-panes -s" in TmuxPaneSync("%2").begin_attach() True """ from libvt.contrib.tmux.profile import parse_tmux_version @@ -972,11 +991,8 @@ def begin_attach(self) -> str: raise ProtocolError(msg) self._capture_cmd = None self._capture_process_changed = False - return self._start_batch( - TmuxAttachPhase.PAUSING, - f"refresh-client -A '{self.pane_id}:pause'", - f"display-message -p -t '{self.pane_id}' '#{{pane_id}}'", - ) + self._phase = TmuxAttachPhase.PAUSING + return self._start_batch("locate", _SESSION_PANES, self._pane_id_query()) def resync(self) -> str: r"""Trigger an explicit two-phase resynchronization in place. @@ -990,7 +1006,7 @@ def resync(self) -> str: Returns ------- str - Reply marker and pause batch, as in :meth:`begin_attach`. + Reply marker and membership query, as in :meth:`begin_attach`. """ return self.begin_attach() @@ -1055,24 +1071,77 @@ def _handle_process_notice(self, event: TmuxSubscriptionChanged) -> str | None: self._capture_process_changed = True return None - def _start_batch(self, phase: TmuxAttachPhase, *commands: str) -> str: + def _pane_id_query(self) -> str: + return f"display-message -p -t '{self.pane_id}' '#{{pane_id}}'" + + def _start_batch(self, stage: _BatchStage, *commands: str) -> str: marker = f"__LIBVT_BATCH_{os.urandom(16).hex()}__" self._batch_marker = marker.encode("ascii") - self._phase = phase + self._batch_stage = stage self._expected_blocks = len(commands) self._collected_blocks.clear() # tmux parses the entire command line before executing its first command. # A separate guard owns even a parse error for the next line. return f"display-message -p {marker}\n" + " ; ".join(commands) - def _batch_error(self, detail: str) -> ProtocolError: - stage = "pause" if self._phase is TmuxAttachPhase.PAUSING else "capture" - self._phase = TmuxAttachPhase.FAILED + def _clear_batch(self) -> None: + self._batch_marker = None + self._batch_stage = None self._expected_blocks = 0 self._collected_blocks.clear() self._capture_cmd = None + + def _batch_error(self, detail: str) -> ProtocolError: + stage = "pause" if self._batch_stage == "locate" else self._batch_stage + self._phase = TmuxAttachPhase.FAILED + self._clear_batch() return ProtocolError(f"tmux {stage} failed for {self.pane_id}: {detail}") + def _session_pane(self, block: TmuxCommandBlock) -> tuple[int, int] | None: + pane_id = self.pane_id.encode("ascii") + for line in block.lines: + fields = line.split() + if not fields or fields[0] != pane_id: + continue + if len(fields) == 4: + _, window, rows, cols = fields + if ( + window.startswith(b"@") + and window[1:].isdigit() + and len(rows) <= 5 + and len(cols) <= 5 + and rows.isdigit() + and cols.isdigit() + and 1 <= (height := int(rows)) <= _MAX_LAYOUT_DIM + and 1 <= (width := int(cols)) <= _MAX_LAYOUT_DIM + ): + self._window_id = window.decode("ascii") + return height, width + detail = "invalid pane geometry in session reply" + raise self._batch_error(detail) + self._window_id = None + self._phase = TmuxAttachPhase.OUT_OF_SCOPE + self._clear_batch() + return None + + def _check_scope(self) -> str | None: + if self._batch_stage is None and self._phase in ( + TmuxAttachPhase.LIVE, + TmuxAttachPhase.PAUSED, + ): + return self._start_batch("scope", _SESSION_PANES) + return None + + def _resize_live(self, rows: int, cols: int) -> str | None: + terminal = self.terminal + if ( + self._phase == TmuxAttachPhase.LIVE + and terminal is not None + and (rows, cols) != (terminal.rows, terminal.cols) + ): + return self.resync() + return None + def _build_capture_batch(self) -> str: from libvt.contrib.tmux.capture import build_tmux_capture_command @@ -1091,9 +1160,11 @@ def _build_capture_batch(self) -> str: subcmds = [s for s in subcmds if s] subcmds.append(["capture-pane", "-P", "-p", "-C", "-t", self.pane_id]) subcmds.append(["refresh-client", "-A", f"{self.pane_id}:continue"]) + self._phase = TmuxAttachPhase.CAPTURING return self._start_batch( - TmuxAttachPhase.CAPTURING, + "capture", *(" ".join(_tmux_quote(arg) for arg in sub) for sub in subcmds), + _SESSION_PANES, ) def _finish_capture(self) -> None: @@ -1102,8 +1173,8 @@ def _finish_capture(self) -> None: cap_cmd = self._capture_cmd assert cap_cmd is not None - cap_blocks = self._collected_blocks[:-2] - pend_block = self._collected_blocks[-2] + cap_blocks = self._collected_blocks[:-3] + pend_block = self._collected_blocks[-3] combined_lines = [ line.decode("utf-8", errors="surrogateescape") for block in cap_blocks @@ -1135,9 +1206,7 @@ def _finish_capture(self) -> None: else: self.terminal = result.terminal self.capture_result = result - self._capture_cmd = None - self._collected_blocks.clear() - self._expected_blocks = 0 + self._clear_batch() self._phase = TmuxAttachPhase.LIVE def handle_event(self, event: TmuxControlEvent) -> str | None: @@ -1168,20 +1237,8 @@ def handle_event(self, event: TmuxControlEvent) -> str | None: -------- >>> from libvt.contrib.tmux.control import TmuxCommandBlock, TmuxPaneSync >>> sync = TmuxPaneSync("%0") - >>> cmd1 = sync.begin_attach() - >>> marker = cmd1.splitlines()[0].rsplit(" ", 1)[1].encode("ascii") - >>> sync.handle_event(TmuxCommandBlock( - ... timestamp=1, command_number=1, flags=1, lines=(marker,) - ... )) - >>> sync.handle_event(TmuxCommandBlock( - ... timestamp=1, command_number=2, flags=1, lines=() - ... )) - >>> cmd2 = sync.handle_event( - ... TmuxCommandBlock( - ... timestamp=1, command_number=3, flags=1, lines=(b"%0",) - ... ) - ... ) - >>> "capture-pane" in (cmd2 or "") and ":continue" in (cmd2 or "") + >>> commands = sync.begin_attach() + >>> "list-panes -s" in commands and "#{pane_id}" in commands True """ if isinstance(event, (TmuxOutput, TmuxExtendedOutput)): @@ -1207,15 +1264,27 @@ def handle_event(self, event: TmuxControlEvent) -> str | None: return None if isinstance(event, TmuxLayoutChange): - if self._phase == TmuxAttachPhase.LIVE and self.terminal is not None: + if self._phase in (TmuxAttachPhase.LIVE, TmuxAttachPhase.PAUSED): size = _parse_layout_pane_size(event.visible_layout, self.pane_id) if size is None: size = _parse_layout_pane_size(event.layout, self.pane_id) - if size is not None and size != ( - self.terminal.rows, - self.terminal.cols, - ): - return self.resync() + if size is not None: + self._window_id = event.window_id + return self._resize_live(*size) + if self._window_id == event.window_id: + return self._check_scope() + return None + + if isinstance(event, TmuxNotification): + if event.name == "session-changed": + return self._check_scope() + if ( + event.name in ("window-close", "unlinked-window-close") + and self._window_id is not None + and event.args.split(maxsplit=1)[:1] + == [self._window_id.encode("ascii")] + ): + return self._check_scope() return None if ( @@ -1244,14 +1313,30 @@ def handle_event(self, event: TmuxControlEvent) -> str | None: if len(self._collected_blocks) < self._expected_blocks: return None - if self._phase == TmuxAttachPhase.PAUSING: + if self._batch_stage in ("locate", "pause"): if event.lines != (self.pane_id.encode("ascii"),): detail = "target pane is unavailable" raise self._batch_error(detail) + if self._batch_stage == "locate": + if self._session_pane(self._collected_blocks[0]) is None: + return None + return self._start_batch( + "pause", + f"refresh-client -A '{self.pane_id}:pause'", + self._pane_id_query(), + ) return self._build_capture_batch() - if self._capture_process_changed: - return self.resync() - self._finish_capture() + if self._batch_stage == "capture": + if self._session_pane(self._collected_blocks[-1]) is None: + return None + if self._capture_process_changed: + return self.resync() + self._finish_capture() + else: + size = self._session_pane(event) + if size is not None: + self._clear_batch() + return self._resize_live(*size) return None diff --git a/tests/test_tmux.py b/tests/test_tmux.py index 65944644..85d596f1 100644 --- a/tests/test_tmux.py +++ b/tests/test_tmux.py @@ -51,16 +51,38 @@ def _ack_tmux_pause(sync: TmuxPaneSync, command: str, number: int) -> str | None _claim_tmux_batch(sync, command, number) assert ( sync.handle_event( - TmuxCommandBlock(timestamp=1, command_number=number + 1, flags=1, lines=()) + TmuxCommandBlock( + timestamp=1, + command_number=number + 1, + flags=1, + lines=(f"{sync.pane_id} @1 2 8".encode("ascii"),), + ) ) is None ) - return sync.handle_event( + pane_reply = (sync.pane_id.encode("ascii"),) + pause = sync.handle_event( TmuxCommandBlock( timestamp=1, command_number=number + 2, flags=1, - lines=(sync.pane_id.encode("ascii"),), + lines=pane_reply, + ) + ) + assert pause is not None + _claim_tmux_batch(sync, pause, number + 3) + assert ( + sync.handle_event( + TmuxCommandBlock(timestamp=1, command_number=number + 4, flags=1, lines=()) + ) + is None + ) + return sync.handle_event( + TmuxCommandBlock( + timestamp=1, + command_number=number + 5, + flags=1, + lines=pane_reply, ) ) @@ -1236,7 +1258,11 @@ def send(command: str) -> None: errors[pane.pane_id] = str(exc) continue if command is not None: - if pane is bad and stage == "capture": + if ( + pane is bad + and stage == "capture" + and pane.phase == TmuxAttachPhase.CAPTURING + ): run("kill-pane", "-t", missing) send(command) if all( @@ -1313,7 +1339,7 @@ def test_tmux_metadata_cursor_keys_history_bounds_layout_resize_and_resync() -> cmd1 = sync.begin_attach() cmd2 = _ack_tmux_pause(sync, cmd1, 1) assert cmd2 is not None and "-S -5" in cmd2 - _claim_tmux_batch(sync, cmd2, 4) + _claim_tmux_batch(sync, cmd2, 7) nonce1 = cmd2.split(":PRE:", 1)[0].rsplit("'", 1)[1] pre1 = ( "8\t2\t3\t0\t1\t0\t4294967295\t4294967295\t0\t1\t" @@ -1333,8 +1359,9 @@ def test_tmux_metadata_cursor_keys_history_bounds_layout_resize_and_resync() -> [f"{nonce1}:POST:{pre1}".encode()], [], [], + [b"%1 @1 2 8"], ] - for i, lines_b in enumerate(blocks1, start=5): + for i, lines_b in enumerate(blocks1, start=8): assert ( sync.handle_event( TmuxCommandBlock( @@ -1384,7 +1411,7 @@ def test_tmux_metadata_cursor_keys_history_bounds_layout_resize_and_resync() -> assert resync_cmd1 is not None and sync.phase == TmuxAttachPhase.PAUSING resync_cmd2 = _ack_tmux_pause(sync, resync_cmd1, 20) assert resync_cmd2 is not None and sync.phase == TmuxAttachPhase.CAPTURING - _claim_tmux_batch(sync, resync_cmd2, 23) + _claim_tmux_batch(sync, resync_cmd2, 26) nonce2 = resync_cmd2.split(":PRE:", 1)[0].rsplit("'", 1)[1] pre2 = ( "12\t3\t6\t0\t1\t0\t4294967295\t4294967295\t0\t2\t" @@ -1404,8 +1431,9 @@ def test_tmux_metadata_cursor_keys_history_bounds_layout_resize_and_resync() -> [f"{nonce2}:POST:{pre2}".encode()], [b"!"], [], + [b"%1 @1 3 12"], ] - for i, lines_b in enumerate(blocks2, start=24): + for i, lines_b in enumerate(blocks2, start=27): sync.handle_event( TmuxCommandBlock( timestamp=2, @@ -1424,6 +1452,44 @@ def test_tmux_metadata_cursor_keys_history_bounds_layout_resize_and_resync() -> assert delta.full_resync is True assert delta.resync_reason == ResyncReason.EPOCH_CHANGED + saved = live_term.committed + scope = sync.handle_event( + TmuxLayoutChange(window_id="@1", layout="b992,12x3,0,0,0", visible_layout="") + ) + assert scope is not None and "list-panes -s" in scope + assert sync.phase is TmuxAttachPhase.CHECKING_SCOPE + _claim_tmux_batch(sync, scope, 40) + assert ( + sync.handle_event( + TmuxCommandBlock( + timestamp=2, command_number=41, flags=1, lines=(b"%0 @1 3 12",) + ) + ) + is None + ) + assert sync.phase is TmuxAttachPhase.OUT_OF_SCOPE + assert sync.terminal is live_term and sync.terminal.committed == saved + + # Resync recovers the same handle, then a V2 layout change requests a new capture. + recover_cmd1 = sync.resync() + recover_cmd2 = _ack_tmux_pause(sync, recover_cmd1, 50) + assert recover_cmd2 is not None and sync.phase == TmuxAttachPhase.CAPTURING + _claim_tmux_batch(sync, recover_cmd2, 56) + nonce3 = recover_cmd2.split(":PRE:", 1)[0].rsplit("'", 1)[1] + for i, lines_b in enumerate(blocks2, start=57): + sync.handle_event( + TmuxCommandBlock( + timestamp=3, + command_number=i, + flags=1, + lines=tuple( + ln.replace(nonce2.encode("ascii"), nonce3.encode("ascii")) + for ln in lines_b + ), + ) + ) + assert sync.phase == TmuxAttachPhase.LIVE and sync.terminal is live_term + # Compare a new V2 layout to the currently installed native frame. v2_layout = ( '{"V":2,"L":{"t":"h","w":30,"h":6,"x":0,"y":0,"c":[' @@ -1435,13 +1501,38 @@ def test_tmux_metadata_cursor_keys_history_bounds_layout_resize_and_resync() -> ) held = live_term.committed refresh = sync.handle_event(layout) - assert refresh is not None and "refresh-client -A '%1:pause'" in refresh + assert refresh is not None and "list-panes -s" in refresh assert sync.phase == TmuxAttachPhase.PAUSING assert sync.terminal is live_term assert live_term.committed is held assert sync.handle_event(layout) is None +def test_tmux_attach_to_pane_outside_client_session() -> None: + """A globally valid pane is reachable through its session's control client.""" + from libvt.contrib.tmux import TmuxAttachPhase + + sync = TmuxPaneSync("%8") + command = sync.begin_attach() + assert "list-panes -s" in command + _claim_tmux_batch(sync, command, 1) + assert ( + sync.handle_event( + TmuxCommandBlock( + timestamp=1, command_number=2, flags=1, lines=(b"%0 @0 3 12",) + ) + ) + is None + ) + assert ( + sync.handle_event( + TmuxCommandBlock(timestamp=1, command_number=3, flags=1, lines=(b"%8",)) + ) + is None + ) + assert sync.phase is TmuxAttachPhase.OUT_OF_SCOPE and sync.terminal is None + + @pytest.mark.integration @pytest.mark.skipif(shutil.which("tmux") is None, reason="tmux binary not installed") def test_live_tmux_capture_and_control_checkpoint_agreement() -> None: @@ -1679,9 +1770,7 @@ def test_older_tmux_attach_identifies_one_shot_capture() -> None: with pytest.raises(ProtocolError, match=r"3\.2.*build_tmux_capture_command"): sync.begin_attach() assert sync.phase.value == "unattached" - assert "refresh-client -A '%0:pause'" in ( - TmuxPaneSync("%0", tmux_version="3.2a").begin_attach() - ) + assert "list-panes -s" in (TmuxPaneSync("%0", tmux_version="3.2a").begin_attach()) @pytest.mark.parametrize( @@ -1884,7 +1973,12 @@ def update( def block(*lines: bytes) -> TmuxCommandBlock: return TmuxCommandBlock(timestamp=1, command_number=1, flags=1, lines=lines) - def begin_capture(pause: str) -> list[TmuxCommandBlock]: + def begin_capture(locate: str) -> list[TmuxCommandBlock]: + marker = locate.splitlines()[0].split()[-1].encode("ascii") + assert sync.handle_event(block(marker)) is None + assert sync.handle_event(block(b"%0 @0 2 8")) is None + pause = sync.handle_event(block(b"%0")) + assert pause is not None and ":pause" in pause marker = pause.splitlines()[0].split()[-1].encode("ascii") assert sync.handle_event(block(marker)) is None assert sync.handle_event(block(b"%pause %0")) is None @@ -1911,6 +2005,7 @@ def begin_capture(pause: str) -> list[TmuxCommandBlock]: block(f"{nonce}:POST:{meta}".encode()), block(), block(), + block(b"%0 @0 2 8"), ] assert sync.handle_event(update("12,0")) is None @@ -1926,7 +2021,7 @@ def begin_capture(pause: str) -> list[TmuxCommandBlock]: assert sync.terminal is None retry = sync.handle_event(capture_blocks[-1]) - assert retry is not None and ":pause" in retry + assert retry is not None and "list-panes -s" in retry assert sync.phase is TmuxAttachPhase.PAUSING assert sync.terminal is None @@ -1949,7 +2044,7 @@ def begin_capture(pause: str) -> list[TmuxCommandBlock]: assert sync.phase is TmuxAttachPhase.LIVE refresh = sync.handle_event(update("15,0")) - assert refresh is not None and ":pause" in refresh + assert refresh is not None and "list-panes -s" in refresh assert sync.phase is TmuxAttachPhase.PAUSING assert term.committed is old for reply in begin_capture(refresh): From 831ffccb6ca496f0485255f7acdd0c4f9c6e16df Mon Sep 17 00:00:00 2001 From: Tony Narlock Date: Wed, 2 Dec 2026 19:35:35 -0600 Subject: [PATCH 2/2] CHANGES(docs): Describe out-of-session panes why: A control client can lose access to a pane while its last screen is still useful. what: - Document scope checks and when the retained pane can resynchronize. --- CHANGES | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/CHANGES b/CHANGES index 65c05418..b739d2ab 100644 --- a/CHANGES +++ b/CHANGES @@ -213,6 +213,13 @@ dimensions. The same terminal receives the new frame and advances its epoch. See {ref}`tmux-row-bookmarks` to check whether an absolute-row bookmark is still valid. +#### Report panes outside the tmux client's session (#166) + +A live or paused {class}`~libvt.contrib.tmux.control.TmuxPaneSync` enters +`CHECKING_SCOPE` when it rechecks session membership. If the pane is +outside the client's session, the sync enters `OUT_OF_SCOPE` and keeps +its last screen. + ### Documentation #### Assert effective colors alongside screen goldens (#190)