fix(client): re-assert host mouse modes after a terminal reconnect - #2285
fix(client): re-assert host mouse modes after a terminal reconnect#2285dengoswei wants to merge 1 commit into
Conversation
A host terminal can be re-created underneath a live client. Web VS Code restores a reconnected terminal from a serialized snapshot that brings back the mouse tracking mode without the SGR encoding herdr asked for, so every mouse report then arrives in an encoding the client cannot parse and leaks into the focused pane as text. Recovering required detaching and reattaching. Re-assert the host mouse mode set on regained focus and on resize, both of which fire when a client reconnects. set_mouse_capture already clears host mouse reporting first, so this also drops the stale tracking mode.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughThe client detects outer-focus-gained input and reapplies configured host mouse capture on Unix, Windows, and terminal resize flows. Tests cover focus gain, focus loss, and regular key input. ChangesHost mouse capture refresh
Estimated code review effort: 3 (Moderate) | ~20 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
Greptile SummaryThe PR reasserts host mouse modes after focus-gained and resize events so terminal surfaces restored with stale tracking encodings recover automatically.
Confidence Score: 4/5The direct-attach resize regression should be fixed before merging because resizing can disable mouse handling for users whose normal mouse-capture setting is off. Direct-terminal attach always enables host mouse capture, but the new resize handler reapplies a separately initialized configuration value and can therefore turn that required mode off. Files Needing Attention: src/client/mod.rs
|
| Filename | Overview |
|---|---|
| src/client/mod.rs | Adds mouse-mode reassertion to focus and resize handling, but the resize refresh can disable the mouse mode that direct-terminal attach installed independently of configuration. |
| src/raw_input.rs | Adds a narrow predicate and tests mapping OuterFocusGained to a required host-mode refresh. |
Sequence Diagram
sequenceDiagram
participant Host as Host terminal
participant Client as Herdr client
participant Server as Herdr server
Host->>Client: Focus gained or resize
Client->>Host: Clear restored mouse modes
Client->>Host: Reapply tracked capture state
Client->>Server: Forward input or resize
Server-->>Client: MouseCapture updates
Reviews (1): Last reviewed commit: "fix(client): re-assert host mouse modes ..." | Re-trigger Greptile
| // A reconnect re-syncs the terminal size before the user touches | ||
| // anything, so this usually restores the mode set before the | ||
| // first stray mouse report can leak into a pane. | ||
| refresh_host_mouse_capture(state.mouse_capture_active); |
There was a problem hiding this comment.
Resize disables direct-attach mouse mode
When a Unix direct-terminal attach has ui.mouse_capture disabled, setup still enables host mouse capture, but this resize refresh reapplies the configuration-derived false state, causing mouse interaction and attach-mode scrolling to stop after the first resize.
Knowledge Base Used: Client attach and raw input pipeline
Current behavior
A host terminal can be re-created underneath a live client. Web VS Code restores a
reconnected terminal from a serialized snapshot that brings back the mouse tracking
mode without the SGR encoding Herdr asked for. Every mouse report then arrives in an
encoding the client cannot parse and leaks into the focused pane as text, so moving
the mouse types garbage. Recovering requires detaching and reattaching.
Reproduction
Fix
Re-assert the host mouse mode set on regained focus and on resize, both of which fire
when a client reconnects.
set_mouse_capturealready clears host mouse reportingfirst, so this also drops the stale tracking mode.
Checks
cargo fmt --check,cargo clippy --all-targets --locked -- -D warnings, and thex86_64-pc-windows-msvcclippy pass are clean on this branch.cargo test --lockedleaves 6 failures on my machine. All 6 fail identically on anunmodified checkout of the same base commit: five
update::testscases that talk to arunning Herdr server (I have one running) and
workspace::tests::generated_workspace_ids_are_short_base32_handles, which passes inisolation. Nothing in
raw_inputorclientfails.