The open source coding agent.
TypeScript
feat(cli): auto-submit prompt when using --prompt flag (#4510)
Mark Jaquithed33d82535cf
diff --git a/packages/opencode/src/cli/cmd/tui/component/prompt/index.tsx b/packages/opencode/src/cli/cmd/tui/component/prompt/index.tsxindex 5cc757ac2ea..784c8648ed3 100644--- a/packages/opencode/src/cli/cmd/tui/component/prompt/index.tsx+++ b/packages/opencode/src/cli/cmd/tui/component/prompt/index.tsx@@ -44,6 +44,7 @@ export type PromptRef = {reset(): voidblur(): voidfocus(): void+ submit(): void}const PLACEHOLDERS = ["Fix a TODO in the codebase", "What is the tech stack of this project?", "Fix broken tests"]@@ -447,11 +448,14 @@ export function Prompt(props: PromptProps) {})setStore("extmarkToPartIndex", new Map())},+ submit() {+ submit()+ },})async function submit() {if (props.disabled) return- if (autocomplete.visible) return+ if (autocomplete?.visible) returnif (!store.prompt.input) returnconst trimmed = store.prompt.input.trim()if (trimmed === "exit" || trimmed === "quit" || trimmed === ":q") {diff --git a/packages/opencode/src/cli/cmd/tui/routes/home.tsx b/packages/opencode/src/cli/cmd/tui/routes/home.tsxindex d0bb296eb6a..ecdf93c43df 100644--- a/packages/opencode/src/cli/cmd/tui/routes/home.tsx+++ b/packages/opencode/src/cli/cmd/tui/routes/home.tsx@@ -57,6 +57,7 @@ export function Home() {} else if (args.prompt) {prompt.set({ input: args.prompt, parts: [] })once = true+ prompt.submit()}})const directory = useDirectory()