Repository navigation
fix(editor): keep an invalidated diff visible until its reload lands - #13777
Merged
Merged
Conversation
Mark invalidated diff content stale instead of dropping it, mirroring the file-content treatment from #13634. The diff read-generation fence (diffReadGenerationRef) already rejects a superseded read's write-back, so retaining the bytes and swapping them on arrival is safe and keeps every RPC saving -- it just stops the loading placeholder flashing on each reveal. The git-status reload effect now treats a stale entry like a missing one so the lazy-load effect stays the single fetcher for it. Co-authored-by: Orca <[email protected]>
Contributor
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (3)
📝 WalkthroughWalkthroughThe editor now retains cached diff content during invalidation and marks it with 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
enrick-dev
pushed a commit
to enrick-dev/orca
that referenced
this pull request
Oct 15, 2026
…tablyai#13777) Mark invalidated diff content stale instead of dropping it, mirroring the file-content treatment from stablyai#13634. The diff read-generation fence (diffReadGenerationRef) already rejects a superseded read's write-back, so retaining the bytes and swapping them on arrival is safe and keeps every RPC saving -- it just stops the loading placeholder flashing on each reveal. The git-status reload effect now treats a stale entry like a missing one so the lazy-load effect stays the single fetcher for it. Co-authored-by: Orca <[email protected]>
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Deferred follow-up to #13634.
That PR made
invalidateFileContentmark cache entries stale instead of deleting them, so revealing a hidden editor panel swaps bytes in place rather than flashingLoading….invalidateDiffContentwas left deleting its entry, so revealing a hidden/inactive diff still flashedLoading diff.... Two reviewers raised it separately; it was out of scope at the time.Safety: the diff path has its own generation fence
Verified before mirroring the change — the diff read is fenced identically to the file read:
diffReadGenerationRefis bumped byinvalidateDiffContent(useEditorPanelContentState.ts), exactly asfileReadGenerationRefis byinvalidateFileContent.loadDiffContentcaptures its generation before anyawaitand re-checksdiffReadGenerationRef.current[file.id] !== generationon both the success and the error path before callingsetDiffContents.So a superseded in-flight diff read can never write back over fresh content, which is what makes retaining the bytes safe. (Covered by the pre-existing test
invalidates a hidden diff nonce without reading until reveal, which still asserts the stale read is dropped.)Changes
DiffContentgains an optionalisStaleflag (renderer-local extension of the sharedGitDiffResultwire type — no wire change, so no remote-compat impact).invalidateDiffContentmarks the entry stale instead of deleting it.needsDiffReadtreats a stale entry as needing a read, so the lazy reveal effect still refetches exactly once (same RPC count as before).Fresh reads and error results overwrite the whole entry, so
isStaleclears naturally.Test
New:
keeps an invalidated diff on screen until the reveal read landsinuseEditorPanelVisibilityContentState.test.tsx— asserts the diff is still'old diff'(not undefined, which is the only thingEditorContent/ChangesModeViewkey theirLoading diff...placeholder on) both right after invalidation and while the reveal read is in flight, then that the fresh read replaces it withisStalegone, in exactly 2 RPCs.Proven discriminating: reverting only the
invalidateDiffContentbody back todeletefails 3 tests —The latter two are existing tests updated from
toBeUndefined()to asserting the retained stale entry.Verification
vitest run src/renderer/src/components/editor/— 167 files, 1123 tests passedtsc --noEmit -p config/tsconfig.tc.web.json— cleanNo
max-linesdisables added or bumped. No UI/token changes (the fix is purely that the existing viewer keeps rendering). Behavior is host-agnostic — it lives in renderer cache bookkeeping, so SSH hosts and folder workspaces are covered identically.Not done
reloadContent's diff branch still deletes before force-loading. That is the explicit user-initiated Reload button, where showing a loading state is legitimate feedback, and perf(editor): stop hidden panels duplicating remote reloads #13634 left the equivalent file-content branch deleting too. Out of scope.Made with Orca 🐋