You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
chat: keep pulled changes out of agent edit review - #347442
Prevent unrelated changes from a terminal git pull from appearing as agent Keep/Undo hunks in the editor.
A disk reload can replace one broad range spanning pending agent edits and unrelated upstream changes. The shared edit tracker treats that replacement as overlapping the agent edit, leaving the review baseline stale.
Refresh Agent Host editor review from recorded Working Set snapshots after non-agent disk reloads and normal editor Undo/Redo.
Keep refreshes ordered with Working Set updates and reject stale results.
Preserve tracked user text when refreshing the review: snapshot-derived adjustments only refine existing pending edits, and must match a pending replacement in both range and text. Both document and original model versions are checked.
Compare ownership with uncoalesced character mappings, so unchanged inline user text and user-deleted separators are not folded into a wider display change.
Retry a comparison that newer edits superseded instead of suspending review.
If a precise comparison is unavailable, suspend editor review with the existing synchronization warning and recovery path instead of applying an incorrect baseline. File contents are preserved. The suspended entry keeps its tracked original, so recovery after save or revert does not rebuild ownership from Working Set snapshots alone; it is released when the file leaves the Working Set and is not reused for a newer revision.
Cover LF/CRLF reloads, editor Undo/Redo, coarse-diff failures and save recovery, typing during refresh, newer agent edits, user text adjacent to deleted agent edits, retained inline text, and suspended-entry removal and replacement.
The behavior change is limited to Agent Host editor review; it does not change legacy local-chat editing semantics.
Shared API note for reviewers: IEditorWorkerService.computeStringEditFromDiff* now takes IStringDiffOptions, which adds an optional computeRawChanges flag. It reuses DefaultLinesDiffComputer.computeDiffWithRawChanges and is only supported with the built-in advanced algorithm. Existing callers are unaffected: the flag is off by default and the display diff path is unchanged.
An earlier revision of this PR also carried a Chat Sessions smoke-test readiness fix. The same fix landed separately in #347394, so it is no longer part of this diff.
Tracking issue: none supplied; reported directly during use.
Validation
The branch includes main at 691ae8dc3b125d88b6e03ee2afb7ff3c5c72ae0e. The only merge conflict was the smoke test above, resolved by taking main's version. The commands below were all rerun on the merged tree.
pnpm run build-fast --client-only, pnpm run typecheck-client, and pnpm run monaco-compile-check — all passed.
The following focused Electron test command — passed, 125 tests:
pnpm run eslint on the seven changed files (the editor worker service, worker, and their tests, plus agentHostEditReview.ts and its test) — passed.
git diff --check origin/main...HEAD — passed.
The original reload regression and the later editor Undo/Redo, coarse-diff, adjacent-user-text, inline-text, suspended-recovery, and superseded-comparison regressions failed before their respective fixes.
Live validation on macOS used a signed-in Code OSS window, a real Copilot SDK edit, and a disposable local repository. A terminal pull left one agent-review hunk; editor Keep/Undo's Undo action removed only the agent change and preserved both upstream changes on disk. This live run preceded the editor Undo/Redo, coarse-diff, adjacent-user-text, and later review-feedback follow-ups; those follow-ups are covered by the automated tests above, not by a live run. Windows/Linux live validation and full integration/smoke suites were not run locally.
Manual test
In a disposable repository, use Copilot SDK to edit a line in the middle of a file and leave Keep/Undo review pending.
Commit that edit without accepting its review, so a normal pull can merge other changes to the same file.
Make upstream changes both before and after the agent-edited line, then run git pull in the integrated terminal.
Verify only the original agent hunk is under review; both pulled changes are ordinary file content.
Use normal editor Undo and Redo and verify the review still contains only the agent hunk.
Use the editor's chat-edit Undo action and verify the pulled changes remain intact on disk.
Reconcile disk reloads and editor undo/redo with recorded Working Set snapshots so unrelated external changes do not become Keep/Undo hunks.
Suspend editor review when precise comparison is unavailable and reuse the existing recovery path. Cover reloads, edit races, line endings, and save recovery.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This PR updates Agent Host editor review to keep unrelated changes from terminal pulls out of agent Keep/Undo hunks, without changing legacy local-chat editing behavior.
Changes:
Refresh review baselines after disk reloads and editor Undo/Redo, ordered with Working Set updates and guarded against stale results.
Suspend review when changes cannot be compared precisely, preserving file contents and allowing recovery after save or revert.
Add regression coverage for line endings, recovery, concurrent typing, and newer agent edits.
The chat view can bind the default Agent Host session while the New Local Chat command is still activating. Wait for a new local session before sending the smoke prompt, reusing the readiness helper used by the other chat suites.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Keep tracked non-agent text in the review baseline when reconciling disk reloads and editor undo/redo. Restrict snapshot-derived adjustments to existing pending changes and guard both model versions.
Add adjacent-user-edit regressions, including a broad reload followed by undo and redo.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The reason will be displayed to describe this comment to others. Learn more.
🟡 Changes recommended
Containment checks and coarse-refresh recovery can misclassify user-authored text as agent edits, risking unintended removal of user content during review.
Every Undo/Redo or reload appends another full-document refresh to _updates, even when an already queued task will compare the same latest models. Repeated Undo on a large file can therefore accumulate redundant worker diffs and delay Working Set updates and Keep/Undo operations on the same sequencer. Coalesce queued refreshes per entry so a burst schedules only the latest necessary comparison.
Retry comparisons superseded by newer edits instead of suspending review. Retain a suspended entry and its tracked original so recovery does not rebuild ownership from Working Set snapshots alone.
Refine the review baseline with uncoalesced character mappings, through an opt-in editor worker option, and require refinements to match pending replacements in range and text.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Resolve the conflict in test/smoke/src/areas/chat/chatSessions.test.ts by taking main's version: microsoft#347394 landed the same Local-session readiness fix.
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
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
Prevent unrelated changes from a terminal
git pullfrom appearing as agent Keep/Undo hunks in the editor.A disk reload can replace one broad range spanning pending agent edits and unrelated upstream changes. The shared edit tracker treats that replacement as overlapping the agent edit, leaving the review baseline stale.
The behavior change is limited to Agent Host editor review; it does not change legacy local-chat editing semantics.
Shared API note for reviewers:
IEditorWorkerService.computeStringEditFromDiff*now takesIStringDiffOptions, which adds an optionalcomputeRawChangesflag. It reusesDefaultLinesDiffComputer.computeDiffWithRawChangesand is only supported with the built-inadvancedalgorithm. Existing callers are unaffected: the flag is off by default and the display diff path is unchanged.An earlier revision of this PR also carried a Chat Sessions smoke-test readiness fix. The same fix landed separately in #347394, so it is no longer part of this diff.
Tracking issue: none supplied; reported directly during use.
Validation
The branch includes
mainat691ae8dc3b125d88b6e03ee2afb7ff3c5c72ae0e. The only merge conflict was the smoke test above, resolved by takingmain's version. The commands below were all rerun on the merged tree.pnpm run build-fast --client-only,pnpm run typecheck-client, andpnpm run monaco-compile-check— all passed.The following focused Electron test command — passed, 125 tests:
pnpm run eslinton the seven changed files (the editor worker service, worker, and their tests, plusagentHostEditReview.tsand its test) — passed.git diff --check origin/main...HEAD— passed.The original reload regression and the later editor Undo/Redo, coarse-diff, adjacent-user-text, inline-text, suspended-recovery, and superseded-comparison regressions failed before their respective fixes.
Live validation on macOS used a signed-in Code OSS window, a real Copilot SDK edit, and a disposable local repository. A terminal pull left one agent-review hunk; editor Keep/Undo's Undo action removed only the agent change and preserved both upstream changes on disk. This live run preceded the editor Undo/Redo, coarse-diff, adjacent-user-text, and later review-feedback follow-ups; those follow-ups are covered by the automated tests above, not by a live run. Windows/Linux live validation and full integration/smoke suites were not run locally.
Manual test
git pullin the integrated terminal.