import type { ExtensionCommandContext } from "@earendil-works/pi-coding-agent"; import { Container, DynamicBorder, matchesKey, Text } from "@earendil-works/pi-tui"; /** Static bordered panel, closed with Esc/Enter. No-op outside TUI mode. */ export const showPanel = async ( ctx: ExtensionCommandContext, body: string, footer = "Press Esc or Enter to close", ): Promise => { if (ctx.mode !== "tui") return; await ctx.ui.custom((_tui, theme, _kb, done) => { const container = new Container(); const border = new DynamicBorder((s: string) => theme.fg("accent", s)); container.addChild(border); container.addChild(new Text(body, 1, 0)); container.addChild(new Text(theme.fg("dim", footer), 1, 0)); container.addChild(border); return { render: (width: number) => container.render(width), invalidate: () => container.invalidate(), handleInput: (data: string) => { if (matchesKey(data, "enter") || matchesKey(data, "escape")) { done(undefined); } }, }; }); };