opencode
opencode copied to clipboard
fix: race condition causing prompt.set undefined error
Summary
Fixes a race condition where onMount() was called before the prompt ref was initialized, causing a "undefined is not an object (evaluating 'prompt.set')" error when starting a new session from inside an existing session.
Root Cause
In packages/opencode/src/cli/cmd/tui/routes/home.tsx:79-90, the onMount() hook attempted to call prompt.set() before the ref had been assigned by the <Prompt ref={(r) => { prompt = r }} /> component. This resulted in prompt being undefined during execution.
Fix
- Changed from
onMount()tocreateEffect()which re-evaluates when reactive dependencies change - Added a guard
if (once || !prompt) returnto check if the prompt ref exists
Fixes #7870