Skip to content

fix(ui): Restore mouse after editor return - #235

Merged
umputun merged 1 commit into
umputun:masterfrom
abhinav:fix-editor-mouse-restore
Jun 22, 2026
Merged

umputun merged 1 commit into
umputun:masterfrom
abhinav:fix-editor-mouse-restore

Conversation

@abhinav

@abhinav abhinav commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

Bug:
Ctrl+E annotation editing releases the terminal to the external editor.
Bubble Tea disables mouse tracking during that release,
then restores the terminal without re-emitting the mouse-enable sequence.
After returning from the editor,
events therefore stay with the terminal instead of reaching revdiff.

Fix:
Mark editor sessions that passed through Bubble Tea's process handoff,
and re-enable mouse cell tracking when those sessions complete
for sessions that started with mouse tracking enabled.

Editor setup failures retry without requesting mouse restoration,
and --no-mouse sessions do not gain mouse tracking after editor return.

Ctrl+E annotation editing releases the terminal to the external editor.
Bubble Tea disables mouse tracking during that release,
then restores the terminal without re-emitting the mouse-enable sequence.
After returning from the editor,
wheel events therefore stay with the terminal instead of reaching revdiff.

Mark editor sessions that actually passed through Bubble Tea's process
handoff,
and re-enable mouse cell tracking when those sessions complete
for sessions that started with mouse tracking enabled.
Editor setup failures keep their existing retry behavior
without requesting mouse restoration,
and `--no-mouse` sessions do not gain mouse tracking after editor return.

The regression test covers the editor-completion path that must request
mouse tracking after a successful handoff.
Copilot AI review requested due to automatic review settings June 22, 2026 00:43
@abhinav
abhinav requested a review from umputun as a code owner June 22, 2026 00:43
@abhinav

abhinav commented Jun 22, 2026

Copy link
Copy Markdown
Contributor Author

This change is part of the following stack:

Change managed by git-spice.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes a UI regression where mouse tracking is not re-enabled after returning from an external editor session (Ctrl+E), causing mouse events to be handled by the terminal instead of revdiff. The change threads an explicit “restore mouse” flag through the editor completion message and re-emits Bubble Tea’s mouse-enable command only for sessions that originally started with mouse tracking enabled.

Changes:

  • Add a MouseTracking config flag to the UI model so editor sessions can know whether mouse tracking was enabled at startup.
  • Mark editor sessions that went through tea.ExecProcess completion to request mouse restoration on return.
  • Re-enable mouse cell-motion tracking on editor completion (and add targeted tests for both enabled/disabled cases).

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.

File Description
app/ui/model.go Adds internal model state + config field to remember whether mouse tracking was enabled for the session.
app/ui/editor.go Propagates a restore-mouse marker through editorFinishedMsg and returns tea.EnableMouseCellMotion when appropriate.
app/ui/editor_test.go Adds unit tests asserting the returned command is emitted only when restoration is requested.
app/main.go Wires MouseTracking from CLI option --no-mouse into ui.ModelConfig.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@umputun umputun left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm. Verified the diagnosis against vendored bubbletea - RestoreTerminal re-enables altscreen/bracketed-paste/report-focus but never mouse, so the fix targets the real gap, and gating on mouseTracking keeps --no-mouse correct.

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.

3 participants