Summary
Typing /exit in the Command Code TUI interactive session does not cleanly exit. The terminal often hangs or returns to shell in a broken state, requiring a manual process kill (SIGTERM). This happens consistently when MCP servers are connected.
Expected Behavior
/exit should gracefully terminate the TUI session:
- Drain all active MCP server connections
- Cancel any in-flight tool calls (GitHub, Neon, Chrome DevTools, Playwright, etc.)
- Save session state
- Restore terminal to clean shell state
- Exit with code 0
Actual Behavior
- Terminal hangs indefinitely after
/exit with no output
- Requires
Ctrl+C or kill <pid> from another terminal
- Sometimes leaves terminal in raw mode (broken echo, line endings)
- Session state may be lost
- MCP server processes may remain running as orphans
Steps to reproduce the issue
- Start Command Code:
cmd
- Connect to a project with MCP servers configured (e.g. GitHub, Neon, Chrome DevTools, Playwright)
- Run a few tool calls (any file reads, searches, or commands)
- Type
/exit
- Observe: terminal hangs, cursor blinks but no response
- Press
Ctrl+C to force kill
- If
/exit does eventually return, terminal may be in raw mode (broken echo, garbled input)
Command Code Version
0.40.4
Operating System
Linux (Ubuntu/NixOS — x64)
Terminal/IDE
kitty / Konsole / GNOME Terminal
Shell
zsh / bash
Additional context
- Node v24.16.0
- Configured MCP servers that may affect exit behavior: GitHub, Neon, Chrome DevTools, Playwright, shadcn/ui, Tailwind CSS, docs-mcp-server, Brave Search, Z.AI Vision, sequential-thinking
- Theory: The TUI event loop doesn't check the exit flag between tool call iterations. When MCP connections are in-flight or streaming, the exit handler never gets a clean window to run. Suggested fix: add an exit-flag check in the main loop after each tool call completes, and add a forced-drain timeout for MCP connections (e.g. 3s) before SIGKILL fallback.
~/.commandcode/config.json contents (no PII): provider command-code, model zai-org/GLM-5.2
- Auth status: authenticated as SOSANA via Command Code provider
Summary
Typing
/exitin the Command Code TUI interactive session does not cleanly exit. The terminal often hangs or returns to shell in a broken state, requiring a manual process kill (SIGTERM). This happens consistently when MCP servers are connected.Expected Behavior
/exitshould gracefully terminate the TUI session:Actual Behavior
/exitwith no outputCtrl+Corkill <pid>from another terminalSteps to reproduce the issue
cmd/exitCtrl+Cto force kill/exitdoes eventually return, terminal may be in raw mode (broken echo, garbled input)Command Code Version
0.40.4
Operating System
Linux (Ubuntu/NixOS — x64)
Terminal/IDE
kitty / Konsole / GNOME Terminal
Shell
zsh / bash
Additional context
~/.commandcode/config.jsoncontents (no PII): providercommand-code, modelzai-org/GLM-5.2