Skip to content

Commit 7206585

Browse files
committed
Merge branch 'main' into compass-collection-redux-integrates-mock-data-schema
2 parents 2e1ca5c + b2931e1 commit 7206585

File tree

62 files changed

+1882
-914
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+1882
-914
lines changed

THIRD-PARTY-NOTICES.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
The following third-party software is used by and included in **Mongodb Compass**.
2-
This document was automatically generated on Fri Aug 29 2025.
2+
This document was automatically generated on Tue Sep 02 2025.
33

44
## List of dependencies
55

docs/tracking-plan.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
> the tracking plan for the specific Compass version you can use the following
77
> URL: `https://github.com/mongodb-js/compass/blob/<compass version>/docs/tracking-plan.md`
88
9-
Generated on Fri, Aug 29, 2025
9+
Generated on Tue, Sep 2, 2025
1010

1111
## Table of Contents
1212

@@ -1283,6 +1283,8 @@ This event is fired when user executes a query
12831283
- Indicates whether the query includes a skip operation.
12841284
- **has_sort** (required): `boolean`
12851285
- Indicates whether the query includes a sort operation.
1286+
- **default_sort** (required): `"none" | "natural" | "_id"`
1287+
- Indicates which default sort was set in settings
12861288
- **has_limit** (required): `boolean`
12871289
- Indicates whether the query includes a limit operation.
12881290
- **has_collation** (required): `boolean`

package-lock.json

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/compass-aggregations/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@
6060
"@mongodb-js/atlas-service": "^0.56.0",
6161
"@mongodb-js/compass-app-registry": "^9.4.20",
6262
"@mongodb-js/compass-app-stores": "^7.57.0",
63+
"@mongodb-js/compass-assistant": "^1.2.0",
6364
"@mongodb-js/compass-collection": "^4.70.0",
6465
"@mongodb-js/compass-components": "^1.49.0",
6566
"@mongodb-js/compass-connections": "^1.71.0",

packages/compass-aggregations/src/components/pipeline-toolbar/pipeline-header/pipeline-actions.spec.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ describe('PipelineActions', function () {
5050
onUpdateView={() => {}}
5151
onCollectionScanInsightActionButtonClick={() => {}}
5252
onShowAIInputClick={() => {}}
53+
stages={[]}
5354
/>
5455
);
5556
});
@@ -115,6 +116,7 @@ describe('PipelineActions', function () {
115116
onExplainAggregation={() => {}}
116117
onCollectionScanInsightActionButtonClick={() => {}}
117118
onShowAIInputClick={() => {}}
119+
stages={[]}
118120
/>
119121
);
120122
});
@@ -158,6 +160,7 @@ describe('PipelineActions', function () {
158160
onExplainAggregation={() => {}}
159161
onCollectionScanInsightActionButtonClick={() => {}}
160162
onShowAIInputClick={() => {}}
163+
stages={[]}
161164
/>
162165
</PreferencesProvider>
163166
);
@@ -195,6 +198,7 @@ describe('PipelineActions', function () {
195198
onUpdateView={() => {}}
196199
onCollectionScanInsightActionButtonClick={() => {}}
197200
onShowAIInputClick={() => {}}
201+
stages={[]}
198202
/>
199203
);
200204
});

packages/compass-aggregations/src/components/pipeline-toolbar/pipeline-header/pipeline-actions.tsx

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import {
2727
useIsAIFeatureEnabled,
2828
} from 'compass-preferences-model/provider';
2929
import { showInput as showAIInput } from '../../../modules/pipeline-builder/pipeline-ai';
30+
import { useAssistantActions } from '@mongodb-js/compass-assistant';
3031

