Skip to content

Keep SGR mouse format winning in snapshot replay - #558

Merged
jiweiyuan merged 1 commit into
mainfrom
fix/441-mouse-format-replay
Aug 31, 2026
Merged

Keep SGR mouse format winning in snapshot replay#558
jiweiyuan merged 1 commit into
mainfrom
fix/441-mouse-format-replay

Conversation

@jiweiyuan

Copy link
Copy Markdown
Collaborator

A snapshot payload re-emits mouse modes from the terminal's mode bits in enum order — SGR (?1006h) before urxvt (?1015h). crossterm's EnableMouseCapture sets urxvt then SGR, so a replaying client landed in urxvt, an encoding crossterm TUIs don't parse. Their mouse went dead after every attach, resize, or backlog resync, and stayed dead because a TUI never re-sends state it believes is already set (#441).

format_vt now re-asserts ?1006h whenever the payload carries both formats with urxvt last. The guard checks the actual byte order, so a formatter that one day restates the winner itself turns this into a no-op. ?1015h only ever appears in the wild as the compatibility fallback written before ?1006h, so preferring SGR reconstructs the real state.

Regression tests cover crossterm's exact enable sequence, a second replay hop, and an SGR-only host staying untouched.

Fixes #441

Release Notes:

  • Fixed mouse input dying in crossterm TUIs (herdr, lazygit, btop, …) after a resize, reattach, or resync.

Mouse format is last-writer-wins, but the formatter re-emits mode bits
in enum order — SGR (?1006h) before urxvt (?1015h). crossterm enables
urxvt then SGR, so replaying a snapshot flipped the client into urxvt,
an encoding crossterm TUIs don't parse: their mouse went dead after
every attach, resize, or resync. Re-assert SGR whenever the payload
carries both, guarded on the actual order so a fixed formatter turns
this into a no-op.

Refs: #441
@vercel

vercel Bot commented Aug 31, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
termio Ready Ready Preview Aug 31, 2026 7:38pm

Request Review

@jiweiyuan
jiweiyuan merged commit 494a706 into main Aug 31, 2026
4 checks passed
@jiweiyuan
jiweiyuan deleted the fix/441-mouse-format-replay branch August 31, 2026 19:52
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.

ai 检查完代码无法上下滑动

1 participant