microsoft / vscode-copilot-release

Feedback on GitHub Copilot Chat UX in Visual Studio Code.
https://marketplace.visualstudio.com/items?itemName=GitHub.copilot-chat
Creative Commons Attribution 4.0 International
328 stars 31 forks source link

Copilot Chat - use opened tabs as context #16

Open AdirD opened 1 year ago

AdirD commented 1 year ago

So before Copilot Chat, i've been working with co pilot and GPT interchangeably, for auto completes and no brainer issues I let co pilot deal with, and where I need to solve something more complex, or get some inspiration I turn to the good ol` chat, I usually inject a bunch of code in it and work my way up to a solution

When the Copilot Chat was released, I was under the impression that since it already resides in your code space, it could just read your files and use them as context, so when you ask a question it would know the project, or parts of it, for example if I ask it "join table X with table Y where Z" it would already know the structure of those tables and yield some query

Because currently in this version I find myself developing the same way I've been so far, copying and pasting code into the chat, so it seem to just save a tab switch, while it could be so much more

Am I missing anything? is this type of feature planned?

tmc101 commented 1 year ago

Version: 1.79.0-insider (user setup) Commit: 2946b1ee55db1d406526d3fd1df49250b2f8322d Date: 2023-05-18T05:25:02.319Z Electron: 22.5.2 Chromium: 108.0.5359.215 Node.js: 16.17.1 V8: 10.8.168.25-electron.0 OS: Windows_NT x64 10.0.19045

GitHub Copilot Chat v0.1.2023051801

When I received the Copilot Chat beta access, the first thing I did was to try to generate some unit tests for a Typescript pure function.

This was the simplest test I could think of. I have two files:

model.ts contains:

export type RelationalOperator = 'None' | 'GT' | 'GE' | 'EQ' | 'NE' | 'LT' | 'LE' | 'BT';

export type BooleanOperator = 'Or' | 'And' | 'Not';

export interface Item {
    id: number;
    name: string;
    order: number;
    creator: string;
    creationDate: string;
    relationship: BooleanOperator;
    countLower: number | null;
    countUpper: number | null;
    countRelation: RelationalOperator;
}

and utils.ts contains:

import { Item } from './model';

export function descriptionText(item: Item) {
    if (item.countRelation === 'None') {
        return '';
    }

    if (item.countRelation === 'EQ') {
        return `(matching exactly ${item.countLower} of the criteria)`;
    }

    if (item.countRelation === 'GT') {
        return `(matching more than ${item.countLower} of the criteria)`;
    }

    if (item.countRelation === 'LT') {
        return `(matching fewer than ${item.countLower} of the criteria)`;
    }

    if (item.countRelation === 'BT') {
        return `(matching between ${item.countLower} and ${item.countUpper} of the criteria)`;
    }

    return '';
}

So I opened both files in VSCode, selected the code for the function and asked Copilot Chat to write unit tests.

It generated a set of tests that would not compile because the required properties were not set e.g.:

import { Item } from './model';
import { descriptionText } from './utils';

describe('descriptionText', () => {
  it('should return an empty string when countRelation is None', () => {
    const item: Item = {
      countRelation: 'None',
    };
    expect(descriptionText(item)).toBe('');
  });

  // etc...
});

I then asked it for definition of the Item interface:

image

So it knows that the Item interface is defined in model.ts but it gives the wrong definition - even though that file is open in the editor.

The only way I could get Copilot Chat to generate a valid set of tests was to paste all of the code into the chat.

It then generated some correct tests, but when I asked it to simplify those tests it reverted back to generating a set of tests like the first ones which would not compile.

I tried ChatGPT4 with the same problem - by pasting all of the code into the chat, and it generated some working tests.

I then asked ChatGPT4 to optimize those test, and it did it correctly.

I was expecting Copilot Chat to perform like ChatGPT4 but with the added benefit that it could use my source files as context.

But so far I have had to paste all of the code into the chat section, and it has produce answers which are not as good as using ChatGPT4.

As a final test I explicitly asked Copilot Chat if it could read my source code files, and to show me the definition of the Item interface:

image

I have no idea where it got its answer - but it was not from my code.

Maybe I have missed the point here?

Can anyone answer the following:

  1. Does Copilot Chat use the GPT-3 or GTP-4 model, or something else?
  2. Can Copilot Chat really read my source files?
carnuare commented 1 year ago
  1. Can Copilot Chat really read my source files?

It can only read what you have highlighted, and if you highlight too much it doesn't take it into account from what I've experienced.

YoraiLevi commented 1 year ago

Could be a user "error" onn my part but I didn't have anything highlighted, discussed with the chat and it "read" my code and reproduced it as an output with the same variables, logic etc. it was mildly infuriating.

theredwillow commented 6 months ago

There is supposed to be an @editor function now, but it doesn't work.

editor bug

You can use #file multiple times though.

double files kinda working

Still double imports though...