From ccde8288a42535f6aaffc5a79fa304f4b241582f Mon Sep 17 00:00:00 2001 From: Chris Scott <99081550+chriswritescode-dev@users.noreply.github.com> Date: Sun, 11 Jan 2026 17:50:55 -0500 Subject: [PATCH] fix: race condition causing prompt.set undefined error Fixes a race condition where onMount() was called before the prompt ref was initialized, causing "undefined is not an object (evaluating 'prompt.set')" error when starting a new session from inside an existing session. Changed from onMount() to createEffect() with a prompt existence check, matching the pattern used in session/index.tsx. Fixes #7870 --- packages/opencode/src/cli/cmd/tui/routes/home.tsx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/opencode/src/cli/cmd/tui/routes/home.tsx b/packages/opencode/src/cli/cmd/tui/routes/home.tsx index 2155ab94744..f28c9090e88 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 { createMemo, Match, createEffect, Show, Switch, onMount } from "solid-js" import { useTheme } from "@tui/context/theme" import { Logo } from "../component/logo" import { DidYouKnow, randomizeTip } from "../component/did-you-know" @@ -76,9 +76,9 @@ export function Home() { let prompt: PromptRef const args = useArgs() - onMount(() => { - randomizeTip() - if (once) return + onMount(() => randomizeTip()) + createEffect(() => { + if (once || !prompt) return if (route.initialPrompt) { prompt.set(route.initialPrompt) once = true