Skip to content

fix(desktop): replace node-pty with @zenyr/bun-pty for Bun compatibility#525

Closed
andreasasprou wants to merge 1 commit intosuperset-sh:mainfrom
andreasasprou:moderate-herring-bba63b
Closed

fix(desktop): replace node-pty with @zenyr/bun-pty for Bun compatibility#525
andreasasprou wants to merge 1 commit intosuperset-sh:mainfrom
andreasasprou:moderate-herring-bba63b

Conversation

@andreasasprou
Copy link
Copy Markdown
Contributor

@andreasasprou andreasasprou commented Dec 28, 2025

Summary

  • Fixes node-gyp build errors during Bun workspace setup
  • Replaces node-pty with @zenyr/bun-pty which is designed for Bun compatibility
  • Resolves "Class extends value # is not a constructor or null" error

    Problem

    Running ./.superset/setup.sh with Bun fails with node-gyp errors because node-pty expects Node.js runtime symbols not available in Bun.

    Solution

    Replace node-pty with @zenyr/bun-pty, a drop-in replacement specifically built for Bun environments that provides the same terminal API.

    Files Changed

    • apps/desktop/package.json: Updated dependency
    • bun.lock: Updated lock file with new dependency versions

    Testing

    • Verified setup script runs without errors after the change
    • Dependencies install successfully without node-gyp compilation failures

    Summary by CodeRabbit

    • Chores
      • Updated terminal PTY library dependency for the desktop application.

    ✏️ Tip: You can customize this high-level summary in your review settings.

Resolves node-gyp build errors during setup by replacing node-pty with
@zenyr/bun-pty, which is specifically designed for Bun environments.
The error "Class extends value #<Object> is not a constructor or null"
was caused by node-pty expecting Node.js runtime symbols not available in Bun.
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Dec 28, 2025

📝 Walkthrough

Walkthrough

Updated the PTY library dependency in the desktop app package configuration, replacing node-pty with @zenyr/bun-pty for terminal pseudo-terminal functionality.

Changes

Cohort / File(s) Summary
PTY dependency replacement
apps/desktop/package.json
Removed node-pty (beta) from dependencies; added @zenyr/bun-pty as a new runtime dependency for PTY functionality

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Possibly related PRs

Poem

🐰 Hop, swap, and bounce with glee!
From node-pty to bun-pty spree,
Terminal shells now spin more neat,
One PTY gone, another's sweet! 🎉

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and specifically describes the main change: replacing node-pty with @zenyr/bun-pty for Bun compatibility, which is the primary objective of this pull request.
Description check ✅ Passed The description includes a clear summary, problem statement, solution, files changed, and testing details. It covers all essential information and matches the expected template structure.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 4c6f71c and e726d70.

⛔ Files ignored due to path filters (1)
  • bun.lock is excluded by !**/*.lock
📒 Files selected for processing (1)
  • apps/desktop/package.json
🧰 Additional context used
🧠 Learnings (3)
📓 Common learnings
Learnt from: CR
Repo: superset-sh/superset PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-28T01:56:39.021Z
Learning: Applies to apps/desktop/src/**/*.{ts,tsx} : Move Node.js functionality needed in Electron renderer to `src/main/lib/` and communicate via IPC
📚 Learning: 2025-12-28T01:56:39.021Z
Learnt from: CR
Repo: superset-sh/superset PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-28T01:56:39.021Z
Learning: Applies to apps/desktop/src/**/*.{ts,tsx} : Move Node.js functionality needed in Electron renderer to `src/main/lib/` and communicate via IPC

Applied to files:

  • apps/desktop/package.json
📚 Learning: 2025-12-28T01:56:39.021Z
Learnt from: CR
Repo: superset-sh/superset PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-28T01:56:39.021Z
Learning: Use Bun as the package manager for this monorepo, not npm/yarn/pnpm

Applied to files:

  • apps/desktop/package.json

Comment thread apps/desktop/package.json
"@xterm/addon-web-links": "^0.11.0",
"@xterm/addon-webgl": "^0.18.0",
"@xterm/xterm": "^5.5.0",
"@zenyr/bun-pty": "^0.4.4",
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.

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Verify all node-pty imports have been updated and check PTY usage location

echo "=== Checking for remaining node-pty imports ==="
rg -n --type=ts --type=tsx "from ['\"]node-pty['\"]|require\(['\"]node-pty['\"]\)" apps/desktop/src/ 2>/dev/null || echo "No results"

echo -e "\n=== Checking new @zenyr/bun-pty imports ==="
rg -n --type=ts --type=tsx "from ['\"]@zenyr/bun-pty['\"]|require\(['\"]@zenyr/bun-pty['\"]\)" apps/desktop/src/ 2>/dev/null || echo "No results"

