From ccbf2b384046426cc95211bc321ae41aab5931c9 Mon Sep 17 00:00:00 2001 From: Nabheet Sandhu Date: Fri, 20 Nov 2026 14:03:30 -0700 Subject: [PATCH] fix: focus the panel when it opens so escape and space work Keymap layers are routed to the focused renderable. A panel opened from the prompt owned no keys until it was clicked: escape did nothing, space did nothing, and the panel looked unresponsive even though its ticker ran. MediaPanel now focuses the panel on mount. Verified by driving keystrokes on a clean session: the panel opens with /media, animates, and closes on escape without any click. --- src/tui.tsx | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/tui.tsx b/src/tui.tsx index a274de0..1f7199f 100644 --- a/src/tui.tsx +++ b/src/tui.tsx @@ -1,7 +1,7 @@ /** @jsxImportSource @opentui/solid */ import { Plugin, usePlugin } from "@opencode/plugin/tui"; import type { PanelInput } from "@opencode/plugin/tui/context"; -import { createSignal, onCleanup, Show } from "solid-js"; +import { createSignal, onCleanup, onMount, Show } from "solid-js"; import { extractFrames } from "./frames"; import { cellsFor, normalizeOptions } from "./options"; @@ -47,6 +47,12 @@ function MediaPanel(props: { // it. onCleanup(() => props.onDispose?.(props.clip.id)); + // Keymap layers are routed to the focused renderable, so a panel opened from + // the prompt owns no keys until something focuses it: `escape` and `space` + // silently do nothing and the panel has to be clicked first. Mounting a + // panel means the user asked for it, so take focus on the way in. + onMount(() => props.panel.focus()); + context.keymap.layer(() => ({ commands: [ { id: "media.panel.close", bind: "escape", run: () => props.panel.close() },