diff --git a/packages/compass-assistant/src/compass-assistant-provider.spec.tsx b/packages/compass-assistant/src/compass-assistant-provider.spec.tsx index 16c9abb9145..d4f3421b8f4 100644 --- a/packages/compass-assistant/src/compass-assistant-provider.spec.tsx +++ b/packages/compass-assistant/src/compass-assistant-provider.spec.tsx @@ -175,6 +175,24 @@ describe('useAssistantActions', function () { }, }); + expect(Object.keys(result.current)).to.have.length.greaterThan(0); + expect(result.current.interpretExplainPlan).to.be.a('function'); + expect(result.current.interpretConnectionError).to.be.a('function'); + expect(result.current.tellMoreAboutInsight).to.be.undefined; + }); + + it('returns actions when both AI features and assistant flag AND enablePerformanceInsightsEntrypoints are enabled', function () { + const { result } = renderHook(() => useAssistantActions(), { + wrapper: createWrapper(createMockChat({ messages: [] })), + preferences: { + enableAIAssistant: true, + enablePerformanceInsightsEntrypoints: true, + enableGenAIFeatures: true, + enableGenAIFeaturesAtlasOrg: true, + cloudFeatureRolloutAccess: { GEN_AI_COMPASS: true }, + }, + }); + expect(Object.keys(result.current)).to.have.length.greaterThan(0); expect(result.current.interpretExplainPlan).to.be.a('function'); expect(result.current.interpretConnectionError).to.be.a('function'); diff --git a/packages/compass-assistant/src/compass-assistant-provider.tsx b/packages/compass-assistant/src/compass-assistant-provider.tsx index bd9a7058346..696276bf65c 100644 --- a/packages/compass-assistant/src/compass-assistant-provider.tsx +++ b/packages/compass-assistant/src/compass-assistant-provider.tsx @@ -91,6 +91,10 @@ export function useAssistantActions(): AssistantActionsType { const actions = useContext(AssistantActionsContext); const isAIFeatureEnabled = useIsAIFeatureEnabled(); const isAssistantFlagEnabled = usePreference('enableAIAssistant'); + const isPerformanceInsightEntrypointsEnabled = usePreference( + 'enablePerformanceInsightsEntrypoints' + ); + if (!isAIFeatureEnabled || !isAssistantFlagEnabled) { return { getIsAssistantEnabled: () => false, @@ -106,7 +110,9 @@ export function useAssistantActions(): AssistantActionsType { return { interpretExplainPlan, interpretConnectionError, - tellMoreAboutInsight, + tellMoreAboutInsight: isPerformanceInsightEntrypointsEnabled + ? tellMoreAboutInsight + : undefined, getIsAssistantEnabled: () => true, }; } diff --git a/packages/compass-preferences-model/src/feature-flags.ts b/packages/compass-preferences-model/src/feature-flags.ts index 6f5a4aea9d4..1c084aac513 100644 --- a/packages/compass-preferences-model/src/feature-flags.ts +++ b/packages/compass-preferences-model/src/feature-flags.ts @@ -30,6 +30,7 @@ export type FeatureFlags = { enableSearchActivationProgramP1: boolean; enableUnauthenticatedGenAI: boolean; enableAIAssistant: boolean; + enablePerformanceInsightsEntrypoints: boolean; }; export const featureFlags: Required<{ @@ -178,4 +179,14 @@ export const featureFlags: Required<{ short: 'Enable AI Assistant', }, }, + + /* + * Feature flag for AI Assistant's performance insight entrypoints. + */ + enablePerformanceInsightsEntrypoints: { + stage: 'development', + description: { + short: 'Enable the performance insights AI Assistant entrypoints', + }, + }, };