Skip to content
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

Make ISemanticSearchCopilotUIProvider import lazy to avoid loading VS.EA.Copilot #77516

Merged
merged 1 commit into from
Mar 18, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ internal sealed class SemanticSearchToolWindowImpl(
IStreamingFindUsagesPresenter resultsPresenter,
ITextUndoHistoryRegistry undoHistoryRegistry,
ISemanticSearchCopilotService copilotService,
ISemanticSearchCopilotUIProvider copilotUIProvider,
Lazy<ISemanticSearchCopilotUIProvider> copilotUIProvider, // lazy to avoid loading Microsoft.VisualStudio.LanguageServices.ExternalAccess.Copilot
Copy link
Member

Choose a reason for hiding this comment

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

It feels a bit weird to me that we have to add a Lazy to avoid an ExternalAccess load of our own assembly. Looking at the interfaces in question rather than having the ExternalAccess wrap our types we're using the ExternalAccess implementation which still eventually wraps our types?

This comment might be worth expanding on a bit on what's going on here....

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm not sure I understand.

We have a couple of interfaces ISemanticSearchCopilotUIProviderImpl and ITextBoxControlImpl defined in EA because Copilot needs to export their implementation.

We can't use these interfaces in VS layer since that would add reverse EA dependency. We need to define another interface ISemanticSearchCopilotUIProvider that is exported in EA and imported in VS layer.

IVsService<SVsUIShell, IVsUIShell> vsUIShellProvider) : ISemanticSearchWorkspaceHost, OptionsProvider<ClassificationOptions>
{
private const int ToolBarHeight = 26;
Expand Down Expand Up @@ -193,7 +193,7 @@ public async Task<FrameworkElement> InitializeAsync(CancellationToken cancellati

private CopilotUI? CreateCopilotUI()
{
if (!copilotUIProvider.IsAvailable || !copilotService.IsAvailable)
if (!copilotUIProvider.Value.IsAvailable || !copilotService.IsAvailable)
{
return null;
}
Expand All @@ -216,7 +216,7 @@ public async Task<FrameworkElement> InitializeAsync(CancellationToken cancellati
promptGrid.ColumnDefinitions.Add(new ColumnDefinition { MaxWidth = 600, Width = GridLength.Auto });
promptGrid.ColumnDefinitions.Add(new ColumnDefinition { Width = GridLength.Auto });

var promptTextBox = copilotUIProvider.GetTextBox();
var promptTextBox = copilotUIProvider.Value.GetTextBox();

var panel = new StackPanel()
{
Expand Down
Loading