feat(terminal): activate terminal with xterm.js + node-pty#595
Open
HUQIANTAO wants to merge 1 commit into
Open
feat(terminal): activate terminal with xterm.js + node-pty#595HUQIANTAO wants to merge 1 commit into
HUQIANTAO wants to merge 1 commit into
Conversation
- Install @xterm/xterm, @xterm/addon-fit, @xterm/addon-web-links, node-pty - Rewrite electron/terminal-manager.ts to use node-pty for real PTY support (resize, full-screen programs, proper readline editing) - Rewrite TerminalInstance.tsx to use xterm.js (replaces ansi-to-react) with FitAddon for auto-resize and WebLinksAddon for clickable links - Mount TerminalDrawer in AppShell layout (bottom drawer, resizable) - Add terminal toggle button in UnifiedTopBar - Add Cmd+` / Ctrl+` keyboard shortcut for terminal toggle - Update build configs: node-pty in esbuild externals, after-pack rebuild, electron-builder asarUnpack
|
Someone is attempting to deploy a commit to the op7418's projects Team on Vercel. A member of the Team first needs to authorize it. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
The desktop app ships with a terminal backend (
electron/terminal-manager.ts) and frontend components (TerminalDrawer,TerminalInstance), but the drawer was never mounted in the layout — users cannot access a terminal at all. The existing backend useschild_process.spawnwith piped stdio, which lacks PTY semantics (no resize, no full-screen TUI apps, broken readline editing). The frontend renders ANSI output viaansi-to-reactwith a plain<input>field, falling far short of a real terminal emulator.This PR activates the dormant terminal and upgrades it end-to-end: node-pty on the backend, xterm.js on the frontend.
What changed
Backend — real PTY via node-pty
electron/terminal-manager.ts— rewritten to usepty.spawn()instead ofchild_process.spawn. This enables:resize(cols, rows)that actually works (was a no-op before)The IPC contract (
terminal:create/write/resize/kill/onData/onExit) is unchanged;electron/main.tsandelectron/preload.tsrequire no modifications.Frontend — xterm.js terminal emulator
src/components/terminal/TerminalInstance.tsx— replacedansi-to-react+<input>with a full@xterm/xtermTerminal instance:terminal.onData()→write(),pty output→terminal.write()Layout integration
AppShell.tsx— mounts<TerminalDrawer />at the bottom of thedata-app-shellflex column (below the content row). Lazy-loaded vianext/dynamicfollowing the existing AppShell pattern.UnifiedTopBar.tsx— adds a terminal toggle button in the panel-controls area (between File Tree and Workspace Sidebar), consistent with existing panel toggle UX.Cmd+`` (macOS) /Ctrl+`` (Windows/Linux) toggles the terminal drawer globally.Build configuration
scripts/build-electron.mjsnode-ptyadded to esbuildexternalscripts/after-pack.jsnode-ptyadded toelectron-rebuild -oandonlyModuleselectron-builder.yml**/node-pty/**added toasarUnpackTesting
npm run electron:dev— launch desktop dev modeCmd+`vim,htop)