Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions packages/opencode/src/cli/cmd/tui/keymap.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ function formatOptions(config: FormatConfig) {
pageup: "pgup",
pagedown: "pgdn",
delete: "del",
enter: "return",
},
modifierAliases: {
meta: "alt",
Expand Down Expand Up @@ -246,6 +247,15 @@ export function useCommandShortcut(command: string): Accessor<string> {
)
}

export function useCommandShortcuts(command: string): Accessor<readonly string[]> {
const config = useTuiConfig()
return useKeymapSelector((keymap) => {
const bindings = keymap.getCommandBindings({ visibility: "registered", commands: [command] }).get(command)
if (!bindings) return []
return bindings.map((b) => formatKeySequence(b.sequence, config)).filter(Boolean)
})
}

export function useLeaderActive(): Accessor<boolean> {
return useKeymapSelector((keymap: OpenTuiKeymap) => keymap.getPendingSequence()[0]?.tokenName === LEADER_TOKEN)
}
Expand Down
8 changes: 4 additions & 4 deletions packages/opencode/src/cli/cmd/tui/ui/dialog-prompt.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { useDialog, type DialogContext } from "./dialog"
import { Show, createEffect, createSignal, onMount, type JSX } from "solid-js"
import { Spinner } from "../component/spinner"
import { useTuiConfig } from "../context/tui-config"
import { useBindings, useCommandShortcut } from "../keymap"
import { useBindings, useCommandShortcuts } from "../keymap"

export type DialogPromptProps = {
title: string
Expand All @@ -21,7 +21,7 @@ export function DialogPrompt(props: DialogPromptProps) {
const dialog = useDialog()
const { theme } = useTheme()
const tuiConfig = useTuiConfig()
const submitShortcut = useCommandShortcut("dialog.prompt.submit")
const submitShortcuts = useCommandShortcuts("dialog.prompt.submit")
const [textareaTarget, setTextareaTarget] = createSignal<TextareaRenderable>()
let textarea: TextareaRenderable

Expand Down Expand Up @@ -103,9 +103,9 @@ export function DialogPrompt(props: DialogPromptProps) {
</box>
<box paddingBottom={1} gap={1} flexDirection="row">
<Show when={!props.busy} fallback={<text fg={theme.textMuted}>processing...</text>}>
<Show when={submitShortcut()}>
<Show when={submitShortcuts().length > 0}>
<text fg={theme.text}>
{submitShortcut()} <span style={{ fg: theme.textMuted }}>submit</span>
{submitShortcuts().join("/")} <span style={{ fg: theme.textMuted }}>submit</span>
</text>
</Show>
</Show>
Expand Down