@@ -245,6 +245,15 @@ async function executeAppLocalNode({
245245 backendCommand = getCommand ( { installCommand, startCommand } ) ; // Fallback
246246 }
247247
248+ // Apply intelligent terminal routing for backend commands
249+ const isPythonBackend = backendCommand . toLowerCase ( ) . includes ( "python" ) ||
250+ backendCommand . toLowerCase ( ) . includes ( "pip" ) ||
251+ backendCommand . toLowerCase ( ) . includes ( "conda" ) ||
252+ backendCommand . toLowerCase ( ) . includes ( "venv" ) ||
253+ backendCommand . toLowerCase ( ) . includes ( "py " ) ;
254+
255+ const backendTerminalType = isPythonBackend ? "backend" : "main" ;
256+
248257 const backendProcess = spawn ( backendCommand , [ ] , {
249258 cwd : backendPath ,
250259 shell : true ,
@@ -265,10 +274,10 @@ async function executeAppLocalNode({
265274 appId,
266275 isNeon,
267276 event,
268- terminalType : "backend" ,
277+ terminalType : backendTerminalType ,
269278 } ) ;
270279
271- logger . info ( `Backend server started for fullstack app ${ appId } (PID: ${ backendProcess . pid } )` ) ;
280+ logger . info ( `Backend server started for fullstack app ${ appId } (PID: ${ backendProcess . pid } ) - routing to ${ backendTerminalType } terminal ` ) ;
272281 }
273282 } catch ( error ) {
274283 logger . error ( `Failed to start backend server for fullstack app ${ appId } :` , error ) ;
@@ -277,6 +286,20 @@ async function executeAppLocalNode({
277286 // Start frontend server
278287 try {
279288 const frontendCommand = "npm run dev --port 32100" ;
289+
290+ // Apply intelligent terminal routing for frontend commands
291+ const isNodeFrontend = frontendCommand . toLowerCase ( ) . includes ( "npm" ) ||
292+ frontendCommand . toLowerCase ( ) . includes ( "yarn" ) ||
293+ frontendCommand . toLowerCase ( ) . includes ( "pnpm" ) ||
294+ frontendCommand . toLowerCase ( ) . includes ( "node" ) ||
295+ frontendCommand . toLowerCase ( ) . includes ( "npx" ) ||
296+ frontendCommand . toLowerCase ( ) . includes ( "vite" ) ||
297+ frontendCommand . toLowerCase ( ) . includes ( "next" ) ||
298+ frontendCommand . toLowerCase ( ) . includes ( "react" ) ||
299+ frontendCommand . toLowerCase ( ) . includes ( "webpack" ) ;
300+
301+ const frontendTerminalType = isNodeFrontend ? "frontend" : "main" ;
302+
280303 const frontendProcess = spawn ( frontendCommand , [ ] , {
281304 cwd : frontendPath ,
282305 shell : true ,
@@ -298,10 +321,10 @@ async function executeAppLocalNode({
298321 appId,
299322 isNeon,
300323 event,
301- terminalType : "frontend" ,
324+ terminalType : frontendTerminalType ,
302325 } ) ;
303326
304- logger . info ( `Frontend server started for fullstack app ${ appId } (PID: ${ frontendProcess . pid } )` ) ;
327+ logger . info ( `Frontend server started for fullstack app ${ appId } (PID: ${ frontendProcess . pid } ) - routing to ${ frontendTerminalType } terminal ` ) ;
305328 }
306329 } catch ( error ) {
307330 logger . error ( `Failed to start frontend server for fullstack app ${ appId } :` , error ) ;
@@ -328,6 +351,43 @@ async function executeAppLocalNode({
328351 }
329352
330353 const command = getCommand ( { installCommand, startCommand } ) ;
354+
355+ // Apply intelligent terminal routing for app startup commands
356+ const isPythonCommand = command . toLowerCase ( ) . includes ( "python" ) ||
357+ command . toLowerCase ( ) . includes ( "pip" ) ||
358+ command . toLowerCase ( ) . includes ( "conda" ) ||
359+ command . toLowerCase ( ) . includes ( "venv" ) ||
360+ command . toLowerCase ( ) . includes ( "py " ) ;
361+
362+ const isNodeCommand = command . toLowerCase ( ) . includes ( "npm" ) ||
363+ command . toLowerCase ( ) . includes ( "yarn" ) ||
364+ command . toLowerCase ( ) . includes ( "pnpm" ) ||
365+ command . toLowerCase ( ) . includes ( "node" ) ||
366+ command . toLowerCase ( ) . includes ( "npx" ) ||
367+ command . toLowerCase ( ) . includes ( "vite" ) ||
368+ command . toLowerCase ( ) . includes ( "next" ) ||
369+ command . toLowerCase ( ) . includes ( "react" ) ||
370+ command . toLowerCase ( ) . includes ( "webpack" ) ;
371+
372+ // Determine terminal type based on command content
373+ let terminalType : "frontend" | "backend" | "main" = "main" ;
374+ if ( isPythonCommand ) {
375+ terminalType = "backend" ;
376+ // Adjust working directory for Python commands
377+ if ( hasBackend ) {
378+ workingDir = backendPath ;
379+ }
380+ } else if ( isNodeCommand ) {
381+ terminalType = "frontend" ;
382+ // Adjust working directory for Node.js commands
383+ if ( hasFrontend ) {
384+ workingDir = frontendPath ;
385+ }
386+ } else {
387+ // Default terminal type based on working directory
388+ terminalType = workingDir === backendPath ? "backend" : workingDir === frontendPath ? "frontend" : "main" ;
389+ }
390+
331391 const spawnedProcess = spawn ( command , [ ] , {
332392 cwd : workingDir ,
333393 shell : true ,
@@ -356,7 +416,6 @@ async function executeAppLocalNode({
356416 isDocker : false ,
357417 } ) ;
358418
359- const terminalType = workingDir === backendPath ? "backend" : "frontend" ;
360419 listenToProcess ( {
361420 process : spawnedProcess ,
362421 appId,
0 commit comments