Skip to content

Commit 39ef7fc

Browse files
committed
Merge remote-tracking branch 'origin/dev' into dev
2 parents 37ae0a4 + b312928 commit 39ef7fc

1 file changed

Lines changed: 16 additions & 2 deletions

File tree

  • packages/opencode/src/cli/cmd/tui/routes

packages/opencode/src/cli/cmd/tui/routes/home.tsx

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { Prompt, type PromptRef } from "@tui/component/prompt"
2-
import { createMemo, Match, onMount, Show, Switch } from "solid-js"
2+
import { createEffect, createMemo, Match, on, onMount, Show, Switch } from "solid-js"
33
import { useTheme } from "@tui/context/theme"
44
import { useKeybind } from "@tui/context/keybind"
55
import { Logo } from "../component/logo"
@@ -14,6 +14,7 @@ import { usePromptRef } from "../context/prompt"
1414
import { Installation } from "@/installation"
1515
import { useKV } from "../context/kv"
1616
import { useCommandDialog } from "../component/dialog-command"
17+
import { useLocal } from "../context/local"
1718

1819
// TODO: what is the best way to do this?
1920
let once = false
@@ -76,6 +77,7 @@ export function Home() {
7677

7778
let prompt: PromptRef
7879
const args = useArgs()
80+
const local = useLocal()
7981
onMount(() => {
8082
if (once) return
8183
if (route.initialPrompt) {
@@ -84,9 +86,21 @@ export function Home() {
8486
} else if (args.prompt) {
8587
prompt.set({ input: args.prompt, parts: [] })
8688
once = true
87-
prompt.submit()
8889
}
8990
})
91+
92+
// Wait for sync and model store to be ready before auto-submitting --prompt
93+
createEffect(
94+
on(
95+
() => sync.ready && local.model.ready,
96+
(ready) => {
97+
if (!ready) return
98+
if (!args.prompt) return
99+
if (prompt.current?.input !== args.prompt) return
100+
prompt.submit()
101+
},
102+
),
103+
)
90104
const directory = useDirectory()
91105

92106
const keybind = useKeybind()

0 commit comments

Comments
 (0)