From d4d8567da804fc9e913363f2b0f59b1002533e07 Mon Sep 17 00:00:00 2001 From: James Long Date: Mon, 9 Nov 2026 13:37:04 -0600 Subject: [PATCH] fix(tui): give the shell output dialog new-design footer actions (#62932) --- .../tui/src/component/dialog-shell-output.tsx | 36 +++++++++++++++++++ .../component/dialog-shell-output.test.tsx | 15 ++++++-- 2 files changed, 49 insertions(+), 2 deletions(-) diff --git a/packages/tui/src/component/dialog-shell-output.tsx b/packages/tui/src/component/dialog-shell-output.tsx index 42f0c98d1b0..a7ca8dd8100 100644 --- a/packages/tui/src/component/dialog-shell-output.tsx +++ b/packages/tui/src/component/dialog-shell-output.tsx @@ -3,10 +3,13 @@ import { useTerminalDimensions } from "@opentui/solid" import { isShellNotFoundError, type LocationRef, type ShellInfo } from "@opencode/client" import { createEffect, createMemo, createSignal, onCleanup, Show, untrack } from "solid-js" import stripAnsi from "strip-ansi" +import { useNewDesigns } from "../config" import { useClient } from "../context/client" +import { useClipboard } from "../context/clipboard" import { Keymap } from "../context/keymap" import { useTheme } from "../context/theme" import { DialogFooter, DialogHeader, DialogLayout, useDialog } from "../ui/dialog" +import { useToast } from "../ui/toast" const PAGE_BYTES = 64 * 1024 @@ -15,6 +18,10 @@ export function DialogShellOutput(props: { shell: ShellInfo; location: LocationR const dialog = useDialog() const theme = useTheme().surface("dialog") const dimensions = useTerminalDimensions() + const clipboard = useClipboard() + const toast = useToast() + const newDesigns = useNewDesigns() + const [copied, setCopied] = createSignal<"command" | "output">() const [info, setInfo] = createSignal(props.shell) const [output, setOutput] = createSignal() const [omitted, setOmitted] = createSignal(false) @@ -87,9 +94,29 @@ export function DialogShellOutput(props: { shell: ShellInfo; location: LocationR return info().exit === undefined ? "Exited" : `Exited · code ${info().exit}` } + const copy = (kind: "command" | "output") => { + const value = kind === "command" ? props.shell.command : text() + if (!value) return + void clipboard + .write(value) + .then(() => setCopied(kind)) + .catch(toast.error) + } + + const copyAction = (kind: "command" | "output", key: string) => + copied() === kind + ? { title: "✓ copied", color: theme.text.feedback.success.base, onTrigger: () => copy(kind) } + : { title: `copy ${kind}`, key, onTrigger: () => copy(kind) } + Keymap.createLayer(() => ({ mode: "modal", commands: [ + ...(newDesigns() + ? [ + { bind: "c", title: "Copy command", group: "Shell", run: () => copy("command") }, + { bind: "o", title: "Copy output", group: "Shell", run: () => copy("output") }, + ] + : []), { bind: "up", title: "Scroll output up", group: "Shell", run: () => scroll?.scrollBy(-1) }, { bind: "down", title: "Scroll output down", group: "Shell", run: () => scroll?.scrollBy(1) }, { bind: "pageup", title: "Previous output page", group: "Shell", run: () => scroll?.scrollBy(-height()) }, @@ -113,6 +140,15 @@ export function DialogShellOutput(props: { shell: ShellInfo; location: LocationR {status()} } + footer={{ + actions: { + primary: [ + { title: "follow", key: "end", onTrigger: () => scroll?.scrollTo(Infinity) }, + copyAction("command", "c"), + copyAction("output", "o"), + ], + }, + }} legacyFooter={ - + @@ -223,3 +223,14 @@ test("large captures open at a bounded tail and clicking a shell opens the viewe expect(reads[1]?.url.searchParams.get("cursor")).toBe(String(Buffer.byteLength(app.state.output) - 65536)) expect(reads[1]?.url.searchParams.get("limit")).toBe("65536") }) + +test("new designs show footer actions instead of the legacy hint line", async () => { + await using app = await setup(100, "Frame 1\n", true) + app.mockInput.pressEnter() + await app.waitForFrame((frame) => frame.includes("Shell output") && frame.includes("Frame 1")) + const frame = app.captureCharFrame() + expect(frame).toContain("follow end") + expect(frame).toContain("copy command c") + expect(frame).toContain("copy output o") + expect(frame).not.toContain("back esc") +})