Skip to content

Conversation

@jeffreyhunter77
Copy link
Collaborator

Include inline completions in @vscode/chat-lib

This exports a function for creating an IInlineCompletionsProvider:

function createInlineCompletionsProvider(options: IInlineCompletionsProviderOptions): IInlineCompletionsProvider

The returned instance provides methods for updating treatment variables and getting inline completions:

export interface IInlineCompletionsProvider {
	updateTreatmentVariables(variables: Record<string, boolean | number | string>): void;
	getInlineCompletions(textDocument: ITextDocument, position: Position, token?: CancellationToken, options?: IGetInlineCompletionsOptions): Promise<CopilotCompletion[] | undefined>;
	dispose(): void;
}

The options object for creating a provider is fairly complex. It allows for customizing much of what was previously passed in to the completions function via a Context object. This is probably a good area for simplifying in future iterations.

I also discovered an undeclared dependency that I've added to the main package.json. Some of the completions code depends on @sinclair/typebox. That's being indirectly supplied by @vitest/snapshot right now, but it we should have an explicit dependency. I'm using the same version as the completions extension here.

Copilot AI review requested due to automatic review settings November 21, 2025 10:54
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR integrates inline completions functionality into the @vscode/chat-lib package, making it available for external consumption. The main purpose is to export a createInlineCompletionsProvider function that allows consumers to create inline completion providers with extensive customization options.

Key changes:

  • Exports inline completions provider creation functionality through chatLibMain.ts
  • Refactors service dependencies to support chat-lib usage (removes direct VS Code API dependencies)
  • Enhances the build system to handle path aliases and improved dependency tracking
  • Adds comprehensive test coverage for the new inline completions API

Reviewed Changes

Copilot reviewed 19 out of 21 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
src/platform/telemetry/node/azureInsightsReporter.ts Exports unwrapEventNameFromPrefix function for telemetry event name normalization in chat-lib
src/lib/node/chatLibMain.ts Main integration point: exports inline completions provider creation with extensive service setup and bridging
src/extension/completions-core/vscode-node/prompt/src/fileLoader.ts Improves path resolution to work correctly in both TypeScript source and transpiled JavaScript contexts
src/extension/completions-core/vscode-node/lib/src/telemetry/userConfig.ts Ensures telemetry user config is initialized immediately when copilot token is already available
src/extension/completions-core/vscode-node/lib/src/notificationSender.ts Removes direct VS Code API dependency, uses injected notification service instead
src/extension/completions-core/vscode-node/lib/src/error/userErrorNotifier.ts Removes direct VS Code API dependency, uses injected env service instead
src/extension/completions-core/vscode-node/lib/src/config.ts Exports EditorInfo and EditorPluginInfo types for chat-lib API surface
src/extension/completions-core/vscode-node/lib/src/completionsObservableWorkspace.ts Removes implementation, keeps only interface definition to avoid circular dependencies
src/extension/completions-core/vscode-node/extension/src/completionsObservableWorkspace.ts Moves CompletionsObservableWorkspace implementation to extension-specific location
src/extension/completions-core/vscode-node/completionsServiceBridges.ts Updates import path for moved CompletionsObservableWorkspace class and fixes service descriptor
script/build/extractChatLib.ts Significantly enhances build script to handle path aliases, JSX imports, and improved comment filtering
package.json Adds explicit dependency on @sinclair/typebox (previously transitive)
eslint.config.mjs Disables restricted import paths rule for chatLibMain.ts to allow cross-boundary imports
chat-lib/vitest.config.ts Removes unused path import
chat-lib/tsconfig.json Adds empty paths object (populated by build script)
chat-lib/test/getInlineCompletions.spec.ts Comprehensive test for inline completions provider functionality
chat-lib/test/getInlineCompletions.reply.txt Test fixture containing mock completion response data
chat-lib/script/postinstall.ts New script to copy static assets (tiktoken files and tree-sitter grammars) after installation
chat-lib/package.json Adds required dependencies and postinstall script
Files not reviewed (1)
  • chat-lib/package-lock.json: Language not supported

Comment on lines +510 to +512
if (this._telemetrySender.sendEnhancedTelemetryEvent) {
this._telemetrySender.sendEnhancedTelemetryEvent(eventName, eventPropertiesToSimpleObject(properties), measurements);
}
Copy link

Copilot AI Nov 21, 2025

Choose a reason for hiding this comment

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

The implementation should avoid creating adhoc one-off mocks. Consider creating a reusable MockTelemetrySender class under a test/ folder that can be configured for different test scenarios, similar to existing patterns like MockFileSystemService.

Copilot generated this review using guidance from repository custom instructions.
// Track block comments
if (line.trim().startsWith('/*')) {
// preserve pragmas in tsx files
if (!(filePath.endsWith('.tsx') && line.match(/\/\*\*\s+@jsxImportSource\s+\S+/))) {
Copy link

Copilot AI Nov 21, 2025

Choose a reason for hiding this comment

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

The regex pattern for JSX import source appears twice (here and at line 233). Extract this into a named constant to avoid duplication and improve maintainability.

Copilot uses AI. Check for mistakes.

}

main();
Copy link

Copilot AI Nov 21, 2025

Choose a reason for hiding this comment

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

The main function call should handle errors. If the async operation fails, the postinstall script will silently succeed. Add .catch(err => { console.error(err); process.exit(1); }) to properly propagate errors.

Copilot uses AI. Check for mistakes.
@jeffreyhunter77
Copy link
Collaborator Author

@microsoft-github-policy-service agree company="GitHub"

Copy link
Collaborator

@chrmarti chrmarti left a comment

Choose a reason for hiding this comment

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

LGTM!

@vs-code-engineering vs-code-engineering bot added this to the November 2025 milestone Nov 21, 2025
@chrmarti chrmarti enabled auto-merge November 21, 2025 15:39
@chrmarti chrmarti added this pull request to the merge queue Nov 21, 2025
Merged via the queue into main with commit 6be35c3 Nov 21, 2025
16 checks passed
@chrmarti chrmarti deleted the jeffreyhunter77/chat-lib-inline-completions branch November 21, 2025 16:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants