nes: dedupe NextEditProvider streamed-edit handling into shared helper - #324451
Merged
Ulugbek Abdullaev (ulugbekna) merged 5 commits intoJul 6, 2026
Merged
Conversation
Ulugbek Abdullaev (ulugbekna)
commented
Jul 6, 2026
Contributor
- nes: dedupe NextEditProvider streamed-edit handling into shared helper
- nes: rename _cacheStreamedEdit to _rebaseAndCacheStreamedEdit
- nes: pass _rebaseAndCacheStreamedEdit args as an options object
- nes: let _rebaseAndCacheStreamedEdit own docContents advancement
Copilot started reviewing on behalf of
Ulugbek Abdullaev (ulugbekna)
July 6, 2026 08:56
View session
Contributor
There was a problem hiding this comment.
Pull request overview
This PR refactors the Copilot NES (Next Edit Suggestions) inline-edits pipeline by deduplicating the streamed-edit processing logic used by both the regular and speculative NextEditProvider flows into a shared helper, while also clarifying the helper’s responsibilities and call signature.
Changes:
- Introduces a shared
_rebaseAndCacheStreamedEdithelper to handle rebasing, caching, cross-file association, and per-doc content advancement for a single streamed edit. - Replaces duplicated streamed-edit loop logic in both the regular request path and the speculative request path with calls into the shared helper.
- Introduces small supporting types (
DocState,RebaseAndCacheStreamedEditArgs) to make the shared logic’s contract explicit.
Show a summary per file
| File | Description |
|---|---|
| extensions/copilot/src/extension/inlineEdits/node/nextEditProvider.ts | Deduplicates regular/speculative streamed-edit handling into _rebaseAndCacheStreamedEdit, updates logging/caching flow, and adds supporting types for clearer state management. |
Review details
- Files reviewed: 1/1 changed files
- Comments generated: 1
- Review effort level: Low
Alex Ross (alexr00)
previously approved these changes
Jul 6, 2026
Extract the per-edit rebase+cache logic shared by the regular fetch path (`_executeNewNextEditRequest`) and the speculative path (`_runSpeculativeProviderCall`) into a single `_cacheStreamedEdit` method. Both loops previously open-coded the same convert -> rebase -> compose -> setKthNextEdit -> cross-file cache pipeline, which had started to drift. Also: - extract the inline doc-state type into a named `DocState` interface and mark the non-reassigned fields `readonly` - reuse the existing exported `StreamedEdit` type instead of a local duplicate Behavior-preserving: the only differences are trace-level log messages. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The method does more than cache: it also rebases the streamed edit onto the edits applied so far and mutates the per-doc accumulators. The new name reflects that wider responsibility. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Replace the nine positional parameters with a single typed RebaseAndCacheStreamedEditArgs object and group the active-document fields (id, contents, cursorOffset) under `activeDoc`. This removes the call-site ambiguity of several same-typed/optional positional arguments. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Previously the helper mutated editsSoFar/nextEdits/patchIndices and the cache, but left advancing the target document's running `docContents` to each caller (a foot-gun: a future caller could forget it, desyncing the cache key from subsequent edits). The helper now owns the full per-edit state transition: it snapshots the pre-edit contents, populates the cache against that snapshot, then advances `docContents`. The snapshot is returned as `docContentsBeforeEdit` so the regular path can still log the first edit against the pre-edit contents. `targetDocState` is no longer returned, so callers can't mutate it. Behavior-preserving. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…dEdit StreamedEdit.targetDocument is a required DocumentId, so the `?? activeDoc.id` fallback was dead code that could mislead readers into thinking targetDocument may be omitted. Addresses PR review feedback. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Ulugbek Abdullaev (ulugbekna)
force-pushed
the
agents/simplify-nexteditprovider-class
branch
from
July 6, 2026 14:34
76b4ccc to
d64b063
Compare
Giuseppe Cianci (Giuspepe)
approved these changes
Jul 6, 2026
Ulugbek Abdullaev (ulugbekna)
deleted the
agents/simplify-nexteditprovider-class
branch
July 6, 2026 15:12
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.