Skip to content

Add smart tmux alt-screen mouse handling#10408

Open
TheWeaklessOne wants to merge 5 commits into
warpdotdev:masterfrom
TheWeaklessOne:theweaklessone/tmux-smart-mouse-actions
Open

Add smart tmux alt-screen mouse handling#10408
TheWeaklessOne wants to merge 5 commits into
warpdotdev:masterfrom
TheWeaklessOne:theweaklessone/tmux-smart-mouse-actions

Conversation

@TheWeaklessOne
Copy link
Copy Markdown

@TheWeaklessOne TheWeaklessOne commented May 7, 2026

Description

Adds smart mouse handling for tmux/alt-screen sessions behind the SmartAltScreenMouseHandling rollout gate.

What:

  • Routes no-Shift left-button drags in tmux SGR mouse mode to Warp selection/copy instead of blindly passing them to tmux.
  • Keeps no-drag, non-link clicks in tmux by replaying the original press/release AltMouseAction sequence to the PTY.
  • Reuses Warp link/file detection and context-menu actions for recognized URLs/paths in alt-screen output.
  • Adds stable pending gesture state on TerminalView, not AltScreenElement, so gesture routing survives element recreation.
  • Adds configurable tmux launcher detection through settings/env (WARP_SMART_ALT_SCREEN_MOUSE_TMUX_LAUNCHERS) for wrapper commands such as omx.

Why: tmux SGR mouse mode currently prevents Warp-native selection and file/path actions in alt-screen, but forcing Warp to intercept all mouse input would break normal tmux mouse mode.

How: The new gate only enables smart handling for tmux-like alt-screen sessions. It classifies each gesture, hands intentional selections/actions to Warp, and preserves passthrough behavior for ordinary tmux clicks.

Rollout note: this remains behind the SmartAltScreenMouseHandling rollout gate. Non-control-mode tmux detection is intentionally heuristic over the active command, with configurable launcher names plus common env/sudo wrapper-option scanning for launchers such as tmux or user-configured wrappers like omx.

Linked Issue

Related to #10353. This PR implements a narrower tmux/SGR smart-mouse slice of the native TUI selection request behind a rollout gate and configurable launcher detection; it should not auto-close #10353 unless maintainers decide this approach satisfies the broader spec.

Also related to the in-flight spec PR #10476 for the broader opt-in TUI native left-drag behavior.

  • The linked issue is labeled ready-to-spec or ready-to-implement.
  • Where appropriate, screenshots or a short video of the implementation are included below (especially for user-visible or UI changes).

Testing

Added/updated unit coverage for flag-off regression, flag-on drag selection, click passthrough, URL/path actions, context-menu helpers, Shift behavior, configurable launcher detection, wrapper-option launcher detection, complete right-click press/release passthrough, pre-SGR right-click context-menu preservation, and fail-closed unknown-locality path detection.

  • cargo test -p warp test_alt_screen_smart_mouse -- --nocapture --test-threads=1 (14 tests after latest review fixes)
  • cargo nextest run -p warp test_alt_screen_smart_mouse (14 tests after latest review fixes)
  • cargo test -p warp test_alt_screen -- --nocapture --test-threads=1 (22 tests after latest review fixes)
  • cargo fmt -- --check && git diff --check
  • cargo clippy -p warp --lib --tests -- -D warnings
  • Manual smoke: local dev build launched directly with WARP_SMART_ALT_SCREEN_MOUSE_TMUX_LAUNCHERS=omx; verified no-Shift tmux drag selection/copy and basic link/path behavior.
  • I have manually tested my changes locally with ./script/run

env -u OPENAI_API_KEY ./script/presubmit note: fmt, clippy, clang-format, wgslfmt, and static formatting checks passed. Full workspace nextest completed with 6093/6101 passing; the 8 local failures were 5 SSH/GCloud IAP auth tests blocked by local credentials, 1 settings migration local-state test outside this change area, and 2 terminal view tests that passed when rerun targeted immediately after the full-suite run.

Screenshots / Videos

N/A. This change is primarily terminal mouse-event routing (Warp selection vs PTY replay vs link/file action dispatch), so a screenshot would only show a selected region and would not demonstrate the important event-routing assertions. The behavior is covered by targeted tests that assert PTY writes/menu/action state, plus local tmux smoke testing for the visible selection/copy path.

Agent Mode

  • Warp Agent Mode - This PR was created via Warp's AI Agent Mode

