fix(app): respect terminal toggle keybind when terminal is focused (#12635)

This commit is contained in:
Ryan Miville
2026-02-07 20:26:54 -05:00
committed by GitHub
parent e772fc6e23
commit ecaeb9e602
2 changed files with 15 additions and 10 deletions

View File

@@ -1,6 +1,6 @@
import { test, expect } from "../fixtures" import { test, expect } from "../fixtures"
import { openSettings, closeDialog, withSession } from "../actions" import { openSettings, closeDialog, withSession } from "../actions"
import { keybindButtonSelector } from "../selectors" import { keybindButtonSelector, terminalSelector } from "../selectors"
import { modKey } from "../utils" import { modKey } from "../utils"
test("changing sidebar toggle keybind works", async ({ page, gotoSession }) => { test("changing sidebar toggle keybind works", async ({ page, gotoSession }) => {
@@ -267,11 +267,14 @@ test("changing terminal toggle keybind works", async ({ page, gotoSession }) =>
await closeDialog(page, dialog) await closeDialog(page, dialog)
await page.keyboard.press(`${modKey}+Y`) const terminal = page.locator(terminalSelector)
await page.waitForTimeout(100) await expect(terminal).not.toBeVisible()
const pageStable = await page.evaluate(() => document.readyState === "complete") await page.keyboard.press(`${modKey}+Y`)
expect(pageStable).toBe(true) await expect(terminal).toBeVisible()
await page.keyboard.press(`${modKey}+Y`)
await expect(terminal).not.toBeVisible()
}) })
test("changing command palette keybind works", async ({ page, gotoSession }) => { test("changing command palette keybind works", async ({ page, gotoSession }) => {

View File

@@ -3,6 +3,7 @@ import { ComponentProps, createEffect, createSignal, onCleanup, onMount, splitPr
import { usePlatform } from "@/context/platform" import { usePlatform } from "@/context/platform"
import { useSDK } from "@/context/sdk" import { useSDK } from "@/context/sdk"
import { monoFontFamily, useSettings } from "@/context/settings" import { monoFontFamily, useSettings } from "@/context/settings"
import { parseKeybind, matchKeybind } from "@/context/command"
import { SerializeAddon } from "@/addons/serialize" import { SerializeAddon } from "@/addons/serialize"
import { LocalPTY } from "@/context/terminal" import { LocalPTY } from "@/context/terminal"
import { resolveThemeVariant, useTheme, withAlpha, type HexColor } from "@opencode-ai/ui/theme" import { resolveThemeVariant, useTheme, withAlpha, type HexColor } from "@opencode-ai/ui/theme"
@@ -10,6 +11,8 @@ import { useLanguage } from "@/context/language"
import { showToast } from "@opencode-ai/ui/toast" import { showToast } from "@opencode-ai/ui/toast"
import { disposeIfDisposable, getHoveredLinkText, setOptionIfSupported } from "@/utils/runtime-adapters" import { disposeIfDisposable, getHoveredLinkText, setOptionIfSupported } from "@/utils/runtime-adapters"
const TOGGLE_TERMINAL_ID = "terminal.toggle"
const DEFAULT_TOGGLE_TERMINAL_KEYBIND = "ctrl+`"
export interface TerminalProps extends ComponentProps<"div"> { export interface TerminalProps extends ComponentProps<"div"> {
pty: LocalPTY pty: LocalPTY
onSubmit?: () => void onSubmit?: () => void
@@ -237,12 +240,11 @@ export const Terminal = (props: TerminalProps) => {
return true return true
} }
// allow for ctrl-` to toggle terminal in parent // allow for toggle terminal keybinds in parent
if (event.ctrlKey && key === "`") { const config = settings.keybinds.get(TOGGLE_TERMINAL_ID) ?? DEFAULT_TOGGLE_TERMINAL_KEYBIND
return true const keybinds = parseKeybind(config)
}
return false return matchKeybind(keybinds, event)
}) })
const fit = new mod.FitAddon() const fit = new mod.FitAddon()