diff --git a/packages/tui/src/component/dialog-debug.tsx b/packages/tui/src/component/dialog-debug.tsx
index 07324320661..9eb89f76ad2 100644
--- a/packages/tui/src/component/dialog-debug.tsx
+++ b/packages/tui/src/component/dialog-debug.tsx
@@ -1,7 +1,7 @@
import { createMemo, createSignal, For } from "solid-js"
import { Keymap } from "../context/keymap"
import { useTheme } from "../context/theme"
-import { DIALOG_INSET, DialogFooter, DialogHeader, useDialog } from "../ui/dialog"
+import { DialogFooter, DialogHeader, DialogLayout, useDialog } from "../ui/dialog"
import { useRoute } from "../context/route"
import { useLocal } from "../context/local"
import { useClipboard } from "../context/clipboard"
@@ -52,37 +52,38 @@ export function DialogDebug() {
}))
return (
-
-
+ }
+ footer={
+
+ Share this when reporting an issue.
+
+ }
+ >
{/* No click-to-copy here: releasing a mouse selection must trigger the
global copy-on-select so users can copy a single value, e.g. the session id. */}
-
-
- {(entry) => (
-
-
- {entry.label.padEnd(10)}
-
-
- {entry.value}
-
-
- )}
-
-
-
- Share this when reporting an issue.
-
-
+
+ {(entry) => (
+
+
+ {entry.label.padEnd(10)}
+
+
+ {entry.value}
+
+
+ )}
+
+
)
}
diff --git a/packages/tui/src/component/dialog-error-details.tsx b/packages/tui/src/component/dialog-error-details.tsx
index b75c6adfe11..094461bce0e 100644
--- a/packages/tui/src/component/dialog-error-details.tsx
+++ b/packages/tui/src/component/dialog-error-details.tsx
@@ -9,7 +9,7 @@ import { useRoute } from "../context/route"
import { getScrollAcceleration } from "../util/scroll"
import { useTheme } from "../context/theme"
import { emptyPrompt } from "../prompt/history"
-import { DIALOG_INSET, DialogFooter, DialogHeader, dialogWidth, useDialog } from "../ui/dialog"
+import { DIALOG_INSET, DialogFooter, DialogHeader, DialogLayout, dialogWidth, useDialog } from "../ui/dialog"
import { FilePath } from "../ui/file-path"
import { useToast } from "../ui/toast"
import { errorDetails } from "../util/error-details"
@@ -71,59 +71,62 @@ export function DialogErrorDetails(props: {
})
return (
-
-
-
- {props.title}
-
- }
+
+
+ {props.title}
+
+ }
+ />
+
+ {(source) => (
+
+ )}
+
+
+ }
+ footer={
+
-
- {(source) => (
-
- )}
-
-
-
- (scroll = element)}
- maxHeight={20}
- contentOptions={{ minHeight: 0 }}
- scrollbarOptions={{ visible: false }}
- scrollAcceleration={getScrollAcceleration(config)}
- >
-
- {props.error}
-
-
-
- Reference: {props.diagnosticRef}
-
-
-
-
+ }
+ >
+ (scroll = element)}
+ maxHeight={20}
+ contentOptions={{ minHeight: 0 }}
+ scrollbarOptions={{ visible: false }}
+ scrollAcceleration={getScrollAcceleration(config)}
+ >
+
+ {props.error}
+
+
+
+ Reference: {props.diagnosticRef}
+
+
)
}
diff --git a/packages/tui/src/component/dialog-image-preview.tsx b/packages/tui/src/component/dialog-image-preview.tsx
index 728a03c67e3..0887bb116a4 100644
--- a/packages/tui/src/component/dialog-image-preview.tsx
+++ b/packages/tui/src/component/dialog-image-preview.tsx
@@ -2,7 +2,7 @@ import { useTerminalDimensions } from "@opentui/solid"
import { createMemo, createSignal } from "solid-js"
import { Keymap } from "../context/keymap"
import { useTheme } from "../context/theme"
-import { DIALOG_INSET, DialogHeader, useDialog } from "../ui/dialog"
+import { DialogHeader, DialogLayout, useDialog } from "../ui/dialog"
type ImagePreviewItem = Readonly<{
uri: string
@@ -36,8 +36,23 @@ export function DialogImagePreview(props: { images: readonly ImagePreviewItem[];
}))
return (
-
-
+ }
+ footer={
+
+ move(-1)}>
+ {props.images.length > 1 ? "← previous" : ""}
+
+
+ {failed() ? "No preview" : (current().mention?.text ?? `Image ${index() + 1}`)}
+
+ move(1)}>
+ {props.images.length > 1 ? "next →" : ""}
+
+
+ }
+ >
setFailed(true)}
/>
-
- move(-1)}>
- {props.images.length > 1 ? "← previous" : ""}
-
-
- {failed() ? "No preview" : (current().mention?.text ?? `Image ${index() + 1}`)}
-
- move(1)}>
- {props.images.length > 1 ? "next →" : ""}
-
-
-
+
)
}
diff --git a/packages/tui/src/component/dialog-pair.tsx b/packages/tui/src/component/dialog-pair.tsx
index 805f5a6a428..0bc0ce44b49 100644
--- a/packages/tui/src/component/dialog-pair.tsx
+++ b/packages/tui/src/component/dialog-pair.tsx
@@ -4,7 +4,7 @@ import { createMemo, createResource, createSignal, For, Show } from "solid-js"
import { renderUnicodeCompact } from "uqr"
import { useClient } from "../context/client"
import { useTheme } from "../context/theme"
-import { DIALOG_INSET, DialogHeader, useDialog } from "../ui/dialog"
+import { DialogHeader, DialogLayout, useDialog } from "../ui/dialog"
import { Link } from "../ui/link"
import { errorMessage } from "../util/error"
@@ -87,8 +87,7 @@ export function DialogPair() {
}
return (
-
-
+ }>
)}
-
+
)
}
diff --git a/packages/tui/src/component/dialog-shell-output.tsx b/packages/tui/src/component/dialog-shell-output.tsx
index c73e0d4c6bd..04acd4374be 100644
--- a/packages/tui/src/component/dialog-shell-output.tsx
+++ b/packages/tui/src/component/dialog-shell-output.tsx
@@ -6,7 +6,7 @@ import stripAnsi from "strip-ansi"
import { useClient } from "../context/client"
import { Keymap } from "../context/keymap"
import { useTheme } from "../context/theme"
-import { DIALOG_INSET, DialogHeader, useDialog } from "../ui/dialog"
+import { DialogHeader, DialogLayout, useDialog } from "../ui/dialog"
const PAGE_BYTES = 64 * 1024
@@ -100,46 +100,53 @@ export function DialogShellOutput(props: { shell: ShellInfo; location: LocationR
}))
return (
-
-
- Shell output
-
- }
- >
- {status()}
-
-
- {props.shell.command}
-
-
- Earlier output omitted · showing recent output
-
- (scroll = value)}
- height={height()}
- stickyScroll
- stickyStart="bottom"
- scrollbarOptions={{ visible: false }}
- >
-
- {text() ||
- (output() === undefined
- ? "Loading output…"
- : "No captured output. Output redirected to files is not shown here.")}
+
+ Shell output
+
+ }
+ >
+ {status()}
+
+ }
+ footer={
+
+ ↑/↓ scroll
+ end follow
+ esc back
+
+ }
+ >
+
+
+ {props.shell.command}
-
-
- {error()}
-
-
- ↑/↓ scroll
- end follow
- esc back
+
+ Earlier output omitted · showing recent output
+
+ (scroll = value)}
+ height={height()}
+ stickyScroll
+ stickyStart="bottom"
+ scrollbarOptions={{ visible: false }}
+ >
+
+ {text() ||
+ (output() === undefined
+ ? "Loading output…"
+ : "No captured output. Output redirected to files is not shown here.")}
+
+
+
+ {error()}
+
-
+
)
}
diff --git a/packages/tui/src/component/dialog-status.tsx b/packages/tui/src/component/dialog-status.tsx
index 025f4450708..f94f906cdf9 100644
--- a/packages/tui/src/component/dialog-status.tsx
+++ b/packages/tui/src/component/dialog-status.tsx
@@ -1,5 +1,5 @@
import { useTheme } from "../context/theme"
-import { DIALOG_INSET, DialogHeader } from "../ui/dialog"
+import { DialogHeader, DialogLayout } from "../ui/dialog"
import { useData } from "../context/data"
import { For, Match, Switch, Show, createMemo } from "solid-js"
@@ -15,8 +15,7 @@ export function DialogStatus() {
return theme.text.muted
}
return (
-
-
+ }>
0} fallback={No MCP servers}>
@@ -46,6 +45,6 @@ export function DialogStatus() {
-
+
)
}
diff --git a/packages/tui/src/component/dialog-update.tsx b/packages/tui/src/component/dialog-update.tsx
index e24d6455e00..81a129dfccc 100644
--- a/packages/tui/src/component/dialog-update.tsx
+++ b/packages/tui/src/component/dialog-update.tsx
@@ -2,7 +2,7 @@ import { createEffect, createMemo, createResource, createSignal, For, Match, onC
import { Keymap } from "../context/keymap"
import { useTheme } from "../context/theme"
import type { UpdateState } from "../context/update-notification"
-import { DIALOG_INSET, DialogHeader, useDialog } from "../ui/dialog"
+import { DialogHeader, DialogLayout, useDialog } from "../ui/dialog"
import { errorMessage } from "../util/error"
import { Spinner } from "./spinner"
@@ -85,73 +85,76 @@ export function DialogUpdate(props: {
}))
return (
-
-
-
-
- {(current) => (
-
-
- Checking for updates…
-
-
-
- An update is available. After installing, you'll be prompted to restart OpenCode.
-
-
-
-
- {current.type === "installing" ? `Installing OpenCode ${current.version}…` : ""}
-
-
-
-
- Update successful! A restart is required. Any active sessions will be resumed automatically.
-
-
-
- OpenCode is already up to date.
-
-
-
- {current.type === "unavailable" ? current.message : ""}
-
-
-
-
- {current.type === "failed" || current.type === "check-failed" ? current.message : ""}
-
-
-
- )}
+
+ }
+ footer={
+ 0}>
+
+
+ {(button, index) => (
+ void button.run()}
+ >
+
+ {button.label}
+
+
+ )}
+
+
-
- 0}>
-
-
- {(button, index) => (
- void button.run()}
- >
-
- {button.label}
-
-
- )}
-
-
+ }
+ >
+
+ {(current) => (
+
+
+ Checking for updates…
+
+
+
+ An update is available. After installing, you'll be prompted to restart OpenCode.
+
+
+
+
+ {current.type === "installing" ? `Installing OpenCode ${current.version}…` : ""}
+
+
+
+
+ Update successful! A restart is required. Any active sessions will be resumed automatically.
+
+
+
+ OpenCode is already up to date.
+
+
+
+ {current.type === "unavailable" ? current.message : ""}
+
+
+
+
+ {current.type === "failed" || current.type === "check-failed" ? current.message : ""}
+
+
+
+ )}
-
+
)
}
diff --git a/packages/tui/src/ui/dialog-alert.tsx b/packages/tui/src/ui/dialog-alert.tsx
index b62dbc714b0..340655851cd 100644
--- a/packages/tui/src/ui/dialog-alert.tsx
+++ b/packages/tui/src/ui/dialog-alert.tsx
@@ -1,6 +1,6 @@
import { Keymap } from "../context/keymap"
import { useTheme } from "../context/theme"
-import { DIALOG_INSET, DialogHeader, useDialog } from "./dialog"
+import { DialogHeader, DialogLayout, useDialog } from "./dialog"
export type DialogAlertProps = {
title: string
@@ -27,24 +27,25 @@ export function DialogAlert(props: DialogAlertProps) {
],
}))
return (
-
-
-
- {props.message}
-
-
- {
- props.onConfirm?.()
- dialog.clear()
- }}
- >
- ok
+ }
+ footer={
+
+ {
+ props.onConfirm?.()
+ dialog.clear()
+ }}
+ >
+ ok
+
-
-
+ }
+ >
+ {props.message}
+
)
}
diff --git a/packages/tui/src/ui/dialog-confirm.tsx b/packages/tui/src/ui/dialog-confirm.tsx
index 8d71b3926f5..3a063555a83 100644
--- a/packages/tui/src/ui/dialog-confirm.tsx
+++ b/packages/tui/src/ui/dialog-confirm.tsx
@@ -1,6 +1,6 @@
import { Keymap } from "../context/keymap"
import { useTheme } from "../context/theme"
-import { DIALOG_INSET, DialogHeader, useDialog } from "./dialog"
+import { DialogHeader, DialogLayout, useDialog } from "./dialog"
import { createStore } from "solid-js/store"
import { For } from "solid-js"
import { Locale } from "../util/locale"
@@ -55,31 +55,32 @@ export function DialogConfirm(props: DialogConfirmProps) {
],
}))
return (
-
-
-
- {props.message}
-
-
-
- {(key) => (
- {
- if (key === "confirm") props.onConfirm?.()
- if (key === "cancel") props.onCancel?.()
- dialog.clear()
- }}
- >
-
- {Locale.titlecase(props.label?.[key] ?? key)}
-
-
- )}
-
-
-
+ }
+ footer={
+
+
+ {(key) => (
+ {
+ if (key === "confirm") props.onConfirm?.()
+ if (key === "cancel") props.onCancel?.()
+ dialog.clear()
+ }}
+ >
+
+ {Locale.titlecase(props.label?.[key] ?? key)}
+
+
+ )}
+
+
+ }
+ >
+ {props.message}
+
)
}
diff --git a/packages/tui/src/ui/dialog-export-options.tsx b/packages/tui/src/ui/dialog-export-options.tsx
index 4f3c758e941..77b35bdf7ff 100644
--- a/packages/tui/src/ui/dialog-export-options.tsx
+++ b/packages/tui/src/ui/dialog-export-options.tsx
@@ -1,6 +1,6 @@
import { Keymap } from "../context/keymap"
import { useTheme } from "../context/theme"
-import { DIALOG_INSET, DialogHeader, type DialogContext } from "./dialog"
+import { DialogHeader, DialogLayout, type DialogContext } from "./dialog"
import { createStore } from "solid-js/store"
import { For, Show } from "solid-js"
@@ -81,184 +81,187 @@ export function DialogExportOptions(props: DialogExportOptionsProps) {
}
return (
-
-
-
- Export as:
+ }
+ footer={
+
+ confirm("copy")}
+ >
+ Copy
+
+ confirm("export")}
+ >
+
+ Export
+
+
+
+ }
+ >
+
-
- {(format) => (
- selectFormat(format)}
- >
- Export as:
+
+
+ {(format) => (
+ selectFormat(format)}
>
- {store.format === format ? "◉" : "○"} {format === "markdown" ? "Markdown" : "JSON"}
-
-
- )}
-
+
+ {store.format === format ? "◉" : "○"} {format === "markdown" ? "Markdown" : "JSON"}
+
+
+ )}
+
+
-
-
- {
- setStore("active", "thinking")
- setStore("thinking", !store.thinking)
- }}
- >
-
+ {
+ setStore("active", "thinking")
+ setStore("thinking", !store.thinking)
+ }}
>
- {store.thinking ? "[x]" : "[ ]"}
-
-
- Include thinking
-
-
- {
- setStore("active", "tools")
- setStore("tools", !store.tools)
- }}
- >
-
+ {store.thinking ? "[x]" : "[ ]"}
+
+
+ Include thinking
+
+
+ {
+ setStore("active", "tools")
+ setStore("tools", !store.tools)
+ }}
>
- {store.tools ? "[x]" : "[ ]"}
-
-
- Include tools
-
-
-
-
- {
- setStore("active", "sanitize")
- setStore("sanitize", !store.sanitize)
- }}
- >
-
+ {store.tools ? "[x]" : "[ ]"}
+
+
+ Include tools
+
+
+
+
+ {
+ setStore("active", "sanitize")
+ setStore("sanitize", !store.sanitize)
+ }}
>
- {store.sanitize ? "[x]" : "[ ]"}
-
-
- Sanitize sensitive data
-
-
-
-
- confirm("copy")}
- >
- Copy
-
- confirm("export")}
- >
-
- Export
-
-
+
+ {store.sanitize ? "[x]" : "[ ]"}
+
+
+ Sanitize sensitive data
+
+
+
-
+
)
}
diff --git a/packages/tui/src/ui/dialog-export-result.tsx b/packages/tui/src/ui/dialog-export-result.tsx
index 66e51a5fdd6..9c78272c592 100644
--- a/packages/tui/src/ui/dialog-export-result.tsx
+++ b/packages/tui/src/ui/dialog-export-result.tsx
@@ -1,6 +1,6 @@
import { Keymap } from "../context/keymap"
import { useTheme } from "../context/theme"
-import { DIALOG_INSET, DialogHeader, useDialog, type DialogContext } from "./dialog"
+import { DialogHeader, DialogLayout, useDialog, type DialogContext } from "./dialog"
export function DialogExportResult(props: { path: string; onClose?: () => void }) {
const dialog = useDialog()
@@ -24,22 +24,23 @@ export function DialogExportResult(props: { path: string; onClose?: () => void }
}))
return (
-
-
-
- {props.path}
-
-
-
- Close
+ }
+ footer={
+
+
+ Close
+
-
-
+ }
+ >
+ {props.path}
+
)
}
diff --git a/packages/tui/src/ui/dialog-help.tsx b/packages/tui/src/ui/dialog-help.tsx
index 670e084bf9c..e0633dce2aa 100644
--- a/packages/tui/src/ui/dialog-help.tsx
+++ b/packages/tui/src/ui/dialog-help.tsx
@@ -1,6 +1,6 @@
import { Keymap } from "../context/keymap"
import { useTheme } from "../context/theme"
-import { DIALOG_INSET, DialogHeader, useDialog } from "./dialog"
+import { DialogHeader, DialogLayout, useDialog } from "./dialog"
export function DialogHelp() {
const dialog = useDialog()
@@ -16,23 +16,24 @@ export function DialogHelp() {
}))
return (
-
-
-
-
- Press {shortcuts.get("command.palette.show")} to see all available actions and commands in any context.
-
-
-
- dialog.clear()}
- >
- ok
+ }
+ footer={
+
+ dialog.clear()}
+ >
+ ok
+
-
-
+ }
+ >
+
+ Press {shortcuts.get("command.palette.show")} to see all available actions and commands in any context.
+
+
)
}
diff --git a/packages/tui/src/ui/dialog.tsx b/packages/tui/src/ui/dialog.tsx
index 7a80abdcd55..6f1269fd302 100644
--- a/packages/tui/src/ui/dialog.tsx
+++ b/packages/tui/src/ui/dialog.tsx
@@ -123,6 +123,28 @@ export function DialogHeader(
)
}
+/**
+ * Standard dialog layout: header, body and an optional footer, one blank row between
+ * each and one blank row at the bottom, with the shared side padding.
+ */
+export function DialogLayout(
+ props: ParentProps<{
+ id?: string
+ /** Usually a `DialogHeader`. */
+ header: JSX.Element
+ /** Usually a `DialogFooter` or a row of buttons. */
+ footer?: JSX.Element
+ }>,
+) {
+ return (
+
+ {props.header}
+ {props.children}
+ {props.footer}
+
+ )
+}
+
export type DialogFooterAction = {
title: string
/** Literal key label, e.g. "enter". */