Skip to content

feat(tui): allow releasing mouse capture for native selection - #570

Merged
emal-avala merged 4 commits into
mainfrom
feat/mouse-capture-toggle
Jul 29, 2026
Merged

feat(tui): allow releasing mouse capture for native selection#570
emal-avala merged 4 commits into
mainfrom
feat/mouse-capture-toggle

Conversation

@emal-avala

Copy link
Copy Markdown
Member

Summary

  • /mouse / /mouse on / /mouse off and Ctrl+Shift+M toggle capture.
  • Default remains capture-on (line selection); off restores native terminal selection.
  • with_main_screen re-entry respects the choice.

Part of #561 (D5-30). Prerequisite for #558 (hit-rect / hover).

Test plan

  • toggle_mouse_capture_via_slash
  • Manual: /mouse off then drag-select in terminal
  • CI green

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 1a1bf6c54e

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread crates/cli/src/ui/modern/run.rs Outdated
Comment on lines +2819 to +2823
app.input = if app.mouse_capture {
"/mouse off".into()
} else {
"/mouse on".into()
};

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Preserve the composer draft when toggling mouse capture

When the composer contains an unsent draft, pressing Ctrl+Shift+M replaces the entire draft with /mouse on or /mouse off, and the subsequent submit() clears it, leaving no way to recover the user's text. Toggle the capture state through a helper that does not mutate app.input, or save and restore the input and cursor around the command.

Useful? React with 👍 / 👎.

Comment thread crates/cli/src/ui/modern/run.rs Outdated
Comment on lines +2816 to +2817
(m, KeyCode::Char('m') | KeyCode::Char('M'))
if m.contains(KeyModifiers::CONTROL) && m.contains(KeyModifiers::SHIFT) =>

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Choose a shortcut that works without keyboard enhancement

On terminals where caps.kitty_keyboard_safe is false—including the explicitly denylisted VS Code, Cursor, Windsurf, and Zed hosts—the run loop never enables key disambiguation. Under conventional terminal encoding Ctrl+Shift+M collapses to carriage return/Enter, so this match cannot fire and pressing the advertised toggle may submit the current composer instead. Gate the shortcut on the capability and avoid advertising it there, or use a chord distinguishable by legacy terminals.

Useful? React with 👍 / 👎.

@emal-avala

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 1a1bf6c54e

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread crates/cli/src/ui/modern/run.rs Outdated
Comment on lines +2819 to +2823
app.input = if app.mouse_capture {
"/mouse off".into()
} else {
"/mouse on".into()
};

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Preserve the composer draft when toggling capture

When Ctrl+Shift+M is pressed while the composer contains a draft, this assignment replaces the entire draft with /mouse on or /mouse off, and the subsequent app.submit() clears it. The user's unsent prompt is therefore silently and irrecoverably lost; toggle mouse_capture directly or preserve and restore the composer input, cursor, and history state.

Useful? React with 👍 / 👎.

EnableMouseCapture was unconditional for the whole session, so terminal
native click-drag copy was unavailable. Add /mouse [on|off], Ctrl+Shift+M,
and re-enter respect for the choice after interactive slash commands.
Ctrl+Alt+M (and Ctrl+Shift+M when kitty keyboard is safe) flip
mouse_capture via a helper instead of rewriting the composer and
submitting /mouse. Do not advertise Ctrl+Shift+M on denylisted hosts.
Write the stub opener via temp+rename under a unique path so parallel
test runners cannot race on a busy binary path (CI Text file busy).
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