The open source coding agent.
TypeScript
feat(tui): make the mouse disablable (#6824, #7926) (#13748)
Gautier DI FOLCO4712c18a5833
diff --git a/packages/opencode/src/cli/cmd/tui/app.tsx b/packages/opencode/src/cli/cmd/tui/app.tsxindex 6b2633c371f..d643c0704f4 100644--- a/packages/opencode/src/cli/cmd/tui/app.tsx+++ b/packages/opencode/src/cli/cmd/tui/app.tsx@@ -125,6 +125,8 @@ import type { EventSource } from "./context/sdk"import { DialogVariant } from "./component/dialog-variant"function rendererConfig(_config: TuiConfig.Info): CliRendererConfig {+ const mouseEnabled = !Flag.OPENCODE_DISABLE_MOUSE && (_config.mouse ?? true)+return {externalOutputMode: "passthrough",targetFps: 60,@@ -133,6 +135,7 @@ function rendererConfig(_config: TuiConfig.Info): CliRendererConfig {useKittyKeyboard: { events: process.platform === "win32" },autoFocus: false,openConsoleOnError: false,+ useMouse: mouseEnabled,consoleOptions: {keyBindings: [{ name: "y", ctrl: true, action: "copy-selection" }],onCopySelection: (text) => {diff --git a/packages/opencode/src/config/tui-schema.ts b/packages/opencode/src/config/tui-schema.tsindex b126d3c96a4..a373b4d8009 100644--- a/packages/opencode/src/config/tui-schema.ts+++ b/packages/opencode/src/config/tui-schema.ts@@ -22,6 +22,7 @@ export const TuiOptions = z.object({.enum(["auto", "stacked"]).optional().describe("Control diff rendering style: 'auto' adapts to terminal width, 'stacked' always shows single column"),+ mouse: z.boolean().optional().describe("Enable or disable mouse capture (default: true)"),})export const TuiInfo = zdiff --git a/packages/opencode/src/flag/flag.ts b/packages/opencode/src/flag/flag.tsindex 1ac52dd17fa..739009502b1 100644--- a/packages/opencode/src/flag/flag.ts+++ b/packages/opencode/src/flag/flag.ts@@ -31,6 +31,7 @@ export namespace Flag {export const OPENCODE_ENABLE_EXPERIMENTAL_MODELS = truthy("OPENCODE_ENABLE_EXPERIMENTAL_MODELS")export const OPENCODE_DISABLE_AUTOCOMPACT = truthy("OPENCODE_DISABLE_AUTOCOMPACT")export const OPENCODE_DISABLE_MODELS_FETCH = truthy("OPENCODE_DISABLE_MODELS_FETCH")+ export const OPENCODE_DISABLE_MOUSE = truthy("OPENCODE_DISABLE_MOUSE")export const OPENCODE_DISABLE_CLAUDE_CODE = truthy("OPENCODE_DISABLE_CLAUDE_CODE")export const OPENCODE_DISABLE_CLAUDE_CODE_PROMPT =OPENCODE_DISABLE_CLAUDE_CODE || truthy("OPENCODE_DISABLE_CLAUDE_CODE_PROMPT")diff --git a/packages/web/src/content/docs/cli.mdx b/packages/web/src/content/docs/cli.mdxindex e2ba2404de9..579038ad03d 100644--- a/packages/web/src/content/docs/cli.mdx+++ b/packages/web/src/content/docs/cli.mdx@@ -573,6 +573,7 @@ OpenCode can be configured using environment variables.| `OPENCODE_DISABLE_CLAUDE_CODE_PROMPT` | boolean | Disable reading `~/.claude/CLAUDE.md` || `OPENCODE_DISABLE_CLAUDE_CODE_SKILLS` | boolean | Disable loading `.claude/skills` || `OPENCODE_DISABLE_MODELS_FETCH` | boolean | Disable fetching models from remote sources |+| `OPENCODE_DISABLE_MOUSE` | boolean | Disable mouse capture in the TUI || `OPENCODE_FAKE_VCS` | string | Fake VCS provider for testing purposes || `OPENCODE_DISABLE_FILETIME_CHECK` | boolean | Disable file time checking for optimization || `OPENCODE_CLIENT` | string | Client identifier (defaults to `cli`) |diff --git a/packages/web/src/content/docs/config.mdx b/packages/web/src/content/docs/config.mdxindex 39f3cd8ff03..52ee1da0a38 100644--- a/packages/web/src/content/docs/config.mdx+++ b/packages/web/src/content/docs/config.mdx@@ -272,7 +272,8 @@ Use a dedicated `tui.json` (or `tui.jsonc`) file for TUI-specific settings."scroll_acceleration": {"enabled": true},- "diff_style": "auto"+ "diff_style": "auto",+ "mouse": true}```@@ -280,8 +281,6 @@ Use `OPENCODE_TUI_CONFIG` to point to a custom TUI config file.Legacy `theme`, `keybinds`, and `tui` keys in `opencode.json` are deprecated and automatically migrated when possible.-[Learn more about TUI configuration here](/docs/tui#configure).----### Serverdiff --git a/packages/web/src/content/docs/tui.mdx b/packages/web/src/content/docs/tui.mdxindex 6dfa7b3125a..e89fb4af39e 100644--- a/packages/web/src/content/docs/tui.mdx+++ b/packages/web/src/content/docs/tui.mdx@@ -368,7 +368,8 @@ You can customize TUI behavior through `tui.json` (or `tui.jsonc`)."scroll_acceleration": {"enabled": true},- "diff_style": "auto"+ "diff_style": "auto",+ "mouse": true}```@@ -381,6 +382,7 @@ This is separate from `opencode.json`, which configures server/runtime behavior.- `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.**- `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`.**- `diff_style` - Controls diff rendering. `"auto"` adapts to terminal width, `"stacked"` always shows a single-column layout.+- `mouse` - Enable or disable mouse capture in the TUI (default: `true`). When disabled, the terminal's native mouse selection/scrolling behavior is preserved.Use `OPENCODE_TUI_CONFIG` to load a custom TUI config path.