-
Notifications
You must be signed in to change notification settings - Fork 62
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(playground): add Generate Query with Copilot code lens in playgr…
…ounds VSCODE-650 (#881) Co-authored-by: Alena Khineika <[email protected]>
- Loading branch information
1 parent
e93006a
commit f18430f
Showing
13 changed files
with
314 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -201,7 +201,7 @@ export default class ConnectionController { | |
ignoreFocusOut: true, | ||
placeHolder: | ||
'e.g. mongodb+srv://username:[email protected]/admin', | ||
prompt: 'Enter your connection string (SRV or standard)', | ||
prompt: 'Enter your SRV or standard connection string', | ||
validateInput: (uri: string) => { | ||
if ( | ||
!uri.startsWith('mongodb://') && | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import * as vscode from 'vscode'; | ||
import EXTENSION_COMMANDS from '../commands'; | ||
import type { SendMessageToParticipantFromInputOptions } from '../participant/participantTypes'; | ||
import { isPlayground } from '../utils/playground'; | ||
import { COPILOT_EXTENSION_ID } from '../participant/constants'; | ||
import { DocumentSource } from '../documentSource'; | ||
|
||
export class QueryWithCopilotCodeLensProvider | ||
implements vscode.CodeLensProvider | ||
{ | ||
constructor() {} | ||
|
||
readonly onDidChangeCodeLenses: vscode.Event<void> = | ||
vscode.extensions.onDidChange; | ||
|
||
provideCodeLenses(document: vscode.TextDocument): vscode.CodeLens[] { | ||
if (!isPlayground(document.uri)) { | ||
return []; | ||
} | ||
|
||
// We can only detect whether a user has the Copilot extension active | ||
// but not whether it has an active subscription. | ||
const hasCopilotChatActive = | ||
vscode.extensions.getExtension(COPILOT_EXTENSION_ID)?.isActive === true; | ||
|
||
if (!hasCopilotChatActive) { | ||
return []; | ||
} | ||
|
||
const options: SendMessageToParticipantFromInputOptions = { | ||
prompt: 'Describe the query you would like to generate', | ||
placeHolder: | ||
'e.g. Find the document in sample_mflix.users with the name of Kayden Washington', | ||
messagePrefix: '/query', | ||
isNewChat: true, | ||
source: DocumentSource.DOCUMENT_SOURCE_QUERY_WITH_COPILOT_CODELENS, | ||
}; | ||
|
||
return [ | ||
new vscode.CodeLens(new vscode.Range(0, 0, 0, 0), { | ||
title: '✨ Generate query with MongoDB Copilot', | ||
command: EXTENSION_COMMANDS.SEND_MESSAGE_TO_PARTICIPANT_FROM_INPUT, | ||
arguments: [options], | ||
}), | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import type * as vscode from 'vscode'; | ||
import type { DocumentSource } from '../documentSource'; | ||
|
||
export type SendMessageToParticipantOptions = { | ||
message: string; | ||
isNewChat?: boolean; | ||
isPartialQuery?: boolean; | ||
}; | ||
|
||
export type SendMessageToParticipantFromInputOptions = { | ||
messagePrefix?: string; | ||
source?: DocumentSource; | ||
} & Omit<SendMessageToParticipantOptions, 'message'> & | ||
vscode.InputBoxOptions; |
Oops, something went wrong.