feat(core): add mouse support to the terminal UI#35868
Draft
AgentEnder wants to merge 5 commits into
Draft
Conversation
✅ Deploy Preview for nx-dev ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
✅ Deploy Preview for nx-docs ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Contributor
|
View your CI Pipeline Execution ↗ for commit edfb563 ☁️ Nx Cloud last updated this comment at |
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.
71f4d0f to
edfb563
Compare
…tion [Self-Healing CI Rerun]
Contributor
There was a problem hiding this comment.
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.
🎓 Learn more about Self-Healing CI on nx.dev
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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, thepanic hook, and the JS
restoreTerminalpath — so the terminal is never leftemitting mouse escape sequences):
buffer; the task list moves its selection).
inline view.
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 — not1003"any-motion" — to avoid a flood of hover events. Capture is intentionallyoff in the inline view, where the moving sub-region of the scrollback makes
absolute mouse coordinates unreliable and native selection is preferable.
Implementation notes
the cursor; the
TasksListcomponent owns its own row/cloud-link geometry.as the pane scrolls; the highlight is painted by reverse-videoing the selected
cells after
tui-termrenders (it exposes no selection API).(
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:
longer leaks to the real terminal
NXC-4199 (mouse/resize forwarding to interactive child programs) is intentionally
deferred as a separate follow-up.