Skip to content

Multi-machine submissions overwrite daily data instead of merging #43

@kenshin579

Description

@kenshin579

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 — ccusage reads all local logs, so cc.json already 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

  1. Machine A: used Claude on 2025-03-01 ($20), 2025-03-02 ($15)
  2. Machine B: used Claude on 2025-03-02 ($10), 2025-03-03 ($25)
  3. Upload Machine A's cc.json → stored correctly
  4. 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:

  1. Track submissions per machine — add a machine identifier so the system knows which data to replace vs. append
  2. Store separate submissions per source/machine — keep them independent and aggregate at query time
  3. Deduplicate by session/conversation ID — if ccusage provides 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions