Problem
A fatal Svelte runtime error occurs when viewing certain sessions in the Web UI:
Uncaught Error: https://svelte.dev/e/each_key_duplicate
This happens at MessageList.svelte because the Svelte {#each} block uses msg.uuid as the uniqueness key:
{#each messages as msg, i (msg.uuid ?? `idx-${i}`)}
When the underlying .jsonl session file contains multiple records with the same uuid (which can happen with file synchronization conflicts, repeated history appends, or edits across sessions), Svelte encounters duplicate keys and crashes the page (white screen).
Proposed Changes
Phase 1: UI Hotfix (Immediate Stability)
Phase 2: UI Duplicate Warning (Visibility)
Phase 3: Backend Deduplication (Data Integrity)
Verification
- Construct a test fixture
.jsonl with intentionally duplicated lines (same uuid).
- Verify the Web UI loads normally without throwing
each_key_duplicate.
- Verify the backend deduplication correctly filters out the duplicated messages from the array returned by
readSession.
Problem
A fatal Svelte runtime error occurs when viewing certain sessions in the Web UI:
Uncaught Error: https://svelte.dev/e/each_key_duplicateThis happens at
MessageList.sveltebecause the Svelte{#each}block usesmsg.uuidas the uniqueness key:{#each messages as msg, i (msg.uuid ?? `idx-${i}`)}When the underlying
.jsonlsession file contains multiple records with the sameuuid(which can happen with file synchronization conflicts, repeated history appends, or edits across sessions), Svelte encounters duplicate keys and crashes the page (white screen).Proposed Changes
Phase 1: UI Hotfix (Immediate Stability)
MessageList.svelteto guarantee unique keys (final implementation: O(n) Set-based first-occurrence keying — preserves stable Svelte identity for the no-duplicate case, only deduplicates true duplicates) — merged in PR fix(web): prevent each_key_duplicate when JSONL has duplicate uuids #183 (commit29876ad):{#each messages as msg, i (msg.uuid ? `${msg.uuid}-${i}` : `idx-${i}`)}Phase 2: UI Duplicate Warning (Visibility)
SessionViewer.svelteorMessageList.svelte, proactively scan themessagesarray for duplicateuuids.Phase 3: Backend Deduplication (Data Integrity)
@claude-sessions/corewhen parsing JSONL files. — merged in PR fix(core): deduplicate messages by uuid in readSession (#137 phase 3) #184 (commit331748b6)crud.ts:readSessionshould deduplicate messages byuuid, keeping the latest (last appearing) message for a givenuuid. — merged in PR fix(core): deduplicate messages by uuid in readSession (#137 phase 3) #184Verification
.jsonlwith intentionally duplicated lines (sameuuid).each_key_duplicate.readSession.