Skip to content

Commit 9cab2b0

Browse files
committed
Fix terminal routing for app startup commands
- Modify listenToProcess to route output based on terminalType parameter - Backend-detected commands now output to Backend terminal atoms - Frontend-detected commands now output to Frontend terminal atoms - Maintain System Console for general app output and undefined routes - Ensure consistent routing between AI chat commands and app startup processes
1 parent 4a65070 commit 9cab2b0

File tree

1 file changed

+28
-11
lines changed

1 file changed

+28
-11
lines changed

src/ipc/handlers/app_handlers.ts

Lines changed: 28 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -455,6 +455,9 @@ function listenToProcess({
455455
event: Electron.IpcMainInvokeEvent;
456456
terminalType?: "frontend" | "backend" | "main";
457457
}) {
458+
// Import the terminal output function for specific terminal routing
459+
const { addTerminalOutput } = require("../handlers/terminal_handlers");
460+
458461
// Log output
459462
spawnedProcess.stdout?.on("data", async (data) => {
460463
const message = util.stripVTControlCharacters(data.toString());
@@ -486,12 +489,18 @@ function listenToProcess({
486489
appId,
487490
});
488491
} else {
489-
// Normal stdout handling
490-
safeSend(event.sender, "app:output", {
491-
type: "stdout",
492-
message,
493-
appId,
494-
});
492+
// Route output based on terminal type
493+
if (terminalType === "frontend" || terminalType === "backend") {
494+
// Send to specific terminal using the Jotai atoms approach
495+
addTerminalOutput(appId, terminalType, message, "output");
496+
} else {
497+
// Send to main app output (System Console) using IPC approach
498+
safeSend(event.sender, "app:output", {
499+
type: "stdout",
500+
message,
501+
appId,
502+
});
503+
}
495504

496505
const urlMatch = message.match(/(https?:\/\/localhost:\d+\/?)/);
497506
if (urlMatch) {
@@ -513,11 +522,19 @@ function listenToProcess({
513522
logger.error(
514523
`App ${appId} (PID: ${spawnedProcess.pid}) stderr: ${message}`,
515524
);
516-
safeSend(event.sender, "app:output", {
517-
type: "stderr",
518-
message,
519-
appId,
520-
});
525+
526+
// Route error output based on terminal type
527+
if (terminalType === "frontend" || terminalType === "backend") {
528+
// Send to specific terminal using the Jotai atoms approach
529+
addTerminalOutput(appId, terminalType, message, "error");
530+
} else {
531+
// Send to main app output (System Console) using IPC approach
532+
safeSend(event.sender, "app:output", {
533+
type: "stderr",
534+
message,
535+
appId,
536+
});
537+
}
521538
});
522539

523540
// Handle process exit/close

0 commit comments

Comments
 (0)