Skip to content

Commit 3c61484

Browse files
authored
refactor(tui): use one side padding for all dialogs (#55505)
1 parent af6ec83 commit 3c61484

28 files changed

Lines changed: 122 additions & 93 deletions

‎packages/tui/src/component/dialog-debug.tsx‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { createMemo, createSignal, For } from "solid-js"
22
import { Keymap } from "../context/keymap"
33
import { useTheme } from "../context/theme"
4-
import { DialogHeader, useDialog } from "../ui/dialog"
4+
import { DIALOG_INSET, DialogHeader, useDialog } from "../ui/dialog"
55
import { useRoute } from "../context/route"
66
import { useLocal } from "../context/local"
77
import { useClipboard } from "../context/clipboard"
@@ -52,7 +52,7 @@ export function DialogDebug() {
5252
}))
5353

5454
return (
55-
<box paddingLeft={2} paddingRight={2} gap={1} paddingBottom={1}>
55+
<box paddingLeft={DIALOG_INSET} paddingRight={DIALOG_INSET} gap={1} paddingBottom={1}>
5656
<DialogHeader title="Debug" />
5757
{/* No click-to-copy here: releasing a mouse selection must trigger the
5858
global copy-on-select so users can copy a single value, e.g. the session id. */}

‎packages/tui/src/component/dialog-error-details.tsx‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { useRoute } from "../context/route"
99
import { getScrollAcceleration } from "../util/scroll"
1010
import { useTheme } from "../context/theme"
1111
import { emptyPrompt } from "../prompt/history"
12-
import { DialogHeader, dialogWidth, useDialog } from "../ui/dialog"
12+
import { DIALOG_INSET, DialogHeader, dialogWidth, useDialog } from "../ui/dialog"
1313
import { FilePath } from "../ui/file-path"
1414
import { useToast } from "../ui/toast"
1515
import { errorDetails } from "../util/error-details"
@@ -71,7 +71,7 @@ export function DialogErrorDetails(props: {
7171
})
7272

7373
return (
74-
<box paddingLeft={2} paddingRight={2} paddingBottom={1} gap={1}>
74+
<box paddingLeft={DIALOG_INSET} paddingRight={DIALOG_INSET} paddingBottom={1} gap={1}>
7575
<box>
7676
<DialogHeader
7777
gap={2}
@@ -93,7 +93,7 @@ export function DialogErrorDetails(props: {
9393
{(source) => (
9494
<FilePath
9595
value={source()}
96-
maxWidth={Math.min(dialogWidth(dialog.size), dimensions().width - 2) - 4}
96+
maxWidth={Math.min(dialogWidth(dialog.size), dimensions().width - 2) - DIALOG_INSET * 2}
9797
fg={theme.text.muted}
9898
/>
9999
)}

‎packages/tui/src/component/dialog-experiments.tsx‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { createMemo, createSignal } from "solid-js"
22
import { useConfig } from "../config"
3+
import { DIALOG_LIST_INSET } from "../ui/dialog"
34
import { DialogSelect } from "../ui/dialog-select"
45
import { useTheme } from "../context/theme"
56
import { useToast } from "../ui/toast"
@@ -62,7 +63,7 @@ export function DialogExperiments() {
6263
onMove={(option) => setSelected(option.value)}
6364
onSelect={(option) => void change(option.value)}
6465
emptyView={
65-
<box paddingLeft={4} paddingRight={4}>
66+
<box paddingLeft={DIALOG_LIST_INSET} paddingRight={DIALOG_LIST_INSET}>
6667
<text fg={theme.text.muted}>No experiments available</text>
6768
</box>
6869
}

‎packages/tui/src/component/dialog-highlights.tsx‎

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { useConfig } from "../config"
55
import { Keymap } from "../context/keymap"
66
import type { TuiHighlight } from "../context/runtime"
77
import { useTheme } from "../context/theme"
8-
import { DialogHeader, useDialog } from "../ui/dialog"
8+
import { DIALOG_INSET, DialogHeader, useDialog } from "../ui/dialog"
99
import { getScrollAcceleration } from "../util/scroll"
1010

1111
export function DialogHighlights(props: { version: string; items: ReadonlyArray<TuiHighlight> }) {
@@ -34,7 +34,7 @@ export function DialogHighlights(props: { version: string; items: ReadonlyArray<
3434

3535
return (
3636
<box gap={1} paddingBottom={1}>
37-
<DialogHeader paddingX={2} title={`What's new in ${props.version}`} />
37+
<DialogHeader newInset={DIALOG_INSET} title={`What's new in ${props.version}`} />
3838
{/* The band owns the vertical padding so it stays visible while the highlights scroll. */}
3939
<box backgroundColor={overlay.background.raised.high} paddingTop={1} paddingBottom={1}>
4040
<scrollbox
@@ -45,7 +45,7 @@ export function DialogHighlights(props: { version: string; items: ReadonlyArray<
4545
scrollbarOptions={{ visible: false }}
4646
scrollAcceleration={getScrollAcceleration(config)}
4747
>
48-
<box gap={1} paddingLeft={2} paddingRight={2}>
48+
<box gap={1} paddingLeft={DIALOG_INSET} paddingRight={DIALOG_INSET}>
4949
<For each={props.items}>
5050
{(item) => (
5151
<box>
@@ -66,7 +66,13 @@ export function DialogHighlights(props: { version: string; items: ReadonlyArray<
6666
</box>
6767
</scrollbox>
6868
</box>
69-
<box flexDirection="row" justifyContent="space-between" alignItems="center" paddingLeft={2} paddingRight={2}>
69+
<box
70+
flexDirection="row"
71+
justifyContent="space-between"
72+
alignItems="center"
73+
paddingLeft={DIALOG_INSET}
74+
paddingRight={DIALOG_INSET}
75+
>
7076
<text fg={theme.text.muted}>↑/↓ scroll</text>
7177
<box
7278
paddingLeft={3}

‎packages/tui/src/component/dialog-image-preview.tsx‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { useTerminalDimensions } from "@opentui/solid"
22
import { createMemo, createSignal } from "solid-js"
33
import { Keymap } from "../context/keymap"
44
import { useTheme } from "../context/theme"
5-
import { DialogHeader, useDialog } from "../ui/dialog"
5+
import { DIALOG_INSET, DialogHeader, useDialog } from "../ui/dialog"
66

77
type ImagePreviewItem = Readonly<{
88
uri: string
@@ -36,7 +36,7 @@ export function DialogImagePreview(props: { images: readonly ImagePreviewItem[];
3636
}))
3737

3838
return (
39-
<box id="prompt-image-viewer" paddingLeft={2} paddingRight={2} paddingBottom={1} gap={1}>
39+
<box id="prompt-image-viewer" paddingLeft={DIALOG_INSET} paddingRight={DIALOG_INSET} paddingBottom={1} gap={1}>
4040
<DialogHeader title={`Image ${index() + 1} of ${props.images.length}`} />
4141
<image
4242
id="prompt-image-viewer-image"

‎packages/tui/src/component/dialog-integration.tsx‎

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import { useClient } from "../context/client"
2121
import { Keymap } from "../context/keymap"
2222
import { useLocation } from "../context/location"
2323
import { useTheme } from "../context/theme"
24-
import { DialogHeader, useDialog } from "../ui/dialog"
24+
import { DIALOG_INSET, DIALOG_LIST_INSET, DialogHeader, useDialog } from "../ui/dialog"
2525
import { DialogPrompt } from "../ui/dialog-prompt"
2626
import { DialogSelect } from "../ui/dialog-select"
2727
import { Link } from "../ui/link"
@@ -145,12 +145,12 @@ export function DialogIntegration(
145145
title="Connect an integration"
146146
options={options()}
147147
emptyView={
148-
<box paddingLeft={4} paddingRight={4}>
148+
<box paddingLeft={DIALOG_LIST_INSET} paddingRight={DIALOG_LIST_INSET}>
149149
<text fg={theme.text.muted}>No integrations available</text>
150150
</box>
151151
}
152152
noMatchView={
153-
<box paddingLeft={4} paddingRight={4}>
153+
<box paddingLeft={DIALOG_LIST_INSET} paddingRight={DIALOG_LIST_INSET}>
154154
<text fg={theme.text.muted}>No integrations found</text>
155155
</box>
156156
}
@@ -510,17 +510,17 @@ function CommandView(props: { title: string; output: string; message: string })
510510
onMount(() => dialog.setSize("large"))
511511
return (
512512
<box gap={1} paddingBottom={1}>
513-
<DialogHeader paddingX={2} title={props.title} closeLabel="esc close" />
513+
<DialogHeader newInset={DIALOG_INSET} title={props.title} closeLabel="esc close" />
514514
<box
515515
backgroundColor={overlayTheme.background.raised.high}
516-
paddingLeft={2}
517-
paddingRight={2}
516+
paddingLeft={DIALOG_INSET}
517+
paddingRight={DIALOG_INSET}
518518
paddingTop={1}
519519
paddingBottom={1}
520520
>
521521
<text fg={overlayTheme.text.base}>{props.output.trim()}</text>
522522
</box>
523-
<box paddingLeft={2} paddingRight={2}>
523+
<box paddingLeft={DIALOG_INSET} paddingRight={DIALOG_INSET}>
524524
<text fg={theme.text.muted}>{props.message}</text>
525525
</box>
526526
</box>
@@ -796,7 +796,7 @@ function OAuthView(props: {
796796
}) {
797797
const theme = useTheme().surface("dialog")
798798
return (
799-
<box paddingLeft={2} paddingRight={2} gap={1} paddingBottom={1}>
799+
<box paddingLeft={DIALOG_INSET} paddingRight={DIALOG_INSET} gap={1} paddingBottom={1}>
800800
<DialogHeader title={props.title} />
801801
<Show when={props.url}>
802802
{(url) => (
@@ -970,7 +970,7 @@ function StringChoiceField(props: {
970970
],
971971
}))
972972
return (
973-
<box paddingLeft={4} paddingRight={4} paddingBottom={1} gap={1}>
973+
<box paddingLeft={DIALOG_INSET} paddingRight={DIALOG_INSET} paddingBottom={1} gap={1}>
974974
<DialogHeader title={formLabel(props.field)} onClose={() => (store.editing ? back() : dialog.clear())} />
975975
<Show when={props.field.description}>{(description) => <text fg={theme.text.muted}>{description()}</text>}</Show>
976976
<scrollbox

‎packages/tui/src/component/dialog-open.tsx‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { batch, createEffect, createMemo, createResource, createSignal, onCleanu
22
import type { OpenCodeEvent, SessionInfo } from "@opencode/client"
33
import path from "path"
44
import { useTerminalDimensions } from "@opentui/solid"
5-
import { dialogWidth, useDialog } from "../ui/dialog"
5+
import { DIALOG_LIST_INSET, dialogWidth, useDialog } from "../ui/dialog"
66
import { DialogSelect, dialogSelectContentWidth, type DialogSelectRef } from "../ui/dialog-select"
77
import { DialogPrompt } from "../ui/dialog-prompt"
88
import { useRoute } from "../context/route"
@@ -352,7 +352,7 @@ export function DialogOpen(props: { sessions: SessionInfo[]; onLoad: (sessions:
352352
onFilter={setFilter}
353353
emptyView={
354354
<Show when={!recent.loading && !projects.loading}>
355-
<box paddingLeft={4} paddingRight={4}>
355+
<box paddingLeft={DIALOG_LIST_INSET} paddingRight={DIALOG_LIST_INSET}>
356356
<text fg={theme.text.muted}>No recent sessions or projects</text>
357357
</box>
358358
</Show>
@@ -418,7 +418,7 @@ export function DialogOpen(props: { sessions: SessionInfo[]; onLoad: (sessions:
418418
]}
419419
footerHints={[...(projectID() ? [{ title: "new worktree", label: "ctrl+n" }] : [])]}
420420
noMatchView={
421-
<box paddingLeft={4} paddingRight={4}>
421+
<box paddingLeft={DIALOG_LIST_INSET} paddingRight={DIALOG_LIST_INSET}>
422422
<text fg={theme.text.muted}>
423423
{projectID()
424424
? worktrees.loading

‎packages/tui/src/component/dialog-pair.tsx‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { createMemo, createResource, createSignal, For, Show } from "solid-js"
44
import { renderUnicodeCompact } from "uqr"
55
import { useClient } from "../context/client"
66
import { useTheme } from "../context/theme"
7-
import { DialogHeader, useDialog } from "../ui/dialog"
7+
import { DIALOG_INSET, DialogHeader, useDialog } from "../ui/dialog"
88
import { Link } from "../ui/link"
99
import { errorMessage } from "../util/error"
1010

@@ -87,7 +87,7 @@ export function DialogPair() {
8787
}
8888

8989
return (
90-
<box paddingLeft={2} paddingRight={2} paddingBottom={1} gap={1}>
90+
<box paddingLeft={DIALOG_INSET} paddingRight={DIALOG_INSET} paddingBottom={1} gap={1}>
9191
<DialogHeader title="Pair" />
9292
<Show
9393
when={loadError()}

‎packages/tui/src/component/dialog-session-list.tsx‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import path from "path"
33
import type { SessionInfo } from "@opencode/client"
44
import { Project } from "@opencode/schema/project"
55
import { TextAttributes, type RGBA } from "@opentui/core"
6-
import { useDialog } from "../ui/dialog"
6+
import { DIALOG_LIST_INSET, useDialog } from "../ui/dialog"
77
import { DialogSelect } from "../ui/dialog-select"
88
import { useRoute } from "../context/route"
99
import { useData } from "../context/data"
@@ -226,14 +226,14 @@ export function DialogSessionList() {
226226
},
227227
]}
228228
emptyView={
229-
<box paddingLeft={4} paddingRight={4}>
229+
<box paddingLeft={DIALOG_LIST_INSET} paddingRight={DIALOG_LIST_INSET}>
230230
<text fg={searchState().error ? theme.text.feedback.error.base : theme.text.muted}>
231231
{searchState().message}
232232
</text>
233233
</box>
234234
}
235235
noMatchView={
236-
<box paddingLeft={4} paddingRight={4}>
236+
<box paddingLeft={DIALOG_LIST_INSET} paddingRight={DIALOG_LIST_INSET}>
237237
<text fg={searchState().error ? theme.text.feedback.error.base : theme.text.muted}>
238238
{searchState().message}
239239
</text>

‎packages/tui/src/component/dialog-shell-output.tsx‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import stripAnsi from "strip-ansi"
66
import { useClient } from "../context/client"
77
import { Keymap } from "../context/keymap"
88
import { useTheme } from "../context/theme"
9-
import { DialogHeader, useDialog } from "../ui/dialog"
9+
import { DIALOG_INSET, DialogHeader, useDialog } from "../ui/dialog"
1010

1111
const PAGE_BYTES = 64 * 1024
1212

@@ -100,9 +100,9 @@ export function DialogShellOutput(props: { shell: ShellInfo; location: LocationR
100100
}))
101101

102102
return (
103-
<box paddingLeft={2} paddingRight={2} paddingBottom={1} gap={1}>
103+
<box paddingLeft={DIALOG_INSET} paddingRight={DIALOG_INSET} paddingBottom={1} gap={1}>
104104
<DialogHeader
105-
gap={2}
105+
gap={dimensions().width < 60 ? 1 : 2}
106106
titleView={
107107
<text fg={theme.text.base} attributes={TextAttributes.BOLD} flexGrow={1}>
108108
Shell output

0 commit comments

Comments
 (0)