Skip to content
Merged
Show file tree
Hide file tree
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
7 changes: 7 additions & 0 deletions src/Cody.Core/Agent/NotificationHandlers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ public class NotificationHandlers : INotificationHandler

public event EventHandler<string> OnRegisterWebViewRequest;
public event EventHandler OnOptionsPageShowRequest;
public event EventHandler OnFocusSidebarRequest;

public event EventHandler<AgentResponseEvent> OnPostMessageEvent;

Expand Down Expand Up @@ -212,5 +213,11 @@ public void SecretDelete(string key)
_logger.Debug(key, $@"SecretDelete - {key}");
_secretStorage.Delete(key);
}

[AgentCallback("window/focusSidebar")]
public void FocusSidebar(object param)
{
OnFocusSidebarRequest?.Invoke(this, EventArgs.Empty);
}
}
}
2 changes: 1 addition & 1 deletion src/Cody.VisualStudio.Tests/TestsBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ protected async Task<CodyPackage> GetPackageAsync()
protected async Task WaitForAsync(Func<bool> condition)
{
var startTime = DateTime.Now;
var timeout = TimeSpan.FromMinutes(2);
var timeout = TimeSpan.FromMinutes(5);
while (!condition.Invoke())
{
await Task.Delay(TimeSpan.FromSeconds(1));
Expand Down
23 changes: 22 additions & 1 deletion src/Cody.VisualStudio/CodyPackage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
using Microsoft.VisualStudio.Editor;
using Microsoft.VisualStudio.Shell;
using Microsoft.VisualStudio.Shell.Connected.CredentialStorage;
using Microsoft.VisualStudio.Shell.Events;
using Microsoft.VisualStudio.Shell.Interop;
using System;
using System.Collections.Generic;
Expand All @@ -33,8 +32,11 @@
using System.Windows;
using System.Windows.Threading;
using Cody.UI.ViewModels;
using EnvDTE;
using EnvDTE80;
using Task = System.Threading.Tasks.Task;
using Microsoft.VisualStudio.TaskStatusCenter;
using SolutionEvents = Microsoft.VisualStudio.Shell.Events.SolutionEvents;

namespace Cody.VisualStudio
{
Expand Down Expand Up @@ -141,6 +143,9 @@ private void InitializeServices()
ProgressService = new ProgressService(statusCenterService);
NotificationHandlers = new NotificationHandlers(UserSettingsService, AgentNotificationsLogger, FileService, SecretStorageService);
NotificationHandlers.OnOptionsPageShowRequest += HandleOnOptionsPageShowRequest;
NotificationHandlers.OnFocusSidebarRequest += HandleOnFocusSidebarRequest;


ProgressNotificationHandlers = new ProgressNotificationHandlers(ProgressService);

var sidebarController = WebView2Dev.InitializeController(ThemeService.GetThemingScript(), Logger);
Expand All @@ -167,6 +172,22 @@ private void HandleOnOptionsPageShowRequest(object sender, EventArgs e)
}
}

private void HandleOnFocusSidebarRequest(object sender, EventArgs e)
{
try
{
var dte = (DTE2)Package.GetGlobalService(typeof(DTE));
var mainWindow = dte.MainWindow;

mainWindow.Visible = true;
mainWindow.SetFocus();
}
catch (Exception ex)
{
Logger.Error("Failed.", ex);
}
}

private async void AuthorizationDetailsChanged(object sender, EventArgs eventArgs)
{
try
Expand Down