Co-Authored-By: Warp agent@warp.dev

TheWeaklessOne and others added 2 commits May 7, 2026 23:53
Tmux SGR mouse mode needs Warp-native selection and link actions without breaking ordinary tmux mouse input. This keeps the behavior behind the smart alt-screen mouse feature gate, stores gesture state on TerminalView, and routes only recognized drags/links through Warp while replaying non-link clicks back to the PTY.

The review and manual-smoke follow-up tightened in-flight gesture continuity when Shift appears after mouse-down, limited cwd-less alt-screen path detection to absolute-looking paths, and split right-click smart routing from the left-button SGR-only predicate so non-link secondary clicks still reach tmux while Shift remains the force-Warp menu path.

Constraint: AltScreenElement is recreated between events, so pending gesture state must remain on TerminalView

Constraint: Non-link tmux clicks must replay AltMouseAction instead of being swallowed by Warp menus

Rejected: A blanket should_intercept_mouse=true path | would break normal tmux mouse mode

Rejected: Hardcoding omx as a tmux launcher | launcher allowlist is configurable through settings/env

Confidence: high

Scope-risk: moderate

Directive: Do not move pending smart mouse gesture state back into AltScreenElement

Tested: cargo test -p warp test_alt_screen_smart_mouse_right_click -- --nocapture --test-threads=1

Tested: cargo test -p warp test_alt_screen_smart_mouse -- --nocapture --test-threads=1

Tested: cargo nextest run -p warp test_alt_screen_smart_mouse

Tested: cargo test -p warp test_alt_screen -- --nocapture --test-threads=1

Tested: cargo fmt -- --check && git diff --check

Tested: cargo clippy -p warp --lib --tests -- -D warnings

Tested: TERM=xterm-256color WARP_SMART_ALT_SCREEN_MOUSE_TMUX_LAUNCHERS=omx ./script/run --features smart_alt_screen_mouse_handling --dont-open

Not-tested: Full app test suite

Co-authored-by: OmX <omx@oh-my-codex.dev>
The PR branch needs to target the latest master state before review, so this merge reconciles the smart alt-screen mouse changes with upstream test-module renames and related repository updates without changing the feature intent.

Constraint: Repository contribution rules ask PR branches to merge master before review
Constraint: Upstream renamed terminal view tests from view_test.rs to view_tests.rs
Confidence: high
Scope-risk: narrow
Tested: cargo test -p warp test_alt_screen_smart_mouse -- --nocapture --test-threads=1
Tested: cargo nextest run -p warp test_alt_screen_smart_mouse
Tested: cargo test -p warp test_alt_screen -- --nocapture --test-threads=1
Tested: cargo fmt -- --check && git diff --check
Tested: cargo clippy -p warp --lib --tests -- -D warnings
Tested: ./script/presubmit reached workspace nextest after fmt/clippy/format/static checks passed
Not-tested: Full presubmit green locally; workspace nextest is blocked here by unrelated local SSH/GCloud auth, OPENAI_API_KEY environment, and settings migration local-state failures
Co-authored-by: OmX <omx@oh-my-codex.dev>
@cla-bot
Copy link
Copy Markdown

cla-bot Bot commented May 7, 2026

Thank you for your pull request and welcome to our community. We require contributors to sign our Contributor License Agreement, and we don't seem to have the users @TheWeaklessOne on file. In order for us to review and merge your code, each contributor must visit https://cla.warp.dev to read and agree to our CLA. Once you have done so, please comment @cla-bot check to trigger another check.

@github-actions github-actions Bot added the external-contributor Indicates that a PR has been opened by someone outside the Warp team. label May 7, 2026
@TheWeaklessOne
Copy link
Copy Markdown
Author

@cla-bot check

@cla-bot cla-bot Bot added the cla-signed label May 8, 2026
@cla-bot
Copy link
Copy Markdown

cla-bot Bot commented May 8, 2026

The cla-bot has been summoned, and re-checked this pull request!

@TheWeaklessOne TheWeaklessOne marked this pull request as ready for review May 8, 2026 13:50
@oz-for-oss
Copy link
Copy Markdown
Contributor

oz-for-oss Bot commented May 8, 2026

@TheWeaklessOne

I'm starting a first review of this pull request.

You can view the conversation on Warp.

I completed the review and no human review was requested for this pull request.

Comment /oz-review on this pull request to retrigger a review (up to 3 times on the same pull request).

Powered by Oz

