Skip to content

Commit e6b4c14

Browse files
committed
Ensure complete log in system console, frontend commands in frontend terminal, backend commands in backend terminal
- Modified terminal output handling to always show complete log in system console - Frontend commands appear in both system console and frontend terminal - Backend commands appear in both system console and backend terminal - Main/bash commands appear only in system console - Maintained separate terminal views for focused command monitoring
1 parent 92cdc1e commit e6b4c14

File tree

1 file changed

+22
-26
lines changed

1 file changed

+22
-26
lines changed

src/ipc/handlers/terminal_handlers.ts

Lines changed: 22 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -40,46 +40,42 @@ export function addTerminalOutput(appId: number, terminal: "main" | "frontend" |
4040
appOutputType = "stdout";
4141
}
4242

43-
const outputItem = {
43+
// Create output item for system console (complete log)
44+
const systemOutputItem = {
4445
message: formattedMessage,
4546
timestamp: Date.now(),
4647
type: appOutputType,
4748
appId
4849
};
4950

50-
if (terminal === "main") {
51-
// Main (system) terminal - add to the general app output
52-
const currentOutput = store.get(appOutputAtom);
53-
store.set(appOutputAtom, [...currentOutput, outputItem]);
51+
// Always add to system console (complete log)
52+
const systemCurrentOutput = store.get(appOutputAtom);
53+
store.set(appOutputAtom, [...systemCurrentOutput, systemOutputItem]);
5454

55-
// Auto-switch to main terminal if it's empty
56-
if (currentOutput.length === 0) {
57-
store.set(activeTerminalAtom, "main");
58-
}
59-
} else if (terminal === "frontend") {
60-
const currentOutput = store.get(frontendTerminalOutputAtom);
61-
store.set(frontendTerminalOutputAtom, [...currentOutput, outputItem]);
55+
// Also add to specific terminal based on command type
56+
if (terminal === "frontend") {
57+
// Add to frontend terminal
58+
const frontendCurrent = store.get(frontendTerminalOutputAtom);
59+
store.set(frontendTerminalOutputAtom, [...frontendCurrent, systemOutputItem]);
6260

6361
// Auto-switch to frontend terminal if it's empty
64-
if (currentOutput.length === 0) {
62+
if (frontendCurrent.length === 0) {
6563
store.set(activeTerminalAtom, "frontend");
6664
}
6765
} else if (terminal === "backend") {
68-
// Backend terminal - combine with main (system) terminal
69-
const currentOutput = store.get(appOutputAtom);
70-
const backendMessage = `[BACKEND] ${formattedMessage}`; // Prefix backend messages
71-
const backendOutputItem = {
72-
...outputItem,
73-
message: backendMessage
74-
};
75-
store.set(appOutputAtom, [...currentOutput, backendOutputItem]);
76-
77-
// Also keep in separate backend atom for backward compatibility if needed
66+
// Add to backend terminal
7867
const backendCurrent = store.get(backendTerminalOutputAtom);
79-
store.set(backendTerminalOutputAtom, [...backendCurrent, outputItem]);
68+
store.set(backendTerminalOutputAtom, [...backendCurrent, systemOutputItem]);
8069

81-
// Auto-switch to main terminal (where backend output appears)
82-
if (currentOutput.length === 0) {
70+
// Auto-switch to backend terminal if it's empty
71+
if (backendCurrent.length === 0) {
72+
store.set(activeTerminalAtom, "backend");
73+
}
74+
} else if (terminal === "main") {
75+
// Main/bash commands - only in system console, no specific terminal
76+
77+
// Auto-switch to main terminal if it's empty
78+
if (systemCurrentOutput.length === 0) {
8379
store.set(activeTerminalAtom, "main");
8480
}
8581
}

0 commit comments

Comments
 (0)