fix(tui): give the shell output dialog new-design footer actions (#62932)

This commit is contained in:
James Long
2026-11-09 13:37:04 -06:00
committed by GitHub
Unverified
parent 9cb8e65dc0
commit d4d8567da8
2 changed files with 49 additions and 2 deletions
@@ -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<string>()
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
<text fg={theme.text.muted}>{status()}</text>
</DialogHeader>
}
footer={{
actions: {
primary: [
{ title: "follow", key: "end", onTrigger: () => scroll?.scrollTo(Infinity) },
copyAction("command", "c"),
copyAction("output", "o"),
],
},
}}
legacyFooter={
<DialogFooter
actions={{
@@ -20,7 +20,7 @@ import { createApi, createEventStream, createFetch, json } from "../fixture/tui-
import { TestTuiContexts } from "../fixture/tui-environment"
import { createTuiResolvedConfig } from "../fixture/tui-runtime"
async function setup(width: number, output = "") {
async function setup(width: number, output = "", newDesigns = false) {
const temporary = await tmpdir()
const location = { directory: `${temporary.path}/original` }
const shell: ShellInfo = {
@@ -70,7 +70,7 @@ async function setup(width: number, output = "") {
<TestTuiContexts directory={temporary.path} paths={{ state: temporary.path }}>
<TuiAppProvider value={{ name: "test", version: "test", channel: "test" }}>
<StorageProvider>
<ConfigProvider config={createTuiResolvedConfig()}>
<ConfigProvider config={createTuiResolvedConfig({ experimental: { "new-designs": newDesigns } })}>
<RouteProvider initialRoute={{ type: "session", sessionID: "ses_fixture" }}>
<ClientProvider api={api}>
<DataProvider directory={temporary.path}>
@@ -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")
})