Transforms the single-session terminal into a full multi-tab system:
- Add useTerminalSessions hook: manages multiple PTY sessions over a
single Socket.IO connection to /terminal namespace. Per-session output
multiplexing via callback registry (registerOutputCallback). Sessions
tracked in a Map with status (active/exited) and auto-selection of
the first available session when active is closed.
- Refactor XTerminal: remove internal useTerminal usage; accept sessionId
and control functions (sendInput, resize, closeSession, registerOutputCallback)
as props from parent. Registers its own output callback on mount and
unregisters on unmount. Exit overlay shows restart button using onRestart
callback.
- Refactor TerminalPanel: fully internally managed tabs via
useTerminalSessions. Real tab bar rendered from sessions Map. Features:
"+" button for new tabs, per-tab close buttons, double-click inline tab
rename (Enter/Escape/blur), connection error banner, auto-create first
session on connect, and XTerminal instances kept mounted (display:none)
for scrollback preservation when switching tabs.
- Add comprehensive test suite: 41 tests for useTerminalSessions, 14 for
updated XTerminal, 43 for updated TerminalPanel (76 total). All pass.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>