Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions packages/app/e2e/settings/settings-keybinds.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { test, expect } from "../fixtures"
import { openSettings, closeDialog, withSession } from "../actions"
import { keybindButtonSelector } from "../selectors"
import { keybindButtonSelector, terminalSelector } from "../selectors"
import { modKey } from "../utils"

test("changing sidebar toggle keybind works", async ({ page, gotoSession }) => {
Expand Down Expand Up @@ -267,11 +267,14 @@ test("changing terminal toggle keybind works", async ({ page, gotoSession }) =>

await closeDialog(page, dialog)

const terminal = page.locator(terminalSelector)
await expect(terminal).not.toBeVisible()

await page.keyboard.press(`${modKey}+Y`)
await page.waitForTimeout(100)
await expect(terminal).toBeVisible()

const pageStable = await page.evaluate(() => document.readyState === "complete")
expect(pageStable).toBe(true)
await page.keyboard.press(`${modKey}+Y`)
await expect(terminal).not.toBeVisible()
})

test("changing command palette keybind works", async ({ page, gotoSession }) => {
Expand Down
12 changes: 7 additions & 5 deletions packages/app/src/components/terminal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,16 @@ import { ComponentProps, createEffect, createSignal, onCleanup, onMount, splitPr
import { usePlatform } from "@/context/platform"
import { useSDK } from "@/context/sdk"
import { monoFontFamily, useSettings } from "@/context/settings"
import { parseKeybind, matchKeybind } from "@/context/command"
import { SerializeAddon } from "@/addons/serialize"
import { LocalPTY } from "@/context/terminal"
import { resolveThemeVariant, useTheme, withAlpha, type HexColor } from "@opencode-ai/ui/theme"
import { useLanguage } from "@/context/language"
import { showToast } from "@opencode-ai/ui/toast"
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"> {
pty: LocalPTY
onSubmit?: () => void
Expand Down Expand Up @@ -237,12 +240,11 @@ export const Terminal = (props: TerminalProps) => {
return true
}

// allow for ctrl-` to toggle terminal in parent
if (event.ctrlKey && key === "`") {
return true
}
// allow for toggle terminal keybinds in parent
const config = settings.keybinds.get(TOGGLE_TERMINAL_ID) ?? DEFAULT_TOGGLE_TERMINAL_KEYBIND
const keybinds = parseKeybind(config)

return false
return matchKeybind(keybinds, event)
})

const fit = new mod.FitAddon()
Expand Down
Loading