Skip to content

fix(tui): guard against undefined prompt ref in onMount#15160

Open
Humeo wants to merge 1 commit intoanomalyco:devfrom
Humeo:fix/tui-prompt-undefined-on-mount
Open

fix(tui): guard against undefined prompt ref in onMount#15160
Humeo wants to merge 1 commit intoanomalyco:devfrom
Humeo:fix/tui-prompt-undefined-on-mount

Conversation

@Humeo
Copy link

@Humeo Humeo commented Feb 26, 2026

Issue for this PR

Closes #7839

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

On Windows Terminal, renderer.getPalette() resolves asynchronously and triggers a setStore update in theme.tsx. This causes SolidJS to flush pending effects — including onMount in home.tsx — before the ref callback has executed, leaving prompt as undefined and crashing with "undefined is not an object (evaluating 'prompt.set')".
Added an early return guard if (!prompt) return in onMount to prevent calling prompt.set() before the ref is assigned.

How did you verify your code works?

Ran opencode --prompt "hello" in a Docker container (Linux). No crash. The bug is Windows-specific due to async terminal palette detection, but the guard prevents the crash regardless of platform.

Screenshots / recordings

not a UI change

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

If you do not follow this template your PR will be automatically rejected.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

opentui: fatal: undefined is not an object (evaluating 'prompt.set')

1 participant