Repository navigation
feat(app): support Mod+J to toggle terminal - #55016
kitlangton wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
Looks good. I ran e2e/regression/terminal-input.spec.ts in headless Chromium: it passes 9/9 with this change. With only the renderer.tsx line reverted, the new test fails because ControlOrMeta+j doesn't open the dock. gui-extensions typecheck passes. Nothing else in the app or the desktop menu binds mod+j.
Public API: unchanged. Only the default keybind of the built-in terminal.toggle command changes.
One trade-off is noted inline: on Linux/Windows, Ctrl+J no longer reaches a focused terminal.
Related: #54559
| section: "terminal", | ||
| featured: true, | ||
| bind: "ctrl+`", | ||
| bind: "ctrl+`,mod+j", |
There was a problem hiding this comment.
On Linux/Windows mod+j means Ctrl+J. terminal.tsx intercepts terminal.toggle matches before the PTY sees them, so a focused terminal can no longer receive ^J (line feed). fzf, vim, emacs and readline users rely on that key. VS Code makes the same choice and the binding can be changed in Settings, so I don't think this blocks the change. It's still a behaviour change for terminal users on those platforms, and could be worth a line in the release notes.
52272a0 to
66630c9
Compare
66630c9 to
d4bdd45
Compare
|
Closing: Beta already binds ⌘J to toggle the bottom panel. |
▶ Pitch (phone, 40 s):
pr-55016-phone.mp4
Desktop: https://github.com/user-attachments/assets/b88bec77-9985-4c27-af9e-251d98e9036d
Head:
d4bdd453357aa302da140f027342a6bed966fd86Risk: On Windows and Linux the shortcut is Ctrl+J, which fzf uses, so a focused terminal no longer gets it. Rebind it in Settings, or revert one line.
Not verified: Recorded in the web build of the desktop app (headless Chromium, Mac user agent) against a hermetic server, not the packaged Electron app. Ctrl+J on Windows and Linux not exercised. The review bot covered the earlier head
2e52effd36.Why
In OpenCode Desktop and the web GUI, toggling the terminal dock is bound only to
⌃`(ctrl+\``). Users coming from ChatGPT/Codex, VS Code, Cursor, or Zed expect⌘J(Mod+J`) to toggle the bottom terminal panel open and closed as well.What Changes
mod+jalongsidectrl+`on theterminal.togglecommand (bind: "ctrl+\,mod+j"), keeping `` ⌃/Ctrl+`` as the primary displayed shortcut in menus, the command palette, and Settings > Shortcuts while allowing⌘J(Ctrl+J` on Windows/Linux) to toggle the terminal dock.terminal.tsxdelegates its custom key event check tokeybinds.matches("terminal.toggle", event), bothMod+JandCtrl+`are intercepted before reaching the PTY and toggle the terminal closed even when the terminal itself has focus.Mod+J(⌘J/Ctrl+J)Ctrl+`(⌃`)Demo
Side-by-side Playwright capture of the web/desktop GUI before (
b4a57f6849) and after this change, pressing⌘Jonce to open and focus the terminal dock and a second time while the terminal is focused to close it:terminal-toggle-demo.mp4
Scope
mod+jto the built-interminal.togglecommand and covering both shortcuts in the terminal input regression suite.Verification
bun run lint:changed bun run check PLAYWRIGHT_PORT=3187 PLAYWRIGHT_SERVER_PORT=4187 PLAYWRIGHT_WORKERS=1 bunx playwright test e2e/regression/terminal-input.spec.tsbun run lint:changed: 0 problems in 2 changed files.bun run check: 35/35 package typechecks passed, 0 errors.playwright test e2e/regression/terminal-input.spec.ts: 9/9 passed, including toggling the terminal open and closed with bothMod+JandControl+Backquotewhile focused without leaking input to the PTY.Added by the opencode bot (AI-generated).
Related: #54559