Skip to content

tmux(feat[sync]): Add metadata, resize, resync (#60) - #63

Open
tony wants to merge 1 commit into
feat/display-lines-viewportfrom
feat/tmux-metadata-resync
Open

tony wants to merge 1 commit into
feat/display-lines-viewportfrom
feat/tmux-metadata-resync

Conversation

@tony

@tony tony commented Nov 29, 2026 •

Copy link
Copy Markdown
Member

Closes #60 (depends on #62)

Summary

  • Extend TMUX_METADATA_FORMAT and TmuxPaneMetadata with cursor shape, blink, keypad, and modifyOtherKeys state.
  • Add bounded history_lines (-S 0 and -S -N) and tmux >= 3.7 -F capture.
  • Resize live TmuxPaneSync terminals from V1 and V2 JSON %layout-change notifications.
  • Add TmuxPaneSync.resync() for in-place re-synchronization while preserving SyncToken watermarks.

Changes

Version detection and pane capture

  • src/libvt/contrib/tmux/profile.py: accept "master" (mapped to (3, 9)) and general -<suffix> build tags in parse_tmux_version().
  • src/libvt/contrib/tmux/capture.py: extend TMUX_METADATA_FORMAT (31 tab-separated fields) while retaining 27-field parsing in TmuxPaneMetadata.from_format_line(), apply cursor_shape, cursor_blinking, keypad_flag, and modify_other_keys to decoded Terminal state, reconcile _scrolled_total/_evicted_total/PromptZone offsets when history_lines bounds scrollback, expose metadata and post_metadata on TmuxCaptureResult, and enable capture-pane -F on tmux >= 3.7.

Live control-mode sync

  • src/libvt/contrib/tmux/control.py: add history_lines and tmux_version to TmuxPaneSync, parse target pane dimensions from compact V1 layout strings (WxH,X,Y,id) and V2 JSON layout payloads (%layout-change) to resize sync.terminal, and add TmuxPaneSync.resync() (also triggered automatically on %pause / %continue recovery) updating sync.terminal in place while advancing its epoch.

Tests and documentation

  • tests/test_tmux.py: cover 31-field and legacy 27-field metadata parsing, history_lines and tmux >= 3.7 -F capture commands, V1 and V2 %layout-change resizes, resync() identity and ScreenDelta.full_resync epoch increments, and live tmux -C subprocess capture/resize/resync parity.
  • docs/topics/migrating-from-pyte.md and CHANGES: link TmuxPaneSync.resync() and record the #60 changelog entry.

Design decisions

  • Mutate sync.terminal in place during TmuxPaneSync.resync() and increment _epoch rather than swapping in a new Terminal instance so caller references stay valid while held SyncToken values report ScreenDelta.full_resync=True.
  • Accept legacy 27-field metadata strings alongside 31-field TMUX_METADATA_FORMAT strings in TmuxPaneMetadata.from_format_line() so callers supplying older format strings continue to parse.

Test plan

  • Validate 31-field and 27-field metadata decoding, history_lines, and tmux >= 3.7 -F capture flags in tests/test_tmux.py
  • Validate V1 and V2 JSON %layout-change resizes and in-place TmuxPaneSync.resync() epoch updates in tests/test_tmux.py
  • Validate live tmux -C subprocess capture, resize, and resync() parity in tests/test_tmux.py
  • Pass ruff format, ruff check, ty check, pytest, and just build-docs

why: Live tmux pane observers and libtmux[vt] need complete pane state
capture, bounded history limits, %layout-change resize tracking, and
in-place resynchronization that preserves SyncToken watermarks.

what:
- Extend TMUX_METADATA_FORMAT and TmuxPaneMetadata with cursor_shape,
  cursor_blinking, keypad_flag, and modify_other_keys, exposed on
  TmuxCaptureResult
- Add bounded history_lines (-S 0 / -S -N) and tmux >= 3.7 -F detection
  (including master and -<suffix> versions) across capture and sync
- Resize live panes from V1 and V2 JSON %layout-change notifications
  and add in-place TmuxPaneSync.resync()
@tony
tony changed the base branch from master to feat/display-lines-viewport November 29, 2026 02:33

This branch was successfully deployed

1 active deployment
docs — ff20d29c Deployed Nov 29, 2026 by tony via build (3.14) #129
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add tmux pane metadata, %layout-change resize, and resync()

1 participant