Skip to content

Load PTY adapter at runtime#1311

Merged
juliusmarminge merged 7 commits intopingdotgg:mainfrom
shivamhwp:bunx-issue
Mar 23, 2026
Merged

Load PTY adapter at runtime#1311
juliusmarminge merged 7 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

Closes #204
Closes ecatuogno1#23

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 compile-time conditional

  • Replaces the compile-time Bun/Node platform check in serverLayers.ts with a makeRuntimePtyAdapterLayer function that dynamically imports the correct PTY layer at runtime.
  • Renames the exported Layer in BunPTY.ts and NodePTY.ts from BunPtyAdapterLive/NodePtyAdapterLive to layer to support the dynamic import pattern.
  • Updates the Bun-on-Windows error message to suggest using Node.js (npx t3) as an alternative.
  • Risk: on Bun for Windows, the Bun PTY layer is now selected and will fail during provisioning rather than falling back to the Node PTY implementation as before.

Macroscope summarized 73623d2.

- 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: 99983321-2c5f-4122-8941-0ed73024f7e4

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.

@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
shivamhwp and others added 6 commits March 23, 2026 01:35
- 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
@juliusmarminge juliusmarminge merged commit 754cded into pingdotgg:main Mar 23, 2026
10 checks passed
gabrielMalonso pushed a commit to gabrielMalonso/t3code that referenced this pull request Mar 23, 2026
Co-authored-by: Julius Marminge <julius0216@outlook.com>
Chrono-byte pushed a commit to Chrono-byte/t3code that referenced this pull request Mar 24, 2026
Co-authored-by: Julius Marminge <julius0216@outlook.com>
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.

Bug: bunx t3@alpha fails on Linux rebuilding node-pty Bug: bunx t3@alpha fails on Linux rebuilding node-pty

2 participants