-
Notifications
You must be signed in to change notification settings - Fork 28.7k
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
TS extension: register call to CopilotRelated with copilot extension #228610
base: main
Are you sure you want to change the base?
Conversation
registerRelatedFilesProvider is a new method on the copilot extension. CopilotRelated is a new tsserver command that provides information from tsserver to copilot. (The information is not necessarily copilot-specific, of course.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sandersn:typescript-relatedfiles-imports
@@ -150,6 +151,60 @@ export default class TypeScriptServiceClientHost extends Disposable { | |||
standardFileExtensions: [], | |||
}, onCompletionAccepted); | |||
} | |||
// TODO: Still probably isn't the right place for this |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can this be registered as a language feature? That way it only gets activated when our other language features activate
// TODO: Still probably isn't the right place for this | ||
const ext = vscode.extensions.getExtension('github.copilot'); | ||
if (!ext) { | ||
vscode.window.showErrorMessage(vscode.l10n.t('Could not find related-files extension')); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Expected so should not show a user error
} | ||
// TODO: This compiles but will never cancel; this needs a token that somebody might actually cancel. | ||
const cancel = new vscode.CancellationTokenSource(); | ||
const response = await this.client.execute('copilotRelated', { file, }, cancel.token); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should have nulToken
that you can use for this
if (response.type !== 'response' || !response.body) { | ||
return []; | ||
} | ||
return response.body.map(vscode.Uri.file); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you want client.toResource
instead. That will handle non file:
uris
callback: (uri: vscode.Uri) => Promise<{ entries: vscode.Uri[]; traits?: { name: string; value: string }[] }> | ||
): void; | ||
} | undefined; | ||
if (relatedAPI) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this also need to be gated on the TS server version?
extensionId: 'vscode.typescript-language-features', | ||
languageId | ||
}; | ||
relatedAPI.registerRelatedFilesProvider(id, async uri => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does copilot pass a cancellation token? If not, we should request that it does
registerRelatedFilesProvider is a new method on the copilot extension. CopilotRelated is a new tsserver command that provides information from tsserver to copilot. (The information is not necessarily copilot-specific, of course.)
This code is quite far from done:
However, I want to make it available so I can get comments on it.