chore: clean up debugging logs and console prints
Frontend: - Remove 18 console.log/warn/error statements from terminal.tsx - Remove console.warn from icon.tsx Backend: - Downgrade routine logger.info to logger.debug in tool_instances.py, terminal.py, terminal_session.py, terminal_manager.py, auth.py, docker_build.py, clone.py, config_profiles.py, user_config.py - Keep important lifecycle events as logger.info: * Instance creation, start, running state * Docker build success/failure * Terminal session creation and reset * Auth success and user creation * Readiness probe success * Tunnel creation/stop
This commit is contained in:
@@ -150,7 +150,6 @@ export const Icon: React.FC<IconProps> = ({
|
||||
const sizeValue = sizeMap[size];
|
||||
|
||||
if (!IconComponent) {
|
||||
console.warn(`Icon "${name}" not found`);
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@@ -73,12 +73,11 @@ export const TerminalComponent: React.FC<TerminalProps> = ({
|
||||
const wsHost = apiUrl.replace(/^https?:\/\//, "").replace(/\/+$/, "");
|
||||
const wsUrl = `${wsProtocol}//${wsHost}/ws/tool-instances/${instanceId}/terminal`;
|
||||
|
||||
console.log(`[Terminal WS] Connecting to ${wsUrl} (attempt ${reconnectAttemptsRef.current + 1}/${RECONNECT_ATTEMPTS + 1})`);
|
||||
// WebSocket connection established
|
||||
const ws = new WebSocket(wsUrl);
|
||||
wsRef.current = ws;
|
||||
|
||||
ws.onopen = () => {
|
||||
console.log(`[Terminal WS] Connected successfully`);
|
||||
setStatus("connected");
|
||||
setError(null);
|
||||
reconnectAttemptsRef.current = 0;
|
||||
@@ -99,10 +98,8 @@ export const TerminalComponent: React.FC<TerminalProps> = ({
|
||||
}
|
||||
heartbeatCheckRef.current = window.setInterval(() => {
|
||||
const elapsed = Date.now() - lastPingRef.current;
|
||||
console.log(`[Terminal WS] Heartbeat check: lastPing=${elapsed}ms ago`);
|
||||
if (elapsed > 60000) {
|
||||
// No ping for 60 seconds, connection may be dead
|
||||
console.warn("[Terminal WS] Heartbeat timeout (>60s), closing connection");
|
||||
ws.close(4000, "Heartbeat timeout");
|
||||
}
|
||||
}, 30000);
|
||||
@@ -143,7 +140,6 @@ export const TerminalComponent: React.FC<TerminalProps> = ({
|
||||
} else if (msg.type === "ping") {
|
||||
// Respond with pong and update last ping time
|
||||
lastPingRef.current = Date.now();
|
||||
console.log(`[Terminal WS] Received ping, sending pong`);
|
||||
if (ws.readyState === WebSocket.OPEN) {
|
||||
ws.send(JSON.stringify({ type: "pong" }));
|
||||
}
|
||||
@@ -155,7 +151,6 @@ export const TerminalComponent: React.FC<TerminalProps> = ({
|
||||
};
|
||||
|
||||
ws.onclose = (event) => {
|
||||
console.log(`[Terminal WS] Connection closed: code=${event.code}, reason="${event.reason}", wasClean=${event.wasClean}, attempts=${reconnectAttemptsRef.current}`);
|
||||
setStatus("disconnected");
|
||||
|
||||
// Clean up heartbeat check
|
||||
@@ -171,30 +166,24 @@ export const TerminalComponent: React.FC<TerminalProps> = ({
|
||||
if (reconnectAttemptsRef.current < RECONNECT_ATTEMPTS) {
|
||||
reconnectAttemptsRef.current++;
|
||||
const delay = RECONNECT_DELAY_BASE * Math.pow(2, reconnectAttemptsRef.current - 1);
|
||||
console.log(`[Terminal WS] Will retry in ${delay}ms (attempt ${reconnectAttemptsRef.current}/${RECONNECT_ATTEMPTS})`);
|
||||
setTimeout(() => {
|
||||
if (isUnmountingRef.current) {
|
||||
console.log(`[Terminal WS] Component unmounting, skipping reconnect`);
|
||||
return;
|
||||
}
|
||||
if (document.visibilityState !== "hidden") {
|
||||
connectWebSocket();
|
||||
} else {
|
||||
console.log(`[Terminal WS] Tab hidden, skipping reconnect`);
|
||||
}
|
||||
}, delay);
|
||||
} else {
|
||||
console.log(`[Terminal WS] Max reconnection attempts (${RECONNECT_ATTEMPTS}) reached`);
|
||||
}
|
||||
} else if (event.code === 4000) {
|
||||
// Server closed old connection for concurrent connection - don't reconnect
|
||||
// The new connection is already established
|
||||
console.log(`[Terminal WS] Server closed old connection (concurrent/heartbeat)`);
|
||||
}
|
||||
};
|
||||
|
||||
ws.onerror = (error) => {
|
||||
console.error(`[Terminal WS] Error event fired`, error);
|
||||
setStatus("error");
|
||||
setError("WebSocket error");
|
||||
};
|
||||
@@ -259,7 +248,6 @@ export const TerminalComponent: React.FC<TerminalProps> = ({
|
||||
return;
|
||||
}
|
||||
const { cols, rows } = termRef.current;
|
||||
console.log(`[Terminal] fit() result: ${cols}x${rows} (was ${oldCols}x${oldRows})`);
|
||||
// Force refresh if dimensions are valid
|
||||
if (cols > 0 && rows > 0) {
|
||||
try {
|
||||
@@ -285,14 +273,11 @@ export const TerminalComponent: React.FC<TerminalProps> = ({
|
||||
fitAttempts++;
|
||||
// Ensure container has dimensions before fitting
|
||||
if (container.clientWidth > 0 && container.clientHeight > 0) {
|
||||
console.log(`[Terminal] Container ready: ${container.clientWidth}x${container.clientHeight} (attempt ${fitAttempts})`);
|
||||
fitTerminal();
|
||||
} else if (fitAttempts < 50) {
|
||||
// Container not ready yet, try again (max 50 attempts ~ 1s)
|
||||
console.log(`[Terminal] Container not ready: ${container.clientWidth}x${container.clientHeight} (attempt ${fitAttempts})`);
|
||||
requestAnimationFrame(doInitialFit);
|
||||
} else {
|
||||
console.warn(`[Terminal] Container never got dimensions after ${fitAttempts} attempts`);
|
||||
}
|
||||
};
|
||||
requestAnimationFrame(doInitialFit);
|
||||
@@ -379,9 +364,7 @@ export const TerminalComponent: React.FC<TerminalProps> = ({
|
||||
|
||||
// Visibility API for reconnection
|
||||
const handleVisibilityChange = () => {
|
||||
console.log(`[Terminal WS] Visibility changed to: ${document.visibilityState}, wsState=${ws?.readyState}`);
|
||||
if (document.visibilityState === "visible" && ws && ws.readyState !== WebSocket.OPEN) {
|
||||
console.log(`[Terminal WS] Tab visible, resetting reconnect attempts and reconnecting`);
|
||||
reconnectAttemptsRef.current = 0;
|
||||
connectWebSocket();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user