fix(tui): repaint + sync mouse mode when display.mouse_tracking changes

Two interacting bugs left the TUI blank when `display.mouse_tracking`
switched at runtime (config edit, /mouse <preset>):

1. AlternateScreen's effect re-runs on every `mouseTracking` change,
   tearing down and re-entering the alt screen. After re-entry, ink's
   frame buffers are reset by `resetFramesForAltScreen()` but nothing
   schedules the follow-up render — the alt screen sits blank until
   some other state change happens to trigger one. Add a
   `scheduleRender()` in `setAltScreenActive`'s active=true branch so
   the freshly-entered alt screen gets a full repaint immediately.

2. `setAltScreenActive` early-returns when `active` hasn't changed,
   which silently drops a `mouseTracking` change if the cleanup→setup
   pair somehow leaves `altScreenActive` already true. Call
   `setAltScreenMouseTracking` explicitly from the AlternateScreen
   effect so the in-memory mode and terminal DECSET sequence stay in
   sync regardless of how `setAltScreenActive` resolved (the call is a
   no-op when the mode is unchanged).
This commit is contained in:
Nat Thrower 2026-05-15 21:51:12 -04:00 committed by Brooklyn Nicholson
parent 6e5b8650cc
commit ece0a2f4cc
2 changed files with 2 additions and 0 deletions

View file

@ -75,6 +75,7 @@ export function AlternateScreen(t0: Props) {
(enableMouse || DISABLE_MOUSE_TRACKING) (enableMouse || DISABLE_MOUSE_TRACKING)
) )
ink?.setAltScreenActive(true, mouseTracking) ink?.setAltScreenActive(true, mouseTracking)
ink?.setAltScreenMouseTracking(mouseTracking)
return () => { return () => {
ink?.setAltScreenActive(false) ink?.setAltScreenActive(false)

View file

@ -1272,6 +1272,7 @@ export default class Ink {
if (active) { if (active) {
this.resetFramesForAltScreen() this.resetFramesForAltScreen()
this.scheduleRender()
} else { } else {
this.repaint() this.repaint()
} }