Skip to content

add multi-session support and auto-open TUI on MCP connection#518

Merged
JeremyDev87 merged 2 commits intomasterfrom
feat/tui-multi-session-485
Feb 17, 2026
Merged

add multi-session support and auto-open TUI on MCP connection#518
JeremyDev87 merged 2 commits intomasterfrom
feat/tui-multi-session-485

Conversation

@JeremyDev87
Copy link
Owner

Summary

Closes #485

Replace single-session TUI client with MultiSessionManager that handles multiple concurrent MCP server connections via IPC, and add TuiAutoLauncher to automatically open the TUI in a new terminal window when an MCP server starts.

New modules

Module Purpose
MultiSessionManager Connect, poll, and disconnect multiple IPC sessions with MAX_SESSIONS=10 limit, per-session EventBus wiring, and onSessionAdded/onSessionRemoved lifecycle hooks
TuiAutoLauncher Platform-aware terminal detection (macOS: iTerm2, WezTerm, Terminal.app; Linux: kitty, alacritty, gnome-terminal, xterm) with SAFE_PATH_PATTERN allowlist and escapeAppleScript defense-in-depth
SessionTabBar Pure + Ink components for session tab navigation with globalState color indicators and keyboard shortcuts (arrow keys, 1-9)
useMultiSessionState React hook tracking per-session globalState via AGENT_ACTIVATED/AGENT_DEACTIVATED events with counter-based logic and Math.max(0, ...) underflow guard
MultiSessionApp Top-level component with key-based session isolation to prevent cross-session React state contamination

Modified modules

Module Change
DashboardApp Added externalState prop for multi-session mode (bypasses internal useDashboardState when provided)
runTui Refactored from single TuiIpcClient to MultiSessionManager with renderMultiSession entry point
main.ts initIpc now returns ipcServer reference; added launchAutoTui helper for both SSE and stdio modes
init.constants.ts Added CODINGBUDDY_AUTO_TUI=1 to Claude settings env entries

Security hardening

  • SAFE_PATH_PATTERN (/^[a-zA-Z0-9._\-/]+$/): Allowlist-based input validation for codingbuddyBin and TERMINAL env var, blocking all shell metacharacters by default
  • escapeAppleScript: Defense-in-depth escaping (\"\r\n\t) with correct backslash-first ordering to prevent double-escaping
  • MAX_SESSIONS=10: Resource exhaustion prevention enforced on both connectAll (break at limit) and poll (skip new connections at limit)
  • Socket path validation: Canonical path check via getSocketPath(pid) prevents registry poisoning

Test plan

  • MultiSessionManager: 11 tests — connectAll, poll (add/remove), getSession, startPolling/stopPolling, disconnectAll, MAX_SESSIONS enforcement, onMessage→EventBus wiring, onError→connected=false
  • TuiAutoLauncher: 15 tests — disabled, client-already-connected, macOS (iTerm2/WezTerm/Terminal.app/custom bin), Linux (TERMINAL env/which fallback/no-terminal), unsupported platform, spawn options, spawn-failed, defaults, SAFE_PATH_PATTERN rejection (7 injection vectors + unsafe TERMINAL env)
  • SessionTabBar (pure): 16 tests — rendering, truncation, globalState indicators, overflow, layout modes
  • SessionTabBar (Ink): 4 tests — render, active indicator, empty state, layout propagation
  • useMultiSessionState: 15 tests — initialization, session add/remove, switching (direct/index/next/prev), EventBus subscriptions (activate→RUNNING, deactivate→IDLE/ERROR, replaced→IDLE, multi-agent counter, underflow guard, dynamic session subscription, cleanup)
  • MultiSessionApp: 3 tests — render, keyboard input, session switching
  • DashboardApp: externalState propagation test
  • runTui: 5 tests — no instances, no connected sessions, successful render, bundle load failure, missing renderMultiSession
  • All 3820 tests pass (165 files, 0 failures)
  • TypeScript strict mode: 0 errors

…ion (#485)

Replace single-session TUI client with MultiSessionManager that handles
multiple concurrent MCP server connections via IPC. Add TuiAutoLauncher
to automatically open TUI in a new terminal window when an MCP server
starts and no TUI client is connected.

Key changes:
- MultiSessionManager: connect/poll/disconnect multiple IPC sessions
  with MAX_SESSIONS=10 limit, per-session EventBus wiring, and
  onSessionAdded/onSessionRemoved lifecycle hooks
- TuiAutoLauncher: platform-aware terminal detection (macOS iTerm2/
  WezTerm/Terminal.app, Linux kitty/alacritty/gnome-terminal/xterm)
  with SAFE_PATH_PATTERN allowlist and escapeAppleScript defense-in-depth
- SessionTabBar: pure + Ink components for session tab navigation with
  globalState color indicators and keyboard shortcuts (arrow keys, 1-9)
- useMultiSessionState: React hook tracking per-session globalState via
  AGENT_ACTIVATED/AGENT_DEACTIVATED events with counter-based logic
- MultiSessionApp: top-level component with key-based session isolation
- DashboardApp: added externalState prop for multi-session mode
- runTui: refactored from single TuiIpcClient to MultiSessionManager
  with renderMultiSession entry point
- CODINGBUDDY_AUTO_TUI=1 env var added to Claude settings
@vercel
Copy link

vercel bot commented Feb 17, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
codingbuddy-landing Ready Ready Preview, Comment Feb 17, 2026 4:07pm

@JeremyDev87 JeremyDev87 self-assigned this Feb 17, 2026
@JeremyDev87 JeremyDev87 added feat tui TUI Agent Monitor labels Feb 17, 2026
@JeremyDev87 JeremyDev87 changed the title feat(tui): add multi-session support and auto-open TUI on MCP connection add multi-session support and auto-open TUI on MCP connection Feb 17, 2026
@JeremyDev87 JeremyDev87 merged commit 2f99ed0 into master Feb 17, 2026
25 checks passed
@JeremyDev87 JeremyDev87 deleted the feat/tui-multi-session-485 branch February 17, 2026 16:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feat tui TUI Agent Monitor

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(tui): Multi-session support + Auto-open TUI on MCP connection

1 participant