[release/insiders] Adopt editor InlinePromptService for documentation comments - #84693
Conversation
…4282) ## Summary Replaces the grey-text `SuggestionService` UX for Copilot documentation-comment generation with the editor's **InlinePrompt** chip. Typing `///` above a member shows a **Tab to generate documentation** chip; accepting it generates the comment and writes it to the buffer. <img width="1014" height="366" alt="CSharpGenDocComments" src="https://github.com/user-attachments/assets/e7265877-93ec-49f9-81fa-03cfb17b484a" /> ## Changes - Remove the grey-text path (`CopilotGenerateDocumentationCommentProvider`, `DocumentationCommentSuggestion`, `StartSuggestionSession`). - Extract an editor-agnostic generation core into the Features layer (`CopilotDocumentationCommentGenerator`, `DocumentationCommentEdit`) shared by the chip-accept path. - Show the chip only when Copilot is available, the generate-documentation option is enabled, and the file is not Copilot-excluded. - Localize the chip accept text; move the provider id to a constant. - Add tests (InlinePrompt, ApplyEdits, generator) and editor package uptake to consume `InlinePromptServiceBase`. ## Notes - The editor/VS package version bumps (`eng/Packages.props`, `eng/Version.Details.xml`, `eng/Versions.props`, `src/Razor/Directory.Packages.props`) are required to consume `InlinePromptServiceBase` from the editor. --------- Co-authored-by: Caleb Blake <calebblake@microsoft.com> Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Co-authored-by: Ankita Khera <ankitakhera@microsoft.com> Co-authored-by: Ankita Khera <40616383+akhera99@users.noreply.github.com> Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
|
Azure Pipelines: Successfully started running 2 pipeline(s). There may be pipelines that require an authorized user to comment /azp run to run. |
There was a problem hiding this comment.
Pull request overview
This PR switches Copilot documentation-comment generation from the prior grey-text suggestion UX to the editor InlinePrompt “chip” UX. It introduces an editor-agnostic generation core in the Features layer, wires the EditorFeatures command flow to show an InlinePrompt chip and apply generated edits to the buffer, and updates dependencies/resources to support the new editor API.
Changes:
- Replace the old suggestion/session-based implementation with an InlinePrompt chip accept flow that generates and applies documentation comment edits.
- Extract editor-agnostic doc-comment generation into
CopilotDocumentationCommentGenerator+DocumentationCommentEdit, with new unit tests for generation and edit application. - Add localized string for the chip accept action, update test composition plumbing, and bump editor/VS package versions needed for
InlinePromptServiceBase.
Show a summary per file
| File | Description |
|---|---|
| src/Razor/Directory.Packages.props | Bumps Razor-side VS/Copilot package versions needed for the new editor API. |
| src/Features/CSharpTest/Copilot/CopilotDocumentationCommentGeneratorTests.cs | Adds unit tests for the editor-agnostic generator mapping behavior. |
| src/Features/Core/Portable/DocumentationComments/DocumentationCommentEdit.cs | Introduces an editor-agnostic “edit” representation for generated documentation inserts. |
| src/Features/Core/Portable/DocumentationComments/CopilotDocumentationCommentGenerator.cs | Refactors generation into an editor-agnostic core producing DocumentationCommentEdits. |
| src/EditorFeatures/TestUtilities/TestToolTipPresenterFactory.cs | Adds a no-op tooltip presenter factory so editor tests can run headless with BackgroundWorkIndicator. |
| src/EditorFeatures/TestUtilities/EditorTestCompositions.cs | Composes the new tooltip presenter factory into editor test compositions. |
| src/EditorFeatures/CSharpTest/DocumentationComments/CopilotGenerateDocumentationInlinePromptTests.cs | Adds WPF tests covering InlinePrompt chip showing/acceptance behavior. |
| src/EditorFeatures/CSharpTest/DocumentationComments/CopilotGenerateDocumentationApplyEditsTests.cs | Adds tests ensuring generated edits translate across snapshots and apply correctly. |
| src/EditorFeatures/Core/xlf/EditorFeaturesResources.de.xlf | Adds a new localized string entry for the chip accept action. |
| src/EditorFeatures/Core/xlf/EditorFeaturesResources.es.xlf | Adds a new localized string entry for the chip accept action. |
| src/EditorFeatures/Core/xlf/EditorFeaturesResources.fr.xlf | Adds a new localized string entry for the chip accept action. |
| src/EditorFeatures/Core/xlf/EditorFeaturesResources.it.xlf | Adds a new localized string entry for the chip accept action. |
| src/EditorFeatures/Core/xlf/EditorFeaturesResources.ja.xlf | Adds a new localized string entry for the chip accept action. |
| src/EditorFeatures/Core/xlf/EditorFeaturesResources.ko.xlf | Adds a new localized string entry for the chip accept action. |
| src/EditorFeatures/Core/xlf/EditorFeaturesResources.pl.xlf | Adds a new localized string entry for the chip accept action. |
| src/EditorFeatures/Core/xlf/EditorFeaturesResources.pt-BR.xlf | Adds a new localized string entry for the chip accept action. |
| src/EditorFeatures/Core/xlf/EditorFeaturesResources.ru.xlf | Adds a new localized string entry for the chip accept action. |
| src/EditorFeatures/Core/xlf/EditorFeaturesResources.tr.xlf | Adds a new localized string entry for the chip accept action. |
| src/EditorFeatures/Core/xlf/EditorFeaturesResources.zh-Hans.xlf | Adds a new localized string entry for the chip accept action. |
| src/EditorFeatures/Core/xlf/EditorFeaturesResources.zh-Hant.xlf | Adds a new localized string entry for the chip accept action. |
| src/EditorFeatures/Core/xlf/EditorFeaturesResources.cs.xlf | Adds a new localized string entry for the chip accept action. |
| src/EditorFeatures/Core/Microsoft.CodeAnalysis.EditorFeatures.csproj | Suppresses the editor’s InlinePrompt experimental warning at the project level. |
| src/EditorFeatures/Core/EditorFeaturesResources.resx | Adds the generate_documentation resource string. |
| src/EditorFeatures/Core/DocumentationComments/DocumentationCommentSuggestion.cs | Removes the old grey-text suggestion implementation. |
| src/EditorFeatures/Core/DocumentationComments/CopilotGenerateDocumentationCommentManager.cs | Implements chip display + accept generation + edit application pipeline. |
| src/EditorFeatures/Core/DocumentationComments/AbstractDocumentationCommentCommandHandler.cs | Removes pre-emptive suggestion-session startup and relies on the new trigger flow. |
| eng/Version.Details.xml | Updates dependency versions (notably Microsoft.Extensions and related). |
| eng/Version.Details.props | Aligns version properties to updated dependency versions. |
| eng/Packages.props | Bumps VS editor package versions and related dependencies to consume InlinePromptServiceBase. |
Copilot's findings
Comments suppressed due to low confidence (1)
src/Features/Core/Portable/DocumentationComments/CopilotDocumentationCommentGenerator.cs:23
- The XML doc still refers to reuse by a "grey-text suggestion path", but that implementation has been removed in this PR (no remaining doc-comment suggestion types/providers). Consider updating the comment to describe the current usage (InlinePrompt) without referencing the removed UX path.
- Files reviewed: 29/29 changed files
- Comments generated: 2
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Copilot's findings
Comments suppressed due to low confidence (7)
src/Features/Core/Portable/DocumentationComments/CopilotDocumentationCommentGenerator.cs:1
- This file appears to be saved without a UTF-8 BOM, but the repo's .editorconfig specifies
charset = utf-8-bomfor*.cs. Please resave this file with a UTF-8 BOM to match the repo convention and avoid potential formatting/encoding checks failing.
src/EditorFeatures/Core/Microsoft.CodeAnalysis.EditorFeatures.csproj:12 - This adds a project-wide suppression for the experimental
VSPREVIEW_INLINEPROMPTwarning. Roslyn typically prefers narrowing warning suppressions to the smallest scope possible (e.g.,#pragma warning disablearound the specific usage file) to avoid masking future unrelated warnings across the entire project.
<!-- InlinePromptServiceBase is marked [Experimental("VSPREVIEW_INLINEPROMPT")] in the editor package. -->
<NoWarn>$(NoWarn);VSPREVIEW_INLINEPROMPT</NoWarn>
src/Features/Core/Portable/DocumentationComments/DocumentationCommentEdit.cs:1
- This file appears to be saved without a UTF-8 BOM, but the repo's .editorconfig specifies
charset = utf-8-bomfor*.cs. Please resave this file with a UTF-8 BOM to match the repo convention and avoid potential formatting/encoding checks failing.
// Licensed to the .NET Foundation under one or more agreements.
src/Features/CSharpTest/Copilot/CopilotDocumentationCommentGeneratorTests.cs:1
- This new file appears to be saved without a UTF-8 BOM, but the repo's .editorconfig specifies
charset = utf-8-bomfor*.cs. Please resave it with a UTF-8 BOM to match the repo convention and avoid potential formatting/encoding checks failing.
// Licensed to the .NET Foundation under one or more agreements.
src/EditorFeatures/CSharpTest/DocumentationComments/CopilotGenerateDocumentationApplyEditsTests.cs:1
- This new file appears to be saved without a UTF-8 BOM, but the repo's .editorconfig specifies
charset = utf-8-bomfor*.cs. Please resave it with a UTF-8 BOM to match the repo convention and avoid potential formatting/encoding checks failing.
// Licensed to the .NET Foundation under one or more agreements.
src/EditorFeatures/CSharpTest/DocumentationComments/CopilotGenerateDocumentationInlinePromptTests.cs:1
- This new file appears to be saved without a UTF-8 BOM, but the repo's .editorconfig specifies
charset = utf-8-bomfor*.cs. Please resave it with a UTF-8 BOM to match the repo convention and avoid potential formatting/encoding checks failing.
// Licensed to the .NET Foundation under one or more agreements.
src/EditorFeatures/TestUtilities/TestToolTipPresenterFactory.cs:1
- This new file appears to be saved without a UTF-8 BOM, but the repo's .editorconfig specifies
charset = utf-8-bomfor*.cs. Please resave it with a UTF-8 BOM to match the repo convention and avoid potential formatting/encoding checks failing.
// Licensed to the .NET Foundation under one or more agreements.
- Files reviewed: 29/29 changed files
- Comments generated: 0 new
There was a problem hiding this comment.
Copilot's findings
Comments suppressed due to low confidence (3)
src/Features/Core/Portable/DocumentationComments/CopilotDocumentationCommentGenerator.cs:23
- The summary comment still says this generator is shared by the removed grey-text SuggestionService path. Since this PR deletes that path, the doc comment is now misleading and should be updated to describe current hosts (InlinePrompt chip) or keep it generic.
src/Features/Core/Portable/DocumentationComments/DocumentationCommentEdit.cs:14 - This doc comment references the removed grey-text suggestion path. Since this PR eliminates that UX, the comment should be updated to avoid pointing readers at a non-existent consumer.
/// <summary>
/// A single edit produced by Copilot documentation generation: the span in the original text to replace
/// and the text to replace it with. This is the editor-agnostic counterpart of the editor's ProposedEdit,
/// so the generation core can be consumed both by the grey-text suggestion path and by the InlinePrompt
/// chip-accept path (which applies the edits directly to the buffer).
/// </summary>
src/EditorFeatures/Core/DocumentationComments/CopilotGenerateDocumentationCommentManager.cs:132
- ApplyEdits translates edit spans with SpanTrackingMode.EdgeInclusive. For zero-length insertion spans, EdgeInclusive will deterministically expand to include text inserted at the same position between snapshots, and bufferEdit.Replace will then delete that newly-inserted user text. Using EdgeExclusive avoids capturing boundary insertions while still translating across versions.
var currentSnapshot = buffer.CurrentSnapshot;
using var bufferEdit = buffer.CreateEdit();
foreach (var edit in edits)
{
var span = new SnapshotSpan(snapshot, edit.SpanToReplace.Start, edit.SpanToReplace.Length)
.TranslateTo(currentSnapshot, SpanTrackingMode.EdgeInclusive);
bufferEdit.Replace(span, edit.ReplacementText);
- Files reviewed: 29/29 changed files
- Comments generated: 1
Cherry-pick of #84282
Summary
Replaces the grey-text
SuggestionServiceUX for Copilot documentation-comment generation with the editor's InlinePrompt chip. Typing///above a member shows a Tab to generate documentation chip; accepting it generates the comment and writes it to the buffer.Changes
CopilotGenerateDocumentationCommentProvider,DocumentationCommentSuggestion,StartSuggestionSession).CopilotDocumentationCommentGenerator,DocumentationCommentEdit) shared by the chip-accept path.InlinePromptServiceBase.Notes
eng/Packages.props,eng/Version.Details.xml,eng/Versions.props,src/Razor/Directory.Packages.props) are required to consumeInlinePromptServiceBasefrom the editor.Microsoft Reviewers: Open in CodeFlow