Skip to content

Commit 2227552

Browse files
Merge remote-tracking branch 'origin/main' into beta-releases
2 parents dfbb8b2 + d1c1078 commit 2227552

File tree

60 files changed

+1816
-900
lines changed

Some content is hidden

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

60 files changed

+1816
-900
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 Sun Aug 31 2025.
2+
This document was automatically generated on Mon Sep 01 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 Sun, Aug 31, 2025
9+
Generated on Mon, Sep 1, 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: 6 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/compass-assistant-provider.tsx

Lines changed: 37 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,16 @@ import {
99
import { atlasServiceLocator } from '@mongodb-js/atlas-service/provider';
1010
import { DocsProviderTransport } from './docs-provider-transport';
1111
import { useDrawerActions } from '@mongodb-js/compass-components';
12-
import { buildConnectionErrorPrompt, buildExplainPlanPrompt } from './prompts';
12+
import {
13+
buildConnectionErrorPrompt,
14+
buildExplainPlanPrompt,
15+
buildProactiveInsightsPrompt,
16+
type EntryPointMessage,
17+
type ProactiveInsightsContext,
18+
} from './prompts';
1319
import { usePreference } from 'compass-preferences-model/provider';
1420
import { createLoggerLocator } from '@mongodb-js/compass-logging/provider';
1521
import type { ConnectionInfo } from '@mongodb-js/connection-info';
16-
import { redactConnectionString } from 'mongodb-connection-string-url';
1722
import { useTelemetry } from '@mongodb-js/compass-telemetry/provider';
1823

1924
export const ASSISTANT_DRAWER_ID = 'compass-assistant-drawer';
@@ -47,11 +52,13 @@ type AssistantActionsContextType = {
4752
error: Error;
4853
}) => void;
4954
clearChat: () => void;
55+
tellMoreAboutInsight: (context: ProactiveInsightsContext) => void;
5056
};
5157
export const AssistantActionsContext =
5258
createContext<AssistantActionsContextType>({
5359
interpretExplainPlan: () => {},
5460
interpretConnectionError: () => {},
61+
tellMoreAboutInsight: () => {},
5562
clearChat: () => {},
5663
});
5764

@@ -89,53 +96,41 @@ export const AssistantProvider: React.FunctionComponent<
8996
chat: Chat<AssistantMessage>;
9097
}>
9198
> = ({ chat, children }) => {
99+
const { openDrawer } = useDrawerActions();
92100
const track = useTelemetry();
93-
const assistantActionsContext = useRef<AssistantActionsContextType>({
94-
interpretExplainPlan: ({ explainPlan }) => {
101+
const createEntryPointHandler = useRef(function <T>(
102+
entryPointName:
103+
| 'explain plan'
104+
| 'performance insights'
105+
| 'connection error',
106+
builder: (props: T) => EntryPointMessage
107+
) {
108+
return (props: T) => {
95109
openDrawer(ASSISTANT_DRAWER_ID);
96-
const { prompt, displayText } = buildExplainPlanPrompt({
97-
explainPlan,
98-
});
99-
void chat.sendMessage(
100-
{
101-
text: prompt,
102-
metadata: {
103-
displayText,
104-
},
105-
},
106-
{}
107-
);
110+
const { prompt, displayText } = builder(props);
111+
void chat.sendMessage({ text: prompt, metadata: { displayText } }, {});
108112
track('Assistant Entry Point Used', {
109-
source: 'explain plan',
113+
source: entryPointName,
110114
});
111-
},
112-
interpretConnectionError: ({ connectionInfo, error }) => {
113-
openDrawer(ASSISTANT_DRAWER_ID);
114-
115-
const connectionString = redactConnectionString(
116-
connectionInfo.connectionOptions.connectionString
117-
);
118-
const connectionError = error.toString();
119-
120-
const { prompt } = buildConnectionErrorPrompt({
121-
connectionString,
122-
connectionError,
123-
});
124-
void chat.sendMessage(
125-
{
126-
text: prompt,
127-
},
128-
{}
129-
);
130-
track('Assistant Entry Point Used', {
131-
source: 'connection error',
132-
});
133-
},
115+
};
116+
});
117+
const assistantActionsContext = useRef<AssistantActionsContextType>({
118+
interpretExplainPlan: createEntryPointHandler.current(
119+
'explain plan',
120+
buildExplainPlanPrompt
121+
),
122+
interpretConnectionError: createEntryPointHandler.current(
123+
'connection error',
124+
buildConnectionErrorPrompt
125+
),
126+
tellMoreAboutInsight: createEntryPointHandler.current(
127+
'performance insights',
128+
buildProactiveInsightsPrompt
129+
),
134130
clearChat: () => {
135131
chat.messages = [];
136132
},
137133
});
138-
const { openDrawer } = useDrawerActions();
139134

140135
return (
141136
<AssistantContext.Provider value={chat}>
@@ -165,7 +160,7 @@ export const CompassAssistantProvider = registerCompassPlugin(
165160
transport: new DocsProviderTransport({
166161
baseUrl: atlasService.assistantApiEndpoint(),
167162
}),
168-
onError: (err: any) => {
163+
onError: (err) => {
169164
logger.log.error(
170165
logger.mongoLogId(1_001_000_370),
171166
'Assistant',

packages/compass-assistant/src/index.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@ export {
55
compassAssistantServiceLocator,
66
} from './compass-assistant-provider';
77
export type { CompassAssistantService } from './compass-assistant-provider';
8+
export type { ProactiveInsightsContext, EntryPointMessage } from './prompts';

0 commit comments

Comments
 (0)