3132
const containerStyles = css({
3233
display: 'flex',
@@ -59,6 +60,8 @@ type PipelineActionsProps = {
5960

6061
showCollectionScanInsight?: boolean;
6162
onCollectionScanInsightActionButtonClick: () => void;
63+
64+
stages: string[];
6265
};
6366

6467
export const PipelineActions: React.FunctionComponent<PipelineActionsProps> = ({
@@ -80,12 +83,14 @@ export const PipelineActions: React.FunctionComponent<PipelineActionsProps> = ({
8083
onExplainAggregation,
8184
showCollectionScanInsight,
8285
onCollectionScanInsightActionButtonClick,
86+
stages,
8387
}) => {
8488
const enableAggregationBuilderExtraOptions = usePreference(
8589
'enableAggregationBuilderExtraOptions'
8690
);
8791
const showInsights = usePreference('showInsights');
8892
const isAIFeatureEnabled = useIsAIFeatureEnabled();
93+
const { tellMoreAboutInsight } = useAssistantActions();
8994

9095
return (
9196
<div className={containerStyles}>
@@ -99,6 +104,14 @@ export const PipelineActions: React.FunctionComponent<PipelineActionsProps> = ({
99104
...PerformanceSignals.get('aggregation-executed-without-index'),
100105
onPrimaryActionButtonClick:
101106
onCollectionScanInsightActionButtonClick,
107+
onAssistantButtonClick:
108+
tellMoreAboutInsight &&
109+
(() => {
110+
tellMoreAboutInsight({
111+
id: 'aggregation-executed-without-index',
112+
stages,
113+
});
114+
}),
102115
}}
103116
></SignalPopover>
104117
</div>
@@ -185,6 +198,7 @@ const mapState = (state: RootState) => {
185198
isUpdateViewButtonDisabled:
186199
!state.isModified || hasSyntaxErrors || isAIFetching,
187200
showCollectionScanInsight: state.insights.isCollectionScan,
201+
stages: resultPipeline,
188202
};
189203
};
190204

packages/compass-assistant/src/assistant-chat.spec.tsx

Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,15 @@ describe('AssistantChat', function () {
2929
},
3030
];
3131

32-
function renderWithChat(messages: AssistantMessage[]) {
33-
const chat = createMockChat({ messages });
32+
function renderWithChat(
33+
messages: AssistantMessage[],
34+
{
35+
status,
36+
}: {
37+
status?: 'submitted' | 'streaming';
38+
} = {}
39+
) {
40+
const chat = createMockChat({ messages, status });
3441
const result = render(<AssistantChat chat={chat} />);
3542
return {
3643
result,
@@ -63,6 +70,34 @@ describe('AssistantChat', function () {
6370
expect(inputField.value).to.equal('What is MongoDB?');
6471
});
6572

73+
it('displays the disclaimer and welcome text', function () {
74+
renderWithChat([]);
75+
expect(screen.getByText(/This feature is powered by generative AI/)).to
76+
.exist;
77+
expect(screen.getByText(/Please review the outputs carefully/)).to.exist;
78+
});
79+
80+
it('displays the welcome text when there are no messages', function () {
81+
renderWithChat([]);
82+
expect(screen.getByText(/Welcome to your MongoDB Assistant./)).to.exist;
83+
});
84+
85+
it('does not display the welcome text when there are messages', function () {
86+
renderWithChat(mockMessages);
87+
expect(screen.queryByText(/Welcome to your MongoDB Assistant./)).to.not
88+
.exist;
89+
});
90+
91+
it('displays loading state when chat status is submitted', function () {
92+
renderWithChat([], { status: 'submitted' });
93+
expect(screen.getByText(/MongoDB Assistant is thinking/)).to.exist;
94+
});
95+
96+
it('does not display loading in all other cases', function () {
97+
renderWithChat(mockMessages, { status: 'streaming' });
98+
expect(screen.queryByText(/MongoDB Assistant is thinking/)).to.not.exist;
99+
});
100+
66101
it('send button is disabled when input is empty', function () {
67102
renderWithChat([]);
68103

packages/compass-assistant/src/assistant-chat.tsx

Lines changed: 31 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,21 @@ import {
1616
fontFamilies,
1717
palette,
1818
useDarkMode,
19+
LgChatChatDisclaimer,
20+
Link,
1921
} from '@mongodb-js/compass-components';
2022
import { useTelemetry } from '@mongodb-js/compass-telemetry/provider';
2123

24+
const { DisclaimerText } = LgChatChatDisclaimer;
2225
const { ChatWindow } = LgChatChatWindow;
2326
const { LeafyGreenChatProvider, Variant } = LgChatLeafygreenChatProvider;
2427
const { Message } = LgChatMessage;
2528
const { MessageFeed } = LgChatMessageFeed;
2629
const { MessageActions } = LgChatMessageActions;
2730
const { InputBar } = LgChatInputBar;
2831

32+
const GEN_AI_FAQ_LINK = 'https://www.mongodb.com/docs/generative-ai-faq/';
33+
2934
interface AssistantChatProps {
3035
chat: Chat<AssistantMessage>;
3136
}
@@ -54,6 +59,9 @@ const headerStyleLightModeFixes = css({
5459

5560
// TODO(COMPASS-9751): These are temporary patches to make the Assistant chat take the entire
5661
// width and height of the drawer since Leafygreen doesn't support this yet.
62+
const inputBarFixesStyles = css({
63+
marginBottom: -spacing[400],
64+
});
5765
const assistantChatFixesStyles = css({
5866
// Negative margin to patch the padding of the drawer.
5967
marginTop: -spacing[400],
@@ -95,6 +103,9 @@ const messageFeedFixesStyles = css({ height: '100%' });
95103
const chatWindowFixesStyles = css({
96104
height: '100%',
97105
});
106+
const welcomeMessageStyles = css({
107+
padding: spacing[400],
108+
});
98109

99110
function makeErrorMessage(message: string) {
100111
message = message || 'An error occurred';
@@ -191,6 +202,17 @@ export const AssistantChat: React.FunctionComponent<AssistantChatProps> = ({
191202
data-testid="assistant-chat-messages"
192203
className={messageFeedFixesStyles}
193204
>
205+
<DisclaimerText>
206+
This feature is powered by generative AI. See our{' '}
207+
<Link
208+
hideExternalIcon={false}
209+
href={GEN_AI_FAQ_LINK}
210+
target="_blank"
211+
>
212+
FAQ
213+
</Link>{' '}
214+
for more information. Please review the outputs carefully.
215+
</DisclaimerText>
194216
{lgMessages.map((messageFields) => (
195217
<Message
196218
key={messageFields.id}
@@ -206,13 +228,6 @@ export const AssistantChat: React.FunctionComponent<AssistantChatProps> = ({
206228
)}
207229
</Message>
208230
))}
209-
{status === 'submitted' && (
210-
<Message
211-
id="loading"
212-
messageBody="Thinking..."
213-
isSender={false}
214-
/>
215-
)}
216231
</MessageFeed>
217232
{error && (
218233
<div className={errorBannerWrapperStyles}>
@@ -221,9 +236,18 @@ export const AssistantChat: React.FunctionComponent<AssistantChatProps> = ({
221236
</Banner>
222237
</div>
223238
)}
239+
{lgMessages.length === 0 && (
240+
<div className={welcomeMessageStyles}>
241+
<h4>Welcome to your MongoDB Assistant.</h4>
242+
Ask any question about MongoDB to receive expert guidance and
243+
documentation right in your window.
244+
</div>
245+
)}
224246
<InputBar
225247
data-testid="assistant-chat-input"
226248
onMessageSend={handleMessageSend}
249+
className={inputBarFixesStyles}
250+
state={status === 'submitted' ? 'loading' : undefined}
227251
textareaProps={{
228252
placeholder: 'Ask MongoDB Assistant a question',
229253
}}

0 commit comments

Comments
 (0)