Skip to content

fix(init): enable interactive Ink UI for npx/Node via ESM sidecar#938

Merged
MathurAditya724 merged 2 commits intomainfrom
issue-937-fix-interactive-ui
May 9, 2026
Merged

fix(init): enable interactive Ink UI for npx/Node via ESM sidecar#938
MathurAditya724 merged 2 commits intomainfrom
issue-937-fix-interactive-ui

Conversation

@MathurAditya724
Copy link
Copy Markdown
Member

@MathurAditya724 MathurAditya724 commented May 8, 2026

npx sentry@latest init now gets the full interactive Ink UI instead of failing with "The interactive UI failed to load."

The pre-bundled ink-app.js sidecar (self-contained ESM with ink/react/yoga-layout inlined) already existed for the Bun binary — this PR ships it in the npm package too. The text-import-plugin emits a path string instead of an external require() for CJS bundles, and createInkUI resolves it via import.meta.url + dynamic import(). Node 22.12+ can load ESM from CJS context this way.

Changes:

  • script/text-import-plugin.ts — for CJS format, emit virtual module exporting path string instead of { external: true }
  • script/bundle.ts — stop deleting dist/ink-app.js after bundling
  • src/lib/init/ui/ink-ui.ts — three-way path resolution (Bun binary / dev mode / Node npm)
  • src/lib/init/ui/factory.ts — remove isBunRuntime() gate from shouldUseLogging()
  • package.json — add dist/ink-app.js to files

Testing

  • bun run test:unit — 6838 tests pass
  • Built bundle, verified dist/ink-app.js ships (2.6 MB self-contained ESM)
  • Verified CJS bundle loads on Node without error
  • Verified sidecar loads via import() from CJS context on Node 22.20
  • Verified node dist/bin.cjs init --yes --dry-run starts the wizard (no UI crash)
  • Verified full import chain: mountApp and App functions available from sidecar

Fixes #937

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 8, 2026

PR Preview Action v1.8.1

QR code for preview link

🚀 View preview at
https://cli.sentry.dev/_preview/pr-938/

Built to branch gh-pages at 2026-05-09 15:16 UTC.
Preview will be ready when the GitHub Pages deployment is complete.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 8, 2026

Codecov Results 📊

6837 passed | Total: 6837 | Pass Rate: 100% | Execution Time: 0ms

📊 Comparison with Base Branch

Metric Change
Total Tests 📈 +1
Passed Tests 📈 +1
Failed Tests
Skipped Tests

All tests are passing successfully.

❌ Patch coverage is 20.00%. Project has 13904 uncovered lines.
✅ Project coverage is 77.05%. Comparing base (base) to head (head).

Files with missing lines (2)
File Patch % Lines
src/lib/init/ui/factory.ts 0.00% ⚠️ 3 Missing
src/lib/init/wizard-runner.ts 0.00% ⚠️ 1 Missing
Coverage diff
@@            Coverage Diff             @@
##          main       #PR       +/-##
==========================================
+ Coverage    77.02%    77.05%    +0.03%
==========================================
  Files          317       317         —
  Lines        60609     60594       -15
  Branches         0         0         —
==========================================
+ Hits         46684     46690        +6
- Misses       13925     13904       -21
- Partials         0         0         —

Generated by Codecov Action

@MathurAditya724 MathurAditya724 force-pushed the issue-937-fix-interactive-ui branch 2 times, most recently from e247010 to a46cca8 Compare May 8, 2026 18:31
@MathurAditya724 MathurAditya724 changed the title fix(init): show actionable error when npx init can't load interactive UI fix(init): enable interactive Ink UI for npx/Node via ESM sidecar May 9, 2026
@MathurAditya724 MathurAditya724 marked this pull request as ready for review May 9, 2026 15:13
Ship the pre-bundled ink-app.js sidecar in the npm package so
`npx sentry@latest init` gets the full interactive Ink UI on Node,
not just LoggingUI.

The text-import-plugin now emits a path string (not an external
require) for the `with { type: "file" }` import in CJS bundles.
`createInkUI` resolves it via import.meta.url and loads the
self-contained ESM sidecar via dynamic import(). The factory no
longer gates on isBunRuntime() — Ink works on both runtimes.

Fixes #937
@MathurAditya724 MathurAditya724 force-pushed the issue-937-fix-interactive-ui branch from 79271ee to 71c2372 Compare May 9, 2026 15:15
@MathurAditya724 MathurAditya724 enabled auto-merge (squash) May 9, 2026 15:16
@MathurAditya724 MathurAditya724 merged commit f800b0a into main May 9, 2026
29 checks passed
@MathurAditya724 MathurAditya724 deleted the issue-937-fix-interactive-ui branch May 9, 2026 15:21
Copy link
Copy Markdown
Contributor

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 4bc4d03. Configure here.

* npm/Node distribution. The `Bun` global only exists in the Bun
* runtime.
*
* Exported for the test suite — production callers should go through
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Exported isBunRuntime() is now dead code

Low Severity

isBunRuntime() is still exported but no longer called anywhere in the codebase. Its only caller was shouldUseLogging(), and that call was removed in this PR. A grep confirms the only references are the definition itself and a stale comment in the test file — no code imports or invokes it.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 4bc4d03. Configure here.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

valid — removed in #943

MathurAditya724 added a commit that referenced this pull request May 9, 2026
## Summary

- removes the exported `isBunRuntime()` function from
`src/lib/init/ui/factory.ts` — it lost its only caller in #938 when
`shouldUseLogging()` stopped gating on the Bun runtime
- updates stale comment in the test file that referenced it

Flagged by Cursor Bugbot in
#938 (review).
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.

npx sentry@latest init fails to load interactive UI

1 participant