Skip to content

fix(tui): reset leaked mouse tracking on startup#18902

Closed
janah01 wants to merge 1 commit into
anomalyco:devfrom
janah01:fix/reset-mouse-tracking-on-startup
Closed

fix(tui): reset leaked mouse tracking on startup#18902
janah01 wants to merge 1 commit into
anomalyco:devfrom
janah01:fix/reset-mouse-tracking-on-startup

Conversation

@janah01
Copy link
Copy Markdown

@janah01 janah01 commented Mar 24, 2026

Issue for this PR

Closes #18901

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

When the TUI is force-killed externally (taskkill /F on Windows, kill -9 on POSIX), for instance when installing OpenCode Desktop while OpenCode CLI is running, mouse tracking stays enabled in the terminal. The next opencode launch inherits this dirty state because the renderer starts from whatever baseline the terminal is already in.

This sends ?1000l ?1002l ?1003l ?1006l on startup to clear any leaked mouse modes before the renderer sets up its own. Disabling already-disabled modes is a safe no-op.

How did you verify your code works?

  • Launch on Windows Terminal, taskkill /F /PID, relaunch — terminal is clean
  • Normal exit (/exit) — no change in behavior
  • Ctrl+C exit — no change in behavior

Screenshots / recordings

N/A — not a UI change, terminal state fix.
Screenshot of the issue:
SCR-20260324-hxjd

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

When a previous process is killed externally (TerminateProcess on
Windows, SIGKILL on POSIX), mouse tracking can be left enabled in
the terminal. Send disable sequences before the renderer configures
its own mouse state to recover from a dirty baseline.
@github-actions github-actions Bot added the needs:compliance This means the issue will auto-close after 2 hours. label Mar 24, 2026
@github-actions
Copy link
Copy Markdown
Contributor

The following comment was made by an LLM, it may be inaccurate:

Based on my search results, I found two related PRs that address similar mouse tracking issues in the TUI:

  1. PR fix(tui): disable mouse tracking on exit to prevent terminal corruption #11019 - "fix(tui): disable mouse tracking on exit to prevent terminal corruption"

  2. PR fix: disable SGR mouse tracking on exit to prevent ASCII codes #6709 - "fix: disable SGR mouse tracking on exit to prevent ASCII codes"

The current PR (18902) is complementary to these - it handles the startup side of the problem (resetting leaked modes from force-killed processes), while the previous PRs addressed the exit side. These could potentially be part of the same comprehensive fix for terminal mouse tracking state management.

@github-actions github-actions Bot removed the needs:compliance This means the issue will auto-close after 2 hours. label Mar 24, 2026
@github-actions
Copy link
Copy Markdown
Contributor

Thanks for updating your PR! It now meets our contributing guidelines. 👍

@rekram1-node
Copy link
Copy Markdown
Collaborator

Automated PR Cleanup

Thank you for contributing to opencode.

Due to the high volume of PRs from users and AI agents, we periodically close older PRs using automated criteria so maintainers can focus review time on the most active and community-supported contributions.

This PR was closed because it matched the following cleanup criteria:

  • The PR was created more than 1 month ago
  • The PR had fewer than 2 positive reactions
  • Positive reactions are counted as thumbs-up, heart, celebration, or rocket reactions on the PR

PRs created within the last month are not affected by this cleanup.

If you believe this PR was closed incorrectly, or if you are still actively working on it, please leave a comment explaining why it should be reopened. A maintainer can review and reopen it if appropriate.

Thanks again for taking the time to contribute.

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.

[Windows] Hard-killed TUI leaves mouse reporting enabled; next launch does not reset terminal state

2 participants