Skip to content

Commit 4712c18

Browse files
authored
feat(tui): make the mouse disablable (anomalyco#6824, anomalyco#7926) (anomalyco#13748)
1 parent 9e156ea commit 4712c18

File tree

6 files changed

+11
-4
lines changed

6 files changed

+11
-4
lines changed

packages/opencode/src/cli/cmd/tui/app.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,8 @@ import type { EventSource } from "./context/sdk"
125125
import { DialogVariant } from "./component/dialog-variant"
126126

127127
function rendererConfig(_config: TuiConfig.Info): CliRendererConfig {
128+
const mouseEnabled = !Flag.OPENCODE_DISABLE_MOUSE && (_config.mouse ?? true)
129+
128130
return {
129131
externalOutputMode: "passthrough",
130132
targetFps: 60,
@@ -133,6 +135,7 @@ function rendererConfig(_config: TuiConfig.Info): CliRendererConfig {
133135
useKittyKeyboard: { events: process.platform === "win32" },
134136
autoFocus: false,
135137
openConsoleOnError: false,
138+
useMouse: mouseEnabled,
136139
consoleOptions: {
137140
keyBindings: [{ name: "y", ctrl: true, action: "copy-selection" }],
138141
onCopySelection: (text) => {

packages/opencode/src/config/tui-schema.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ export const TuiOptions = z.object({
2222
.enum(["auto", "stacked"])
2323
.optional()
2424
.describe("Control diff rendering style: 'auto' adapts to terminal width, 'stacked' always shows single column"),
25+
mouse: z.boolean().optional().describe("Enable or disable mouse capture (default: true)"),
2526
})
2627

2728
export const TuiInfo = z

packages/opencode/src/flag/flag.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ export namespace Flag {
3131
export const OPENCODE_ENABLE_EXPERIMENTAL_MODELS = truthy("OPENCODE_ENABLE_EXPERIMENTAL_MODELS")
3232
export const OPENCODE_DISABLE_AUTOCOMPACT = truthy("OPENCODE_DISABLE_AUTOCOMPACT")
3333
export const OPENCODE_DISABLE_MODELS_FETCH = truthy("OPENCODE_DISABLE_MODELS_FETCH")
34+
export const OPENCODE_DISABLE_MOUSE = truthy("OPENCODE_DISABLE_MOUSE")
3435
export const OPENCODE_DISABLE_CLAUDE_CODE = truthy("OPENCODE_DISABLE_CLAUDE_CODE")
3536
export const OPENCODE_DISABLE_CLAUDE_CODE_PROMPT =
3637
OPENCODE_DISABLE_CLAUDE_CODE || truthy("OPENCODE_DISABLE_CLAUDE_CODE_PROMPT")

packages/web/src/content/docs/cli.mdx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -573,6 +573,7 @@ OpenCode can be configured using environment variables.
573573
| `OPENCODE_DISABLE_CLAUDE_CODE_PROMPT` | boolean | Disable reading `~/.claude/CLAUDE.md` |
574574
| `OPENCODE_DISABLE_CLAUDE_CODE_SKILLS` | boolean | Disable loading `.claude/skills` |
575575
| `OPENCODE_DISABLE_MODELS_FETCH` | boolean | Disable fetching models from remote sources |
576+
| `OPENCODE_DISABLE_MOUSE` | boolean | Disable mouse capture in the TUI |
576577
| `OPENCODE_FAKE_VCS` | string | Fake VCS provider for testing purposes |
577578
| `OPENCODE_DISABLE_FILETIME_CHECK` | boolean | Disable file time checking for optimization |
578579
| `OPENCODE_CLIENT` | string | Client identifier (defaults to `cli`) |

packages/web/src/content/docs/config.mdx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -272,16 +272,15 @@ Use a dedicated `tui.json` (or `tui.jsonc`) file for TUI-specific settings.
272272
"scroll_acceleration": {
273273
"enabled": true
274274
},
275-
"diff_style": "auto"
275+
"diff_style": "auto",
276+
"mouse": true
276277
}
277278
```
278279

279280
Use `OPENCODE_TUI_CONFIG` to point to a custom TUI config file.
280281

281282
Legacy `theme`, `keybinds`, and `tui` keys in `opencode.json` are deprecated and automatically migrated when possible.
282283

283-
[Learn more about TUI configuration here](/docs/tui#configure).
284-
285284
---
286285

287286
### Server

packages/web/src/content/docs/tui.mdx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,8 @@ You can customize TUI behavior through `tui.json` (or `tui.jsonc`).
368368
"scroll_acceleration": {
369369
"enabled": true
370370
},
371-
"diff_style": "auto"
371+
"diff_style": "auto",
372+
"mouse": true
372373
}
373374
```
374375

@@ -381,6 +382,7 @@ This is separate from `opencode.json`, which configures server/runtime behavior.
381382
- `scroll_acceleration.enabled` - Enable macOS-style scroll acceleration for smooth, natural scrolling. When enabled, scroll speed increases with rapid scrolling gestures and stays precise for slower movements. **This setting takes precedence over `scroll_speed` and overrides it when enabled.**
382383
- `scroll_speed` - Controls how fast the TUI scrolls when using scroll commands (minimum: `0.001`, supports decimal values). Defaults to `3`. **Note: This is ignored if `scroll_acceleration.enabled` is set to `true`.**
383384
- `diff_style` - Controls diff rendering. `"auto"` adapts to terminal width, `"stacked"` always shows a single-column layout.
385+
- `mouse` - Enable or disable mouse capture in the TUI (default: `true`). When disabled, the terminal's native mouse selection/scrolling behavior is preserved.
384386

385387
Use `OPENCODE_TUI_CONFIG` to load a custom TUI config path.
386388

0 commit comments

Comments
 (0)