YC (S26) | Open Computer History | Continuously record your company computer work, map your workflows, help you find work worth automating, and power your agents' context
Rust agentsagiaiai-memoryaudio-recordingcomputer-visionhermeshermes-agentllmlocal-ailocal-firstmachine-learningmcpmultimodalopenclawprivacyrewindscreen-recordingspeech-to-textycombinator
fix usage tab double counting (#2915)
Ayush Singh33c935a4197b
diff --git a/apps/screenpipe-app-tauri/components/settings/usage-section.tsx b/apps/screenpipe-app-tauri/components/settings/usage-section.tsxindex 942a8955f..4cfcd02c3 100644--- a/apps/screenpipe-app-tauri/components/settings/usage-section.tsx+++ b/apps/screenpipe-app-tauri/components/settings/usage-section.tsx@@ -108,6 +108,20 @@ function aggregateEntries(entries: UsageEntry[], since?: number): ModelUsage[] {return Array.from(map.values()).sort((a, b) => b.count - a.count);}+function dedupeEntries(entries: UsageEntry[]): UsageEntry[] {+ const seen = new Set<string>();+ const deduped: UsageEntry[] = [];++ for (const entry of entries) {+ const key = `${entry.timestamp}::${entry.source}::${entry.provider}::${entry.model}`;+ if (seen.has(key)) continue;+ seen.add(key);+ deduped.push(entry);+ }++ return deduped;+}+function getTimeSince(range: TimeRange): number | undefined {if (range === "all") return undefined;const now = Date.now();@@ -144,7 +158,7 @@ export function UsageSection() {// Step 2: Incremental updatetry {- const newEntries = [...cache.entries];+ const newEntries: UsageEntry[] = [];let totalChatsCount = 0;let chatMsgs = 0;let untracked = 0;@@ -186,7 +200,6 @@ export function UsageSection() {}// Pipe executions - only fetch newer than cache watermark- let pipeNewCount = 0;try {const pipesRes = await fetch(`${SCREENPIPE_API}/pipes`);if (pipesRes.ok) {@@ -218,7 +231,6 @@ export function UsageSection() {const entryKey = `${ts}::${exec.provider || "pipe"}::${exec.model}`;if (cachedPipeEntrySet.has(entryKey)) continue;- pipeNewCount++;newEntries.push({model: exec.model,provider: exec.provider || "pipe",@@ -236,8 +248,8 @@ export function UsageSection() {// screenpipe not running}- // Merge new entries with cached entries (deduplicated by timestamp::model)- const allEntries = [...(cache.entries || []), ...newEntries];+ // Merge new entries with cached entries and hard-dedupe to prevent inflation.+ const allEntries = dedupeEntries([...(cache.entries || []), ...newEntries]);// Update cacheconst updatedCache: UsageCache = {