-
Notifications
You must be signed in to change notification settings - Fork 37.2k
Inline completions support for chat input #285831
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
base: main
Are you sure you want to change the base?
Conversation
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.
Pull request overview
This PR introduces support for AI-powered inline completions within the chat input editor through a new proposed API. It provides infrastructure for extensions to offer intelligent completion suggestions as users type in chat conversations.
Key Changes
- New
chatInlineCompletionsproposed API enabling extensions to register inline completion providers for chat input - Service layer implementation for aggregating completions from multiple providers
- RPC protocol infrastructure for extension host communication
- Integration with the chat input editor via InlineCompletionsController
Reviewed changes
Copilot reviewed 11 out of 12 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
src/vscode-dts/vscode.proposed.chatInlineCompletions.d.ts |
New API proposal defining ChatInlineCompletionItemProvider interface and registration method |
src/vs/workbench/contrib/chat/common/chatInlineCompletionsService.ts |
Service interface for managing chat inline completion providers |
src/vs/workbench/contrib/chat/browser/chatInlineCompletionsService.ts |
Browser service implementation that aggregates completions from registered providers |
src/vs/workbench/contrib/chat/browser/widget/input/editor/chatInputCompletions.ts |
ChatInputInlineCompletions contribution that bridges service to editor's inline completion infrastructure |
src/vs/workbench/contrib/chat/browser/widget/input/chatInputPart.ts |
Adds InlineCompletionsController to chat input editor contributions |
src/vs/workbench/contrib/chat/browser/chat.contribution.ts |
Registers ChatInlineCompletionsService singleton |
src/vs/workbench/api/common/extHostChatInlineCompletions.ts |
Extension host implementation managing provider registration and type conversion |
src/vs/workbench/api/common/extHost.protocol.ts |
RPC protocol shape definitions for main/extension thread communication |
src/vs/workbench/api/common/extHost.api.impl.ts |
Exposes registerChatInlineCompletionItemProvider API to extensions |
src/vs/workbench/api/browser/mainThreadChatInlineCompletions.ts |
Main thread coordinator delegating to service layer |
src/vs/workbench/api/browser/extensionHost.contribution.ts |
Imports main thread coordinator for initialization |
src/vs/platform/extensions/common/extensionsApiProposals.ts |
Registers chatInlineCompletions as available API proposal |
| class ChatInputInlineCompletions extends Disposable { | ||
| private readonly _ourProvider: InlineCompletionsProvider; | ||
|
|
||
| constructor( | ||
| @ILanguageFeaturesService private readonly languageFeaturesService: ILanguageFeaturesService, | ||
| @IChatWidgetService private readonly chatWidgetService: IChatWidgetService, | ||
| @IChatInlineCompletionsService private readonly chatInlineCompletionsService: IChatInlineCompletionsService, | ||
| ) { | ||
| super(); | ||
|
|
||
| this._ourProvider = { | ||
| debounceDelayMs: 150, // prevents excessive provider calls during rapid typing. | ||
| provideInlineCompletions: async (model: ITextModel, position: Position, _context: InlineCompletionContext, token: CancellationToken): Promise<InlineCompletions | undefined> => { | ||
| const widget = this.chatWidgetService.getWidgetByInputUri(model.uri); | ||
| if (!widget || !widget.viewModel) { | ||
| return undefined; | ||
| } | ||
|
|
||
| // Only show suggestions at end of line with non-empty content. | ||
| const lineContent = model.getLineContent(position.lineNumber); | ||
| // Column is 1-based, so subtract 1 to compare with 0-based line length | ||
| const isAtEndOfLine = position.column - 1 === lineContent.length; | ||
|
|
||
| if (!isAtEndOfLine || lineContent.trim().length < 3) { | ||
| return undefined; | ||
| } | ||
|
|
||
| // Call chat-specific inline completion providers | ||
| const input = model.getValue(); | ||
| const cursorPosition = model.getOffsetAt(position); | ||
|
|
||
| const result = await this.chatInlineCompletionsService.provideChatInlineCompletions( | ||
| input, | ||
| cursorPosition, | ||
| token | ||
| ); | ||
|
|
||
| return result; | ||
| }, | ||
| disposeInlineCompletions: () => { }, | ||
| }; | ||
|
|
||
| this._register(this.languageFeaturesService.inlineCompletionsProvider.register({ scheme: Schemas.vscodeChatInput, hasAccessToAllModels: true }, this._ourProvider)); | ||
| } | ||
| } | ||
|
|
||
| Registry.as<IWorkbenchContributionsRegistry>(WorkbenchExtensions.Workbench).registerWorkbenchContribution(ChatInputInlineCompletions, LifecyclePhase.Eventually); |
Copilot
AI
Jan 4, 2026
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.
This PR introduces a new proposed API and significant functionality but lacks any test coverage. The repository has comprehensive test suites for similar API features (e.g., mainThreadChatSessions.test.ts, extHostLanguageFeatures.test.ts). Consider adding tests for: provider registration/unregistration, completion item conversion, error handling in the service aggregation, and the RPC protocol between extension host and main thread.
src/vs/workbench/contrib/chat/browser/widget/input/editor/chatInputCompletions.ts
Outdated
Show resolved
Hide resolved
…InputCompletions.ts Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
See this PR to understand why this feature may be needed: microsoft/vscode-copilot-chat#2698
Introduces a new proposed API and supporting infrastructure for providing AI completions inline within the chat input editor. This includes: