Skip to content

Load PTY adapter at runtime#1311

Open
shivamhwp wants to merge 3 commits intopingdotgg:mainfrom
shivamhwp:bunx-issue
Open

Load PTY adapter at runtime#1311
shivamhwp wants to merge 3 commits intopingdotgg:mainfrom
shivamhwp:bunx-issue

Conversation

@shivamhwp
Copy link
Collaborator

@shivamhwp shivamhwp commented Mar 22, 2026

What Changed

Updated the server PTY adapter wiring in apps/server/src/serverLayers.ts to lazy-load the runtime-specific adapter instead of eagerly importing both BunPTY and NodePTY.

The server now:

  • Detects the active runtime with process.versions.bun
  • Loads ./terminal/Layers/BunPTY only for Bun on non-Windows platforms
  • Loads ./terminal/Layers/NodePTY for Node and other fallback cases

Fixes

Why

bunx t3 should use the Bun terminal API path, while npx t3 should use the Node PTY path. The previous implementation imported both adapters up front and only selected between them later, which made runtime-specific loading less explicit.

This change makes PTY adapter resolution match the actual runtime in use and keeps Bun-only code out of the Node path and Node-only code out of the Bun path. It also aligns the PTY loading pattern with the existing runtime-specific lazy loading already used in the SQLite layer.

UI Changes

Not applicable.

Checklist

  • This PR is small and focused
  • I explained what changed and why
  • I included before/after screenshots for any UI changes
  • I included a video for animation/interaction changes

Note

Load PTY adapter via dynamic import at runtime instead of static import

  • Replaces the compile-time ternary between BunPtyAdapterLive and NodePtyAdapterLive with a makeRuntimePtyAdapterLayer function in serverLayers.ts that selects and loads the adapter at runtime.
  • Selects the Bun adapter when process.versions.bun is defined and the platform is not win32, otherwise falls back to the Node adapter.
  • Uses dynamic import() via Effect.promise so neither adapter module is bundled or evaluated unless it is needed.

Macroscope summarized d3ebbe6.

- Switch terminal PTY layer selection to dynamic imports
- Avoid bundling the Bun adapter in Node-only runtimes
@coderabbitai
Copy link

coderabbitai bot commented Mar 22, 2026

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 346d031e-80e2-479f-bb64-2a8c5cbe9a6b

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Tip

CodeRabbit can generate a title for your PR based on the changes with custom instructions.

Set the reviews.auto_title_instructions setting to generate a title for your PR based on the changes in the PR with custom instructions.

@github-actions github-actions bot added size:M 30-99 changed lines (additions + deletions). vouch:unvouched PR author is not yet trusted in the VOUCHED list. labels Mar 22, 2026
- Detect Bun at startup and select the matching Effect runtime layer
- Keep the server entrypoint working in both Bun and Node environments
- Remove Bun runtime branching from `apps/server/src/index.ts`
- Run the server with the Node platform layer and runtime
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:M 30-99 changed lines (additions + deletions). vouch:unvouched PR author is not yet trusted in the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant