-
Notifications
You must be signed in to change notification settings - Fork 10
Open
Description
Problem
When a user uploads cc.json from multiple machines under the same GitHub username, daily data for overlapping dates is overwritten instead of being summed/appended.
Current behavior
The merge logic in convex/submissions.ts uses Map.set() to handle overlapping dates:
ccData.daily.forEach(day => {
existingDailyMap.set(day.date, { ... }); // overwrites existing data
});This means:
- Same machine, account switch: Works fine —
ccusagereads all local logs, socc.jsonalready contains combined data - Different machines, non-overlapping dates: Creates a separate submission — data is preserved but split
- Different machines, overlapping dates: Second upload replaces the first machine's data for shared dates → data loss
Example
- Machine A: used Claude on 2025-03-01 ($20), 2025-03-02 ($15)
- Machine B: used Claude on 2025-03-02 ($10), 2025-03-03 ($25)
- Upload Machine A's
cc.json→ stored correctly - Upload Machine B's
cc.json→ 2025-03-02 becomes $10 (Machine A's $15 is lost)
Expected: 2025-03-02 should be $25 ($15 + $10)
Considerations
A simple "sum on overlap" approach introduces a new problem: re-uploading from the same machine would double-count data. Possible solutions:
- Track submissions per machine — add a machine identifier so the system knows which data to replace vs. append
- Store separate submissions per source/machine — keep them independent and aggregate at query time
- Deduplicate by session/conversation ID — if
ccusageprovides session-level granularity
Environment
- Scenario: User with multiple machines (e.g., work desktop + personal laptop) under the same GitHub account
- Submission method: Both CLI and OAuth affected
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels