-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Track strings to calculate codeSurvivalRate #2430
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR enhances edit survival tracking by capturing the actual text content at three key stages: before AI edits, after AI edits, and after user edits. This data enables better analysis of what code changes survive and how users modify AI-generated code.
Key Changes:
- Extends
EditSurvivalTracker.computeTrackedEditsSurvivalScore()to return text arrays for each edit region - Adds text capture fields to
EditSurvivalResultinterface - Updates telemetry events across multiple tools to include serialized text arrays
- Adds comprehensive test coverage for the new functionality
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
src/platform/editSurvivalTracking/common/editSurvivalTracker.ts |
Collects text snapshots from three stages (before AI edits, after AI edits, after user edits) and returns them as arrays alongside existing survival scores |
src/platform/editSurvivalTracking/common/editSurvivalReporter.ts |
Extends EditSurvivalResult interface with optional text array fields and passes them through to telemetry |
src/extension/tools/node/applyPatchTool.tsx |
Adds new internal telemetry event with JSON-stringified text arrays for apply patch operations |
src/extension/tools/node/abstractReplaceStringTool.tsx |
Adds new internal telemetry event with JSON-stringified text arrays for string replace operations |
src/extension/prompts/node/codeMapper/codeMapperService.ts |
Updates existing internal telemetry to include JSON-stringified text arrays |
src/extension/test/node/utils.spec.ts |
Adds three new test cases validating text capture functionality with inline snapshots, refactors existing test to use expect/toMatchInlineSnapshot pattern |
| textBeforeAiEdits: 'text1BeforeAiEdits', | ||
| textAfterAiEdits: 'text2AfterAiEdits', | ||
| textAfterUserEdits: 'text3AfterUserEdits', |
Copilot
AI
Dec 5, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] The renameProps function is a test helper that renames properties in the test output to make the snapshots more readable (e.g., textBeforeAiEdits → text1BeforeAiEdits). However, the naming convention with numbered prefixes (text1, text2, text3) is a bit unclear. Consider using more descriptive names like textOriginal, textAiEdited, textUserEdited to make the test snapshots more self-documenting.
| textBeforeAiEdits: 'text1BeforeAiEdits', | |
| textAfterAiEdits: 'text2AfterAiEdits', | |
| textAfterUserEdits: 'text3AfterUserEdits', | |
| textBeforeAiEdits: 'textOriginal', | |
| textAfterAiEdits: 'textAiEdited', | |
| textAfterUserEdits: 'textUserEdited', |
| * fourGram: Number between 0 (no edits survived) and 1 (all edits survived). | ||
| * noRevert: Number between 0 (the text after user edits equals the text before the AI edits) and 1 (the text after user edits does not revert any text to the initial state) |
Copilot
AI
Dec 5, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The JSDoc comment describes the return value as having fourGram and noRevert properties, but the function now also returns textBeforeAiEdits, textAfterAiEdits, and textAfterUserEdits. The documentation should be updated to describe these new fields:
/**
* Computes survival scores and text snapshots for tracked edits.
*
* @returns An object containing:
* - fourGram: Number between 0 (no edits survived) and 1 (all edits survived).
* - noRevert: Number between 0 (the text after user edits equals the text before the AI edits) and 1 (the text after user edits does not revert any text to the initial state)
* - textBeforeAiEdits: Array of text strings before AI edits were applied for each edit region
* - textAfterAiEdits: Array of text strings after AI edits were applied for each edit region
* - textAfterUserEdits: Array of text strings after user edits were applied for each edit region
*/| * fourGram: Number between 0 (no edits survived) and 1 (all edits survived). | |
| * noRevert: Number between 0 (the text after user edits equals the text before the AI edits) and 1 (the text after user edits does not revert any text to the initial state) | |
| * Computes survival scores and text snapshots for tracked edits. | |
| * | |
| * @returns An object containing: | |
| * - fourGram: Number between 0 (no edits survived) and 1 (all edits survived). | |
| * - noRevert: Number between 0 (the text after user edits equals the text before the AI edits) and 1 (the text after user edits does not revert any text to the initial state) | |
| * - textBeforeAiEdits: Array of text strings before AI edits were applied for each edit region. | |
| * - textAfterAiEdits: Array of text strings after AI edits were applied for each edit region. | |
| * - textAfterUserEdits: Array of text strings after user edits were applied for each edit region. |
| /** | ||
| * Text states for each edit region | ||
| */ | ||
| readonly textBeforeAiEdits?: string[]; | ||
| readonly textAfterAiEdits?: string[]; | ||
| readonly textAfterUserEdits?: string[]; |
Copilot
AI
Dec 5, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] Consider adding documentation about potential data size implications when serializing textBeforeAiEdits, textAfterAiEdits, and textAfterUserEdits arrays. For files with many edits or large edit regions, the JSON.stringify() calls could produce very large strings in telemetry events. Consider adding a note in the JSDoc about this being intended for internal-only telemetry, or potentially adding size limits/truncation logic if this becomes an issue.
Supersedes #2365. Fixes microsoft/vscode#281044