oz-for-oss[bot]
oz-for-oss Bot previously requested changes May 8, 2026
Copy link
Copy Markdown
Contributor

@oz-for-oss oz-for-oss Bot left a comment

Choose a reason for hiding this comment

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

Overview

This PR adds gated smart mouse routing for tmux-like alt-screen sessions, including Warp-native drag selection, link/file actions, click passthrough, and configurable tmux launcher detection.

Concerns

  • Right-click smart routing is not limited to sessions that have enabled SGR/mouse tracking, so enabling the rollout gate changes ordinary tmux alt-screen right-clicks into PTY mouse escape writes instead of preserving Warp's context menu.
  • The new absolute-path fallback treats unknown session locality as local, which can make untrusted terminal output trigger local filesystem path resolution/actions when Warp cannot prove the session is local.
  • This is a user-visible terminal interaction change with manual smoke testing described, but no screenshot or screen recording is attached and the PR does not justify why visual evidence is not possible. Manual testing evidence is required for manually testable behavioral changes.

Security

  • Unknown session locality should fail closed before resolving absolute paths against the user's local filesystem.

Verdict

Found: 0 critical, 3 important, 0 suggestions

Request changes

Comment /oz-review on this pull request to retrigger a review (up to 3 times on the same pull request).

Powered by Oz

Comment thread app/src/terminal/alt_screen/mod.rs Outdated
Comment thread app/src/terminal/view/link_detection.rs Outdated
Oz review flagged two places where the gated smart mouse path should fail closed: right-click passthrough before a terminal has advertised SGR mouse tracking, and absolute path detection when Warp cannot prove the active alt-screen session is local. This keeps smart behavior available for observed tmux SGR mouse sessions while preserving Warp's ordinary context menu and avoiding local filesystem actions for unknown session locality.

Constraint: Right-click PTY replay should only happen after observed mouse tracking, not merely because alt-screen and tmux heuristics match
Constraint: Unknown session locality must not resolve terminal output against the user's local filesystem
Rejected: Keep unknown locality as local for absolute paths | unsafe for remote or muxed output
Rejected: Keep pre-SGR right-click passthrough | changes ordinary alt-screen context menus under the rollout gate
Confidence: high
Scope-risk: narrow
Directive: Smart path/file actions in alt-screen should require known-local session context before touching local filesystem paths
Tested: cargo test -p warp test_alt_screen_smart_mouse -- --nocapture --test-threads=1
Tested: cargo nextest run -p warp test_alt_screen_smart_mouse
Tested: cargo test -p warp test_alt_screen -- --nocapture --test-threads=1
Tested: cargo fmt -- --check && git diff --check
Tested: cargo clippy -p warp --lib --tests -- -D warnings
Not-tested: Full presubmit rerun after this review fix; previous presubmit reached nextest and only failed unrelated local SSH/GCloud auth, settings migration state, and two suite-order view tests that passed targeted
Co-authored-by: OmX <omx@oh-my-codex.dev>
@TheWeaklessOne
Copy link
Copy Markdown
Author

Addressed the Oz review in 9c99ba89:

  • Pre-SGR/no-mouse-tracking right-click now stays on the normal Warp context-menu path instead of entering smart PTY replay.
  • Alt-screen absolute-path detection now fails closed unless Warp knows the active session is local before synthesizing / as cwd.
  • Added regression coverage for both paths and updated the PR testing/screenshot rationale.

Re-ran:

  • cargo test -p warp test_alt_screen_smart_mouse -- --nocapture --test-threads=1
  • cargo nextest run -p warp test_alt_screen_smart_mouse
  • cargo test -p warp test_alt_screen -- --nocapture --test-threads=1
  • cargo fmt -- --check && git diff --check
  • cargo clippy -p warp --lib --tests -- -D warnings

@TheWeaklessOne
Copy link
Copy Markdown
Author

/oz-review

@oz-for-oss
Copy link
Copy Markdown
Contributor

oz-for-oss Bot commented May 8, 2026

@TheWeaklessOne

I'm re-reviewing this pull request in response to a review request.

You can view the conversation on Warp.

I completed the review and no human review was requested for this pull request.

Comment /oz-review on this pull request to retrigger a review (up to 3 times on the same pull request).

Powered by Oz

oz-for-oss[bot]
oz-for-oss Bot previously requested changes May 8, 2026
Copy link
Copy Markdown
Contributor

@oz-for-oss oz-for-oss Bot left a comment

