Skip to content

Commit 6af38f8

Browse files
authored
feat(participant): remove in-app notification for participant VSCODE-662 (#899)
1 parent 07e01d4 commit 6af38f8

File tree

5 files changed

+3
-266
lines changed

5 files changed

+3
-266
lines changed

src/mdbExtensionController.ts

Lines changed: 1 addition & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,8 @@ import type {
4949
SendMessageToParticipantFromInputOptions,
5050
ParticipantCommand,
5151
} from './participant/participantTypes';
52-
import {
53-
COPILOT_CHAT_EXTENSION_ID,
54-
COPILOT_EXTENSION_ID,
55-
} from './participant/constants';
5652
import EXTENSION_COMMANDS from './commands';
53+
import { COPILOT_EXTENSION_ID } from './participant/constants';
5754

5855
// This class is the top-level controller for our extension.
5956
// Commands which the extensions handles are defined in the function `activate`.
@@ -79,7 +76,6 @@ export default class MDBExtensionController implements vscode.Disposable {
7976
_editDocumentCodeLensProvider: EditDocumentCodeLensProvider;
8077
_exportToLanguageCodeLensProvider: ExportToLanguageCodeLensProvider;
8178
_participantController: ParticipantController;
82-
_startupNotificationShown = false;
8379

8480
constructor(
8581
context: vscode.ExtensionContext,
@@ -177,9 +173,6 @@ export default class MDBExtensionController implements vscode.Disposable {
177173
this.registerCommands();
178174
this.showOverviewPageIfRecentlyInstalled();
179175

180-
// ------ In-app notifications ------ //
181-
void this.showCopilotIntroductionForEstablishedUsers();
182-
183176
const copilot = vscode.extensions.getExtension(COPILOT_EXTENSION_ID);
184177
void vscode.commands.executeCommand(
185178
'setContext',
@@ -971,59 +964,6 @@ export default class MDBExtensionController implements vscode.Disposable {
971964
}
972965
}
973966

974-
async showCopilotIntroductionForEstablishedUsers(): Promise<void> {
975-
const copilotIntroductionShown =
976-
this._storageController.get(
977-
StorageVariables.GLOBAL_COPILOT_INTRODUCTION_SHOWN
978-
) === true;
979-
980-
// Show the toast when startup notifications have not been shown
981-
// to the user yet and they have saved connections
982-
// -> they haven't just started using this extension.
983-
if (
984-
this._startupNotificationShown ||
985-
copilotIntroductionShown ||
986-
!this._connectionStorage.hasSavedConnections()
987-
) {
988-
return;
989-
}
990-
991-
this._startupNotificationShown = true;
992-
993-
const action = 'Chat with @MongoDB';
994-
const text =
995-
'Generate queries, interact with documentation, and explore your database schema using the MongoDB Copilot extension. Give it a try!';
996-
const result = await vscode.window.showInformationMessage(
997-
text,
998-
{},
999-
{
1000-
title: action,
1001-
}
1002-
);
1003-
1004-
const copilot = vscode.extensions.getExtension(COPILOT_CHAT_EXTENSION_ID);
1005-
if (result?.title === action) {
1006-
await this._participantController.sendMessageToParticipant({
1007-
message: '',
1008-
isNewChat: true,
1009-
isPartialQuery: true,
1010-
});
1011-
this._telemetryService.trackCopilotIntroductionClicked({
1012-
is_copilot_active: !!copilot?.isActive,
1013-
});
1014-
} else {
1015-
this._telemetryService.trackCopilotIntroductionDismissed({
1016-
is_copilot_active: !!copilot?.isActive,
1017-
});
1018-
}
1019-
1020-
// Whether action was taken or the prompt dismissed, we won't show this again.
1021-
void this._storageController.update(
1022-
StorageVariables.GLOBAL_COPILOT_INTRODUCTION_SHOWN,
1023-
true
1024-
);
1025-
}
1026-
1027967
async dispose(): Promise<void> {
1028968
await this.deactivate();
1029969
}

src/participant/prompts/promptBase.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ import type {
55
ParticipantPromptProperties,
66
} from '../../telemetry/telemetryService';
77
import { PromptHistory } from './promptHistory';
8-
import { getCopilotModel } from '../model';
98
import type { ParticipantCommandType } from '../participantTypes';
9+
import { getCopilotModel } from '../model';
1010

1111
export interface PromptArgsBase {
1212
request: {

src/storage/storageController.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import type { StoreConnectionInfo } from './connectionStorage';
66
export enum StorageVariables {
77
// Only exists on globalState.
88
GLOBAL_HAS_BEEN_SHOWN_INITIAL_VIEW = 'GLOBAL_HAS_BEEN_SHOWN_INITIAL_VIEW',
9-
GLOBAL_COPILOT_INTRODUCTION_SHOWN = 'GLOBAL_COPILOT_INTRODUCTION_SHOWN',
109
GLOBAL_SAVED_CONNECTIONS = 'GLOBAL_SAVED_CONNECTIONS',
1110
// Analytics user identify.
1211
GLOBAL_USER_ID = 'GLOBAL_USER_ID',
@@ -52,7 +51,6 @@ interface StorageVariableContents {
5251
[StorageVariables.GLOBAL_USER_ID]: string;
5352
[StorageVariables.GLOBAL_ANONYMOUS_ID]: string;
5453
[StorageVariables.GLOBAL_HAS_BEEN_SHOWN_INITIAL_VIEW]: boolean;
55-
[StorageVariables.GLOBAL_COPILOT_INTRODUCTION_SHOWN]: boolean;
5654
[StorageVariables.GLOBAL_SAVED_CONNECTIONS]: ConnectionsFromStorage;
5755
[StorageVariables.WORKSPACE_SAVED_CONNECTIONS]: ConnectionsFromStorage;
5856
[StorageVariables.COPILOT_HAS_BEEN_SHOWN_WELCOME_MESSAGE]: boolean;

src/telemetry/telemetryService.ts

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -127,10 +127,6 @@ export type ParticipantResponseProperties = {
127127
output_length: number;
128128
};
129129

130-
export type CopilotIntroductionProperties = {
131-
is_copilot_active: boolean;
132-
};
133-
134130
export type ParticipantPromptSubmittedFromActionProperties = {
135131
source: DocumentSource;
136132
input_length: number;
@@ -181,8 +177,7 @@ type TelemetryEventProperties =
181177
| ParticipantPromptProperties
182178
| ParticipantPromptSubmittedFromActionProperties
183179
| ParticipantChatOpenedFromActionProperties
184-
| ParticipantResponseProperties
185-
| CopilotIntroductionProperties;
180+
| ParticipantResponseProperties;
186181

187182
export enum TelemetryEventTypes {
188183
PLAYGROUND_CODE_EXECUTED = 'Playground Code Executed',
@@ -212,8 +207,6 @@ export enum TelemetryEventTypes {
212207
/** Tracks after a participant interacts with the input box we open to let the user write the prompt for participant. */
213208
PARTICIPANT_INPUT_BOX_SUBMITTED = 'Participant Inbox Box Submitted',
214209
PARTICIPANT_RESPONSE_GENERATED = 'Participant Response Generated',
215-
COPILOT_INTRODUCTION_CLICKED = 'Copilot Introduction Clicked',
216-
COPILOT_INTRODUCTION_DISMISSED = 'Copilot Introduction Dismissed',
217210
}
218211

219212
/**
@@ -527,14 +520,4 @@ export default class TelemetryService {
527520
trackParticipantResponse(props: ParticipantResponseProperties): void {
528521
this.track(TelemetryEventTypes.PARTICIPANT_RESPONSE_GENERATED, props);
529522
}
530-
531-
trackCopilotIntroductionClicked(props: CopilotIntroductionProperties): void {
532-
this.track(TelemetryEventTypes.COPILOT_INTRODUCTION_CLICKED, props);
533-
}
534-
535-
trackCopilotIntroductionDismissed(
536-
props: CopilotIntroductionProperties
537-
): void {
538-
this.track(TelemetryEventTypes.COPILOT_INTRODUCTION_DISMISSED, props);
539-
}
540523
}

src/test/suite/mdbExtensionController.test.ts

Lines changed: 0 additions & 184 deletions
Original file line numberDiff line numberDiff line change
@@ -1712,190 +1712,6 @@ suite('MDBExtensionController Test Suite', function () {
17121712
});
17131713
});
17141714
});
1715-
1716-
suite('copilot introduction prompt', function () {
1717-
suite(
1718-
'when a user has been shown the startup notification already',
1719-
function () {
1720-
beforeEach(() => {
1721-
sandbox
1722-
.stub(
1723-
mdbTestExtension.testExtensionController,
1724-
'_startupNotificationShown'
1725-
)
1726-
.get(function getterFn() {
1727-
return true;
1728-
});
1729-
});
1730-
1731-
test('they are not shown the copilot introduction prompt', () => {
1732-
assert(showInformationMessageStub.notCalled);
1733-
});
1734-
}
1735-
);
1736-
1737-
suite(
1738-
"when a user hasn't been shown the copilot introduction prompt yet, and they have connections saved",
1739-
() => {
1740-
[
1741-
{
1742-
description: 'clicked the button',
1743-
value: { title: 'Chat with @MongoDB' },
1744-
},
1745-
{ description: 'dismissed', value: undefined },
1746-
].forEach((reaction) => {
1747-
suite(`user ${reaction.description}`, () => {
1748-
let connectionsUpdateStub: SinonStub;
1749-
let executeCommandStub: SinonStub;
1750-
beforeEach(async () => {
1751-
sandbox
1752-
.stub(
1753-
mdbTestExtension.testExtensionController,
1754-
'_startupNotificationShown'
1755-
)
1756-
.set(function setterFn() {})
1757-
.get(function getterFn() {
1758-
return false;
1759-
});
1760-
showInformationMessageStub.resolves(reaction.value);
1761-
executeCommandStub = sandbox.stub(
1762-
vscode.commands,
1763-
'executeCommand'
1764-
);
1765-
sandbox.replace(
1766-
mdbTestExtension.testExtensionController._storageController,
1767-
'get',
1768-
sandbox.fake.returns(undefined)
1769-
);
1770-
sandbox.replace(
1771-
mdbTestExtension.testExtensionController._connectionStorage,
1772-
'hasSavedConnections',
1773-
sandbox.fake.returns(true)
1774-
);
1775-
connectionsUpdateStub = sandbox.stub(
1776-
mdbTestExtension.testExtensionController._storageController,
1777-
'update'
1778-
);
1779-
connectionsUpdateStub.resolves(undefined);
1780-
await mdbTestExtension.testExtensionController.showCopilotIntroductionForEstablishedUsers();
1781-
});
1782-
1783-
afterEach(() => {
1784-
sandbox.restore();
1785-
});
1786-
1787-
test('they are shown the copilot introduction prompt', () => {
1788-
assert(showInformationMessageStub.called);
1789-
assert.strictEqual(
1790-
showInformationMessageStub.firstCall.args[0],
1791-
'Generate queries, interact with documentation, and explore your database schema using the MongoDB Copilot extension. Give it a try!'
1792-
);
1793-
});
1794-
1795-
test('the link was open if and only if they click the button', () => {
1796-
if (reaction.value === undefined) {
1797-
assert(executeCommandStub.notCalled);
1798-
}
1799-
if (reaction.value) {
1800-
assert(executeCommandStub.called);
1801-
assert.strictEqual(
1802-
executeCommandStub.firstCall.args[0],
1803-
'workbench.action.chat.newChat'
1804-
);
1805-
}
1806-
});
1807-
1808-
test("it sets that they've been shown the copilot introduction", () => {
1809-
assert(connectionsUpdateStub.called);
1810-
assert.strictEqual(
1811-
connectionsUpdateStub.firstCall.args[0],
1812-
StorageVariables.GLOBAL_COPILOT_INTRODUCTION_SHOWN
1813-
);
1814-
assert.strictEqual(
1815-
connectionsUpdateStub.firstCall.args[1],
1816-
true
1817-
);
1818-
});
1819-
});
1820-
});
1821-
}
1822-
);
1823-
1824-
suite(
1825-
'when a user has been shown the copilot introduction prompt already',
1826-
() => {
1827-
let connectionsUpdateStub: SinonStub;
1828-
beforeEach(() => {
1829-
sandbox
1830-
.stub(
1831-
mdbTestExtension.testExtensionController,
1832-
'_startupNotificationShown'
1833-
)
1834-
.set(function setterFn() {})
1835-
.get(function getterFn() {
1836-
return false;
1837-
});
1838-
sandbox.replace(
1839-
mdbTestExtension.testExtensionController._storageController,
1840-
'get',
1841-
sandbox.fake.returns(true) // copilot introduction has been shown
1842-
);
1843-
sandbox.replace(
1844-
mdbTestExtension.testExtensionController._connectionStorage,
1845-
'hasSavedConnections',
1846-
sandbox.fake.returns(true)
1847-
);
1848-
connectionsUpdateStub = sandbox.stub(
1849-
mdbTestExtension.testExtensionController._storageController,
1850-
'update'
1851-
);
1852-
connectionsUpdateStub.resolves(undefined);
1853-
1854-
void mdbTestExtension.testExtensionController.showCopilotIntroductionForEstablishedUsers();
1855-
});
1856-
1857-
test('they are not shown the copilot introduction prompt', () => {
1858-
assert(showInformationMessageStub.notCalled);
1859-
});
1860-
}
1861-
);
1862-
1863-
suite('when a has no connections saved', () => {
1864-
let connectionsUpdateStub: SinonStub;
1865-
beforeEach(() => {
1866-
sandbox
1867-
.stub(
1868-
mdbTestExtension.testExtensionController,
1869-
'_startupNotificationShown'
1870-
)
1871-
.set(function setterFn() {})
1872-
.get(function getterFn() {
1873-
return false;
1874-
});
1875-
sandbox.replace(
1876-
mdbTestExtension.testExtensionController._storageController,
1877-
'get',
1878-
sandbox.fake.returns(undefined)
1879-
);
1880-
sandbox.replace(
1881-
mdbTestExtension.testExtensionController._connectionStorage,
1882-
'hasSavedConnections',
1883-
sandbox.fake.returns(false) // no connections yet - this might be the first install
1884-
);
1885-
connectionsUpdateStub = sandbox.stub(
1886-
mdbTestExtension.testExtensionController._storageController,
1887-
'update'
1888-
);
1889-
connectionsUpdateStub.resolves(undefined);
1890-
1891-
void mdbTestExtension.testExtensionController.showCopilotIntroductionForEstablishedUsers();
1892-
});
1893-
1894-
test('they are not shown the copilot introduction prompt', () => {
1895-
assert(showInformationMessageStub.notCalled);
1896-
});
1897-
});
1898-
});
18991715
});
19001716

19011717
test('mdb.participantViewRawSchemaOutput command opens a json document with the output', async () => {

0 commit comments

Comments
 (0)