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/outbound/delivery-queue.ts b/src/infra/outbound/delivery-queue.ts index e0d7abcb9ee..ac16911329b 100644 --- a/src/infra/outbound/delivery-queue.ts +++ b/src/infra/outbound/delivery-queue.ts @@ -321,7 +321,7 @@ export async function recoverPendingDeliveries(opts: { log: RecoveryLogger; cfg: OpenClawConfig; stateDir?: string; - /** Maximum wall-clock time for recovery in ms. Remaining entries are deferred to next restart. Default: 60 000. */ + /** Maximum wall-clock time for recovery in ms. Remaining entries are deferred to next startup. Default: 60 000. */ maxRecoveryMs?: number; }): Promise { const pending = await loadPendingDeliveries(opts.stateDir); @@ -344,8 +344,7 @@ export async function recoverPendingDeliveries(opts: { for (const entry of pending) { const now = Date.now(); if (now >= deadline) { - const deferred = pending.length - recovered - failed - skippedMaxRetries - deferredBackoff; - opts.log.warn(`Recovery time budget exceeded — ${deferred} entries deferred to next restart`); + opts.log.warn(`Recovery time budget exceeded — remaining entries deferred to next startup`); break; } if (entry.retryCount >= MAX_RETRIES) { diff --git a/src/infra/outbound/outbound.test.ts b/src/infra/outbound/outbound.test.ts index 006a160e6ab..9d7a266bc8d 100644 --- a/src/infra/outbound/outbound.test.ts +++ b/src/infra/outbound/outbound.test.ts @@ -509,7 +509,7 @@ describe("delivery-queue", () => { expect(remaining).toHaveLength(3); // Should have logged a warning about deferred entries. - expect(log.warn).toHaveBeenCalledWith(expect.stringContaining("deferred to next restart")); + expect(log.warn).toHaveBeenCalledWith(expect.stringContaining("deferred to next startup")); }); it("defers entries until backoff becomes eligible", async () => { 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;