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

Autocomplete #166

Merged
merged 21 commits into from
Jan 6, 2025
Merged

Autocomplete #166

merged 21 commits into from
Jan 6, 2025

Conversation

tomaszgolebiowski
Copy link
Collaborator

@tomaszgolebiowski tomaszgolebiowski commented Dec 12, 2024

  • implemented the agent protocols for autocompletions
  • inline text changes that can be accepted with the Tab keyboard press (lalt+, for rotating suggestions if there is more than one)
  • explicitly trigger completion suggestions (lalt+.)
  • user option to enable/disable Autocompletions
  • telemetry to compute CAR
  • tests

Test plan

  • Create a new solution
  • Start adding code
  • Check if 'grey code' with suggestions appears
  • Accept the suggestions by pressing Tab
  • Reject the suggestion by pressing Esc

Copy link

github-actions bot commented Dec 12, 2024

Test Results

17 tests  ±0   17 ✅ ±0   19m 44s ⏱️ + 16m 18s
 1 suites ±0    0 💤 ±0 
 1 files   ±0    0 ❌ ±0 

Results for commit fd3be80. ± Comparison against base commit b52b944.

♻️ This comment has been updated with latest results.

Copy link
Collaborator

@abeatrix abeatrix left a comment

Choose a reason for hiding this comment

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

Haven't tested it locally but the code lgtm. Approve to unblock

Comment on lines +84 to +85
//var result = agentService.GetWorkspaceDocuments(new GetDocumentsParams { Uris = new[] { fullPath.ToUri() } }).Result;
//trace.TraceEvent("AfterDidChange", result.Documents.First().Content);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
//var result = agentService.GetWorkspaceDocuments(new GetDocumentsParams { Uris = new[] { fullPath.ToUri() } }).Result;
//trace.TraceEvent("AfterDidChange", result.Documents.First().Content);

Left over?

@tomaszgolebiowski tomaszgolebiowski merged commit 3cb8d9d into main Jan 6, 2025
6 checks passed
@tomaszgolebiowski tomaszgolebiowski deleted the tg/completions branch January 6, 2025 08:34
Copy link
Collaborator

Choose a reason for hiding this comment

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

Add unit tests for both methods.

@@ -30,6 +30,7 @@ public async Task Solution_Name_Is_Added_To_Chat_Input()
await OpenSolution(SolutionsPaths.GetConsoleApp1File("ConsoleApp1.sln"));

// when
await ShowChatTab();
Copy link
Collaborator

Choose a reason for hiding this comment

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

Redundant call to ShowChatTab() - its called in the GetChatContextTags() method.

@@ -77,6 +77,7 @@ private async Task NotInLoggedState(Func<Task> action)
finally
{
await RevertToken();
await Task.Delay(1000);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Try removing the delay and check in the CI. It should work without it.


WriteLog($"Opening solution '{path}' ...");
Dte.Solution.Open(path);

await Task.Delay(TimeSpan.FromSeconds(5));
WriteLog("Delay after solution open stopped.");
await tcs.Task;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Nice refactor and removing Task.Delay() from here.

@@ -55,10 +55,10 @@ public sealed partial class CodyPackage : AsyncPackage
public ILog AgentLogger;
public ILog AgentNotificationsLogger;

public static IAgentService AgentService;
public static IUserSettingsService UserSettingsService;
Copy link
Collaborator

@PiotrKarczmarz PiotrKarczmarz Jan 6, 2025

Choose a reason for hiding this comment

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

Is there any specific reason why static is used for UserSettingsService?

private static TraceLogger trace = new TraceLogger(nameof(CodyProposalSourceProvider));

private readonly ITextDocumentFactoryService textDocumentFactoryService;
private readonly IVsEditorAdaptersFactoryService editorAdaptersFactoryService;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Looks like editorAdaptersFactoryService is not used anywhere.


namespace Cody.VisualStudio.Services
{
public class TestingSupportService
Copy link
Collaborator

@PiotrKarczmarz PiotrKarczmarz Jan 6, 2025

Choose a reason for hiding this comment

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

In which scenario this class is used and how? Looks like SetAutocompleteSuggestion() is only called but not GetAutocompleteSuggestion().

caret = caret.TranslateTo(trackedSnapshot);
if (completionState != null)
{
completionState = completionState.TranslateTo(trackedSnapshot);
Copy link
Collaborator

@PiotrKarczmarz PiotrKarczmarz Jan 6, 2025

Choose a reason for hiding this comment

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

trackedSnapshot could be null. Shouldn't if (completionState != null) also check trackedSnapshot != null?

if (textView != null)
{
var wpfTextView = editorAdaptersFactoryService.GetWpfTextView(textView);
snapshot = snapshot ?? wpfTextView.TextSnapshot;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Shouldn't wpfTextView be checked if not null?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants