Skip to content

fix(tui): re-exec with package tsconfig when cwd cannot compile solid jsx - #464

Merged
LeXwDeX merged 3 commits into
devfrom
fix/tui-jsx-runtime
Aug 29, 2026
Merged

fix(tui): re-exec with package tsconfig when cwd cannot compile solid jsx#464
LeXwDeX merged 3 commits into
devfrom
fix/tui-jsx-runtime

Conversation

@LeXwDeX

@LeXwDeX LeXwDeX commented Aug 29, 2026

Copy link
Copy Markdown
Owner

Closes #465

Why

Source-mode boots of the CLI (e.g. bun --conditions=browser packages/opencode/src/index.ts) crash from any directory without a compatible tsconfig.json:

Unexpected error
Cannot find package 'react' imported from packages/tui/src/config/index.tsx

Root cause: Bun snapshots JSX transpiler settings from $cwd/tsconfig.json at startup. When the cwd has none (or one without @opentui/solid as jsxImportSource), every TUI .tsx file is compiled against the react runtime, and resolution of react/jsx-dev-runtime fails — react is not installed anywhere in this monorepo. The whole TUI graph is affected (app.tsx, config/index.tsx, …), not a single file. Reproduced identically on main; not introduced by the upstream sync.

What changed

  • packages/opencode/src/cli/cmd/tui.ts: before entering the TUI flow, detect the hostile-transpile condition (source mode + cwd tsconfig missing or lacking @opentui/solid) and re-exec the same entry from the package directory, which owns a compatible tsconfig. process.execArgv is preserved (--conditions=browser etc. survive), and the original directory keeps reaching thread/worker resolution through the existing [project] positional + process.chdir path — project keys stay on the user's directory.
  • Compiled binaries are unaffected and skip the guard (the candidate tsconfig only exists in a source checkout; binaries embed pre-compiled code).
  • The re-exec is loop-proof: the child boots with the package tsconfig in cwd, so the guard no-ops.

Evidence

  • Hostile cwd (fixture project, no tsconfig) + pty: before = crash in ~2s with react resolution error; after = TUI alive at 20s with real render output (ANSI frames, provider labels), zero errors.
  • Normal path untouched: bun run dev -- --version from packages/opencode does not re-exec (tsconfig present).
  • bun typecheck PASS; test/cli/cmd/tui/ 18 pass / 0 fail.
  • Non-TUI commands (serve, models) never load the TUI graph and never hit the guard.

@LeXwDeX
LeXwDeX merged commit cd2ba42 into dev Aug 29, 2026
11 checks passed
@LeXwDeX
LeXwDeX deleted the fix/tui-jsx-runtime branch August 29, 2026 05:39
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.

1 participant