perf(workstation): debounce + cache commit file-preview hydration#1571
Open
gfargo-horizon-agent[bot] wants to merge 1 commit into
Open
perf(workstation): debounce + cache commit file-preview hydration#1571gfargo-horizon-agent[bot] wants to merge 1 commit into
gfargo-horizon-agent[bot] wants to merge 1 commit into
Conversation
Adds the same 120ms debounce + bounded (hash, path, oldPath)-keyed cache pattern already shipped for useCommitDetailHydration (#1533) to useCommitFilePreviewHydration, so holding j/k in a commit's file list no longer fires an uncached git show subprocess per cursor move and previously-visited previews redisplay instantly. Co-Authored-By: Claude Sonnet 5 <[email protected]>
Contributor
Author
There was a problem hiding this comment.
🔎 Agent review (sonnet) — LGTM
REVIEW: LGTM
RESOLVES: full
The diff correctly mirrors the already-merged useCommitDetailHydration debounce+cache pattern for the file-preview loader, preserving the active-flag guard, safe() wrapper, and hook-position constraints, with fake-timer tests covering debounce, cancellation, and cache-hit-skips-loading behavior. Scope is tightly limited to the two named files with no touches to app.ts or the sibling hook.
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.
What
Adds a ~120ms debounce and a bounded
(hash, path, oldPath)-keyed cache touseCommitFilePreviewHydration, so holding j/k over a commit's file list stops firing an uncachedgit showsubprocess per cursor move and previously-visited previews redisplay instantly with no loading flash.Why
Plane: OSS-595
Sub-item 2/5 of OSS-338. Its sibling hook,
useCommitDetailHydration, already got this treatment in #1533. This closes the remaining gap:useCommitFilePreviewHydration(inuseDiffHydration.ts) was still fetching uncached on everyselectedDetailFilechange.How
useCommitFilePreviewHydration: added auseRef-backed, size-capped (100 entries, FIFO eviction) cache keyed by${hash}\0${path}\0${oldPath ?? ''}(oldPath is included because renamed files pass different paths togit show).active-flag cleanup, mirroringuseCommitDetailHydration.setFilePreview(cached)+setFilePreviewLoading(false), no fetch, andsetFilePreviewLoading(true)is never called.active-flag stale-response guard, thesafe()wrapper, the no-selection bail, and the dependency array exactly — no change to the exported hook signature or theapp.tscall site (only an internaluseRefwas added).useCommitDetailHydration.ts— that half of the ticket was already merged in perf(workstation): debounce + cache commit detail hydration #1533.Testing
npm run buildpassesnpm run test:jestpasses (useDiffHydration.test.ts: 17/17; full jest suite: 4707/4724 passing — the 10 unrelated failing suites wereSIGKILL/OOM from running the full suite under constrained sandbox memory, confirmed to pass individually and unrelated to any file touched here)npm run lintclean (0 errors; pre-existingexhaustive-depswarnings only, consistent with sibling hooks in this file)true)🤖 Generated by the harbor agent loop. Reviewed by a human before merge.