Skip to content

Add adversarial tests for early cursor-line divergence cancellation#309516

Merged
ulugbekna merged 2 commits intomainfrom
ulugbekna/xtab-cursor-divergence-tests
Apr 14, 2026
Merged

Add adversarial tests for early cursor-line divergence cancellation#309516
ulugbekna merged 2 commits intomainfrom
ulugbekna/xtab-cursor-divergence-tests

Conversation

@ulugbekna
Copy link
Copy Markdown
Contributor

Expand test coverage for the InlineEditsXtabEarlyCursorLineDivergenceCancellation feature across all three architectural layers (+33 tests total).

isModelCursorLineCompatible (+20 tests)

  • Case sensitivity (F vs f correctly cancels — intentional for code identifiers)
  • Unicode/emoji/CJK character handling
  • Replacement edge cases (shorter replacement, pure deletion, different-region replacements)
  • Auto-close angle brackets <>
  • Non-auto-close text ((x) correctly uses startsWith, not subsequence)
  • Model produced less than user typed
  • Identical changes, net-zero edits
  • Substring vs prefix distinction
  • Whitespace edits outside model edit range
  • User deletion matching model deletion

getCurrentCursorLine (+7 tests)

  • Compound edits (line insertion above cursor + cursor line modification)
  • Multi-line replacement of cursor line
  • Empty document edge case
  • Edit at document end (appending text and new lines)

Integration streaming wrapper (+6 tests)

  • Feature disabled → no cancellation even with divergent typing
  • Model output shorter than edit window → cursor line never reached, no false cancel
  • getCurrentCursorLine returns undefined → divergence check safely skipped
  • Net-zero intermediate edit → check skipped
  • Partial edits yielded before cursor-line cancellation
  • Auto-close pair end-to-end (() typed, model fills parens → compatible)

Findings

  • No bugs discovered — the implementation correctly handles all tested adversarial cases
  • The range-containment check is deliberately strict (known false positive for disjoint edits on the same line, traded for safety)
  • Auto-close pair logic is correctly scoped to exactly 7 pairs

Expand test coverage for the InlineEditsXtabEarlyCursorLineDivergenceCancellation
feature across all three layers:

isModelCursorLineCompatible (+20 tests):
- Case sensitivity (F vs f correctly cancels)
- Unicode/emoji/CJK characters
- Replacement edge cases (shorter replacement, pure deletion, different region)
- Auto-close angle brackets (<>)
- Non-auto-close text ((x) correctly uses startsWith, not subsequence)
- Model produced less than user typed
- Identical changes, net-zero edits
- Substring vs prefix distinction
- Whitespace edits outside model range

getCurrentCursorLine (+7 tests):
- Compound edits (line shift + cursor line modification)
- Multi-line replacement of cursor line
- Empty document, edit at document end

Integration streaming wrapper (+6 tests):
- Feature disabled: no cancellation with divergent typing
- Model output shorter than edit window: cursor line never reached
- getCurrentCursorLine returns undefined: check safely skipped
- Net-zero intermediate edit: check skipped
- Partial edits yielded before cursor-line cancellation
- Auto-close pair end-to-end
Copilot AI review requested due to automatic review settings April 13, 2026 16:41
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds adversarial test coverage for early cursor-line divergence cancellation in the Copilot xtab pipeline, exercising both the core compatibility logic and the integration streaming behavior.

Changes:

  • Adds multiple integration tests in xtabProvider.spec.ts to validate cancellation/skip conditions and end-to-end auto-close compatibility.
  • Expands unit tests in cursorLineDivergence.spec.ts for isModelCursorLineCompatible and getCurrentCursorLine across edge cases (case sensitivity, Unicode, replacements, compound edits, empty doc, end-of-doc edits).
Show a summary per file
File Description
extensions/copilot/src/extension/xtab/test/node/xtabProvider.spec.ts Adds integration-level streaming/cancellation tests for cursor-line divergence behavior.
extensions/copilot/src/extension/xtab/test/node/cursorLineDivergence.spec.ts Adds unit tests covering adversarial inputs for cursor-line compatibility and cursor-line mapping under edits.

Copilot's findings

  • Files reviewed: 2/2 changed files
  • Comments generated: 2

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 13, 2026

Screenshot Changes

Base: 689454c4 Current: 24e129b2

Changed (1)

agentSessionsViewer/ApprovalRowLongLabel/Dark
Before After
before after

- Rename 'returns undefined when cursor line is entirely replaced' to
  'returns first replacement line when cursor line start coincides with
  replacement start' — aligns name with actual assertion (returns 'X').
- Clarify partial-edit-before-cancellation test: ResponseProcessor.diff
  may buffer lines, so pre-cursor edits aren't guaranteed to be yielded
  before stream termination.
@ulugbekna ulugbekna force-pushed the ulugbekna/xtab-cursor-divergence-tests branch from 3c9cbe7 to 7e1150e Compare April 13, 2026 17:10
@ulugbekna ulugbekna merged commit 4ac3295 into main Apr 14, 2026
26 checks passed
@ulugbekna ulugbekna deleted the ulugbekna/xtab-cursor-divergence-tests branch April 14, 2026 08:49
@vs-code-engineering vs-code-engineering bot added this to the 1.117.0 milestone Apr 14, 2026
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.

3 participants