Skip to content

Prioritize active PR patch loading - #139

Merged
pandemicsyn merged 1 commit into
mainfrom
agent/prioritize-active-pr-patch
Jul 17, 2026
Merged

pandemicsyn merged 1 commit into
mainfrom
agent/prioritize-active-pr-patch

Conversation

@pandemicsyn

Copy link
Copy Markdown
Owner

Summary

  • fetch the selected PR patch before neighboring, draft-comment, and unresolved-thread patches
  • keep deferred draft anchors unknown until their patches load, while preserving removed-file staleness
  • make revision-keyed patch data immutable in TanStack Query and keep background reads cancellable on selection changes
  • extend the real-PR harness with request-order evidence and mark the retained performance-plan/report item completed

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:

Metric Before After
First patch visible 1,195 ms 798 ms
Patch requests/sample 6 4
Aborted patch reads 0 0
Last API response 2,782 ms 2,021 ms

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 verify
  • npm 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
  • final HTML report rendered in Chrome without horizontal overflow

@pandemicsyn
pandemicsyn merged commit e209a3d into main Jul 17, 2026
5 checks passed
@pandemicsyn
pandemicsyn deleted the agent/prioritize-active-pr-patch branch July 17, 2026 13:58

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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] : []),

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

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.

1 participant