[BUG] VSCode reopen appends duplicate entries to session JSONL, corrupting /insights analysis

Resolved 💬 4 comments Opened May 5, 2026 by An0nya Closed Jun 11, 2026

Description

When VSCode is closed and reopened with an active Claude Code session, entries from that session are re-appended to the JSONL log file. Each replayed entry is byte-for-byte identical to the original (same uuid, same timestamp, same content) with only minor context fields differing (e.g. cwd).

Minimal example — same UUID at two different line offsets in the same file

// line 528
{"uuid":"01cd4a53-9d16-4fc8-860d-b9b46b1abce4","timestamp":"2026-04-23T07:25:36.857Z","cwd":"/path/to/project/subdir","sessionId":"110e2e95-...","type":"assistant",...}

// line 1172 — identical entry, replayed on VSCode reopen
{"uuid":"01cd4a53-9d16-4fc8-860d-b9b46b1abce4","timestamp":"2026-04-23T07:25:36.857Z","cwd":"/path/to/project","sessionId":"110e2e95-...","type":"assistant",...}

A single affected session can have hundreds of duplicate UUID pairs.

Impact on /insights

The duplicated entries cause /insights to see phantom session segments — it reported 13 analyzed sessions against an actual count of ~30–50. The duplicate segments appear as empty or compaction-only sessions, and friction analysis was skewed as a result (flagged "excessive context compaction loops" as the primary friction pattern — this was an artifact of the phantom sessions, not real behavior).

Suggested fix

Deduplicate entries by uuid on read before any processing. The uuid field is stable across replays and is present on all substantive entry types. One-liner in the session parser:

entries = [...new Map(entries.map(e => [e.uuid ?? Math.random(), e])).values()];

To reproduce

  1. Open a session in the VSCode extension with active conversation history
  2. Close VSCode without ending the session
  3. Reopen VSCode
  4. Inspect the session JSONL in ~/.claude/projects/ — entries from before the close will appear duplicated

Environment

macOS, Claude Code VSCode extension

View original on GitHub ↗

This issue has 4 comments on GitHub. Read the full discussion on GitHub ↗