You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
projectFileCacheKey keys file contents by length plus a 32-bit FNV-1a hash. Pierre's WorkerPoolManager looks up rendered file ASTs by cacheKey alone (fileCache.get(file.cacheKey)) and never compares the contents. So when an edit keeps the file the same length and the hash collides, the source preview (SourceFilePreview) and the file editor (editableFileContents) in FilePreviewPanel.tsx keep showing the old highlighted text.
Deterministic repro on origin/main (f4412ae485e9dedeefe0001f120b946be0d1fcb3): with cwd /repo and path sample.js, both console.log('c475b532');\n and console.log('bb9b5e11');\n map to /repo:sample.js:25:raba69. Render the first through Pierre's highlighter, store it with WorkerPoolManager.setFileResultCache, then request the edited file.
Observed: the cache hits, and the AST shown for the edited file contains c475b532 and not bb9b5e11.
Expected: the edited file misses the cache and its highlighted view contains bb9b5e11.
Change
fileContentRevision now keys contents by length plus a SHA-256 of the UTF-8 bytes. It uses the existing @noble/hashes web dependency, so the key stays synchronous. Both callers (read-only source preview and editable file surface) go through projectFileCacheKey, so web and desktop both get the fix.
Scope
Small fix for an obvious bug; no issue needed under CONTRIBUTING.md.
Verification
Added the colliding pair to the existing case in fileContentRevision.test.ts. On base it fails with AssertionError: expected '/repo:sample.js:25:raba69' not to be '/repo:sample.js:25:raba69'. On head it passes.
Runtime transcript using Pierre's real WorkerPoolManager cache and Shiki highlighter, base vs head: https://gist.github.com/saphid/571005f19087bb692b4df884dada53bc. On base the edited file hits the cache and shows c475b532. On head it misses the cache and shows bb9b5e11.
Not shown: no screenshots. The colliding edit is hard to stage by hand in the live UI, so the proof drives Pierre's cache directly. Mobile clients don't use this preview cache.
Authored by Claude Opus 5.5 (Model Hub); reviewed by Kimi K3.1 Pro (Model Hub).
Not shown
apps/web/src/components/files/FilePreviewPanel.tsx:2006 — No integrated live-client UI pass or screenshot is shown; the runtime proof drives Pierre's cache and inspects the highlighted AST rather than the final rendered preview.
Macroscope's review found this PR approvable — Uses SHA-256 for file-preview cache identities so colliding edits no longer reuse stale highlighting. The change is confined to UI cache keys, without changing file writes, permissions or product defaults.
You can add or adjust custom eligibility rules. Learn more.
Reviewing files that changed from the base of the PR and between 4e0561a and 801b389.
You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.
Use the checkbox below for a quick retry:
Trigger review
No actionable comments were generated in the recent review.
Walkthrough
The file content revision now uses SHA-256 over UTF-8 content and formats the digest as hexadecimal. The contents.length prefix remains. A test checks that two same-length contents produce different cache keys.
Changes: File revision hashing
Layer / File(s)
Summary
Hash calculation and cache-key test apps/web/src/components/files/fileContentRevision.ts, apps/web/src/components/files/fileContentRevision.test.ts
The revision calculation replaces its 32-bit rolling hash with SHA-256 and hexadecimal output. The test checks that same-length contents produce different cache keys.
This change makes the file preview cache key collision-resistant, so same-length file contents no longer show a stale highlighted preview. No actionable merge-blocking risk remains.
Pre-merge checks: 4
Check name
Status
Explanation
Title check
The title names the fix and its area: file preview highlighting going stale after same-length edits that collide on the cache key. The changeset replaces the length-plus-32-bit-hash cache key with a l…
Description check
The description follows the template. It has Problem, Change, Scope, and Verification sections. The problem is clearly stated with a deterministic repro, the change is explained, and the scope cites C…
Linked Issues check
Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check
Check skipped because no linked issues were found for this pull request.
Full details: Title check
Explanation
The title names the fix and its area: file preview highlighting going stale after same-length edits that collide on the cache key. The changeset replaces the length-plus-32-bit-hash cache key with a length-plus-SHA-256 key in fileContentRevision, which addresses that collision. The title is in conventional commit form and is specific enough for a teammate to understand the main change.
Full details: Description check
Explanation
The description follows the template. It has Problem, Change, Scope, and Verification sections. The problem is clearly stated with a deterministic repro, the change is explained, and the scope cites CONTRIBUTING.md for a small obvious fix. Verification lists a focused test, a check run, and a runtime transcript, and it states what was not shown (no screenshots, no live UI pass). The description does not include the template's HTML comment guidance, but that guidance is not a required section. The author also left a 'Not shown' note, which is appropriately transparent. The agent attribution line is present as the template requests. The only gap is that the UI-change evidence requirement is not fully met, since no before/after screenshot is provided and the author explains why. Overall the description is mostly complete.
Finishing Touches
Generate unit tests (beta)
Create a new PR
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 0 remain after this review.
Real web app (Vite client and real local server), driven by the repository's e2e scenario runner in its browser, 1280×800 viewport, light theme, local loopback connection. Fresh per-side databases; synthetic project and thread seeded through t3.project/t3.thread with Replay (dev). External edits use filesystem writes, followed by the app's Refresh workspace files button.
Create sample.js containing exactly console.log('c475b532'); followed by a newline. Seed a project and Replay thread, open the thread, open the Files panel and sample.js. Rewrite the file outside the app to console.log('bb9b5e11'); plus newline and click Refresh workspace files. Capture the highlighted editor. Rewrite to the non-colliding bb9b5e12 and refresh; restore c475b532 and refresh; rewrite to bb9b5e11 and refresh again. Capture each state. Run the identical scenario on both commits with fresh state.
Scenario: File preview refresh shows external edits that collide under the old hash
Base retains c475b532 after both colliding edits; the non-colliding control updates to bb9b5e12. Head updates correctly after every edit. All paired captures were visually inspected.
Not shown:
The read-only SourceFilePreview path through a read-only project connection was not exercised; this proof covers the editable Files panel path from the report.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
size:S10-29 changed lines (additions + deletions).vouch:trustedAuthor is trusted by repo permissions or the VOUCHED list.
2 participants
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
projectFileCacheKeykeys file contents by length plus a 32-bit FNV-1a hash. Pierre'sWorkerPoolManagerlooks up rendered file ASTs bycacheKeyalone (fileCache.get(file.cacheKey)) and never compares the contents. So when an edit keeps the file the same length and the hash collides, the source preview (SourceFilePreview) and the file editor (editableFileContents) inFilePreviewPanel.tsxkeep showing the old highlighted text.Deterministic repro on
origin/main(f4412ae485e9dedeefe0001f120b946be0d1fcb3): with cwd/repoand pathsample.js, bothconsole.log('c475b532');\nandconsole.log('bb9b5e11');\nmap to/repo:sample.js:25:raba69. Render the first through Pierre's highlighter, store it withWorkerPoolManager.setFileResultCache, then request the edited file.c475b532and notbb9b5e11.bb9b5e11.Change
fileContentRevisionnow keys contents by length plus a SHA-256 of the UTF-8 bytes. It uses the existing@noble/hashesweb dependency, so the key stays synchronous. Both callers (read-only source preview and editable file surface) go throughprojectFileCacheKey, so web and desktop both get the fix.Scope
Small fix for an obvious bug; no issue needed under CONTRIBUTING.md.
Verification
fileContentRevision.test.ts. On base it fails withAssertionError: expected '/repo:sample.js:25:raba69' not to be '/repo:sample.js:25:raba69'. On head it passes.vp run check:changedexits 0 (format, lint, knip, i18n, typecheck, tests, react compiler).WorkerPoolManagercache and Shiki highlighter, base vs head: https://gist.github.com/saphid/571005f19087bb692b4df884dada53bc. On base the edited file hits the cache and showsc475b532. On head it misses the cache and showsbb9b5e11.Not shown: no screenshots. The colliding edit is hard to stage by hand in the live UI, so the proof drives Pierre's cache directly. Mobile clients don't use this preview cache.
Authored by Claude Opus 5.5 (Model Hub); reviewed by Kimi K3.1 Pro (Model Hub).
Not shown