Skip to content

Commit c2f8101

Browse files
committed
Turn mouse reporting on by default in the main shell
Wheel/trackpad scroll only reaches OpenTUI when the terminal is told to report it; otherwise the terminal's own alternate-scroll mode resends it as arrow keys, which the prompt reads as history navigation. Flipping the default lets routePromptWheelToTranscript run for real scroll instead of only after Alt+M. Trade accepted: this suppresses the terminal's native drag-select in the main shell, which a separate ticket recorded wanting the opposite default. Alt+M still hands the mouse back for drag-select and copy. enableMouseMovement stays off; only clicks and wheel need reporting.
1 parent f3a3071 commit c2f8101

4 files changed

Lines changed: 17 additions & 12 deletions

File tree

src/tui-opentui/keybindings.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ export const SHELL_SHORTCUTS: readonly ShellShortcut[] = [
2525
{ keys: "Ctrl+C", description: "interrupt the run, or clear the prompt when idle; press twice to exit" },
2626
{ keys: "Ctrl+O", description: "open the command palette; press again to close it" },
2727
{ keys: "Alt+C", description: "copy mode: pick a message, tool output, or diff; press again to close it" },
28-
{ keys: "Alt+M", description: "take the mouse for click-to-expand and drag-scroll; off by default so drag-select and copy work" },
28+
{ keys: "Alt+M", description: "release the mouse to the terminal for native drag-select and copy; on by default for wheel scroll and click-to-expand" },
2929
{ keys: "Alt+E", description: "expand or collapse every collapsible row (tool call, diff, skill, reasoning)" },
3030
{ keys: "Tab", description: "move focus between the prompt and the transcript" },
3131
{ keys: "Esc", description: "close the open overlay, or leave subagent observe" },

src/tui-opentui/palette.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ export const DEFAULT_PALETTE_COMMANDS: readonly PaletteCommand[] = [
171171
},
172172
{
173173
id: "toggle_mouse",
174-
label: "Toggle mouse capture (off by default so you can drag-select)",
174+
label: "Toggle mouse capture (on by default; release it to drag-select)",
175175
keywords: ["mouse", "select", "selection", "copy", "drag"],
176176
dispatch: "residual",
177177
category: "view",

src/tui-opentui/product-host.ts

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -116,9 +116,10 @@ export type ProductHostConfig = {
116116
/** First-run telemetry disclosure, shown on the landing screen. */
117117
readonly telemetryNotice?: string
118118
/**
119-
* Take DEC mouse reporting. Default false: while it is on the terminal hands
120-
* drags to us and cannot select text, which breaks copy with the mouse.
121-
* Alt+M flips it at runtime for click-to-expand and drag-scroll.
119+
* Take DEC mouse reporting. Default true: wheel/trackpad scroll only
120+
* reaches OpenTUI when the terminal is told to report it, otherwise the
121+
* terminal's own alternate-scroll mode resends it as arrow keys. Alt+M
122+
* hands the mouse back to the terminal for native drag-select.
122123
*/
123124
readonly useMouse?: boolean
124125
}
@@ -206,11 +207,15 @@ export async function mountProductHost(
206207
: await createCliRenderer({
207208
exitOnCtrlC: false,
208209
targetFps: 30,
209-
// Mouse reporting off by default: any of DEC 1000/1002/1003/1006 makes
210-
// the terminal forward drags to us instead of selecting text, so the
211-
// user cannot copy with the mouse. Alt+M takes the mouse when
212-
// click-to-expand or drag-scroll is wanted.
213-
useMouse: config.useMouse ?? false,
210+
// Mouse reporting on by default: without it, wheel/trackpad scroll
211+
// never reaches OpenTUI — the terminal's own alternate-scroll mode
212+
// swallows it and resends it as arrow keys, which the prompt then
213+
// reads as history navigation instead of the transcript scrolling.
214+
// Cost accepted: this suppresses the terminal's native drag-select
215+
// in the main shell. Alt+M hands the mouse back when that is wanted.
216+
// enableMouseMovement stays off (no ?1003): only clicks and wheel
217+
// are needed.
218+
useMouse: config.useMouse ?? true,
214219
enableMouseMovement: false,
215220
// A plain terminal sends a bare CR for both Enter and Shift+Enter, so
216221
// the modifier only arrives once the kitty keyboard protocol is

src/tui-opentui/shell.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3999,8 +3999,8 @@ export function copyAllTargets(shell: AppShell): boolean {
39993999

40004000
/**
40014001
* Alt+M: take DEC mouse reporting, or hand it back to the terminal.
4002-
* Reporting is off by default so drag-select and the terminal's own copy keep
4003-
* working; taking it enables click-to-expand and drag-scroll at that cost.
4002+
* Reporting is on by default so wheel scroll and click-to-expand work;
4003+
* releasing it restores the terminal's own drag-select and copy.
40044004
* Returns the new enabled state, or null when the host exposes no control.
40054005
*/
40064006
export function toggleMouseCapture(shell: AppShell): boolean | null {

0 commit comments

Comments
 (0)