GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — dialog prompt submit keybind + opentui event sink (#27945) · BlueBlock/opencode@f97e115

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • bun.lock
  • package.json
  • packages
    • opencode
      • src/cli/cmd/tui
        • config
          • keybind.ts
        • ui
          • dialog-prompt.tsx
      • test
        • cli/tui
          • dialog-prompt.test.tsx
        • config
          • tui.test.ts
    • plugin
      • package.json
    • web/src/content/docs
      • keybinds.mdx
  • script
    • upgrade-opentui.ts
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎bun.lock‎

Copy file name to clipboardExpand all lines: bun.lock
+15-37Lines changed: 15 additions & 37 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Collapse file

‎package.json‎

Copy file name to clipboardExpand all lines: package.json
+3-3Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,9 @@
3535
"@types/cross-spawn": "6.0.6",
3636
"@octokit/rest": "22.0.0",
3737
"@hono/zod-validator": "0.4.2",
38-
"@opentui/core": "0.2.11",
39-
"@opentui/keymap": "0.2.11",
40-
"@opentui/solid": "0.2.11",
38+
"@opentui/core": "0.2.13",
39+
"@opentui/keymap": "0.2.13",
40+
"@opentui/solid": "0.2.13",
4141
"ulid": "3.0.1",
4242
"@kobalte/core": "0.13.11",
4343
"@types/luxon": "3.7.1",
Collapse file

‎packages/opencode/src/cli/cmd/tui/config/keybind.ts‎

Copy file name to clipboardExpand all lines: packages/opencode/src/cli/cmd/tui/config/keybind.ts
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,7 @@ export const Definitions = {
188188
"dialog.select.home": keybind("home", "Move to first dialog item"),
189189
"dialog.select.end": keybind("end", "Move to last dialog item"),
190190
"dialog.select.submit": keybind("return", "Submit selected dialog item"),
191+
"dialog.prompt.submit": keybind("return", "Submit dialog prompt"),
191192
"dialog.mcp.toggle": keybind("space", "Toggle MCP in MCP dialog"),
192193
"prompt.autocomplete.prev": keybind("up,ctrl+p", "Move to previous autocomplete item"),
193194
"prompt.autocomplete.next": keybind("down,ctrl+n", "Move to next autocomplete item"),
Collapse file

‎packages/opencode/src/cli/cmd/tui/ui/dialog-prompt.tsx‎

Copy file name to clipboardExpand all lines: packages/opencode/src/cli/cmd/tui/ui/dialog-prompt.tsx
+33-8Lines changed: 33 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
import { TextareaRenderable, TextAttributes } from "@opentui/core"
22
import { useTheme } from "../context/theme"
33
import { useDialog, type DialogContext } from "./dialog"
4-
import { Show, createEffect, onMount, type JSX } from "solid-js"
4+
import { Show, createEffect, createSignal, onMount, type JSX } from "solid-js"
55
import { Spinner } from "../component/spinner"
6+
import { useTuiConfig } from "../context/tui-config"
7+
import { useBindings, useCommandShortcut } from "../keymap"
68

79
export type DialogPromptProps = {
810
title: string
@@ -18,8 +20,32 @@ export type DialogPromptProps = {
1820
export function DialogPrompt(props: DialogPromptProps) {
1921
const dialog = useDialog()
2022
const { theme } = useTheme()
23+
const tuiConfig = useTuiConfig()
24+
const submitShortcut = useCommandShortcut("dialog.prompt.submit")
25+
const [textareaTarget, setTextareaTarget] = createSignal<TextareaRenderable>()
2126
let textarea: TextareaRenderable
2227

28+
function confirm() {
29+
if (props.busy) return
30+
props.onConfirm?.(textarea.plainText)
31+
}
32+
33+
useBindings(() => ({
34+
target: textareaTarget,
35+
enabled: textareaTarget() !== undefined && !props.busy,
36+
// Dialog form semantics must win over the global managed textarea input layer.
37+
priority: 1,
38+
commands: [
39+
{
40+
name: "dialog.prompt.submit",
41+
title: "Submit dialog prompt",
42+
category: "Dialog",
43+
run: confirm,
44+
},
45+
],
46+
bindings: tuiConfig.keybinds.gather("dialog.prompt", ["dialog.prompt.submit"]),
47+
}))
48+
2349
onMount(() => {
2450
dialog.setSize("medium")
2551
setTimeout(() => {
@@ -59,13 +85,10 @@ export function DialogPrompt(props: DialogPromptProps) {
5985
<box gap={1}>
6086
{props.description}
6187
<textarea
62-
onSubmit={() => {
63-
if (props.busy) return
64-
props.onConfirm?.(textarea.plainText)
65-
}}
6688
height={3}
6789
ref={(val: TextareaRenderable) => {
6890
textarea = val
91+
setTextareaTarget(val)
6992
}}
7093
initialValue={props.value}
7194
placeholder={props.placeholder ?? "Enter text"}
@@ -80,9 +103,11 @@ export function DialogPrompt(props: DialogPromptProps) {
80103
</box>
81104
<box paddingBottom={1} gap={1} flexDirection="row">
82105
<Show when={!props.busy} fallback={<text fg={theme.textMuted}>processing...</text>}>
83-
<text fg={theme.text}>
84-
enter <span style={{ fg: theme.textMuted }}>submit</span>
85-
</text>
106+
<Show when={submitShortcut()}>
107+
<text fg={theme.text}>
108+
{submitShortcut()} <span style={{ fg: theme.textMuted }}>submit</span>
109+
</text>
110+
</Show>
86111
</Show>
87112
</box>
88113
</box>

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.