add multi-session support and auto-open TUI on MCP connection#518
Merged
JeremyDev87 merged 2 commits intomasterfrom Feb 17, 2026
Merged
add multi-session support and auto-open TUI on MCP connection#518JeremyDev87 merged 2 commits intomasterfrom
JeremyDev87 merged 2 commits intomasterfrom
Conversation
…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
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
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.
Summary
Closes #485
Replace single-session TUI client with
MultiSessionManagerthat handles multiple concurrent MCP server connections via IPC, and addTuiAutoLauncherto automatically open the TUI in a new terminal window when an MCP server starts.New modules
MultiSessionManagerMAX_SESSIONS=10limit, per-session EventBus wiring, andonSessionAdded/onSessionRemovedlifecycle hooksTuiAutoLauncherSAFE_PATH_PATTERNallowlist andescapeAppleScriptdefense-in-depthSessionTabBaruseMultiSessionStateglobalStateviaAGENT_ACTIVATED/AGENT_DEACTIVATEDevents with counter-based logic andMath.max(0, ...)underflow guardMultiSessionAppkey-based session isolation to prevent cross-session React state contaminationModified modules
DashboardAppexternalStateprop for multi-session mode (bypasses internaluseDashboardStatewhen provided)runTuiTuiIpcClienttoMultiSessionManagerwithrenderMultiSessionentry pointmain.tsinitIpcnow returnsipcServerreference; addedlaunchAutoTuihelper for both SSE and stdio modesinit.constants.tsCODINGBUDDY_AUTO_TUI=1to Claude settings env entriesSecurity hardening
SAFE_PATH_PATTERN(/^[a-zA-Z0-9._\-/]+$/): Allowlist-based input validation forcodingbuddyBinandTERMINALenv var, blocking all shell metacharacters by defaultescapeAppleScript: Defense-in-depth escaping (\→"→\r→\n→\t) with correct backslash-first ordering to prevent double-escapingMAX_SESSIONS=10: Resource exhaustion prevention enforced on bothconnectAll(break at limit) andpoll(skip new connections at limit)getSocketPath(pid)prevents registry poisoningTest plan
MultiSessionManager: 11 tests — connectAll, poll (add/remove), getSession, startPolling/stopPolling, disconnectAll, MAX_SESSIONS enforcement, onMessage→EventBus wiring, onError→connected=falseTuiAutoLauncher: 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 modesSessionTabBar(Ink): 4 tests — render, active indicator, empty state, layout propagationuseMultiSessionState: 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 switchingDashboardApp: externalState propagation testrunTui: 5 tests — no instances, no connected sessions, successful render, bundle load failure, missing renderMultiSession