Skip to content

Commit

Permalink
only range
Browse files Browse the repository at this point in the history
  • Loading branch information
gagik committed Nov 29, 2024
1 parent 93fb8f8 commit 82cff2a
Showing 1 changed file with 27 additions and 6 deletions.
33 changes: 27 additions & 6 deletions src/participant/participant.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@ export type RunParticipantCodeCommandArgs = {
runnableContent: string;
};

export type ParticipantCommand = '/query' | '/schema' | '/docs';
export type ParticipantCommandName = 'query' | 'schema' | 'docs';
export type ParticipantCommand = `/${ParticipantCommandName}`;

const MAX_MARKDOWN_LIST_LENGTH = 10;

Expand Down Expand Up @@ -179,6 +180,8 @@ export default class ParticipantController {
message,
isNewChat = false,
isPartialQuery = false,
source,

Check failure on line 183 in src/participant/participant.ts

View workflow job for this annotation

GitHub Actions / Test and Build (ubuntu-latest)

Property 'source' does not exist on type 'SendMessageToParticipantOptions'.

Check failure on line 183 in src/participant/participant.ts

View workflow job for this annotation

GitHub Actions / Test and Build (windows-2019)

Property 'source' does not exist on type 'SendMessageToParticipantOptions'.

Check failure on line 183 in src/participant/participant.ts

View workflow job for this annotation

GitHub Actions / Test and Build (macos-latest)

Property 'source' does not exist on type 'SendMessageToParticipantOptions'.
command,

Check failure on line 184 in src/participant/participant.ts

View workflow job for this annotation

GitHub Actions / Test and Build (ubuntu-latest)

Property 'command' does not exist on type 'SendMessageToParticipantOptions'.

Check failure on line 184 in src/participant/participant.ts

View workflow job for this annotation

GitHub Actions / Test and Build (windows-2019)

Property 'command' does not exist on type 'SendMessageToParticipantOptions'.

Check failure on line 184 in src/participant/participant.ts

View workflow job for this annotation

GitHub Actions / Test and Build (macos-latest)

Property 'command' does not exist on type 'SendMessageToParticipantOptions'.
...otherOptions
} = options;

Expand All @@ -189,9 +192,26 @@ export default class ParticipantController {
);
}

if (source) {
if (isNewChat) {
this._telemetryService.trackCopilotParticipantChatOpenedFromAction({

Check failure on line 197 in src/participant/participant.ts

View workflow job for this annotation

GitHub Actions / Test and Build (ubuntu-latest)

Property 'trackCopilotParticipantChatOpenedFromAction' does not exist on type 'TelemetryService'. Did you mean 'trackCopilotParticipantPrompt'?

Check failure on line 197 in src/participant/participant.ts

View workflow job for this annotation

GitHub Actions / Test and Build (windows-2019)

Property 'trackCopilotParticipantChatOpenedFromAction' does not exist on type 'TelemetryService'. Did you mean 'trackCopilotParticipantPrompt'?

Check failure on line 197 in src/participant/participant.ts

View workflow job for this annotation

GitHub Actions / Test and Build (macos-latest)

Property 'trackCopilotParticipantChatOpenedFromAction' does not exist on type 'TelemetryService'. Did you mean 'trackCopilotParticipantPrompt'?
source,
});
}
if (!isPartialQuery) {
this._telemetryService.trackCopilotParticipantPromptSubmittedFromAction(

Check failure on line 202 in src/participant/participant.ts

View workflow job for this annotation

GitHub Actions / Test and Build (ubuntu-latest)

Property 'trackCopilotParticipantPromptSubmittedFromAction' does not exist on type 'TelemetryService'. Did you mean 'trackCopilotParticipantSubmittedFromInputBox'?

Check failure on line 202 in src/participant/participant.ts

View workflow job for this annotation

GitHub Actions / Test and Build (windows-2019)

Property 'trackCopilotParticipantPromptSubmittedFromAction' does not exist on type 'TelemetryService'. Did you mean 'trackCopilotParticipantSubmittedFromInputBox'?

Check failure on line 202 in src/participant/participant.ts

View workflow job for this annotation

GitHub Actions / Test and Build (macos-latest)

Property 'trackCopilotParticipantPromptSubmittedFromAction' does not exist on type 'TelemetryService'. Did you mean 'trackCopilotParticipantSubmittedFromInputBox'?
{
source,
}
);
}
}

const commandPrefix = command ? `/${command} ` : '';

return await vscode.commands.executeCommand('workbench.action.chat.open', {
...otherOptions,
query: `@MongoDB ${message}`,
query: `@MongoDB ${commandPrefix}${message}`,
isPartialQuery,
});
}
Expand All @@ -207,7 +227,7 @@ export default class ParticipantController {
...inputBoxOptions
} = options;

this._telemetryService.trackCopilotParticipantSubmittedFromInputBox({
this._telemetryService.trackCopilotParticipantPromptSubmittedFromAction({

Check failure on line 230 in src/participant/participant.ts

View workflow job for this annotation

GitHub Actions / Test and Build (ubuntu-latest)

Property 'trackCopilotParticipantPromptSubmittedFromAction' does not exist on type 'TelemetryService'. Did you mean 'trackCopilotParticipantSubmittedFromInputBox'?

Check failure on line 230 in src/participant/participant.ts

View workflow job for this annotation

GitHub Actions / Test and Build (windows-2019)

Property 'trackCopilotParticipantPromptSubmittedFromAction' does not exist on type 'TelemetryService'. Did you mean 'trackCopilotParticipantSubmittedFromInputBox'?

Check failure on line 230 in src/participant/participant.ts

View workflow job for this annotation

GitHub Actions / Test and Build (macos-latest)

Property 'trackCopilotParticipantPromptSubmittedFromAction' does not exist on type 'TelemetryService'. Did you mean 'trackCopilotParticipantSubmittedFromInputBox'?
source,
});

Expand Down Expand Up @@ -236,14 +256,15 @@ export default class ParticipantController {
message: `I want to ask questions about the \`${databaseName}\` database.`,
isNewChat: true,
});
}
if (treeItem instanceof CollectionTreeItem) {
} else if (treeItem instanceof CollectionTreeItem) {
const { databaseName, collectionName } = treeItem;

await this.sendMessageToParticipant({
message: `I want to ask questions about the \`${databaseName}\` database's \`${collectionName}\` collection.`,
isNewChat: true,
});
} else {
throw new Error('Unsupported tree item type');
}

await this.sendMessageToParticipant({
Expand Down Expand Up @@ -1949,7 +1970,7 @@ Please see our [FAQ](https://www.mongodb.com/docs/generative-ai-faq/) for more i
} catch (error) {
this._telemetryService.trackCopilotParticipantError(
error,
request.command || 'generic'
(request.command as ParticipantCommandName) || 'generic'
);
// Re-throw other errors so they show up in the UI.
throw error;
Expand Down

0 comments on commit 82cff2a

Please sign in to comment.