echo -e "\n=== Checking PTY usage location (should be in main process, not renderer) ==="
rg -n --type=ts --type=tsx -C3 "@zenyr/bun-pty|pty\|IPty" apps/desktop/src/renderer/ 2>/dev/null || echo "No PTY usage in renderer"

echo -e "\n=== Checking for @types/node-pty in package.json ==="
rg -n "@types/node-pty" apps/desktop/package.json 2>/dev/null || echo "Not found"

echo -e "\n=== Checking PTY usage in main process ==="
rg -n --type=ts --type=tsx "@zenyr/bun-pty|pty\|IPty" apps/desktop/src/main/ 2>/dev/null || echo "No results"

Repository: superset-sh/superset

Length of output: 401


🌐 Web query:

@zenyr/bun-pty node-pty drop-in replacement API compatibility

💡 Result:

Short answer: Mostly — @zenyr/bun-pty implements a node-pty–like API (spawn, write, resize, kill, onData/onExit, pid/cols/rows/process) and is intended as a Bun-native replacement, so common node-pty code will often work with little or no changes. [1][2]

Notes / caveats:

  • Method names/shape: bun-pty exposes spawn and an IPty with onData/onExit, write, resize, kill and similar properties — matching the typical node-pty surface. [1][2]
  • Event vs callback style: modern node-pty docs also show onData/onExit APIs (not only EventEmitter), but if your code relies on older event-emitter internals or undocumented behaviors you should test. [2]
  • Options/edge cases: confirm options you use (env, cwd, name, cols/rows, encoding, signal handling) behave identically in your target Bun version; prebuilt binaries and Bun runtime differences may affect behavior. [1]
  • Recommendation: treat it as “mostly drop-in” for typical terminal use, but run your test-suite (or quick smoke tests) for any advanced/edge-case features (signals, custom streams, platforms). If you want, tell me a specific node-pty code sample and I’ll point out required changes/test checklist.

Sources:
[1] @zenyr/bun-pty README (API, types, examples).
[2] node-pty (API / examples).


🏁 Script executed:

#!/bin/bash
# Check all file types for PTY usage

echo "=== Searching all file types for node-pty usage ==="
rg "node-pty" apps/desktop/ 2>/dev/null || echo "No node-pty found"

echo -e "\n=== Searching all file types for @zenyr/bun-pty usage ==="
rg "@zenyr/bun-pty" apps/desktop/ 2>/dev/null || echo "No @zenyr/bun-pty found"

echo -e "\n=== Checking if pty/IPty is used anywhere in codebase ==="
rg "spawn.*pty|IPty|bun-pty" apps/desktop/src/ 2>/dev/null || echo "No PTY usage found"

echo -e "\n=== List all files in apps/desktop/src/main/ ==="
find apps/desktop/src/main -type f \( -name "*.ts" -o -name "*.tsx" -o -name "*.js" \) 2>/dev/null | head -20

Repository: superset-sh/superset

Length of output: 3099


Complete the migration from node-pty to @zenyr/bun-pty across the entire codebase.

The dependency has been added to package.json, but the integration is incomplete. The following files still import and use node-pty:

  • apps/desktop/src/main/lib/terminal/session.ts — imports "node-pty"
  • apps/desktop/src/main/lib/terminal/types.ts — imports "node-pty" for types
  • apps/desktop/src/main/lib/terminal/manager.test.ts — imports and mocks "node-pty"

Additionally, the build and tooling configuration still reference node-pty:

  • apps/desktop/electron-builder.ts — copy rules for node-pty native modules
  • apps/desktop/electron.vite.config.ts — marks node-pty as external
  • apps/desktop/scripts/copy-native-modules.ts — lists node-pty as native module

Update all these files to import @zenyr/bun-pty instead. Verify that the @zenyr/bun-pty API is compatible with existing terminal operations (spawn, IPty interface, write, resize, kill, onData/onExit).

🤖 Prompt for AI Agents
In apps/desktop/package.json around line 68 and across the codebase, the
dependency was added but imports and tooling still reference node-pty; update
all occurrences to @zenyr/bun-pty: replace import "node-pty" with
"@zenyr/bun-pty" in apps/desktop/src/main/lib/terminal/session.ts and
apps/desktop/src/main/lib/terminal/types.ts (adjust type imports to use the
IPty/type names exported by @zenyr/bun-pty), update tests in
apps/desktop/src/main/lib/terminal/manager.test.ts to mock and import
@zenyr/bun-pty, and change build/tooling references in
apps/desktop/electron-builder.ts, apps/desktop/electron.vite.config.ts, and
apps/desktop/scripts/copy-native-modules.ts to reference @zenyr/bun-pty; while
making these changes, ensure API compatibility by mapping any differing method
or event names (spawn, write, resize, kill, onData/onExit or their equivalents)
to the existing terminal usage and update types or small adapters where
necessary so existing code calls continue to work.

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