fix(renderer): handle SIGTSTP to prevent mouse garbling on external suspend#907
Open
agutmanstein-scale wants to merge 2 commits intoanomalyco:mainfrom
Open
fix(renderer): handle SIGTSTP to prevent mouse garbling on external suspend#907agutmanstein-scale wants to merge 2 commits intoanomalyco:mainfrom
agutmanstein-scale wants to merge 2 commits intoanomalyco:mainfrom
Conversation
…uspend When a process receives SIGTSTP from an external source (e.g., job control, terminal multiplexer, code-server), the process is suspended by the kernel without any terminal cleanup. Mouse tracking, Kitty keyboard protocol, and raw mode remain active, causing mouse events to appear as garbled escape sequences in the shell. Add SIGTSTP/SIGCONT signal handlers that call suspend()/resume() to properly clean up terminal state before suspension and restore it after resuming. The SIGTSTP handler removes itself before re-raising the signal to allow the default suspend behavior. The handlers are registered alongside exit listeners and removed symmetrically in suspend(), resume(), and cleanupBeforeDestroy(). Fixes anomalyco#906 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
agutmanstein-scale
added a commit
to agutmanstein-scale/opencode
that referenced
this pull request
Apr 1, 2026
When opencode receives SIGTSTP from an external source (code-server terminal management, job control, kill -TSTP), the process is suspended without terminal cleanup. Mouse tracking remains enabled, causing mouse events to echo as garbled escape sequences in the shell. Register SIGTSTP/SIGCONT handlers after renderer creation that call renderer.suspend()/resume() — the same cleanup the manual suspend keybind uses. The SIGTSTP handler removes itself before re-raising to allow default suspend behavior. Includes test-sigtstp-mouse.sh reproduction script. Upstream fix: anomalyco/opentui#907 Closes anomalyco#20506 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Open
6 tasks
18vijayb
pushed a commit
to 18vijayb/opencode
that referenced
this pull request
Apr 2, 2026
When opencode receives SIGTSTP from an external source (code-server terminal management, job control, kill -TSTP), the process is suspended without terminal cleanup. Mouse tracking remains enabled, causing mouse events to echo as garbled escape sequences in the shell. Register SIGTSTP/SIGCONT handlers after renderer creation that call renderer.suspend()/resume() — the same cleanup the manual suspend keybind uses. The SIGTSTP handler removes itself before re-raising to allow default suspend behavior. Includes test-sigtstp-mouse.sh reproduction script. Upstream fix: anomalyco/opentui#907 Closes anomalyco#20506 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
… input When SIGCONT arrives without a prior SIGTSTP through our handler (e.g., terminal refocus/reconnect in code-server), calling resume() adds a duplicate stdin listener — every keystroke is delivered twice. Guard resume() with _suspendedBySigtstp so it only runs if our SIGTSTP handler actually called suspend(). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
agutmanstein-scale
added a commit
to agutmanstein-scale/opencode
that referenced
this pull request
Apr 2, 2026
When opencode receives SIGTSTP from an external source (code-server terminal management, job control, kill -TSTP), the process is suspended without terminal cleanup. Mouse tracking remains enabled, causing mouse events to echo as garbled escape sequences in the shell. Register SIGTSTP/SIGCONT handlers after renderer creation that call renderer.suspend()/resume() — the same cleanup the manual suspend keybind uses. The SIGTSTP handler removes itself before re-raising to allow default suspend behavior. Includes test-sigtstp-mouse.sh reproduction script. Upstream fix: anomalyco/opentui#907 Closes anomalyco#20506 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
3 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue for this PR
Closes #906
Type of change
What does this PR do?
When a process receives SIGTSTP from an external source (job control, terminal multiplexer, code-server), the process is suspended by the kernel without any terminal cleanup. Mouse tracking and raw mode remain active, causing mouse events to echo as garbled text in the shell.
This PR adds SIGTSTP/SIGCONT signal handlers to the renderer that call
suspend()/resume()— the same cleanup that the manual suspend keybind uses.Implementation:
sigtstpHandler: callssuspend()to disable mouse/raw mode, removes itself, re-raises SIGTSTP for default suspend behaviorsigcontHandler: re-registers the SIGTSTP handler, callsresume()to restore terminal stateaddSigtstpListeners()/removeSigtstpListeners(): symmetric lifecycle management matchingaddExitListeners()/removeExitListeners()suspend(),cleanupBeforeDestroy(); re-added inresume()How did you verify your code works?
suspend()/resume()which are already well-testedReproduction without fix
Checklist
🤖 Generated with Claude Code