A desktop coding agent with free access to frontier models.
TypeScript
feat: bottom panel and terminal shortcuts in the IDE
ogsamrat486fef64b514
diff --git a/apps/app/src/react-app/shell/use-shell-shortcuts.ts b/apps/app/src/react-app/shell/use-shell-shortcuts.tsindex 16ee4893..75e1670e 100644--- a/apps/app/src/react-app/shell/use-shell-shortcuts.ts+++ b/apps/app/src/react-app/shell/use-shell-shortcuts.ts@@ -56,6 +56,11 @@ export function useCommandPaletteShortcut(enabled = true) {return { commandPaletteOpen, setCommandPaletteOpen };}+/** Ctrl+` (the Backquote key, no Shift): show and focus the terminal. */+export function isToggleTerminalShortcut(event: KeyboardEvent): boolean {+ return event.ctrlKey && !event.shiftKey && !event.altKey && !event.metaKey && event.code === "Backquote";+}+/** Ctrl+Shift+` (the Backquote key, whatever the layout prints on it): a new terminal tab. */export function isNewTerminalShortcut(event: Pick<KeyboardEvent, "ctrlKey" | "shiftKey" | "altKey" | "metaKey" | "code">) {return event.ctrlKey && event.shiftKey && !event.altKey && !event.metaKey && event.code === "Backquote";@@ -145,6 +150,25 @@ export function useShellShortcuts(input: UseShellShortcutsInput) {setTerminalOpen(true);return;}+ // Ctrl+` (every platform, as in VS Code): show the terminal and focus it; again from inside it hides it.+ if (isToggleTerminalShortcut(event) && platform.capabilities.terminal) {+ event.preventDefault();+ if (event.repeat) return;+ const inTerminal = Boolean((document.activeElement as HTMLElement | null)?.closest?.(".xterm"));+ if (terminalOpen && inTerminal) {+ setTerminalOpen(false);+ return;+ }+ setTerminalOpen(true);+ useEditorStore.getState().setBottomTab("terminal");+ const focus = (tries: number) => window.requestAnimationFrame(() => {+ const input = document.querySelector<HTMLTextAreaElement>(".xterm-helper-textarea");+ if (input) input.focus();+ else if (tries > 0) focus(tries - 1);+ });+ focus(20);+ return;+ }const thinkingModeDirection = getThinkingModeShortcutDirection(event, thinkingModeShortcutOs);if (thinkingModeDirection) {event.preventDefault();@@ -223,6 +247,16 @@ export function useShellShortcuts(input: UseShellShortcutsInput) {}if (key === "j" && platform.capabilities.terminal) {event.preventDefault();+ // IDE layout: the whole bottom panel (Problems and Terminal), back on the tab it last showed.+ if (document.querySelector("[data-editor-layout='ide']")) {+ const editor = useEditorStore.getState();+ if (terminalOpen || editor.problemsOpen) {+ editor.setProblemsOpen(false);+ setTerminalOpen(false);+ } else if (editor.bottomTab === "problems") editor.setProblemsOpen(true);+ else setTerminalOpen(true);+ return;+ }setTerminalOpen((value) => !value);return;}diff --git a/apps/app/tests/terminal-tabs-store.test.ts b/apps/app/tests/terminal-tabs-store.test.tsindex 0b48be3c..dd552bbd 100644--- a/apps/app/tests/terminal-tabs-store.test.ts+++ b/apps/app/tests/terminal-tabs-store.test.ts@@ -1,7 +1,7 @@import { beforeEach, describe, expect, test } from "bun:test";import { TERMINAL_TABS_STORAGE_KEY, useTerminalTabsStore } from "../src/react-app/domains/session/terminal/terminal-tabs-store";-import { isNewTerminalShortcut } from "../src/react-app/shell/use-shell-shortcuts";+import { isNewTerminalShortcut, isToggleTerminalShortcut } from "../src/react-app/shell/use-shell-shortcuts";import { removeRouteWorkspace } from "../src/react-app/shell/route-workspaces";class MemoryStorage {@@ -111,6 +111,14 @@ describe("terminal tabs", () => {expect(store().takeNewTabRequest()).toBe(false);});+ test("Ctrl+` (no Shift) shows the terminal; Ctrl+Shift+` stays the new-tab key", () => {+ const key = { ctrlKey: true, shiftKey: false, altKey: false, metaKey: false, code: "Backquote" } as KeyboardEvent;+ expect(isToggleTerminalShortcut(key)).toBe(true);+ expect(isToggleTerminalShortcut({ ...key, shiftKey: true } as KeyboardEvent)).toBe(false);+ expect(isNewTerminalShortcut(key)).toBe(false);+ expect(isToggleTerminalShortcut({ ...key, metaKey: true } as KeyboardEvent)).toBe(false);+ });+test("removing a workspace ends its terminals before the server removes the folder", async () => {const order: string[] = [];await removeRouteWorkspace({