Skip to content

fix(ui): prevent highlight cache identity collisions - #889

Merged
benvinegar merged 1 commit into
mainfrom
fix/highlight-cache-identity
Aug 27, 2026
Merged

fix(ui): prevent highlight cache identity collisions#889
benvinegar merged 1 commit into
mainfrom
fix/highlight-cache-identity

Conversation

@benvinegar

Copy link
Copy Markdown
Member

Summary

  • replace sampled patch fingerprints with a memoized SHA-256 identity over the complete patch and parsed diff metadata
  • include the file language in highlighted-diff cache identity
  • add an adversarial regression proving equal-length patches that collided under sampling cannot reuse stale highlighted text
  • add a patch changeset

Validation

  • bun run typecheck
  • bun run test — 1,591 pass, 2 skip
  • bun run test:integration — 132 pass, 1 skip
  • bun run test:tty-smoke — 9 pass
  • bun run deps:check
  • focused format and lint checks
  • real-TTY source-diff smoke
  • bun run benchmarks/highlight-cache-layers.ts
    • cold: 379.99 ms
    • main cache hit: 0.03 ms
    • worker cache revisit: 4.29 ms

This PR description was generated by Pi using gpt-5.6-sol

@vercel

vercel Bot commented Aug 27, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
hunk-web Ignored Ignored Aug 27, 2026 7:46pm

Request Review

@greptile-apps

greptile-apps Bot commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR replaces sampled highlight-cache fingerprints with memoized SHA-256 identities covering complete patch and parsed metadata content.

  • Includes file language in highlighted-diff cache keys.
  • Adds an adversarial regression test for formerly colliding equal-length patches.
  • Adds a patch changeset documenting the stale-highlight fix.

Confidence Score: 5/5

The PR appears safe to merge, with the cache-identity fix covered by a targeted adversarial regression test.

The new key hashes all patch and metadata content, separates languages, preserves source-provider identity, and memoizes repeat hashing without exposing a concrete stale-cache, startup, or compatibility failure.

Important Files Changed

Filename Overview
src/ui/diff/useHighlightedDiff.ts Replaces collision-prone sampled identities with complete content hashing, memoizes fingerprints by immutable file snapshot, and includes language in the cache key.
src/ui/diff/useHighlightedDiff.test.ts Adds a focused regression fixture proving patches that collide under the former sampling scheme receive distinct keys and highlighted output.
.changeset/fuzzy-diffs-refresh.md Correctly records the user-visible cache-collision fix as a patch release.

Reviews (1): Last reviewed commit: "fix(ui): prevent highlight cache identit..." | Re-trigger Greptile

@benvinegar
benvinegar merged commit 129ad5b into main Aug 27, 2026
13 checks passed
@benvinegar
benvinegar deleted the fix/highlight-cache-identity branch August 27, 2026 19:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant