Skip to content

feat(desktop): add embedded terminal panel with multi-tab support#4180

Open
myipanta wants to merge 17 commits into
esengine:main-v2from
myipanta:feat/embedded-terminal-panel
Open

feat(desktop): add embedded terminal panel with multi-tab support#4180
myipanta wants to merge 17 commits into
esengine:main-v2from
myipanta:feat/embedded-terminal-panel

Conversation

@myipanta

Copy link
Copy Markdown
  • Add embedded xterm.js terminal panel as a new dock tab (Terminal) alongside Context / Files / Changed in the right workspace dock
  • Multi-tab terminal: support opening multiple shell sessions, switch between tabs, close individual tabs
  • Right-click file/folder in workspace tree → 'Open in terminal' creates a new terminal tab cd'd to that directory
  • System terminal launchers for macOS (Terminal.app), Linux (auto-detect 12 terminals), Windows (wt.exe / cmd.exe)
  • Go PTY backend with per-session management and Wails event streaming for real-time terminal I/O

Files:

  • desktop/terminal.go: multi-session PTY manager
  • desktop/open_terminal_*.go: platform-specific system terminal launcher
  • desktop/app.go: OpenTerminal, OpenTerminalAt, StartTerminal, StartTerminalAt, TerminalInput, StopTerminal, TerminalResize
  • frontend/src/components/TerminalPanel.tsx: xterm.js terminal panel
  • frontend/src/components/WorkspacePanel.tsx: right-click menu items
  • frontend/src/App.tsx: Terminal dock tab integration
  • frontend/src/lib/bridge.ts: Wails bindings + browser dev mock
  • frontend/src/locales/{en,zh}.ts: i18n keys

- Add embedded xterm.js terminal panel as a new dock tab (Terminal)
  alongside Context / Files / Changed in the right workspace dock
- Multi-tab terminal: support opening multiple shell sessions,
  switch between tabs, close individual tabs
- Right-click file/folder in workspace tree → 'Open in terminal'
  creates a new terminal tab cd'd to that directory
- System terminal launchers for macOS (Terminal.app), Linux
  (auto-detect 12 terminals), Windows (wt.exe / cmd.exe)
- Go PTY backend with per-session management and Wails event
  streaming for real-time terminal I/O

Files:
- desktop/terminal.go: multi-session PTY manager
- desktop/open_terminal_*.go: platform-specific system terminal launcher
- desktop/app.go: OpenTerminal, OpenTerminalAt, StartTerminal,
  StartTerminalAt, TerminalInput, StopTerminal, TerminalResize
- frontend/src/components/TerminalPanel.tsx: xterm.js terminal panel
- frontend/src/components/WorkspacePanel.tsx: right-click menu items
- frontend/src/App.tsx: Terminal dock tab integration
- frontend/src/lib/bridge.ts: Wails bindings + browser dev mock
- frontend/src/locales/{en,zh}.ts: i18n keys
@github-actions github-actions Bot added v2 Go rewrite (1.x) — main-v2 branch, active development desktop Wails desktop app (desktop/**) labels Jun 12, 2026
@myipanta myipanta changed the title feat: add embedded terminal panel with multi-tab support feat(desktop): add embedded terminal panel with multi-tab support Jun 12, 2026
myipanta and others added 9 commits June 12, 2026 23:22
- Terminal background now uses #090a0c (--bg) instead of #1a1a2e
- Full ANSI color palette to match app theme
- Auto-focus terminal input when tab is opened/switched
- xterm container fills full height with slight padding
…-TW locale

- New terminal tabs now auto-select (activate) on creation
- Close button always visible, closing last tab restarts a fresh one
- Start shell with -i flag for interactive mode (fixes process exited)
- Add missing i18n keys to zh-TW locale
- Fix merge conflict residue in package.json
- Read --bg, --fg, --fg-dim, --accent from document CSS vars
- xterm theme now auto-adapts to any Reasonix theme variant
  (graphite, aurora, carbon, nocturne, etc.)
- Cursor color matches --accent for visual consistency
- Copy: Cmd+C copies terminal selection to clipboard
- Paste: Cmd+V pastes clipboard content to terminal
- Search: Ctrl+F toggles search bar with incremental find
- Tab shortcuts: Cmd+T new tab, Cmd+W close tab
- Tab cycling: Ctrl+Tab / Ctrl+Shift+Tab switch tabs
- WebLinksAddon: auto-detect and click URLs in terminal output
- MacOptionIsMeta: macOS Option key sends Meta+ sequences
- .terminal-panel__body now has background: var(--bg)
- .xterm-viewport forced to var(--bg) to prevent white gap
  between terminal canvas and surrounding panel
- Frontend: fallback to workspace-root terminal if StartTerminalAt fails
- Frontend: log specific error reason to console
- Go: include actual error message in failure return string
- Check os.Stat(dir) in startTerminalAt to fail fast on
  non-existent or inaccessible directories
- Prevents PTY hang when path doesn't exist or is slow
@myipanta

Copy link
Copy Markdown
Author
image

ipanta added 4 commits June 13, 2026 13:08
- Replace os.Stat with filepath.Ext() to detect files vs directories
- Remove os.Stat from startTerminalAt (Wails RPC must not block)
- Path detection now uses extension check: files have extensions,
  directories usually don't
- Move restart logic from setTabs callback to dedicated useEffect
- 100ms debounce to avoid race with state update
- Close last tab → auto-creates new Terminal tab
Both OpenTerminalAt and StartTerminalAt now use extension-based
file/dir detection, eliminating all blocking os.Stat calls in
Wails RPC thread
- Force --bg on .xterm-viewport AND .xterm-screen
- Remove any panel borders that create color gaps
- Terminal should now perfectly blend with dock background
ipanta and others added 3 commits June 13, 2026 13:42
- StartTerminalAt runs PTY creation in a goroutine
- 5s timeout returns error string if shell doesn't start
- Wails bound method returns instantly, no UI freeze possible
Keep terminal:output subscribed for the panel lifetime, buffer PTY
output until tabs exist, and unify dock/terminal backgrounds so open
from file tree shows shell output reliably.

Co-authored-by: Cursor <cursoragent@cursor.com>
The test file remains for manual runs; CI does not invoke pnpm test.

Co-authored-by: Cursor <cursoragent@cursor.com>
@myipanta

Copy link
Copy Markdown
Author
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

desktop Wails desktop app (desktop/**) v2 Go rewrite (1.x) — main-v2 branch, active development

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants