mirror of
https://github.com/anomalyco/opencode.git
synced 2026-11-29 03:24:54 +00:00
refactor(tui): add shared dialog layout with one vertical rhythm (#55519)
This commit is contained in:
parent
0478ba6459
commit
611bc3662c
13 changed files with 500 additions and 455 deletions
|
|
@ -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 (
|
||||
<box paddingLeft={DIALOG_INSET} paddingRight={DIALOG_INSET} gap={1} paddingBottom={1}>
|
||||
<DialogHeader title="Debug" />
|
||||
<DialogLayout
|
||||
header={<DialogHeader title="Debug" />}
|
||||
footer={
|
||||
<DialogFooter
|
||||
actions={[
|
||||
{
|
||||
title: copied() ? "✓ copied" : "copy",
|
||||
key: "enter",
|
||||
side: "right",
|
||||
color: copied() ? theme.text.feedback.success.base : undefined,
|
||||
onTrigger: copy,
|
||||
},
|
||||
]}
|
||||
>
|
||||
<text fg={theme.text.muted}>Share this when reporting an issue.</text>
|
||||
</DialogFooter>
|
||||
}
|
||||
>
|
||||
{/* 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. */}
|
||||
<box>
|
||||
<For each={entries()}>
|
||||
{(entry) => (
|
||||
<box flexDirection="row" gap={1}>
|
||||
<text flexShrink={0} fg={theme.text.muted}>
|
||||
{entry.label.padEnd(10)}
|
||||
</text>
|
||||
<text fg={theme.text.base} wrapMode="word">
|
||||
{entry.value}
|
||||
</text>
|
||||
</box>
|
||||
)}
|
||||
</For>
|
||||
</box>
|
||||
<DialogFooter
|
||||
actions={[
|
||||
{
|
||||
title: copied() ? "✓ copied" : "copy",
|
||||
key: "enter",
|
||||
side: "right",
|
||||
color: copied() ? theme.text.feedback.success.base : undefined,
|
||||
onTrigger: copy,
|
||||
},
|
||||
]}
|
||||
>
|
||||
<text fg={theme.text.muted}>Share this when reporting an issue.</text>
|
||||
</DialogFooter>
|
||||
</box>
|
||||
<For each={entries()}>
|
||||
{(entry) => (
|
||||
<box flexDirection="row" gap={1}>
|
||||
<text flexShrink={0} fg={theme.text.muted}>
|
||||
{entry.label.padEnd(10)}
|
||||
</text>
|
||||
<text fg={theme.text.base} wrapMode="word">
|
||||
{entry.value}
|
||||
</text>
|
||||
</box>
|
||||
)}
|
||||
</For>
|
||||
</DialogLayout>
|
||||
)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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 (
|
||||
<box paddingLeft={DIALOG_INSET} paddingRight={DIALOG_INSET} paddingBottom={1} gap={1}>
|
||||
<box>
|
||||
<DialogHeader
|
||||
gap={2}
|
||||
onClose={props.onBack}
|
||||
titleView={
|
||||
<text
|
||||
attributes={TextAttributes.BOLD}
|
||||
fg={theme.text.base}
|
||||
flexGrow={1}
|
||||
minWidth={0}
|
||||
wrapMode="none"
|
||||
truncate
|
||||
>
|
||||
{props.title}
|
||||
</text>
|
||||
}
|
||||
<DialogLayout
|
||||
header={
|
||||
<box>
|
||||
<DialogHeader
|
||||
gap={2}
|
||||
onClose={props.onBack}
|
||||
titleView={
|
||||
<text
|
||||
attributes={TextAttributes.BOLD}
|
||||
fg={theme.text.base}
|
||||
flexGrow={1}
|
||||
minWidth={0}
|
||||
wrapMode="none"
|
||||
truncate
|
||||
>
|
||||
{props.title}
|
||||
</text>
|
||||
}
|
||||
/>
|
||||
<Show when={props.source}>
|
||||
{(source) => (
|
||||
<FilePath
|
||||
value={source()}
|
||||
maxWidth={Math.min(dialogWidth(dialog.size), dimensions().width - 2) - DIALOG_INSET * 2}
|
||||
fg={theme.text.muted}
|
||||
/>
|
||||
)}
|
||||
</Show>
|
||||
</box>
|
||||
}
|
||||
footer={
|
||||
<DialogFooter
|
||||
actions={[
|
||||
{ title: "investigate", key: "i", onTrigger: investigate },
|
||||
copied()
|
||||
? { title: "✓ copied", color: theme.text.feedback.success.base, onTrigger: copy }
|
||||
: { title: "copy details", key: "c", onTrigger: copy },
|
||||
{ title: "scroll", key: "↑/↓", side: "right" },
|
||||
]}
|
||||
/>
|
||||
<Show when={props.source}>
|
||||
{(source) => (
|
||||
<FilePath
|
||||
value={source()}
|
||||
maxWidth={Math.min(dialogWidth(dialog.size), dimensions().width - 2) - DIALOG_INSET * 2}
|
||||
fg={theme.text.muted}
|
||||
/>
|
||||
)}
|
||||
</Show>
|
||||
</box>
|
||||
<box>
|
||||
<scrollbox
|
||||
ref={(element: ScrollBoxRenderable) => (scroll = element)}
|
||||
maxHeight={20}
|
||||
contentOptions={{ minHeight: 0 }}
|
||||
scrollbarOptions={{ visible: false }}
|
||||
scrollAcceleration={getScrollAcceleration(config)}
|
||||
>
|
||||
<text fg={theme.text.base} wrapMode="word">
|
||||
{props.error}
|
||||
</text>
|
||||
</scrollbox>
|
||||
<Show when={props.diagnosticRef}>
|
||||
<text fg={theme.text.muted}>Reference: {props.diagnosticRef}</text>
|
||||
</Show>
|
||||
</box>
|
||||
<DialogFooter
|
||||
actions={[
|
||||
{ title: "investigate", key: "i", onTrigger: investigate },
|
||||
copied()
|
||||
? { title: "✓ copied", color: theme.text.feedback.success.base, onTrigger: copy }
|
||||
: { title: "copy details", key: "c", onTrigger: copy },
|
||||
{ title: "scroll", key: "↑/↓", side: "right" },
|
||||
]}
|
||||
/>
|
||||
</box>
|
||||
}
|
||||
>
|
||||
<scrollbox
|
||||
ref={(element: ScrollBoxRenderable) => (scroll = element)}
|
||||
maxHeight={20}
|
||||
contentOptions={{ minHeight: 0 }}
|
||||
scrollbarOptions={{ visible: false }}
|
||||
scrollAcceleration={getScrollAcceleration(config)}
|
||||
>
|
||||
<text fg={theme.text.base} wrapMode="word">
|
||||
{props.error}
|
||||
</text>
|
||||
</scrollbox>
|
||||
<Show when={props.diagnosticRef}>
|
||||
<text fg={theme.text.muted}>Reference: {props.diagnosticRef}</text>
|
||||
</Show>
|
||||
</DialogLayout>
|
||||
)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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 (
|
||||
<box id="prompt-image-viewer" paddingLeft={DIALOG_INSET} paddingRight={DIALOG_INSET} paddingBottom={1} gap={1}>
|
||||
<DialogHeader title={`Image ${index() + 1} of ${props.images.length}`} />
|
||||
<DialogLayout
|
||||
id="prompt-image-viewer"
|
||||
header={<DialogHeader title={`Image ${index() + 1} of ${props.images.length}`} />}
|
||||
footer={
|
||||
<box flexDirection="row" justifyContent="space-between">
|
||||
<text fg={theme.text.muted} onMouseUp={() => move(-1)}>
|
||||
{props.images.length > 1 ? "← previous" : ""}
|
||||
</text>
|
||||
<text fg={failed() ? theme.text.feedback.error.base : theme.text.muted} wrapMode="none" truncate>
|
||||
{failed() ? "No preview" : (current().mention?.text ?? `Image ${index() + 1}`)}
|
||||
</text>
|
||||
<text fg={theme.text.muted} onMouseUp={() => move(1)}>
|
||||
{props.images.length > 1 ? "next →" : ""}
|
||||
</text>
|
||||
</box>
|
||||
}
|
||||
>
|
||||
<image
|
||||
id="prompt-image-viewer-image"
|
||||
source={current().uri}
|
||||
|
|
@ -47,17 +62,6 @@ export function DialogImagePreview(props: { images: readonly ImagePreviewItem[];
|
|||
height={imageHeight()}
|
||||
onError={() => setFailed(true)}
|
||||
/>
|
||||
<box flexDirection="row" justifyContent="space-between">
|
||||
<text fg={theme.text.muted} onMouseUp={() => move(-1)}>
|
||||
{props.images.length > 1 ? "← previous" : ""}
|
||||
</text>
|
||||
<text fg={failed() ? theme.text.feedback.error.base : theme.text.muted} wrapMode="none" truncate>
|
||||
{failed() ? "No preview" : (current().mention?.text ?? `Image ${index() + 1}`)}
|
||||
</text>
|
||||
<text fg={theme.text.muted} onMouseUp={() => move(1)}>
|
||||
{props.images.length > 1 ? "next →" : ""}
|
||||
</text>
|
||||
</box>
|
||||
</box>
|
||||
</DialogLayout>
|
||||
)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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 (
|
||||
<box paddingLeft={DIALOG_INSET} paddingRight={DIALOG_INSET} paddingBottom={1} gap={1}>
|
||||
<DialogHeader title="Pair" />
|
||||
<DialogLayout header={<DialogHeader title="Pair" />}>
|
||||
<Show
|
||||
when={loadError()}
|
||||
fallback={
|
||||
|
|
@ -119,6 +118,6 @@ export function DialogPair() {
|
|||
</box>
|
||||
)}
|
||||
</Show>
|
||||
</box>
|
||||
</DialogLayout>
|
||||
)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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 (
|
||||
<box paddingLeft={DIALOG_INSET} paddingRight={DIALOG_INSET} paddingBottom={1} gap={1}>
|
||||
<DialogHeader
|
||||
gap={dimensions().width < 60 ? 1 : 2}
|
||||
titleView={
|
||||
<text fg={theme.text.base} attributes={TextAttributes.BOLD} flexGrow={1}>
|
||||
Shell output
|
||||
</text>
|
||||
}
|
||||
>
|
||||
<text fg={theme.text.muted}>{status()}</text>
|
||||
</DialogHeader>
|
||||
<text fg={theme.text.muted} maxHeight={3} wrapMode="word">
|
||||
{props.shell.command}
|
||||
</text>
|
||||
<Show when={omitted()}>
|
||||
<text fg={theme.text.muted}>Earlier output omitted · showing recent output</text>
|
||||
</Show>
|
||||
<scrollbox
|
||||
id="shell-output-scroll"
|
||||
ref={(value: ScrollBoxRenderable) => (scroll = value)}
|
||||
height={height()}
|
||||
stickyScroll
|
||||
stickyStart="bottom"
|
||||
scrollbarOptions={{ visible: false }}
|
||||
>
|
||||
<text fg={theme.text.base} wrapMode="word">
|
||||
{text() ||
|
||||
(output() === undefined
|
||||
? "Loading output…"
|
||||
: "No captured output. Output redirected to files is not shown here.")}
|
||||
<DialogLayout
|
||||
header={
|
||||
<DialogHeader
|
||||
gap={dimensions().width < 60 ? 1 : 2}
|
||||
titleView={
|
||||
<text fg={theme.text.base} attributes={TextAttributes.BOLD} flexGrow={1}>
|
||||
Shell output
|
||||
</text>
|
||||
}
|
||||
>
|
||||
<text fg={theme.text.muted}>{status()}</text>
|
||||
</DialogHeader>
|
||||
}
|
||||
footer={
|
||||
<box flexDirection="row" gap={2} flexWrap="wrap">
|
||||
<text fg={theme.text.muted}>↑/↓ scroll</text>
|
||||
<text fg={theme.text.muted}>end follow</text>
|
||||
<text fg={theme.text.muted}>esc back</text>
|
||||
</box>
|
||||
}
|
||||
>
|
||||
<box gap={1}>
|
||||
<text fg={theme.text.muted} maxHeight={3} wrapMode="word">
|
||||
{props.shell.command}
|
||||
</text>
|
||||
</scrollbox>
|
||||
<Show when={error()}>
|
||||
<text fg={theme.text.feedback.error.base}>{error()}</text>
|
||||
</Show>
|
||||
<box flexDirection="row" gap={2} flexWrap="wrap">
|
||||
<text fg={theme.text.muted}>↑/↓ scroll</text>
|
||||
<text fg={theme.text.muted}>end follow</text>
|
||||
<text fg={theme.text.muted}>esc back</text>
|
||||
<Show when={omitted()}>
|
||||
<text fg={theme.text.muted}>Earlier output omitted · showing recent output</text>
|
||||
</Show>
|
||||
<scrollbox
|
||||
id="shell-output-scroll"
|
||||
ref={(value: ScrollBoxRenderable) => (scroll = value)}
|
||||
height={height()}
|
||||
stickyScroll
|
||||
stickyStart="bottom"
|
||||
scrollbarOptions={{ visible: false }}
|
||||
>
|
||||
<text fg={theme.text.base} wrapMode="word">
|
||||
{text() ||
|
||||
(output() === undefined
|
||||
? "Loading output…"
|
||||
: "No captured output. Output redirected to files is not shown here.")}
|
||||
</text>
|
||||
</scrollbox>
|
||||
<Show when={error()}>
|
||||
<text fg={theme.text.feedback.error.base}>{error()}</text>
|
||||
</Show>
|
||||
</box>
|
||||
</box>
|
||||
</DialogLayout>
|
||||
)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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 (
|
||||
<box paddingLeft={DIALOG_INSET} paddingRight={DIALOG_INSET} gap={1} paddingBottom={1}>
|
||||
<DialogHeader title="Status" />
|
||||
<DialogLayout header={<DialogHeader title="Status" />}>
|
||||
<Show when={mcp().length > 0} fallback={<text fg={theme.text.base}>No MCP servers</text>}>
|
||||
<box>
|
||||
<text fg={theme.text.base}>
|
||||
|
|
@ -46,6 +45,6 @@ export function DialogStatus() {
|
|||
</For>
|
||||
</box>
|
||||
</Show>
|
||||
</box>
|
||||
</DialogLayout>
|
||||
)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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 (
|
||||
<box paddingLeft={DIALOG_INSET} paddingRight={DIALOG_INSET} gap={1}>
|
||||
<DialogHeader
|
||||
title={
|
||||
state().type === "installing"
|
||||
? "Updating OpenCode"
|
||||
: state().type === "available" || state().type === "failed"
|
||||
? "Update available"
|
||||
: "Update"
|
||||
}
|
||||
/>
|
||||
<box paddingBottom={1}>
|
||||
<Show when={state()} keyed>
|
||||
{(current) => (
|
||||
<Switch>
|
||||
<Match when={current.type === "checking"}>
|
||||
<Spinner shimmer={theme.text.base}>Checking for updates…</Spinner>
|
||||
</Match>
|
||||
<Match when={current.type === "available"}>
|
||||
<text fg={theme.text.muted}>
|
||||
An update is available. After installing, you'll be prompted to restart OpenCode.
|
||||
</text>
|
||||
</Match>
|
||||
<Match when={current.type === "installing"}>
|
||||
<Spinner shimmer={theme.text.base}>
|
||||
{current.type === "installing" ? `Installing OpenCode ${current.version}…` : ""}
|
||||
</Spinner>
|
||||
</Match>
|
||||
<Match when={current.type === "installed"}>
|
||||
<text fg={theme.text.muted} wrapMode="word">
|
||||
Update successful! A restart is required. Any active sessions will be resumed automatically.
|
||||
</text>
|
||||
</Match>
|
||||
<Match when={current.type === "current"}>
|
||||
<text fg={theme.text.muted}>OpenCode is already up to date.</text>
|
||||
</Match>
|
||||
<Match when={current.type === "unavailable"}>
|
||||
<text fg={theme.text.muted} wrapMode="word">
|
||||
{current.type === "unavailable" ? current.message : ""}
|
||||
</text>
|
||||
</Match>
|
||||
<Match when={current.type === "failed" || current.type === "check-failed"}>
|
||||
<text fg={theme.text.feedback.error.base}>
|
||||
{current.type === "failed" || current.type === "check-failed" ? current.message : ""}
|
||||
</text>
|
||||
</Match>
|
||||
</Switch>
|
||||
)}
|
||||
<DialogLayout
|
||||
header={
|
||||
<DialogHeader
|
||||
title={
|
||||
state().type === "installing"
|
||||
? "Updating OpenCode"
|
||||
: state().type === "available" || state().type === "failed"
|
||||
? "Update available"
|
||||
: "Update"
|
||||
}
|
||||
/>
|
||||
}
|
||||
footer={
|
||||
<Show when={buttons().length > 0}>
|
||||
<box flexDirection="row" justifyContent="flex-end">
|
||||
<For each={buttons()}>
|
||||
{(button, index) => (
|
||||
<box
|
||||
paddingLeft={1}
|
||||
paddingRight={1}
|
||||
backgroundColor={active() === index() ? theme.background.action.primary.focused : undefined}
|
||||
onMouseUp={() => void button.run()}
|
||||
>
|
||||
<text fg={active() === index() ? theme.text.action.primary.focused : theme.text.muted}>
|
||||
{button.label}
|
||||
</text>
|
||||
</box>
|
||||
)}
|
||||
</For>
|
||||
</box>
|
||||
</Show>
|
||||
</box>
|
||||
<Show when={buttons().length > 0}>
|
||||
<box flexDirection="row" justifyContent="flex-end" paddingBottom={1}>
|
||||
<For each={buttons()}>
|
||||
{(button, index) => (
|
||||
<box
|
||||
paddingLeft={1}
|
||||
paddingRight={1}
|
||||
backgroundColor={active() === index() ? theme.background.action.primary.focused : undefined}
|
||||
onMouseUp={() => void button.run()}
|
||||
>
|
||||
<text fg={active() === index() ? theme.text.action.primary.focused : theme.text.muted}>
|
||||
{button.label}
|
||||
</text>
|
||||
</box>
|
||||
)}
|
||||
</For>
|
||||
</box>
|
||||
}
|
||||
>
|
||||
<Show when={state()} keyed>
|
||||
{(current) => (
|
||||
<Switch>
|
||||
<Match when={current.type === "checking"}>
|
||||
<Spinner shimmer={theme.text.base}>Checking for updates…</Spinner>
|
||||
</Match>
|
||||
<Match when={current.type === "available"}>
|
||||
<text fg={theme.text.muted}>
|
||||
An update is available. After installing, you'll be prompted to restart OpenCode.
|
||||
</text>
|
||||
</Match>
|
||||
<Match when={current.type === "installing"}>
|
||||
<Spinner shimmer={theme.text.base}>
|
||||
{current.type === "installing" ? `Installing OpenCode ${current.version}…` : ""}
|
||||
</Spinner>
|
||||
</Match>
|
||||
<Match when={current.type === "installed"}>
|
||||
<text fg={theme.text.muted} wrapMode="word">
|
||||
Update successful! A restart is required. Any active sessions will be resumed automatically.
|
||||
</text>
|
||||
</Match>
|
||||
<Match when={current.type === "current"}>
|
||||
<text fg={theme.text.muted}>OpenCode is already up to date.</text>
|
||||
</Match>
|
||||
<Match when={current.type === "unavailable"}>
|
||||
<text fg={theme.text.muted} wrapMode="word">
|
||||
{current.type === "unavailable" ? current.message : ""}
|
||||
</text>
|
||||
</Match>
|
||||
<Match when={current.type === "failed" || current.type === "check-failed"}>
|
||||
<text fg={theme.text.feedback.error.base}>
|
||||
{current.type === "failed" || current.type === "check-failed" ? current.message : ""}
|
||||
</text>
|
||||
</Match>
|
||||
</Switch>
|
||||
)}
|
||||
</Show>
|
||||
</box>
|
||||
</DialogLayout>
|
||||
)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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 (
|
||||
<box paddingLeft={DIALOG_INSET} paddingRight={DIALOG_INSET} gap={1}>
|
||||
<DialogHeader title={props.title} />
|
||||
<box paddingBottom={1}>
|
||||
<text fg={theme.text.muted}>{props.message}</text>
|
||||
</box>
|
||||
<box flexDirection="row" justifyContent="flex-end" paddingBottom={1}>
|
||||
<box
|
||||
paddingLeft={3}
|
||||
paddingRight={3}
|
||||
backgroundColor={theme.background.action.primary.focused}
|
||||
onMouseUp={() => {
|
||||
props.onConfirm?.()
|
||||
dialog.clear()
|
||||
}}
|
||||
>
|
||||
<text fg={theme.text.action.primary.focused}>ok</text>
|
||||
<DialogLayout
|
||||
header={<DialogHeader title={props.title} />}
|
||||
footer={
|
||||
<box flexDirection="row" justifyContent="flex-end">
|
||||
<box
|
||||
paddingLeft={3}
|
||||
paddingRight={3}
|
||||
backgroundColor={theme.background.action.primary.focused}
|
||||
onMouseUp={() => {
|
||||
props.onConfirm?.()
|
||||
dialog.clear()
|
||||
}}
|
||||
>
|
||||
<text fg={theme.text.action.primary.focused}>ok</text>
|
||||
</box>
|
||||
</box>
|
||||
</box>
|
||||
</box>
|
||||
}
|
||||
>
|
||||
<text fg={theme.text.muted}>{props.message}</text>
|
||||
</DialogLayout>
|
||||
)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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 (
|
||||
<box paddingLeft={DIALOG_INSET} paddingRight={DIALOG_INSET} gap={1}>
|
||||
<DialogHeader title={props.title} />
|
||||
<box paddingBottom={1}>
|
||||
<text fg={theme.text.muted}>{props.message}</text>
|
||||
</box>
|
||||
<box flexDirection="row" justifyContent="flex-end" paddingBottom={1}>
|
||||
<For each={["cancel", "confirm"] as const}>
|
||||
{(key) => (
|
||||
<box
|
||||
paddingLeft={1}
|
||||
paddingRight={1}
|
||||
backgroundColor={key === store.active ? theme.background.action.primary.focused : undefined}
|
||||
onMouseUp={() => {
|
||||
if (key === "confirm") props.onConfirm?.()
|
||||
if (key === "cancel") props.onCancel?.()
|
||||
dialog.clear()
|
||||
}}
|
||||
>
|
||||
<text fg={key === store.active ? theme.text.action.primary.focused : theme.text.muted}>
|
||||
{Locale.titlecase(props.label?.[key] ?? key)}
|
||||
</text>
|
||||
</box>
|
||||
)}
|
||||
</For>
|
||||
</box>
|
||||
</box>
|
||||
<DialogLayout
|
||||
header={<DialogHeader title={props.title} />}
|
||||
footer={
|
||||
<box flexDirection="row" justifyContent="flex-end">
|
||||
<For each={["cancel", "confirm"] as const}>
|
||||
{(key) => (
|
||||
<box
|
||||
paddingLeft={1}
|
||||
paddingRight={1}
|
||||
backgroundColor={key === store.active ? theme.background.action.primary.focused : undefined}
|
||||
onMouseUp={() => {
|
||||
if (key === "confirm") props.onConfirm?.()
|
||||
if (key === "cancel") props.onCancel?.()
|
||||
dialog.clear()
|
||||
}}
|
||||
>
|
||||
<text fg={key === store.active ? theme.text.action.primary.focused : theme.text.muted}>
|
||||
{Locale.titlecase(props.label?.[key] ?? key)}
|
||||
</text>
|
||||
</box>
|
||||
)}
|
||||
</For>
|
||||
</box>
|
||||
}
|
||||
>
|
||||
<text fg={theme.text.muted}>{props.message}</text>
|
||||
</DialogLayout>
|
||||
)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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 (
|
||||
<box paddingLeft={DIALOG_INSET} paddingRight={DIALOG_INSET} gap={1}>
|
||||
<DialogHeader title="Export session" />
|
||||
<box flexDirection="row" gap={1}>
|
||||
<text fg={theme.text.base}>Export as:</text>
|
||||
<DialogLayout
|
||||
header={<DialogHeader title="Export session" />}
|
||||
footer={
|
||||
<box flexDirection="row" justifyContent="flex-end" gap={1}>
|
||||
<box
|
||||
paddingLeft={4}
|
||||
paddingRight={4}
|
||||
backgroundColor={overlayTheme.background.raised.high}
|
||||
onMouseUp={() => confirm("copy")}
|
||||
>
|
||||
<text fg={overlayTheme.text.base}>Copy</text>
|
||||
</box>
|
||||
<box
|
||||
paddingLeft={4}
|
||||
paddingRight={4}
|
||||
backgroundColor={
|
||||
store.active === "export" ? theme.background.action.primary.focused : theme.background.action.primary.base
|
||||
}
|
||||
onMouseUp={() => confirm("export")}
|
||||
>
|
||||
<text fg={store.active === "export" ? theme.text.action.primary.focused : theme.text.action.primary.base}>
|
||||
Export
|
||||
</text>
|
||||
</box>
|
||||
</box>
|
||||
}
|
||||
>
|
||||
<box gap={1}>
|
||||
<box flexDirection="row" gap={1}>
|
||||
<For each={["markdown", "json"] as const}>
|
||||
{(format) => (
|
||||
<box
|
||||
paddingLeft={1}
|
||||
paddingRight={1}
|
||||
backgroundColor={
|
||||
store.active === format
|
||||
? theme.background.formfield.focused
|
||||
: store.format === format
|
||||
? theme.background.formfield.selected
|
||||
: theme.background.formfield.base
|
||||
}
|
||||
onMouseUp={() => selectFormat(format)}
|
||||
>
|
||||
<text
|
||||
fg={
|
||||
<text fg={theme.text.base}>Export as:</text>
|
||||
<box flexDirection="row" gap={1}>
|
||||
<For each={["markdown", "json"] as const}>
|
||||
{(format) => (
|
||||
<box
|
||||
paddingLeft={1}
|
||||
paddingRight={1}
|
||||
backgroundColor={
|
||||
store.active === format
|
||||
? theme.text.formfield.focused
|
||||
? theme.background.formfield.focused
|
||||
: store.format === format
|
||||
? theme.text.formfield.selected
|
||||
: theme.text.formfield.base
|
||||
? theme.background.formfield.selected
|
||||
: theme.background.formfield.base
|
||||
}
|
||||
onMouseUp={() => selectFormat(format)}
|
||||
>
|
||||
{store.format === format ? "◉" : "○"} {format === "markdown" ? "Markdown" : "JSON"}
|
||||
</text>
|
||||
</box>
|
||||
)}
|
||||
</For>
|
||||
<text
|
||||
fg={
|
||||
store.active === format
|
||||
? theme.text.formfield.focused
|
||||
: store.format === format
|
||||
? theme.text.formfield.selected
|
||||
: theme.text.formfield.base
|
||||
}
|
||||
>
|
||||
{store.format === format ? "◉" : "○"} {format === "markdown" ? "Markdown" : "JSON"}
|
||||
</text>
|
||||
</box>
|
||||
)}
|
||||
</For>
|
||||
</box>
|
||||
</box>
|
||||
</box>
|
||||
<Show when={store.format === "markdown"}>
|
||||
<box
|
||||
flexDirection="row"
|
||||
gap={1}
|
||||
backgroundColor={
|
||||
store.active === "thinking"
|
||||
? theme.background.formfield.focused
|
||||
: store.thinking
|
||||
? theme.background.formfield.selected
|
||||
: theme.background.formfield.base
|
||||
}
|
||||
onMouseUp={() => {
|
||||
setStore("active", "thinking")
|
||||
setStore("thinking", !store.thinking)
|
||||
}}
|
||||
>
|
||||
<text
|
||||
fg={
|
||||
<Show when={store.format === "markdown"}>
|
||||
<box
|
||||
flexDirection="row"
|
||||
gap={1}
|
||||
backgroundColor={
|
||||
store.active === "thinking"
|
||||
? theme.text.formfield.focused
|
||||
? theme.background.formfield.focused
|
||||
: store.thinking
|
||||
? theme.text.formfield.selected
|
||||
: theme.text.formfield.base
|
||||
? theme.background.formfield.selected
|
||||
: theme.background.formfield.base
|
||||
}
|
||||
onMouseUp={() => {
|
||||
setStore("active", "thinking")
|
||||
setStore("thinking", !store.thinking)
|
||||
}}
|
||||
>
|
||||
{store.thinking ? "[x]" : "[ ]"}
|
||||
</text>
|
||||
<text
|
||||
fg={
|
||||
store.active === "thinking"
|
||||
? theme.text.formfield.focused
|
||||
: store.thinking
|
||||
? theme.text.formfield.selected
|
||||
: theme.text.formfield.base
|
||||
}
|
||||
>
|
||||
Include thinking
|
||||
</text>
|
||||
</box>
|
||||
<box
|
||||
flexDirection="row"
|
||||
gap={1}
|
||||
backgroundColor={
|
||||
store.active === "tools"
|
||||
? theme.background.formfield.focused
|
||||
: store.tools
|
||||
? theme.background.formfield.selected
|
||||
: theme.background.formfield.base
|
||||
}
|
||||
onMouseUp={() => {
|
||||
setStore("active", "tools")
|
||||
setStore("tools", !store.tools)
|
||||
}}
|
||||
>
|
||||
<text
|
||||
fg={
|
||||
<text
|
||||
fg={
|
||||
store.active === "thinking"
|
||||
? theme.text.formfield.focused
|
||||
: store.thinking
|
||||
? theme.text.formfield.selected
|
||||
: theme.text.formfield.base
|
||||
}
|
||||
>
|
||||
{store.thinking ? "[x]" : "[ ]"}
|
||||
</text>
|
||||
<text
|
||||
fg={
|
||||
store.active === "thinking"
|
||||
? theme.text.formfield.focused
|
||||
: store.thinking
|
||||
? theme.text.formfield.selected
|
||||
: theme.text.formfield.base
|
||||
}
|
||||
>
|
||||
Include thinking
|
||||
</text>
|
||||
</box>
|
||||
<box
|
||||
flexDirection="row"
|
||||
gap={1}
|
||||
backgroundColor={
|
||||
store.active === "tools"
|
||||
? theme.text.formfield.focused
|
||||
? theme.background.formfield.focused
|
||||
: store.tools
|
||||
? theme.text.formfield.selected
|
||||
: theme.text.formfield.base
|
||||
? theme.background.formfield.selected
|
||||
: theme.background.formfield.base
|
||||
}
|
||||
onMouseUp={() => {
|
||||
setStore("active", "tools")
|
||||
setStore("tools", !store.tools)
|
||||
}}
|
||||
>
|
||||
{store.tools ? "[x]" : "[ ]"}
|
||||
</text>
|
||||
<text
|
||||
fg={
|
||||
store.active === "tools"
|
||||
? theme.text.formfield.focused
|
||||
: store.tools
|
||||
? theme.text.formfield.selected
|
||||
: theme.text.formfield.base
|
||||
}
|
||||
>
|
||||
Include tools
|
||||
</text>
|
||||
</box>
|
||||
</Show>
|
||||
<Show when={store.format === "json"}>
|
||||
<box
|
||||
flexDirection="row"
|
||||
gap={1}
|
||||
backgroundColor={
|
||||
store.active === "sanitize"
|
||||
? theme.background.formfield.focused
|
||||
: store.sanitize
|
||||
? theme.background.formfield.selected
|
||||
: theme.background.formfield.base
|
||||
}
|
||||
onMouseUp={() => {
|
||||
setStore("active", "sanitize")
|
||||
setStore("sanitize", !store.sanitize)
|
||||
}}
|
||||
>
|
||||
<text
|
||||
fg={
|
||||
<text
|
||||
fg={
|
||||
store.active === "tools"
|
||||
? theme.text.formfield.focused
|
||||
: store.tools
|
||||
? theme.text.formfield.selected
|
||||
: theme.text.formfield.base
|
||||
}
|
||||
>
|
||||
{store.tools ? "[x]" : "[ ]"}
|
||||
</text>
|
||||
<text
|
||||
fg={
|
||||
store.active === "tools"
|
||||
? theme.text.formfield.focused
|
||||
: store.tools
|
||||
? theme.text.formfield.selected
|
||||
: theme.text.formfield.base
|
||||
}
|
||||
>
|
||||
Include tools
|
||||
</text>
|
||||
</box>
|
||||
</Show>
|
||||
<Show when={store.format === "json"}>
|
||||
<box
|
||||
flexDirection="row"
|
||||
gap={1}
|
||||
backgroundColor={
|
||||
store.active === "sanitize"
|
||||
? theme.text.formfield.focused
|
||||
? theme.background.formfield.focused
|
||||
: store.sanitize
|
||||
? theme.text.formfield.selected
|
||||
: theme.text.formfield.base
|
||||
? theme.background.formfield.selected
|
||||
: theme.background.formfield.base
|
||||
}
|
||||
onMouseUp={() => {
|
||||
setStore("active", "sanitize")
|
||||
setStore("sanitize", !store.sanitize)
|
||||
}}
|
||||
>
|
||||
{store.sanitize ? "[x]" : "[ ]"}
|
||||
</text>
|
||||
<text
|
||||
fg={
|
||||
store.active === "sanitize"
|
||||
? theme.text.formfield.focused
|
||||
: store.sanitize
|
||||
? theme.text.formfield.selected
|
||||
: theme.text.formfield.base
|
||||
}
|
||||
>
|
||||
Sanitize sensitive data
|
||||
</text>
|
||||
</box>
|
||||
</Show>
|
||||
<box flexDirection="row" justifyContent="flex-end" gap={1} paddingBottom={1}>
|
||||
<box
|
||||
paddingLeft={4}
|
||||
paddingRight={4}
|
||||
backgroundColor={overlayTheme.background.raised.high}
|
||||
onMouseUp={() => confirm("copy")}
|
||||
>
|
||||
<text fg={overlayTheme.text.base}>Copy</text>
|
||||
</box>
|
||||
<box
|
||||
paddingLeft={4}
|
||||
paddingRight={4}
|
||||
backgroundColor={
|
||||
store.active === "export"
|
||||
? theme.background.action.primary.focused
|
||||
: theme.background.action.primary.base
|
||||
}
|
||||
onMouseUp={() => confirm("export")}
|
||||
>
|
||||
<text fg={store.active === "export" ? theme.text.action.primary.focused : theme.text.action.primary.base}>
|
||||
Export
|
||||
</text>
|
||||
</box>
|
||||
<text
|
||||
fg={
|
||||
store.active === "sanitize"
|
||||
? theme.text.formfield.focused
|
||||
: store.sanitize
|
||||
? theme.text.formfield.selected
|
||||
: theme.text.formfield.base
|
||||
}
|
||||
>
|
||||
{store.sanitize ? "[x]" : "[ ]"}
|
||||
</text>
|
||||
<text
|
||||
fg={
|
||||
store.active === "sanitize"
|
||||
? theme.text.formfield.focused
|
||||
: store.sanitize
|
||||
? theme.text.formfield.selected
|
||||
: theme.text.formfield.base
|
||||
}
|
||||
>
|
||||
Sanitize sensitive data
|
||||
</text>
|
||||
</box>
|
||||
</Show>
|
||||
</box>
|
||||
</box>
|
||||
</DialogLayout>
|
||||
)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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 (
|
||||
<box paddingLeft={DIALOG_INSET} paddingRight={DIALOG_INSET} gap={1}>
|
||||
<DialogHeader title="Session exported" onClose={close} />
|
||||
<box>
|
||||
<text fg={theme.text.base}>{props.path}</text>
|
||||
</box>
|
||||
<box flexDirection="row" justifyContent="flex-end" gap={1} paddingBottom={1}>
|
||||
<box
|
||||
paddingLeft={3}
|
||||
paddingRight={3}
|
||||
backgroundColor={theme.background.action.primary.focused}
|
||||
onMouseUp={close}
|
||||
>
|
||||
<text fg={theme.text.action.primary.focused}>Close</text>
|
||||
<DialogLayout
|
||||
header={<DialogHeader title="Session exported" onClose={close} />}
|
||||
footer={
|
||||
<box flexDirection="row" justifyContent="flex-end" gap={1}>
|
||||
<box
|
||||
paddingLeft={3}
|
||||
paddingRight={3}
|
||||
backgroundColor={theme.background.action.primary.focused}
|
||||
onMouseUp={close}
|
||||
>
|
||||
<text fg={theme.text.action.primary.focused}>Close</text>
|
||||
</box>
|
||||
</box>
|
||||
</box>
|
||||
</box>
|
||||
}
|
||||
>
|
||||
<text fg={theme.text.base}>{props.path}</text>
|
||||
</DialogLayout>
|
||||
)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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 (
|
||||
<box paddingLeft={DIALOG_INSET} paddingRight={DIALOG_INSET} gap={1}>
|
||||
<DialogHeader title="Help" closeLabel="esc/enter" />
|
||||
<box paddingBottom={1}>
|
||||
<text fg={theme.text.muted}>
|
||||
Press {shortcuts.get("command.palette.show")} to see all available actions and commands in any context.
|
||||
</text>
|
||||
</box>
|
||||
<box flexDirection="row" justifyContent="flex-end" paddingBottom={1}>
|
||||
<box
|
||||
paddingLeft={3}
|
||||
paddingRight={3}
|
||||
backgroundColor={theme.background.action.primary.focused}
|
||||
onMouseUp={() => dialog.clear()}
|
||||
>
|
||||
<text fg={theme.text.action.primary.focused}>ok</text>
|
||||
<DialogLayout
|
||||
header={<DialogHeader title="Help" closeLabel="esc/enter" />}
|
||||
footer={
|
||||
<box flexDirection="row" justifyContent="flex-end">
|
||||
<box
|
||||
paddingLeft={3}
|
||||
paddingRight={3}
|
||||
backgroundColor={theme.background.action.primary.focused}
|
||||
onMouseUp={() => dialog.clear()}
|
||||
>
|
||||
<text fg={theme.text.action.primary.focused}>ok</text>
|
||||
</box>
|
||||
</box>
|
||||
</box>
|
||||
</box>
|
||||
}
|
||||
>
|
||||
<text fg={theme.text.muted}>
|
||||
Press {shortcuts.get("command.palette.show")} to see all available actions and commands in any context.
|
||||
</text>
|
||||
</DialogLayout>
|
||||
)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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 (
|
||||
<box id={props.id} paddingLeft={DIALOG_INSET} paddingRight={DIALOG_INSET} paddingBottom={1} gap={1}>
|
||||
{props.header}
|
||||
<box>{props.children}</box>
|
||||
{props.footer}
|
||||
</box>
|
||||
)
|
||||
}
|
||||
|
||||
export type DialogFooterAction = {
|
||||
title: string
|
||||
/** Literal key label, e.g. "enter". */
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue