Skip to content

Commit

Permalink
Agent: Use updated agent protocols (#44)
Browse files Browse the repository at this point in the history
Update to use the latest changes for the agent protocols from
sourcegraph/cody#5211

This let agent knows when we have a workspace added or removed.

Also updated to use `View = WebviewView.Single,` for webview to always
run chats in sidebar view

```

22:05:32.767: [ProcessId:38884] [ThreadId:5] Debug [AgentJsonMessageFormatter.OnSerializationComplete] Sending to agent: {"jsonrpc":"2.0","id":3,"method":"workspaceFolder/didChange","params":[{"uris":["file:///C:/Users/BeatrixW/source/repos/TestingApp"]}]}
```
  • Loading branch information
abeatrix authored Aug 16, 2024
1 parent 12b4e94 commit f4c7d03
Show file tree
Hide file tree
Showing 7 changed files with 386 additions and 353 deletions.
1 change: 1 addition & 0 deletions src/Cody.AgentTester/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ private static async Task Initialize()
Webview = "native",
WebviewNativeConfig = new WebviewCapabilities
{
View = WebviewView.Single,
CspSource = "'self' https://cody.vs",
WebviewBundleServingPrefix = "https://cody.vs",
},
Expand Down
6 changes: 4 additions & 2 deletions src/Cody.Core/Agent/IAgentService.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
using Cody.Core.Agent.Protocol;
using Cody.Core.Agent.Protocol;
using System.Collections.Generic;
using System;
using System.Threading.Tasks;

namespace Cody.Core.Agent
Expand Down Expand Up @@ -52,6 +54,6 @@ public interface IAgentService
Task<ChatPanelInfo> NewEditorChat();

[AgentMethod("workspaceFolder/didChange")]
Task WorkspaceFolderDidChange(CodyFilePath path);
Task WorkspaceFolderDidChange(WorkspaceFolderDidChangeEvent uris);
}
}
1 change: 1 addition & 0 deletions src/Cody.Core/Agent/InitializeCallback.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ public async Task Initialize(IAgentService client)
Webview = "native",
WebviewNativeConfig = new WebviewCapabilities
{
View = WebviewView.Single,
CspSource = "'self' https://cody.vs",
WebviewBundleServingPrefix = "https://cody.vs",
},
Expand Down
13 changes: 7 additions & 6 deletions src/Cody.Core/Agent/Protocol/WebviewCapabilities.cs
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Cody.Core.Agent.Protocol
{
public class WebviewCapabilities
{
public string CspSource { get; set; }
public string WebviewBundleServingPrefix { get; set; }
public WebviewView View { get; set; }
}

public enum WebviewView
{
Single,
Multiple
}
}
19 changes: 19 additions & 0 deletions src/Cody.Core/Agent/Protocol/WorkspaceFolderDidChangeEvent.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Cody.Core.Agent.Protocol
{
public class WorkspaceFolderDidChangeEvent
{
public List<string> Uris { get; set; }

public WorkspaceFolderDidChangeEvent()
{
Uris = new List<string>();
}
}

}
1 change: 1 addition & 0 deletions src/Cody.Core/Cody.Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
<Compile Include="Agent\NotificationHandlers.cs" />
<Compile Include="Agent\Protocol\AuthStatus.cs" />
<Compile Include="Agent\Protocol\ChatPanelInfo.cs" />
<Compile Include="Agent\Protocol\WorkspaceFolderDidChangeEvent.cs" />
<Compile Include="Agent\Protocol\TextDocumentShowParamsOptions.cs" />
<Compile Include="Agent\Protocol\TextDocumentShowParams.cs" />
<Compile Include="Agent\Protocol\CodyFilePath.cs" />
Expand Down
Loading

0 comments on commit f4c7d03

Please sign in to comment.