fix: console error leak (#1049)

Co-authored-by: Letta <noreply@letta.com>
This commit is contained in:
Charles Packer
2026-02-19 16:49:21 -08:00
committed by GitHub
parent b7f381c183
commit 5378cc6dd8
6 changed files with 31 additions and 18 deletions

View File

@@ -2547,7 +2547,11 @@ export default function App({
setApprovalContexts(contexts);
} catch (error) {
// If analysis fails, leave context as null (will show basic options)
console.error("Failed to analyze startup approvals:", error);
debugLog(
"approvals",
"Failed to analyze startup approvals: %O",
error,
);
}
};
@@ -2861,7 +2865,7 @@ export default function App({
setCurrentToolset(persistedToolsetPreference);
}
} catch (error) {
console.error("Error fetching agent config:", error);
debugLog("agent-config", "Error fetching agent config: %O", error);
}
};
fetchConfig();
@@ -3680,7 +3684,7 @@ export default function App({
}
} catch (error) {
// Silently fail - don't interrupt the conversation flow
console.error("Failed to sync agent state:", error);
debugLog("sync-agent", "Failed to sync agent state: %O", error);
}
};
@@ -7496,8 +7500,9 @@ export default function App({
setApprovalContexts(contexts);
} catch (approvalError) {
// If analysis fails, leave context as null (will show basic options)
console.error(
"Failed to analyze resume approvals:",
debugLog(
"approvals",
"Failed to analyze resume approvals: %O",
approvalError,
);
}
@@ -9524,9 +9529,12 @@ ${SYSTEM_REMINDER_CLOSE}
a.size === b.size && [...a].every((id) => b.has(id));
if (!setsEqual(expectedIds, sendingIds)) {
console.error("[BUG] Approval ID mismatch detected");
console.error("Expected IDs:", Array.from(expectedIds));
console.error("Sending IDs:", Array.from(sendingIds));
debugLog(
"approvals",
"[BUG] Approval ID mismatch detected. Expected: %O, Sending: %O",
Array.from(expectedIds),
Array.from(sendingIds),
);
throw new Error(
"Approval ID mismatch - refusing to send mismatched IDs",
);
@@ -12229,8 +12237,9 @@ Plan file path: ${planFilePath}`;
setApprovalContexts(contexts);
} catch (approvalError) {
// If analysis fails, leave context as null (will show basic options)
console.error(
"Failed to analyze resume approvals:",
debugLog(
"approvals",
"Failed to analyze resume approvals: %O",
approvalError,
);
}

View File

@@ -3,6 +3,7 @@ import { Box, useInput } from "ink";
import Link from "ink-link";
import { useEffect, useState } from "react";
import { getClient } from "../../agent/client";
import { debugLog } from "../../utils/debug";
import { useTerminalWidth } from "../hooks/useTerminalWidth";
import { colors } from "./colors";
import { MarkdownDisplay } from "./MarkdownDisplay";
@@ -56,7 +57,7 @@ export function MemoryTabViewer({
});
setFreshBlocks(agent.memory?.blocks || []);
} catch (error) {
console.error("Failed to fetch memory blocks:", error);
debugLog("memory-tab", "Failed to fetch memory blocks: %O", error);
// Fall back to passed-in blocks if fetch fails
setFreshBlocks(blocks);
} finally {

View File

@@ -15,6 +15,7 @@ import {
type AwsProfile,
parseAwsCredentials,
} from "../../utils/aws-credentials";
import { debugLog } from "../../utils/debug";
import { useTerminalWidth } from "../hooks/useTerminalWidth";
import { colors } from "./colors";
import { Text } from "./Text";
@@ -166,8 +167,7 @@ export function ProviderSelector({
}
})
.catch((err) => {
// eslint-disable-next-line no-console
console.error("Failed to parse AWS credentials:", err);
debugLog("provider", "Failed to parse AWS credentials: %O", err);
if (mountedRef.current) {
setAwsProfiles([]);
setIsLoadingProfiles(false);

View File

@@ -1,5 +1,6 @@
import { readdirSync, statSync } from "node:fs";
import { join, resolve } from "node:path";
import { debugLog } from "../../utils/debug";
interface FileMatch {
path: string;
@@ -245,7 +246,7 @@ export async function searchFiles(
});
} catch (error) {
// Return empty array on any error
console.error("File search error:", error);
debugLog("file-search", "File search error: %O", error);
return [];
}

View File

@@ -8,6 +8,7 @@ import { LETTA_CLOUD_API_URL } from "../../auth/oauth.js";
import { resizeImageIfNeeded } from "../../cli/helpers/imageResize.js";
import { SYSTEM_REMINDER_CLOSE, SYSTEM_REMINDER_OPEN } from "../../constants";
import { settingsManager } from "../../settings-manager.js";
import { debugLog } from "../../utils/debug.js";
import { OVERFLOW_CONFIG, writeOverflowFile } from "./overflow.js";
import { LIMITS } from "./truncation.js";
import { validateRequiredParams } from "./validation.js";
@@ -179,7 +180,7 @@ function formatWithLineNumbers(
overflowPath = writeOverflowFile(content, workingDirectory, "Read");
} catch (error) {
// Silently fail if overflow file creation fails
console.error("Failed to write overflow file:", error);
debugLog("read", "Failed to write overflow file: %O", error);
}
}

View File

@@ -4,6 +4,7 @@
* When outputs exceed limits, full content can be written to overflow files.
*/
import { debugLog } from "../../utils/debug.js";
import { OVERFLOW_CONFIG, writeOverflowFile } from "./overflow.js";
// Limits based on Claude Code's proven production values
@@ -64,7 +65,7 @@ export function truncateByChars(
);
} catch (error) {
// Silently fail if overflow file creation fails
console.error("Failed to write overflow file:", error);
debugLog("truncation", "Failed to write overflow file: %O", error);
}
}
@@ -167,7 +168,7 @@ export function truncateByLines(
);
} catch (error) {
// Silently fail if overflow file creation fails
console.error("Failed to write overflow file:", error);
debugLog("truncation", "Failed to write overflow file: %O", error);
}
}
@@ -250,7 +251,7 @@ export function truncateArray<T>(
);
} catch (error) {
// Silently fail if overflow file creation fails
console.error("Failed to write overflow file:", error);
debugLog("truncation", "Failed to write overflow file: %O", error);
}
}