diff --git a/src/browser/chrome.ts b/src/browser/chrome.ts index 1cb94cf39fb..14ef91e0093 100644 --- a/src/browser/chrome.ts +++ b/src/browser/chrome.ts @@ -316,7 +316,7 @@ export async function launchOpenClawChrome( args.push("about:blank"); return spawn(exe.path, args, { - stdio: "pipe", + stdio: ["ignore", "ignore", "ignore"], env: { ...process.env, // Reduce accidental sharing with the user's env. diff --git a/src/gateway/server-methods/usage.ts b/src/gateway/server-methods/usage.ts index 8b6be35f654..f074a0c66b1 100644 --- a/src/gateway/server-methods/usage.ts +++ b/src/gateway/server-methods/usage.ts @@ -769,22 +769,22 @@ export const usageHandlers: GatewayRequestHandlers = { .toSorted((a, b) => b.count - a.count), }, byModel: Array.from(byModelMap.values()).toSorted((a, b) => { - const costDiff = b.totals.totalCost - a.totals.totalCost; + const costDiff = (b.totals?.totalCost ?? 0) - (a.totals?.totalCost ?? 0); if (costDiff !== 0) { return costDiff; } - return b.totals.totalTokens - a.totals.totalTokens; + return (b.totals?.totalTokens ?? 0) - (a.totals?.totalTokens ?? 0); }), byProvider: Array.from(byProviderMap.values()).toSorted((a, b) => { - const costDiff = b.totals.totalCost - a.totals.totalCost; + const costDiff = (b.totals?.totalCost ?? 0) - (a.totals?.totalCost ?? 0); if (costDiff !== 0) { return costDiff; } - return b.totals.totalTokens - a.totals.totalTokens; + return (b.totals?.totalTokens ?? 0) - (a.totals?.totalTokens ?? 0); }), byAgent: Array.from(byAgentMap.entries()) .map(([id, totals]) => ({ agentId: id, totals })) - .toSorted((a, b) => b.totals.totalCost - a.totals.totalCost), + .toSorted((a, b) => (b.totals?.totalCost ?? 0) - (a.totals?.totalCost ?? 0)), ...tail, }; diff --git a/src/infra/session-cost-usage.ts b/src/infra/session-cost-usage.ts index 230ebd60c2e..4c021bcc72f 100644 --- a/src/infra/session-cost-usage.ts +++ b/src/infra/session-cost-usage.ts @@ -707,11 +707,11 @@ export async function loadSessionCostSummary(params: { const modelUsage = modelUsageMap.size ? Array.from(modelUsageMap.values()).toSorted((a, b) => { - const costDiff = b.totals.totalCost - a.totals.totalCost; + const costDiff = (b.totals?.totalCost ?? 0) - (a.totals?.totalCost ?? 0); if (costDiff !== 0) { return costDiff; } - return b.totals.totalTokens - a.totals.totalTokens; + return (b.totals?.totalTokens ?? 0) - (a.totals?.totalTokens ?? 0); }) : undefined;