Adopt editor InlinePromptService for documentation comments - #84282
Conversation
Replace the grey-text SuggestionService UX for Copilot documentation-comment generation with the editor's InlinePrompt chip: typing `///` shows a "Tab to generate documentation" chip, and accepting it generates the comment and writes it to the buffer. - 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. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
9e367b4 to
c496f25
Compare
@dotnet-policy-service agree company="Microsoft" |
…prompt-doc-comment # Conflicts: # eng/Packages.props # eng/Version.Details.props # src/EditorFeatures/TestUtilities/EditorTestCompositions.cs
There was a problem hiding this comment.
Pull request overview
This PR updates the Copilot documentation-comment generation UX in the editor to use the InlinePrompt chip flow (instead of the prior grey-text suggestion flow), and factors generation/apply logic so it can be reused by the accept path. It also adds targeted unit tests and localizes the chip accept text.
Changes:
- Switch documentation-comment generation UX to an InlinePrompt chip accept flow in
CopilotGenerateDocumentationCommentManager. - Add a portable “edit” representation (
DocumentationCommentEdit) and tests for generator + edit application + InlinePrompt behavior. - Localize the chip accept text and adjust editor test composition to run headless by exporting a no-op tooltip presenter factory.
Show a summary per file
| File | Description |
|---|---|
| src/Razor/Directory.Packages.props | Updates VS/Copilot package versions referenced by Razor. |
| src/Features/CSharpTest/Copilot/CopilotDocumentationCommentGeneratorTests.cs | Adds unit tests for proposal/edit generation mapping. |
| src/Features/Core/Portable/DocumentationComments/DocumentationCommentEdit.cs | Introduces portable edit representation for applying generated doc updates. |
| src/Features/Core/Portable/DocumentationComments/CopilotDocumentationCommentGenerator.cs | Refactors generation core to return portable edits. |
| src/EditorFeatures/TestUtilities/TestToolTipPresenterFactory.cs | Adds a no-op tooltip presenter factory for headless test composition. |
| src/EditorFeatures/TestUtilities/EditorTestCompositions.cs | Includes the new tooltip presenter factory in editor test composition. |
| src/EditorFeatures/CSharpTest/DocumentationComments/CopilotGenerateDocumentationInlinePromptTests.cs | Adds WPF tests for InlinePrompt show/accept gating and edit application. |
| src/EditorFeatures/CSharpTest/DocumentationComments/CopilotGenerateDocumentationApplyEditsTests.cs | Adds tests for translating/applying edits across snapshot versions. |
| src/EditorFeatures/Core/xlf/EditorFeaturesResources.zh-Hant.xlf | Adds localization entry for chip accept text. |
| src/EditorFeatures/Core/xlf/EditorFeaturesResources.zh-Hans.xlf | Adds localization entry for chip accept text. |
| src/EditorFeatures/Core/xlf/EditorFeaturesResources.tr.xlf | Adds localization entry for chip accept text. |
| src/EditorFeatures/Core/xlf/EditorFeaturesResources.ru.xlf | Adds localization entry for chip accept text. |
| src/EditorFeatures/Core/xlf/EditorFeaturesResources.pt-BR.xlf | Adds localization entry for chip accept text. |
| src/EditorFeatures/Core/xlf/EditorFeaturesResources.pl.xlf | Adds localization entry for chip accept text. |
| src/EditorFeatures/Core/xlf/EditorFeaturesResources.ko.xlf | Adds localization entry for chip accept text. |
| src/EditorFeatures/Core/xlf/EditorFeaturesResources.ja.xlf | Adds localization entry for chip accept text. |
| src/EditorFeatures/Core/xlf/EditorFeaturesResources.it.xlf | Adds localization entry for chip accept text. |
| src/EditorFeatures/Core/xlf/EditorFeaturesResources.fr.xlf | Adds localization entry for chip accept text. |
| src/EditorFeatures/Core/xlf/EditorFeaturesResources.es.xlf | Adds localization entry for chip accept text. |
| src/EditorFeatures/Core/xlf/EditorFeaturesResources.de.xlf | Adds localization entry for chip accept text. |
| src/EditorFeatures/Core/xlf/EditorFeaturesResources.cs.xlf | Adds localization entry for chip accept text. |
| src/EditorFeatures/Core/Microsoft.CodeAnalysis.EditorFeatures.csproj | Suppresses InlinePrompt experimental warning at project level. |
| src/EditorFeatures/Core/EditorFeaturesResources.resx | Adds localized resource string for chip accept text. |
| src/EditorFeatures/Core/DocumentationComments/DocumentationCommentSuggestion.cs | Removes the old grey-text suggestion implementation. |
| src/EditorFeatures/Core/DocumentationComments/CopilotGenerateDocumentationCommentManager.cs | Implements chip show/accept flow and applies generated edits to the buffer. |
| src/EditorFeatures/Core/DocumentationComments/AbstractDocumentationCommentCommandHandler.cs | Removes pre-typing suggestion-session start hook; triggers proposal generation after snippet insertion. |
| eng/Versions.props | Updates cryptography package version properties. |
| eng/Version.Details.xml | Updates dependency versions tracked for the repo. |
| eng/Version.Details.props | Updates Maestro-tracked dependency version properties. |
| eng/Packages.props | Updates multiple VS/MSBuild package versions (editor uptake). |
Copilot's findings
Comments suppressed due to low confidence (1)
src/EditorFeatures/Core/DocumentationComments/CopilotGenerateDocumentationCommentManager.cs:145
- CopilotDocumentationCommentGenerator currently hard-codes C# doc-comment prefixes ("///") when wrapping/constructing multi-line edits (e.g. remarks insertion and line-wrapping). Since AbstractDocumentationCommentCommandHandler is shared by both C# and VB, this chip path can currently be offered in VB too, producing invalid doc comments ("///" inside VB doc comments). Until the generator is parameterized by exterior trivia, consider gating the feature to C# here.
private static async Task<ICopilotCodeAnalysisService?> IsCopilotAvailableAsync(Document document, CancellationToken cancellationToken)
{
// Bailing out if copilot is not available or the option is not enabled.
if (document.GetLanguageService<ICopilotOptionsService>() is not { } copilotOptionService ||
!await copilotOptionService.IsGenerateDocumentationCommentOptionEnabledAsync().ConfigureAwait(false))
{
return null;
}
- Files reviewed: 30/30 changed files
- Comments generated: 7
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
| <comment>The text surrounded by "[" and "]" characters will be hyperlinked. Please ensure the localized text still has "[" and "]" characters.</comment> | ||
| </data> | ||
| <data name="Generate_documentation" xml:space="preserve"> | ||
| <value>generate documentation</value> |
There was a problem hiding this comment.
I saw this in the video clip as [TAB] generate documentation. Is all lowercase the desired design here?
There was a problem hiding this comment.
oh you're right it should say "Tab to generate documentation"
Removing as the UI is not what is expected
…hub.com/cdblake1/roslyn into dev/calebblake/inlineprompt-doc-comment
|
/backport to release/insiders |
|
Started backporting to |
|
@akhera99 backporting to git am output$ git am --3way --empty=keep --ignore-whitespace --keep-non-patch changes.patch
Applying: Adopt editor InlinePromptService for documentation comments
Using index info to reconstruct a base tree...
M eng/Packages.props
M eng/Version.Details.props
M src/EditorFeatures/Core/EditorFeaturesResources.resx
M src/EditorFeatures/Core/Microsoft.CodeAnalysis.EditorFeatures.csproj
M src/EditorFeatures/Core/xlf/EditorFeaturesResources.cs.xlf
M src/EditorFeatures/Core/xlf/EditorFeaturesResources.de.xlf
M src/EditorFeatures/Core/xlf/EditorFeaturesResources.es.xlf
M src/EditorFeatures/Core/xlf/EditorFeaturesResources.fr.xlf
M src/EditorFeatures/Core/xlf/EditorFeaturesResources.it.xlf
M src/EditorFeatures/Core/xlf/EditorFeaturesResources.ja.xlf
M src/EditorFeatures/Core/xlf/EditorFeaturesResources.ko.xlf
M src/EditorFeatures/Core/xlf/EditorFeaturesResources.pl.xlf
M src/EditorFeatures/Core/xlf/EditorFeaturesResources.pt-BR.xlf
M src/EditorFeatures/Core/xlf/EditorFeaturesResources.ru.xlf
M src/EditorFeatures/Core/xlf/EditorFeaturesResources.tr.xlf
M src/EditorFeatures/Core/xlf/EditorFeaturesResources.zh-Hans.xlf
M src/EditorFeatures/Core/xlf/EditorFeaturesResources.zh-Hant.xlf
M src/EditorFeatures/TestUtilities/EditorTestCompositions.cs
Falling back to patching base and 3-way merge...
Auto-merging eng/Packages.props
CONFLICT (content): Merge conflict in eng/Packages.props
Auto-merging eng/Version.Details.props
CONFLICT (content): Merge conflict in eng/Version.Details.props
Auto-merging src/EditorFeatures/Core/EditorFeaturesResources.resx
Auto-merging src/EditorFeatures/Core/Microsoft.CodeAnalysis.EditorFeatures.csproj
Auto-merging src/EditorFeatures/Core/xlf/EditorFeaturesResources.cs.xlf
Auto-merging src/EditorFeatures/Core/xlf/EditorFeaturesResources.de.xlf
Auto-merging src/EditorFeatures/Core/xlf/EditorFeaturesResources.es.xlf
Auto-merging src/EditorFeatures/Core/xlf/EditorFeaturesResources.fr.xlf
Auto-merging src/EditorFeatures/Core/xlf/EditorFeaturesResources.it.xlf
Auto-merging src/EditorFeatures/Core/xlf/EditorFeaturesResources.ja.xlf
Auto-merging src/EditorFeatures/Core/xlf/EditorFeaturesResources.ko.xlf
Auto-merging src/EditorFeatures/Core/xlf/EditorFeaturesResources.pl.xlf
Auto-merging src/EditorFeatures/Core/xlf/EditorFeaturesResources.pt-BR.xlf
Auto-merging src/EditorFeatures/Core/xlf/EditorFeaturesResources.ru.xlf
Auto-merging src/EditorFeatures/Core/xlf/EditorFeaturesResources.tr.xlf
Auto-merging src/EditorFeatures/Core/xlf/EditorFeaturesResources.zh-Hans.xlf
Auto-merging src/EditorFeatures/Core/xlf/EditorFeaturesResources.zh-Hant.xlf
Auto-merging src/EditorFeatures/TestUtilities/EditorTestCompositions.cs
CONFLICT (content): Merge conflict in src/EditorFeatures/TestUtilities/EditorTestCompositions.cs
error: Failed to merge in the changes.
hint: Use 'git am --show-current-patch=diff' to see the failed patch
hint: When you have resolved this problem, run "git am --continue".
hint: If you prefer to skip this patch, run "git am --skip" instead.
hint: To restore the original branch and stop patching, run "git am --abort".
hint: Disable this message with "git config set advice.mergeConflict false"
Patch failed at 0001 Adopt editor InlinePromptService for documentation comments
Error: The process '/usr/bin/git' failed with exit code 128 |
… comments (#84693) Cherry-pick of #84282 ## 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. --------- ###### Microsoft Reviewers: [Open in CodeFlow](https://microsoft.github.io/open-pr/?codeflow=https://github.com/dotnet/roslyn/pull/84693) --------- Co-authored-by: cdblake1 <cdblake31@gmail.com> Co-authored-by: Caleb Blake <calebblake@microsoft.com> Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
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.