Skip to content

Commit ccde828

Browse files
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 anomalyco#7870
1 parent fa79736 commit ccde828

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

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

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

Lines changed: 4 additions & 4 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 { createMemo, Match, createEffect, Show, Switch, onMount } from "solid-js"
33
import { useTheme } from "@tui/context/theme"
44
import { Logo } from "../component/logo"
55
import { DidYouKnow, randomizeTip } from "../component/did-you-know"
@@ -76,9 +76,9 @@ export function Home() {
7676

7777
let prompt: PromptRef
7878
const args = useArgs()
79-
onMount(() => {
80-
randomizeTip()
81-
if (once) return
79+
onMount(() => randomizeTip())
80+
createEffect(() => {
81+
if (once || !prompt) return
8282
if (route.initialPrompt) {
8383
prompt.set(route.initialPrompt)
8484
once = true

0 commit comments

Comments
 (0)