Skip to content

fix: refresh probability improvements and instance switch fixes#20

Merged
linletian merged 3 commits intodevelopfrom
fix/refresh-prob-1
Mar 14, 2026
Merged

fix: refresh probability improvements and instance switch fixes#20
linletian merged 3 commits intodevelopfrom
fix/refresh-prob-1

Conversation

@linletian
Copy link
Owner

Changes

  • docs: update architecture and test cases for instance switch
  • fix(ui): disable mouse tracking on instance switch
  • docs: add missing scrollback documentation from PR13

Related

Branch: fix/refresh-prob-1

PR13 added scrollback: 10000 to xterm.js Terminal configuration and
documented it in ARCHITECTURE.md. This documentation line was
accidentally removed when the Terminal Protocol Timing Specification
was added in later commits.

This restores the client-side config documentation while preserving
all TUI and anomalous string fixes from the current branch.
When a TUI program (like opencode) enables mouse tracking mode and the user
switches to another instance, xterm.js continues generating mouse event
sequences. These were being sent to the new instance's PTY and displayed
as garbage text like "35;29;1M35;29;2M...".

Root cause: Terminal modes (including mouse tracking) leak between instances
because the same xterm.js terminal is reused across instance switches.

Fix: Explicitly disable common mouse tracking modes when switching instances:
- ?1000l: Disable mouse button press/release
- ?1002l: Disable mouse drag tracking
- ?1003l: Disable mouse all motion tracking
- ?1006l: Disable SGR extended mouse mode

This ensures each instance starts with a clean terminal state, preventing
mode leakage from previous TUI programs.
Architecture updates (ARCHITECTURE.md §5.3):
- Document mouse tracking mode reset in instance switch protocol
- Add Step 1.3 for terminal mode reset before buffer clearing
- Document that TUI programs re-initialize on SIGWINCH

Test case updates (TERMINAL_TEST_CASES.md):
- Add §7 ESC Key Handling test cases (6 cases)
- Add §8 Instance Switch Terminal Reset test cases (5 cases)
- Add §9 UTF-8 Multi-byte Handling test cases (4 cases)
- Update test statistics from 27 to 42 cases
- Expand manual testing section with instance switch scenarios

Related: Fixes mouse event leakage when switching from TUI to shell instance
@linletian linletian merged commit bdda603 into develop Mar 14, 2026
2 checks passed
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