Skip to content

feat(core): add mouse support to the terminal UI#35868

Draft
AgentEnder wants to merge 5 commits into
masterfrom
feature/nxc-tui-mouse-capture
Draft

feat(core): add mouse support to the terminal UI#35868
AgentEnder wants to merge 5 commits into
masterfrom
feature/nxc-tui-mouse-capture

Conversation

@AgentEnder
Copy link
Copy Markdown
Member

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.

@netlify
Copy link
Copy Markdown

netlify Bot commented Jun 3, 2026

Deploy Preview for nx-dev ready!

Name Link
🔨 Latest commit 7d30e86
🔍 Latest deploy log https://app.netlify.com/projects/nx-dev/deploys/6a21baac360b850008c60785
😎 Deploy Preview https://deploy-preview-35868--nx-dev.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@netlify
Copy link
Copy Markdown

netlify Bot commented Jun 3, 2026

Deploy Preview for nx-docs ready!

Name Link
🔨 Latest commit 7d30e86
🔍 Latest deploy log https://app.netlify.com/projects/nx-docs/deploys/6a21baac1544f20008354c2d
😎 Deploy Preview https://deploy-preview-35868--nx-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@nx-cloud
Copy link
Copy Markdown
Contributor

nx-cloud Bot commented Jun 3, 2026

View your CI Pipeline Execution ↗ for commit edfb563


☁️ Nx Cloud last updated this comment at 2026-06-04 17:50:07 UTC

nx-cloud[bot]

This comment was marked as outdated.

Enable terminal mouse reporting (DECSET 1000/1002/1006 — press, drag, SGR;
no any-motion hover firehose) when entering or switching to the full-screen
TUI, and disable it when dropping to inline mode or tearing down (restore,
Drop, panic hook, and the JS restoreTerminal path) so the terminal is never
left emitting mouse sequences.

Decode crossterm mouse events into a new Event::Mouse variant and route wheel
ScrollUp/ScrollDown through the existing momentum-scroll model. This makes
scrolling work in terminals that don't translate the wheel to arrow keys
(notably macOS Terminal.app).

Refs NXC-3945, NXC-3944, NXC-3558
Build a per-frame hit-test region map (panes + task list) and route mouse
clicks through it:

- click a task row to select it (NXC-3941)
- double-click an output pane, or a selected task row, to drop into the
  inline view (NXC-3942, NXC-3943)
- click the cloud link to open it in the browser (NXC-3940)

Also upgrades wheel scrolling to target whatever is under the cursor rather
than only the focused element.

Refs NXC-3940, NXC-3941, NXC-3942, NXC-3943
Drag with the left mouse button inside a focused output pane to select its
text (NXC-3946). The selection is tracked in absolute content coordinates so
it stays anchored as the pane scrolls, auto-scrolls when the drag reaches the
top/bottom edge, and is copied to the clipboard on release. The highlight is
painted by reverse-videoing the selected cells after tui-term renders, since
it exposes no selection API.

Adds unit tests for selection containment/normalization and text extraction.

Refs NXC-3946
…tion

The TUI surfaces the Nx Cloud run URL by intercepting the cloud client's
stdout/stderr writes — it matches each write's stack trace against the cloud
client's bundle directory. That directory was hardcoded to
`{workspaceRoot}/.nx/cache/cloud`, but the client actually loads from the
resolved `cacheDir/cloud`, which differs when the cache dir isn't the literal
default: most notably in a git worktree (where the cache is shared with the
main repo), and also with NX_CACHE_DIRECTORY, a custom `cacheDirectory` in
nx.json, or the lerna `node_modules/.cache` location.

In those cases the stack-trace check never matched, so the cloud message was
never forwarded to the TUI (it only reappeared in the post-run output). Use the
client's own `getBundleInstallDefaultLocation()` resolver so the interception
matches wherever the bundle really lives.
@AgentEnder AgentEnder force-pushed the feature/nxc-tui-mouse-capture branch from 71f4d0f to edfb563 Compare June 4, 2026 17:06
Copy link
Copy Markdown
Contributor

@nx-cloud nx-cloud Bot left a comment

Choose a reason for hiding this comment

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

Nx Cloud has identified a flaky task in your failed CI:

🔂 Since the failure was identified as flaky, we triggered a CI rerun by adding an empty commit to this branch.

Nx Cloud View detailed reasoning in Nx Cloud ↗


🎓 Learn more about Self-Healing CI on nx.dev

@AgentEnder AgentEnder changed the title feat(nx): add mouse support to the terminal UI feat(core): add mouse support to the terminal UI Jun 4, 2026
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.

1 participant