From 97c5dbbffd397f8633eb51fccd7e74996e28eff0 Mon Sep 17 00:00:00 2001 From: shrwnsan <38465+shrwnsan@users.noreply.github.com> Date: Fri, 30 Jan 2026 16:59:24 +0800 Subject: [PATCH] fix(keybinds): remove ctrl+c from default app_exit keybind to prevent accidental exits Ctrl+C is the universal copy shortcut on Windows and commonly used on Linux. Users frequently press Ctrl+C out of habit to copy text, accidentally terminating their session and losing context. Changes: - Changed default app_exit from "ctrl+c,ctrl+d,q" to "ctrl+d,q" - Fixed hardcoded ctrl+c check in ErrorComponent to respect keybind config Users can restore old behavior by setting: "keybinds": { "app_exit": "ctrl+c,ctrl+d,q" } Closes #7957 Co-Authored-By: Kimi k2.5 --- packages/opencode/src/cli/cmd/tui/app.tsx | 5 +++-- packages/opencode/src/config/config.ts | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/packages/opencode/src/cli/cmd/tui/app.tsx b/packages/opencode/src/cli/cmd/tui/app.tsx index 97c910a47d4..15eb6d0c9d4 100644 --- a/packages/opencode/src/cli/cmd/tui/app.tsx +++ b/packages/opencode/src/cli/cmd/tui/app.tsx @@ -20,7 +20,7 @@ import { DialogHelp } from "./ui/dialog-help" import { CommandProvider, useCommandDialog } from "@tui/component/dialog-command" import { DialogAgent } from "@tui/component/dialog-agent" import { DialogSessionList } from "@tui/component/dialog-session-list" -import { KeybindProvider } from "@tui/context/keybind" +import { KeybindProvider, useKeybind } from "@tui/context/keybind" import { ThemeProvider, useTheme } from "@tui/context/theme" import { Home } from "@tui/routes/home" import { Session } from "@tui/routes/session" @@ -777,8 +777,9 @@ function ErrorComponent(props: { await props.onExit() } + const keybind = useKeybind() useKeyboard((evt) => { - if (evt.ctrl && evt.name === "c") { + if (keybind.match("app_exit", evt)) { handleExit() } }) diff --git a/packages/opencode/src/config/config.ts b/packages/opencode/src/config/config.ts index 141f6156985..7733cfa22a7 100644 --- a/packages/opencode/src/config/config.ts +++ b/packages/opencode/src/config/config.ts @@ -754,7 +754,7 @@ export namespace Config { export const Keybinds = z .object({ leader: z.string().optional().default("ctrl+x").describe("Leader key for keybind combinations"), - app_exit: z.string().optional().default("ctrl+c,ctrl+d,q").describe("Exit the application"), + app_exit: z.string().optional().default("ctrl+d,q").describe("Exit the application"), editor_open: z.string().optional().default("e").describe("Open external editor"), theme_list: z.string().optional().default("t").describe("List available themes"), sidebar_toggle: z.string().optional().default("b").describe("Toggle sidebar"),