fix(tui): queue autocompleted commands (#46414)

Co-authored-by: vimtor <36263538+vimtor@users.noreply.github.com>
This commit is contained in:
opencode-agent[bot] 2026-08-31 19:52:29 +05:30 committed by GitHub
parent 711a0a2da2
commit 1b3eb1138e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 21 additions and 4 deletions

View file

@ -36,6 +36,7 @@ import {
export type AutocompleteRef = {
onInput: (value: string) => void
visible: false | "reference" | "command" | "directory"
completeQueueableCommand: () => boolean
}
export type AutocompleteOption = {
@ -50,6 +51,7 @@ export type AutocompleteOption = {
absolute?: string
destructive?: { id: string; confirm: string; run: () => void }
kind?: "skill"
queueable?: boolean
}
type AutocompleteResults = {
@ -542,6 +544,7 @@ export function Autocomplete(props: {
results.push({
display: "/" + serverCommand.name,
description: serverCommand.description,
queueable: true,
onSelect: () => insertSlash(serverCommand.name),
})
}
@ -732,6 +735,7 @@ export function Autocomplete(props: {
mode: "autocomplete",
target: props.input,
enabled: () => Boolean(store.visible),
bindings: ["prompt.queue"],
commands: [
{
id: "prompt.autocomplete.prev",
@ -837,6 +841,11 @@ export function Autocomplete(props: {
get visible() {
return store.visible
},
completeQueueableCommand() {
if (store.visible !== "command" || !options()[store.selected]?.queueable) return false
select()
return true
},
onInput(value) {
if (dismissedValue() === value) return
setDismissedValue(undefined)

View file

@ -468,6 +468,7 @@ export function Prompt(props: PromptProps) {
event?.preventDefault()
event?.stopPropagation()
if (!input.focused) return
if (auto()?.visible && !auto()?.completeQueueableCommand()) return
const handled = await submit("queue")
if (!handled) return
dialog.clear()

View file

@ -843,7 +843,7 @@ export function createPromptState(input: PromptInput): PromptState {
}
}
const select = (item?: PromptOption) => {
const select = (item?: PromptOption, delivery: RunDelivery = "steer") => {
const next = item ?? options()[menu.selected()]
if (!next || !area || area.isDestroyed) {
return
@ -920,7 +920,7 @@ export function createPromptState(input: PromptInput): PromptState {
hide()
syncDraft()
if (!shell()) {
submitPrompt(promptCopy(draft))
submitPrompt(promptCopy(draft), delivery)
return
}
@ -1047,7 +1047,7 @@ export function createPromptState(input: PromptInput): PromptState {
Keymap.createLayer(() => ({
priority: 1,
enabled: input.prompt() && !visible(),
enabled: input.prompt() && (!visible() || mode() === "slash"),
commands: [
{
id: "prompt.queue",
@ -1059,6 +1059,13 @@ export function createPromptState(input: PromptInput): PromptState {
submitPrompt(promptCopy(draft), "queue")
},
},
],
}))
Keymap.createLayer(() => ({
priority: 1,
enabled: input.prompt() && !visible(),
commands: [
{
id: "prompt.editor",
title: "Open editor",
@ -1201,7 +1208,7 @@ export function createPromptState(input: PromptInput): PromptState {
if (visible()) {
if (mode() !== "slash" || options().length > 0) {
select()
select(undefined, delivery)
return
}