Repository navigation
Open
Labels
enhancementNew feature or request
Description
Summary
src/libvt/tmux.py (#18) provides decode_tmux_capture() and unescape_tmux_control_output() for 0.1.0, but does not yet provide a streaming sans-I/O TmuxControlParser (%begin/%end/%error command blocks, %output, %extended-output, %layout-change) or a lossless live tmux -CC pane-attachment state machine (0.2.0 deferral).
Motivation
Attaching a live Terminal to a running tmux (>= 3.3a floor; control.c at 17c016750) pane via tmux -C / -CC has three protocol subtleties proven against live tmux 3.4, 3.8, and trunk (17c016750):
- Naive single-command bootstrap (issuing
capture-paneand discarding%output %Nlines arriving beforecapture-pane's%begin) loses bytes under multi-pane load (6of183-pane flood trials dropped output) because another command's pending block delays the capture reply while fresh pane output flushes ahead of%begin. - Passing
refresh-client -A '%N:off'beforeontriggered a crash ontmux 3.4, whereas a non-pipelined two-phaserefresh-client -A '%N:pause'barrier (wait for%endso no further%output %Ncan arrive -> rundisplay-message+capture-pane+capture-pane -P -p -Cfor incomplete escape state ->refresh-client -A '%N:continue') passed72of72stalled-client flood trials (100%). - In
control.c(17c016750),CONTROL_WRITE_MINIMUM(32) is a per-pane write floor underCONTROL_BUFFER_HIGH(8,192bytes),pause-afteremits"%%extended-output %%%u %llu : <escaped>"(requiring parsing up to the:separator before octal-unescaping), andcontrol_write_outputoctal-escapes only bytes< 0x20and'\\'while passing0x7F(DEL) and split multi-byte UTF-8 continuation bytes raw.
Proposal
Invariants
The invariants below are load-bearing; everything under Intent is open.
TmuxControlParseroperates strictly onbytes(memoryview/bytearray), never decoding%outputor%extended-outputlines as UTF-8 text prior to octal unescaping (so split multi-byte UTF-8 sequences across two%outputnotifications reassemble insideTerminal's incremental UTF-8 decoder withoutU+FFFDcorruption).- Live pane attachment uses the two-phase
refresh-client -A '%N:pause'->%end-> capture +-P -p -C->continuehandshake rather than discarding pre-%begin%output, and keepslibvtsans-I/O (subprocess transport stays in libtmux /libvt.aio).
Intent (non-binding)
- Target
0.2.0: addTmuxControlParseremitting typed%begin/%end/%error,%output(pane_id, raw unescapedbytes),%extended-output(pane_id,age_ms, rawbytes),%subscription-changed, and%exitevents, plus a sans-I/OTmuxPaneSyncstate machine coordinating two-phasepause->decode_tmux_capture(+-Pincomplete escape seed) ->continue.
Not doing
- Blocking
0.1.0on live-CCstreaming attachment (0.1.0shipsdecode_tmux_captureandunescape_tmux_control_output).
References
Metadata
Metadata
Assignees
Labels
enhancementNew feature or request
Activity