Skip to content

fix(attach): stop wheel scroll typing arrows and keep quick detach armed through terminal replies#27

Merged
aksOps merged 1 commit into
mainfrom
fix/attach-scroll-and-replies
Jun 12, 2026
Merged

fix(attach): stop wheel scroll typing arrows and keep quick detach armed through terminal replies#27
aksOps merged 1 commit into
mainfrom
fix/attach-scroll-and-replies

Conversation

@aksOps

@aksOps aksOps commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

Summary

Two attach-client bugs reported against v0.2.0. Both live entirely in uam __attach; session hosts are untouched.

Wheel scroll typed up/down arrows into the agent

Alternate scroll mode (?1007, default-on in VTE terminals) converts mouse wheel motion into arrow keys on the alternate screen when mouse reporting is off — introduced by #23 moving the bridge onto its own alt screen. screenEnter now saves the user's setting (XTSAVE) and disables the mode; screenExit restores it (XTRESTORE) before leaving the alt screen. Terminals without ?1007 ignore all three sequences.

Behavior note: for agents that don't enable mouse reporting, the wheel is now inert in-session instead of typing arrows (uam has no scrollback viewer yet); mouse-aware agents are unaffected.

Left-arrow quick detach only worked after Enter

Terminal replies to agent queries arrive on stdin — Ink-based agents request the cursor position on every render — and every reply poisoned the empty-box estimate: completed CSI sequences latched unknown, DA1 replies overflowed maxEscLen (8), and OSC/DCS payload bytes counted as typed runes. The filter now:

  • classifies terminal-generated traffic as neutral (seqPoisons): private-prefix CSI (</?/>) and reply/event finals (CPR, DA1, DSR, mode/window reports, focus in/out, legacy mouse)
  • consumes OSC/DCS/SOS/PM/APC string sequences verbatim through their BEL/ST terminator (capped at 4 KiB), without touching the estimate
  • sizes maxEscLen for replies (64; a DA1 attribute list runs ~40 bytes)

Real keystrokes (arrows, function keys, alt/meta chords, tab) still disarm the quick detach as before. One documented, test-pinned trade-off: xterm's modified F3 (CSI 1;2R) shares its grammar with a cursor position report and is treated as a reply — CPR is constant Ink traffic, while no supported agent binds modified F3 to text entry.

Testing

  • 8 new regression tests (TDD: confirmed red before the fix): terminal replies, OSC/DCS strings (incl. split across reads), mouse and focus events, keys-still-disarm, the F3/CPR trade-off, and ?1007 disable/restore assertions in the TTY terminal-state test
  • Full suite: 396 tests / 20 packages, plus -race on the session package
  • vet, golangci-lint, gofmt, gosec, govulncheck all clean

🤖 Generated with Claude Code

…med through terminal replies

Two attach-client bugs reported against v0.2.0:

Mouse wheel typed up/down arrows into the agent. Alternate scroll mode
(?1007, default-on in VTE terminals) converts wheel motion into arrow
keys on the alternate screen when mouse reporting is off. screenEnter
now saves the user's setting (XTSAVE) and disables the mode; screenExit
restores it (XTRESTORE) before leaving the alt screen.

The left-arrow quick detach only worked after pressing Enter, even with
nothing typed. Terminal replies to agent queries arrive on stdin — Ink
agents request the cursor position on every render — and every reply
poisoned the empty-box estimate: completed CSI sequences latched
unknown, DA1 replies overflowed maxEscLen, and OSC/DCS payload bytes
counted as typed runes. The filter now classifies terminal-generated
traffic (CPR/DA1/DSR/kitty/mode reports, mouse and focus events) as
neutral via seqPoisons, consumes OSC/DCS/SOS/PM/APC strings verbatim
through their terminator, and sizes maxEscLen for replies (64).
@sonarqubecloud

Copy link
Copy Markdown

@aksOps aksOps merged commit dd5808b into main Jun 12, 2026
13 checks passed
@aksOps aksOps deleted the fix/attach-scroll-and-replies branch June 12, 2026 04:16
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.

1 participant