fix(desktop): upgrade xterm.js to 6.1.0-beta to fix renderer crashes#1218
Conversation
📝 WalkthroughWalkthroughPins multiple Changes
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
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
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. Comment |
🧹 Preview Cleanup CompleteThe following preview resources have been cleaned up:
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.
40dbc55 to
f670c0e
Compare
@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)
Summary
@xterm/xtermand@xterm/headlessfrom 6.0.0 to 6.1.0-beta.145@xterm/addon-*packages to matching beta versionsWhy 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
dimensionsundefined on mouse events during terminal killsubstringundefined in glyph rasterizerPackage versions
Note:
@xterm/headlessVite alias workaround inelectron.vite.config.tsis still needed — the packaging bug persists in the beta.Test plan
localStorage.setItem('terminal-renderer', 'dom'))Summary by CodeRabbit