From b312928e9f9149aaacf1cbb9af96399c1672c334 Mon Sep 17 00:00:00 2001 From: Kyle Altendorf Date: Mon, 9 Mar 2026 15:22:38 -0400 Subject: [PATCH] fix(tui): wait for model store before auto-submitting --prompt (#7476) --- .../opencode/src/cli/cmd/tui/routes/home.tsx | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/packages/opencode/src/cli/cmd/tui/routes/home.tsx b/packages/opencode/src/cli/cmd/tui/routes/home.tsx index c011f6c62..24ea8f3b3 100644 --- a/packages/opencode/src/cli/cmd/tui/routes/home.tsx +++ b/packages/opencode/src/cli/cmd/tui/routes/home.tsx @@ -1,5 +1,5 @@ import { Prompt, type PromptRef } from "@tui/component/prompt" -import { createMemo, Match, onMount, Show, Switch } from "solid-js" +import { createEffect, createMemo, Match, on, onMount, Show, Switch } from "solid-js" import { useTheme } from "@tui/context/theme" import { useKeybind } from "@tui/context/keybind" import { Logo } from "../component/logo" @@ -14,6 +14,7 @@ import { usePromptRef } from "../context/prompt" import { Installation } from "@/installation" import { useKV } from "../context/kv" import { useCommandDialog } from "../component/dialog-command" +import { useLocal } from "../context/local" // TODO: what is the best way to do this? let once = false @@ -76,6 +77,7 @@ export function Home() { let prompt: PromptRef const args = useArgs() + const local = useLocal() onMount(() => { if (once) return if (route.initialPrompt) { @@ -84,9 +86,21 @@ export function Home() { } else if (args.prompt) { prompt.set({ input: args.prompt, parts: [] }) once = true - prompt.submit() } }) + + // Wait for sync and model store to be ready before auto-submitting --prompt + createEffect( + on( + () => sync.ready && local.model.ready, + (ready) => { + if (!ready) return + if (!args.prompt) return + if (prompt.current?.input !== args.prompt) return + prompt.submit() + }, + ), + ) const directory = useDirectory() const keybind = useKeybind()