Skip to content

Comments

fix: restore mouse state after ExecProcess#1583

Open
veeceey wants to merge 1 commit intocharmbracelet:mainfrom
veeceey:fix/restore-mouse-state-after-exec
Open

fix: restore mouse state after ExecProcess#1583
veeceey wants to merge 1 commit intocharmbracelet:mainfrom
veeceey:fix/restore-mouse-state-after-exec

Conversation

@veeceey
Copy link

@veeceey veeceey commented Feb 10, 2026

Summary

  • Fixes a bug where mouse events (cell motion and all motion tracking) stop working after returning from a process launched via tea.ExecProcess (e.g., spawning vim from a TUI program)
  • ReleaseTerminal already saved and restored bracketed paste, alt screen, and focus reporting state, but mouse mode was missing from this save/restore cycle
  • Adds mouse state tracking to the renderer and wires it through ReleaseTerminal/RestoreTerminal

Fixes #1424

What changed

  • renderer.go: Added mouseCellMotionActive() and mouseAllMotionActive() to the renderer interface
  • standard_renderer.go: Added mouseCellMotion and mouseAllMotion boolean fields, updated enable/disable methods to track state, added getter methods
  • nil_renderer.go: Implemented the new interface methods (always return false)
  • tea.go: Added mouseCellMotionWasActive and mouseAllMotionWasActive fields to Program; ReleaseTerminal now saves mouse state; RestoreTerminal now re-enables mouse mode (including SGR extended mode) when it was previously active
  • screen_test.go / nil_renderer_test.go: Added tests for mouse state tracking

Test plan

  • All existing tests pass (go test ./...)
  • go vet ./... passes cleanly
  • New TestMouseStateTracking test verifies enable/disable state tracking on the standard renderer
  • Nil renderer tests updated to cover new interface methods
  • Manual testing: run a Bubble Tea program with mouse enabled, exec an external process (e.g., vim), exit it, and verify mouse events still work

🤖 Generated with Claude Code

ReleaseTerminal saves bracketed paste, alt screen, and focus reporting
state so they can be re-enabled by RestoreTerminal (used by ExecProcess
to run external commands). However, mouse mode state (cell motion and
all motion tracking) was not saved or restored, causing mouse events to
stop working after returning from an exec'd process like vim.

This adds mouse state tracking to the renderer and saves/restores it
across ReleaseTerminal/RestoreTerminal, fixing the issue.

Fixes charmbracelet#1424

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@veeceey
Copy link
Author

veeceey commented Feb 19, 2026

Friendly ping - any chance someone could take a look at this when they get a chance? Happy to make any changes if needed.

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.

tea.ExecProcess does not restore mouse motion

1 participant