Choose a reason for hiding this comment

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

Overview

This PR adds feature-gated smart mouse routing for tmux SGR alt-screen sessions, including Warp-native selection/link handling, PTY replay for ordinary clicks, configurable launcher detection, and targeted tests.

Concerns

  • Right-click passthrough only replays the press event, which likely explains the documented tmux native context-menu smoke-test failure and leaves SGR consumers without the complete click sequence.
  • tmux launcher detection stops at the first non-wrapper token, so common wrapper options before the actual launcher disable the smart path even when tmux is ultimately executed.

Verdict

Found: 0 critical, 2 important, 0 suggestions

Request changes

Comment /oz-review on this pull request to retrigger a review (up to 3 times on the same pull request).

Powered by Oz

Comment thread app/src/terminal/view.rs
Comment thread app/src/terminal/alt_screen/mod.rs Outdated
Oz found that right-click passthrough only replayed the press and that wrapper command options could hide the configured tmux launcher. The smart path now replays a complete right-click press/release sequence for tmux consumers and keeps scanning after common env/sudo wrapper options before deciding whether the active command enables smart mouse routing.

Constraint: No-Shift non-link right-clicks must still pass through to tmux when SGR mouse reporting is active.

Constraint: Launcher detection remains configurable and should not hardcode omx as a special tmux launcher.

Rejected: Treat every non-link right-click as a Warp menu | this regresses ordinary tmux mouse mode.

Confidence: high

Scope-risk: narrow

Directive: Keep smart alt-screen mouse routing gated and preserve complete PTY mouse sequences for passthrough gestures.

Tested: cargo fmt -- --check && git diff --check

Tested: cargo test -p warp test_alt_screen_smart_mouse -- --nocapture --test-threads=1

Tested: cargo nextest run -p warp test_alt_screen_smart_mouse

Tested: cargo test -p warp test_alt_screen -- --nocapture --test-threads=1

Tested: cargo clippy -p warp --lib --tests -- -D warnings
@TheWeaklessOne
Copy link
Copy Markdown
Author

/oz-review

@oz-for-oss
Copy link
Copy Markdown
Contributor

oz-for-oss Bot commented May 8, 2026

@TheWeaklessOne

I'm re-reviewing this pull request in response to a review request.

You can view the conversation on Warp.

I reviewed this pull request and requested human review from: @warpdotdev/oss-maintainers.

Comment /oz-review on this pull request to retrigger a review (up to 3 times on the same pull request).

Powered by Oz

@oz-for-oss oz-for-oss Bot dismissed stale reviews from themself May 8, 2026 15:59

Oz no longer requests changes for this pull request after the latest automated review.

Copy link
Copy Markdown
Contributor

@oz-for-oss oz-for-oss Bot left a comment

Choose a reason for hiding this comment

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

Overview

This PR adds feature-flagged smart mouse routing for tmux-like SGR alt-screen sessions, keeping Warp selection/link handling for intentional gestures while replaying ordinary clicks to the PTY. The implementation keeps gesture state on TerminalView, preserves the existing non-smart path behind the rollout gate, and adds targeted coverage for selection, passthrough, link/file actions, Shift behavior, and launcher detection.

Concerns

No blocking correctness, security, or error-handling issues found in the annotated diff. The behavioral change is manually tested in the PR description, and the description explains why a screenshot would not demonstrate the event-routing behavior.

Verdict

Found: 0 critical, 0 important, 0 suggestions

Approve

Comment /oz-review on this pull request to retrigger a review (up to 3 times on the same pull request).

Powered by Oz

@oz-for-oss oz-for-oss Bot requested review from a team and vorporeal and removed request for a team May 8, 2026 15:59
@TheWeaklessOne
Copy link
Copy Markdown
Author

Addressed the latest Oz review in b5476acd:

  • Non-link smart right-click passthrough now emits a complete right-button press + release sequence to the PTY.
  • tmux launcher detection now scans past common env/sudo wrapper options before deciding whether the active command is a configured launcher.
  • Replied to and resolved all Oz review threads.

Re-ran:

  • cargo fmt -- --check && git diff --check
  • cargo test -p warp test_alt_screen_smart_mouse -- --nocapture --test-threads=1
  • cargo nextest run -p warp test_alt_screen_smart_mouse
  • cargo test -p warp test_alt_screen -- --nocapture --test-threads=1
  • cargo clippy -p warp --lib --tests -- -D warnings

