Files
Craigory Coppola b7afb7351c feat(core): add mouse support to the terminal UI (#35868)
## Current Behavior

The Nx terminal UI (TUI) does not capture mouse events. Scroll only
works in
terminals that translate the wheel into arrow keys, so it is
non-functional in
terminals that don't (notably macOS Terminal.app). Clicks,
double-clicks,
opening the Nx Cloud link, and selecting terminal output are all
unavailable.

## Expected Behavior

The full-screen TUI now captures the mouse (and releases it again when
dropping
to the inline view and on every teardown path — normal restore, `Drop`,
the
panic hook, and the JS `restoreTerminal` path — so the terminal is never
left
emitting mouse escape sequences):

- **Wheel** scrolls whatever is under the cursor (an output pane scrolls
its
  buffer; the task list moves its selection).
- **Click** a task row to select it; **click** the Nx Cloud link to open
it.
- **Double-click** an output pane, or a selected task row, to drop into
the
  inline view.
- **Drag** in a focused pane to select its output, with auto-scroll when
the
drag reaches the top/bottom edge; the selection is copied to the
clipboard on
  release and highlighted while active.

Mouse reporting uses DECSET `1000`/`1002`/`1006` (press, drag, SGR) only
— not
`1003` "any-motion" — to avoid a flood of hover events. Capture is
intentionally
**off** in the inline view, where the moving sub-region of the
scrollback makes
absolute mouse coordinates unreliable and native selection is
preferable.

### Implementation notes

- New per-frame hit-test region map (panes + task list) resolves what's
under
the cursor; the `TasksList` component owns its own row/cloud-link
geometry.
- Text selection is tracked in absolute content coordinates so it stays
anchored
as the pane scrolls; the highlight is painted by reverse-videoing the
selected
  cells after `tui-term` renders (it exposes no selection API).
- Unit tests cover selection containment/normalization and text
extraction
  (`cargo test --lib tui::` — 210 passing).

> [!IMPORTANT]
> Mouse interaction has been verified by compilation and unit tests, but
the
> on-screen behavior (click targeting, drag feel, auto-scroll cadence,
> wide-character selection fidelity) should be **dogfooded in a real
terminal**
> before this is marked ready. Opening as a draft for that reason.

## Related Issue(s)

Implements the Nx TUI mouse-capture work:

- NXC-3945 — enable mouse capture when entering full-screen terminal
view
- NXC-3944 — disable mouse capture when entering inline view
- NXC-3941 — click on task in tasks list to select it
- NXC-3940 — click to open cloud link
- NXC-3942 — double-click terminal pane to enter inline mode
- NXC-3943 — double-click already-selected task to enter inline view
- NXC-3946 — text selection within terminal pane
- NXC-3558 — likely fixed (TUI shifted off screen on scroll) since the
wheel no
  longer leaks to the real terminal

NXC-4199 (mouse/resize forwarding to interactive child programs) is
intentionally
deferred as a separate follow-up.

---------

Co-authored-by: nx-cloud[bot] <71083854+nx-cloud[bot]@users.noreply.github.com>
2026-07-02 11:02:28 -04:00

6 lines
550 B
TOML

disallowed-types = [
# We need to ensure adjustments for light and dark themes are applied appropriately
{ path = "ratatui::style::Color", reason = "Use our utils from crate::native::tui::colors instead to ensure appropriate light/dark theme support" },
# Embedded links need their rendered position; ratatui's Paragraph discards it.
{ path = "ratatui::widgets::Paragraph", reason = "Use crate::native::tui::components::nx_paragraph::NxParagraph instead (supports clickable links; nx_paragraph.rs is the only sanctioned wrapper)" },
]