Skip to content

feat: LCS array diffing in snapshot diff view #35

Description

@jamilagibson

Context

Arrays in snapshot state are currently compared atomically via JSON.stringify. A changed array appears as a single changed node with prevValue/nextValue. This works for the common case but hides granular information about array insertions, deletions, and reordering.

Implementation

diffSnapshots.ts is the only file that needs updating. The isPlainObject boundary is the explicit extension point — arrays fall through to the atomic comparison today; upgrading to LCS swaps in at that boundary.

A Longest Common Subsequence algorithm should produce per-element added, removed, and unchanged nodes for changed arrays.

Acceptance criteria

  • Array insertions, deletions, and reordering surfaced as granular diff nodes
  • Plain object recursive diffing unchanged
  • All existing diffSnapshots unit tests pass
  • New unit tests cover: array insertion, array deletion, array reorder, mixed array/object state
  • Performance acceptable for arrays up to ~100 elements

References

  • Decision 16 in CLAUDE.md — atomic array comparison rationale and explicit extension point

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions