Skip to content

fix(terminal): replay pane terminal modes on reattach so TUIs keep mouse reporting - #181

Open
Kihsomray wants to merge 1 commit into
a9a4k:mainfrom
Kihsomray:fix/reattach-pane-modes
Open

fix(terminal): replay pane terminal modes on reattach so TUIs keep mouse reporting#181
Kihsomray wants to merge 1 commit into
a9a4k:mainfrom
Kihsomray:fix/reattach-pane-modes

Conversation

@Kihsomray

Copy link
Copy Markdown

Fixes #180

Problem

A Terminal reattached after a Switch or reload gets its content, cursor, and
alt-screen state seeded into the new xterm, but not the terminal modes the
running TUI set once at startup — so the fresh xterm comes up with mouse
tracking off and clicks never reach the process. The post-seed SIGWINCH
repaint (repaintAfterSeed) doesn't help: TUIs redraw on resize but don't
re-send DECSET modes.

Fix

Read tmux's per-pane mode flags (mouse_standard/button/all/sgr_flag,
cursor_flag, keypad_cursor_flag, keypad_flag, bracket_paste_flag) in
the list-panes -F that already discovers the pane id, and replay the set
ones into xterm before the captured frame — the same technique iTerm2 uses on
attach (sources/tmux/TmuxStateParser.m, TmuxWindowOpener.m). Generic:
applies to any TUI, nothing app-specific. Comma-separated format so a tmux
lacking a flag yields an empty field instead of shifting the rest.

Verification

  • Unit tests pin the seed order (modes → frame → CUP) plus the empty-field
    tolerance case; full suite passes (802 tests).
  • tmux 3.7c: every flag tracks DECSET on/off; the built format round-trips
    through real tmux -C control mode.

ADR-0012 decision 5 amended with one paragraph.

…use reporting

A Terminal reattached after a Switch or reload seeds xterm with the pane's
content, cursor, and alt-screen state, but not the modes the running TUI
set once at startup — so a fresh xterm came up with mouse tracking off and
clicks never reached the process. The post-seed SIGWINCH repaint does not
help: TUIs redraw on resize but do not re-send DECSET modes.

Read tmux's per-pane mode flags (mouse_*_flag, cursor_flag,
keypad_*_flag, bracket_paste_flag) in the list-panes -F that already
discovers the pane id, and replay the set ones before the captured frame.
Comma-separated so a tmux lacking a flag yields an empty field instead of
shifting the rest.
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.

Mouse input stops working in a Deck terminal after switching to another worktree and then switching back.

1 participant