The AliFullstack application includes a sophisticated terminal system that supports streaming backend commands (like Python) in fullstack development mode. The system intelligently routes commands to appropriate terminals based on command type and development mode.
- Frontend Terminal: For client-side commands (npm, yarn, node, vite, etc.)
- Backend Terminal: For server-side commands (python, pip, django, flask, etc.)
- Main Terminal: Default fallback terminal
- Parses AI responses for terminal command tags
- Routes commands to appropriate terminals
- Executes commands and streams output
<run_terminal_cmd>- General commands with intelligent routing<alifullstack-run-backend-terminal-cmd>- Explicit backend commands<alifullstack-run-frontend-terminal-cmd>- Explicit frontend commands
// Python/backend commands β backend terminal
const isPythonCommand =
cleanCommand.toLowerCase().includes("python") ||
cleanCommand.toLowerCase().includes("pip") ||
cleanCommand.toLowerCase().includes("conda");
// Node.js/frontend commands β frontend terminal
const isNodeCommand =
cleanCommand.toLowerCase().includes("npm") ||
cleanCommand.toLowerCase().includes("yarn") ||
cleanCommand.toLowerCase().includes("node");- Python/pip commands β Backend Terminal β
- npm/yarn/node commands β Frontend Terminal
- General commands β Backend Terminal (default)
-
src/ipc/processors/response_processor.ts- Main command execution logic- Lines 313-447: General terminal command processing
- Lines 220-269: Backend terminal command processing
- Lines 272-311: Frontend terminal command processing
-
src/ipc/utils/alifullstack_tag_parser.ts- Tag parsing functionsgetAliFullStackRunBackendTerminalCmdTags()- Backend command extractiongetAliFullStackRunFrontendTerminalCmdTags()- Frontend command extractiongetAliFullStackRunTerminalCmdTags()- General command extraction
-
src/ipc/utils/runShellCommand.ts- Shell command execution- Synchronous command execution with stdout/stderr capture
-
src/ipc/handlers/terminal_handlers.ts- Terminal output routingaddTerminalOutput()- Adds formatted output to terminal atoms- Manages frontend/backend terminal state
-
src/components/backend-chat/BackendChatInput.tsx- Terminal initialization- Lines 104-129: Initializes terminals in backend/fullstack mode
- Sets up welcome messages and terminal state
test_terminal_commands.js- Terminal command tag testing- Validates tag parsing and rendering logic
The system automatically streams Python commands to the backend terminal in fullstack mode:
if (isPythonCommand) {
terminalType = "backend";
// Ensures backend directory exists
// Routes to backend terminal
}The backend server now automatically starts when you run/restart fullstack apps through the preview panel.
The frontend server now automatically starts when you run/restart fullstack apps through the preview panel.
The backend and frontend servers automatically start when you run/restart the app through the normal preview controls:
- Click "Run" or "Restart" in the Preview Panel
- App running process detects fullstack mode (both frontend/ and backend/ directories exist)
- Automatically starts both backend and frontend servers
- Streams output to appropriate terminals
When entering Backend/Fullstack chat modes, terminals are initialized and ready for command streaming:
src/components/backend-chat/BackendChatInput.tsx- Terminal initializationsrc/ipc/handlers/terminal_handlers.ts- Terminal output routingsrc/ipc/processors/response_processor.ts- Command processing and routing
User Clicks "Run" or "Restart" in Preview Panel
β
executeApp() detects fullstack mode (frontend/ + backend/ exist)
β
Backend server automatically starts
β
Frontend server automatically starts
β
Both servers stream output to respective terminals
β
Preview iframe shows running app
β Python commands automatically routed to backend terminal in fullstack mode β Backend server automatically starts when running fullstack apps β Frontend server automatically starts when running fullstack apps β Terminal output streams server output and command execution β Preview panel works correctly without conflicts
The system provides automatic backend server streaming through the normal app running process, ensuring proper integration with the preview panel.