Skip to content
Closed
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
2 changes: 1 addition & 1 deletion packages/app/src/custom-elements.d.ts
2 changes: 1 addition & 1 deletion packages/enterprise/src/custom-elements.d.ts
25 changes: 16 additions & 9 deletions packages/opencode/src/cli/cmd/tui/component/dialog-command.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,15 @@ import type { KeybindsConfig } from "@opencode-ai/sdk/v2"
type Context = ReturnType<typeof init>
const ctx = createContext<Context>()

export type Slash = {
name: string
aliases?: string[]
}

export type CommandOption = DialogSelectOption & {
keybind?: keyof KeybindsConfig
suggested?: boolean
slash?: Slash
}

function init() {
Expand Down Expand Up @@ -84,15 +90,16 @@ function init() {
return options()
},
slashes() {
return options()
.filter((o) => (o as CommandOption).value.startsWith("/"))
.map((o) => ({
display: (o as any).display ?? (o as CommandOption).value,
value: (o as CommandOption).value,
description: (o as CommandOption).description,
aliases: (o as any).aliases,
onSelect: () => (o as CommandOption).onSelect?.(dialog),
})) as any
return options().flatMap((option) => {
const slash = option.slash
if (!slash) return []
return {
display: "/" + slash.name,
description: option.description ?? option.title,
aliases: slash.aliases?.map((alias) => "/" + alias),
onSelect: () => result.trigger(option.value),
}
})
},
}
return result
Expand Down
Loading