spalagu added a commit to spalagu/warp that referenced this pull request May 11, 2026
Product spec + tech spec for warpdotdevGH-10353, derived from a working reference
implementation (spalagu/warp:fix/left-drag-selection, f1c38c7).

product.md:
- One opt-in boolean (default false), backwards-compatible
- Behavior matrix covering all mouse-event types in mouse-reporting TUIs
  (bare-left intercepts; Shift / right / scroll / middle / modifier+click
  all preserve current behavior)
- Settings UI / command palette / context flag exposure
- Success criteria + manual validation across Claude Code / vim / htop / tmux

tech.md:
- 7 call-site enumeration with the bare_left_button computation each
  performs (locally strips Cmd / Ctrl / Alt; Shift handled by existing
  earlier early-return)
- One-branch addition to should_intercept_mouse, placed between Shift
  early-return and SGR forwarding gate
- Naming: bare_left_button (revised from is_left_button per oz-bot
  feedback on PR warpdotdev#10552 — naive is_left_button would intercept
  modifier+left when setting is enabled, contradicting the product-spec
  behavior matrix)
- Test coverage: existing view_tests.rs signature update + decision-matrix
  tests including the three modifier-left cases
- Risk table + comparison vs competing specs (warpdotdev#10476, warpdotdev#10455, warpdotdev#10408)
@TheWeaklessOne
Copy link
Copy Markdown
Author

@oss-maintainers gentle ping — Oz is green now, all Oz review threads are resolved, and the PR is waiting for human review.

I noticed the broader native TUI selection work is still in the #10353 spec flow (#10476 / #10455 / #10552). This PR is intentionally narrower: a feature-gated tmux/SGR smart-mouse slice that preserves normal tmux mouse mode by routing:

  • no-Shift drag → Warp selection
  • non-link click/right-click → PTY passthrough
  • URL/path click/right-click → Warp actions/menu

It also stays default-off behind SmartAltScreenMouseHandling.

Could you advise whether maintainers would like to review this as an independently mergeable gated improvement, or whether it should be deferred/folded into whichever #10353 spec direction wins?

Merge the latest upstream master so the PR is no longer blocked by GitHub merge conflicts before maintainer review. Upstream removed several old feature flags near this branch's smart mouse flag, so the conflict resolution keeps SmartAltScreenMouseHandling registered while accepting the upstream flag cleanup.

Constraint: Preserve the feature-gated smart tmux/SGR mouse behavior and avoid reintroducing the removed RemoveAltScreenPadding flag.

Rejected: Force-rebase the public PR branch | a merge commit is safer for an already-reviewed external PR and matches the repo guidance to merge master in.

Confidence: high

Scope-risk: narrow

Directive: Keep SmartAltScreenMouseHandling wired in app/src/lib.rs and crates/warp_features/src/lib.rs when resolving future feature-flag churn.

Tested: cargo fmt -- --check && git diff --check

Tested: cargo test -p warp test_alt_screen_smart_mouse -- --nocapture --test-threads=1

Tested: cargo nextest run -p warp test_alt_screen_smart_mouse

Tested: cargo test -p warp test_alt_screen -- --nocapture --test-threads=1

Tested: cargo clippy -p warp --lib --tests -- -D warnings

Co-authored-by: OmX <omx@oh-my-codex.dev>
@TheWeaklessOne
Copy link
Copy Markdown
Author

Updated the branch with latest origin/master and resolved the merge conflicts in app/src/lib.rs / crates/warp_features/src/lib.rs by keeping SmartAltScreenMouseHandling and accepting upstream feature-flag cleanup. PR is now mergeable again on GitHub; remaining block appears to be human review.

Re-ran locally:

  • cargo fmt -- --check && git diff --check
  • cargo test -p warp test_alt_screen_smart_mouse -- --nocapture --test-threads=1
  • cargo nextest run -p warp test_alt_screen_smart_mouse
  • cargo test -p warp test_alt_screen -- --nocapture --test-threads=1
  • cargo clippy -p warp --lib --tests -- -D warnings

@vorporeal vorporeal requested review from peicodes and removed request for vorporeal May 15, 2026 02:43
@vorporeal
Copy link
Copy Markdown
Contributor

@peicodes is going to handle getting agreement on the desired spec here!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla-signed external-contributor Indicates that a PR has been opened by someone outside the Warp team.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Opt-in: bare left-drag selects in TUI without holding Shift on macOS

2 participants