Skip to content

fix(desktop): upgrade xterm.js to 6.1.0-beta to fix renderer crashes#1218

Merged
Kitenite merged 3 commits into
mainfrom
kitenite/investigate-release-66-renderer-issues-possible-xt
Feb 5, 2026
Merged

fix(desktop): upgrade xterm.js to 6.1.0-beta to fix renderer crashes#1218
Kitenite merged 3 commits into
mainfrom
kitenite/investigate-release-66-renderer-issues-possible-xt

Conversation

@Kitenite
Copy link
Copy Markdown
Collaborator

@Kitenite Kitenite commented Feb 5, 2026

Summary

  • Upgrade @xterm/xterm and @xterm/headless from 6.0.0 to 6.1.0-beta.145
  • Upgrade all @xterm/addon-* packages to matching beta versions
  • Fixes multiple known crash bugs in the WebGL renderer that shipped with 6.0.0

Why beta?

xterm.js 6.0.0 has several confirmed crash-level bugs with no stable patch release (no 6.0.1 exists). All fixes are only available in the 6.1.0-beta series. VS Code ships these betas internally.

Bugs fixed by this upgrade

Issue Severity Description
#5585 Crash Stack overflow in WebGL glyph rasterizer
#5586 Crash dimensions undefined on mouse events during terminal kill
#5622 Crash substring undefined in glyph rasterizer
#5606 Visual WebGL wrong dimensions at 125% DPI scaling (Windows)
#5620 UX Scrollbar jumping with AI CLI tools (Claude Code, etc.)
#5548 Perf DOM renderer layout thrashing
#5570 Crash OOM with CommitMono font + ligatures

Package versions

Package Old New
@xterm/xterm ^6.0.0 6.1.0-beta.145
@xterm/headless ^6.0.0 6.1.0-beta.145
@xterm/addon-clipboard ^0.2.0 0.3.0-beta.145
@xterm/addon-fit ^0.11.0 0.12.0-beta.145
@xterm/addon-image ^0.9.0 0.10.0-beta.145
@xterm/addon-ligatures ^0.10.0 0.11.0-beta.145
@xterm/addon-search ^0.16.0 0.17.0-beta.145
@xterm/addon-serialize ^0.14.0 0.15.0-beta.145
@xterm/addon-unicode11 ^0.9.0 0.10.0-beta.145
@xterm/addon-webgl ^0.19.0 0.20.0-beta.144

Note: @xterm/headless Vite alias workaround in electron.vite.config.ts is still needed — the packaging bug persists in the beta.

Test plan

  • Verify terminal renders correctly on startup
  • Test WebGL renderer works (check console for renderer type)
  • Test DOM fallback works (localStorage.setItem('terminal-renderer', 'dom'))
  • Verify scrolling behavior (especially with AI CLI tools)
  • Test copy/paste functionality
  • Test at non-100% DPI scaling if possible
  • Verify Option+Left/Right word navigation still works on macOS

Summary by CodeRabbit

  • Chores
    • Pinned terminal core and addon packages to specific prerelease (beta) versions for consistent installs.
  • Bug Fixes
    • Added an environment polyfill and a preload step to improve terminal compatibility and stability in non-browser runtimes.
    • Adjusted daemon startup behavior to ensure more reliable process startup and I/O handling during tests.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Feb 5, 2026

📝 Walkthrough

Walkthrough

Pins multiple @xterm packages to exact beta prerelease versions and introduces a Bun preload polyfill plus test startup changes so @xterm/headless is safe to load in Bun by preloading xterm-env-polyfill.ts before the daemon.

Changes

Cohort / File(s) Summary
Xterm dependency pins
apps/desktop/package.json
Replaced caret ranges with exact beta prerelease versions for @xterm packages (addons, headless, xterm). No script changes.
Bun polyfill file
apps/desktop/src/main/terminal-host/xterm-env-polyfill.ts
New polyfill that assigns globalThis.window = globalThis when window is absent to satisfy @xterm/headless runtime checks in Bun/Node environments.
Daemon startup & tests
apps/desktop/src/main/terminal-host/daemon.test.ts, apps/desktop/src/main/terminal-host/session-lifecycle.test.ts
Tests add XTERM_POLYFILL_PATH and spawn Bun with --preload the polyfill before the daemon; stdio and detached options moved into the spawn configuration.
Bun test config
apps/desktop/bunfig.toml
Updated test preload configuration to include xterm-env-polyfill.ts before test-setup.ts with explanatory comments.

Sequence Diagram(s)

sequenceDiagram
  participant Test as Test Process
  participant Bun as Bun (runner)
  participant Polyfill as xterm-env-polyfill
  participant Daemon as Terminal Daemon
  participant Xterm as `@xterm/headless`

  Test->>Bun: spawn("bun", ["run", "--preload", "xterm-env-polyfill.ts", "daemon"], {stdio, detached})
  Bun->>Polyfill: preload & execute
  Polyfill-->>Bun: set globalThis.window if absent
  Bun->>Daemon: start daemon process
  Daemon->>Xterm: import/require `@xterm/headless`
  Xterm-->>Daemon: initialize (safe due to polyfill)
  Daemon-->>Test: ready / emits expected signals
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Poem

🐰 I hopped in with a tiny patch,
Preloaded a blanket for a terminal match.
Betas snug, no headless fright,
Window found in Bun tonight.
Thump-thump — tests pass bright.

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main change: upgrading xterm.js to fix renderer crashes, which is the primary objective of the PR.
Description check ✅ Passed The PR description includes a comprehensive summary, detailed rationale, linked issues table, package version changes, test plan, and additional notes about the workaround. While not strictly following the template format, it provides all essential information and exceeds typical requirements.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch kitenite/investigate-release-66-renderer-issues-possible-xt

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
Copy link
Copy Markdown
Contributor

github-actions Bot commented Feb 5, 2026

🧹 Preview Cleanup Complete

The following preview resources have been cleaned up:

  • ✅ Neon database branch
  • ✅ Electric Fly.io app

Thank you for your contribution! 🎉

xterm.js 6.0.0 has known crash bugs in the WebGL renderer (stack overflow
in glyph rasterizer, dimensions undefined on mouse events, scrollbar
jumping with AI CLI tools). These are fixed only in the 6.1.0-beta series.
No stable patch exists yet. Using beta.109 as it includes all critical
fixes while avoiding later potentially destabilizing refactors.
@xterm/headless 6.x detects Node via navigator.userAgent.startsWith("Node.js/").
Bun's userAgent is "Bun/...", so isNode returns false and the bundle hits
"requestIdleCallback" in window, which throws in server runtimes. Preload a
polyfill that sets globalThis.window = globalThis before the daemon loads.
- Add xterm-env-polyfill.ts to bunfig.toml [test] preload so
  headless-emulator.test.ts doesn't crash on window reference
- Remove unused biome-ignore suppression comment
- Format spawn calls (biome)
@Kitenite Kitenite merged commit 30a54d0 into main Feb 5, 2026
13 checks passed
@Kitenite Kitenite deleted the kitenite/investigate-release-66-renderer-issues-possible-xt branch February 5, 2026 08:21
@coderabbitai coderabbitai Bot mentioned this pull request Feb 6, 2026
5 tasks
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