Prioritize active PR patch loading - #139
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ca7da2e9a8
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| const draft = draftQuery.data ?? null; | ||
| const eagerPatchPaths = useMemo( | ||
| const activePatchPaths = useMemo( | ||
| () => (activePath ? [activePath] : []), |
There was a problem hiding this comment.
Gate active patch reads on the current file list
When a PR head refreshes while this component stays mounted and the previously selected file was renamed or removed, this still issues the active patch query for that stale path before the new file list has validated it. The file-diff endpoint can settle successfully with file: null; on the next render with the new file list, background draft/thread paths may then start before the effect corrects activePath to the new first reviewable file, defeating the active-patch-first ordering and wasting an expensive diff request on large PRs. Filter activePatchPaths through fileList (as the old eager path builder did) or reset the path before starting patch queries for the new revision.
Useful? React with 👍 / 👎.
Summary
Why
The remediated real-PR trace still loaded active and background patches together. On
Kilo-Org/kilocode#12204, first patch remained 195 ms over the 1-second browser target even though the sequential backend path passed.Measured impact
On the same immutable 1,019-file PR:
All three first-patch samples passed the 1-second target (771–948 ms). A direct DevTools trace measured 498 ms LCP, 0.00 CLS, and 36 ms total Pierre forced reflow with no estimated savings.
Validation
npm run verifynpm run bench:pr-review -- --origin http://127.0.0.1:3417 --repo Kilo-Org/kilocode --number 12204 --head 3e0d20c03d43124ac1bc7841ba4ba6aa503d96bd --base a4aceaa2b9ebc72b3fda807ed34da72f5e300872 --base-ref main --samples 3