Skip to content

fix(core): include last 2KB in sampledChecksum window#33099

Open
Robin1987China wants to merge 1 commit into
anomalyco:devfrom
Robin1987China:fix-sampled-checksum
Open

fix(core): include last 2KB in sampledChecksum window#33099
Robin1987China wants to merge 1 commit into
anomalyco:devfrom
Robin1987China:fix-sampled-checksum

Conversation

@Robin1987China

Copy link
Copy Markdown
Contributor

Issue for this PR

Closes #33098

Type of change

  • Bug fix

What does this PR do?

sampledChecksum() in packages/core/src/util/encode.ts used content.length - size as the last sampling point. After centering and clamping, the last window covered [content.length - 6144, content.length - 2048] — the final ~2KB was never hashed. Since this function is used as a cache key for file viewers (file.tsx, file-tabs.tsx), edits to the end of large files (>500KB) went undetected and the UI showed stale content.

This PR changes the last point to content.length so the clamped window ends exactly at content.length, covering the final bytes.

How did you verify your code works?

  • bun turbo typecheck: all 29 packages pass
  • Verified with a 600KB string: editing the last 100 bytes now changes the checksum (previously it did not)

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

The last sampling point was content.length - size, which after centering
and clamping produced a window ending at content.length - 2048. The final
~2KB was never hashed, so edits to the end of large files did not change
the cache key and the UI showed stale content.

Closes anomalyco#33098
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.

sampledChecksum() skips the last ~2KB of content, causing stale file caches

2 participants