nes: make tryRebase conflict limit exp-configurable#312708
Merged
ulugbekna merged 2 commits intoApr 27, 2026
Merged
Conversation
Add `maxImperfectAgreementLength` to `NesRebaseConfigs` as a required field (no fallback needed at call sites). Wire it up through a new experiment-based `ConfigKey.TeamInternal.InlineEditsMaxImperfectAgreementLength` setting (default 5, key `chat.advanced.inlineEdits.maxImperfectAgreementLength`). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR makes the tryRebase “imperfect agreement” conflict threshold configurable via an experiment-backed setting, replacing the previously hard-coded maxImperfectAgreementLength = 5 limit so it can be tuned without code changes.
Changes:
- Adds an experiment-based config key
chat.advanced.inlineEdits.maxImperfectAgreementLength(default5). - Wires the setting into NES rebase logic by making
maxImperfectAgreementLengtha required field ofNesRebaseConfigsand using it in both agreement paths. - Updates rebase debugging output and unit tests to include the new required config field.
Show a summary per file
| File | Description |
|---|---|
| extensions/copilot/src/platform/configuration/common/configurationService.ts | Adds new experiment-based team-internal config key for the threshold. |
| extensions/copilot/src/extension/inlineEdits/node/nextEditCache.ts | Reads the new config and supplies it in NesRebaseConfigs. |
| extensions/copilot/src/extension/inlineEdits/common/editRebase.ts | Makes the threshold required in NesRebaseConfigs and uses it in strict rejection logic; adds defaulting in public helpers. |
| extensions/copilot/src/extension/inlineEdits/node/rebaseResult.ts | Includes the new config in auto-generated reproduction test output. |
| extensions/copilot/src/extension/inlineEdits/test/common/editRebase.spec.ts | Updates test config objects to include maxImperfectAgreementLength. |
Copilot's findings
Comments suppressed due to low confidence (2)
extensions/copilot/src/extension/inlineEdits/node/rebaseResult.ts:136
- Same as above: since
maxImperfectAgreementLengthis required, this ternary will always append, nesConfigseven when no optional flags are enabled. If you only want to passnesConfigswhen it meaningfully differs from defaults, gate on that instead of!== undefined.
const configsArg = (this.nesRebaseConfigs.absorbSubsequenceTyping || this.nesRebaseConfigs.reverseAgreement || this.nesRebaseConfigs.maxImperfectAgreementLength !== undefined) ? ', nesConfigs' : '';
lines.push(`\texpect(tryRebase(originalDocument, editWindow, originalEdits, [], userEditSince, currentDocumentContent, currentSelection, 'strict', logger${configsArg})).toMatchInlineSnapshot();`);
extensions/copilot/src/extension/inlineEdits/common/editRebase.ts:144
tryRebaseStringEditshas the same issue astryRebase: the defaultnesConfigs = { maxImperfectAgreementLength }can throw at runtime in circular-import scenarios becausemaxImperfectAgreementLengthis initialized later in the module. Define the constant before these exported functions (or otherwise ensure it's initialized before use).
export function tryRebaseStringEdits<T extends IEditData<T>>(content: string, ours: StringEdit, base: StringEdit, resolution: 'strict' | 'lenient', nesConfigs: NesRebaseConfigs = { maxImperfectAgreementLength }): StringEdit | undefined {
return tryRebaseEdits(content, ours.mapData(r => new VoidEditData()), base, resolution, nesConfigs)?.toStringEdit();
- Files reviewed: 5/5 changed files
- Comments generated: 5
- Move maxAgreementOffset/maxImperfectAgreementLength constants before the interface and function declarations to eliminate the TDZ risk in default parameter values - Clarify JSDoc: the field is required on NesRebaseConfigs; the default only applies when the whole nesConfigs param is omitted - Clamp maxImperfectAgreementLength to >= 0 in _getNesRebaseConfigs() to guard against negative experiment values - Add vNumber() validator to InlineEditsMaxImperfectAgreementLength config key - Simplify rebaseResult.ts: always emit maxImperfectAgreementLength (required field); drop redundant !== undefined guards Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
alexr00
approved these changes
Apr 27, 2026
dmitrivMS
pushed a commit
that referenced
this pull request
Apr 27, 2026
nes: make tryRebase conflict limit exp-configurable (#312708) Add `maxImperfectAgreementLength` to `NesRebaseConfigs` as a required field (no fallback needed at call sites). Wire it up through a new experiment-based `ConfigKey.TeamInternal.InlineEditsMaxImperfectAgreementLength` setting (default 5, key `chat.advanced.inlineEdits.maxImperfectAgreementLength`). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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.
Summary
The
tryRebaselogic uses a hard-coded limit of 5 characters (maxImperfectAgreementLength) to decide whether a rebase with an imperfect agreement (i.e. the user's typed text is found in the suggestion but not at offset 0) should be accepted or rejected. This PR makes that limit configurable via an experiment setting so we can tune it without a code change.Changes
NesRebaseConfigsinterface (editRebase.ts)maxImperfectAgreementLength: numberas a required field (non-optional, so call sites always supply an explicit value — no hidden fallbacks).nesConfigs.maxImperfectAgreementLength:agreementIndexOftryRebaseEditstryRebase,tryRebaseStringEdits) are set to{ maxImperfectAgreementLength }(the existing constant, value5), preserving current behaviour for callers that don't pass configs.Config key (
configurationService.ts)ConfigKey.TeamInternal.InlineEditsMaxImperfectAgreementLength— an experiment-basednumbersetting with keychat.advanced.inlineEdits.maxImperfectAgreementLengthand default5.Wire-up (
nextEditCache.ts)_getNesRebaseConfigs()now reads the new key and includes it in the returnedNesRebaseConfigs.Telemetry / debug code (
rebaseResult.ts)toReproductionTestCode()emitsmaxImperfectAgreementLengthin the generatednesConfigssnippet when it is set.Tests (
editRebase.spec.ts)nesConfigsobject literals updated to includemaxImperfectAgreementLength(using the imported constant) to satisfy the now-required field.