feat(cli): auto-submit prompt when using --prompt flag (#4510)

This commit is contained in:
Mark Jaquith 2025-12-14 22:06:04 -05:00 committed by GitHub
parent 2d63c22d1a
commit ed33d82535
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 6 additions and 1 deletions

View file

@ -44,6 +44,7 @@ export type PromptRef = {
reset(): void
blur(): void
focus(): 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) return
if (!store.prompt.input) return
const trimmed = store.prompt.input.trim()
if (trimmed === "exit" || trimmed === "quit" || trimmed === ":q") {

View file

@ -57,6 +57,7 @@ export function Home() {
} else if (args.prompt) {
prompt.set({ input: args.prompt, parts: [] })
once = true
prompt.submit()
}
})
const directory = useDirectory()