From 969bca8e78713316eb71ee736ff7232148fc58ca Mon Sep 17 00:00:00 2001 From: Le Roux Bodenstein Date: Tue, 12 Aug 2025 14:00:13 +0100 Subject: [PATCH 1/4] Don't require Atlas login, use the unauthenticated NLQ endpoints. --- .../src/atlas-ai-service.spec.ts | 7 ------- .../src/atlas-ai-service.ts | 19 +++++-------------- .../src/feature-flags.ts | 8 -------- 3 files changed, 5 insertions(+), 29 deletions(-) diff --git a/packages/compass-generative-ai/src/atlas-ai-service.spec.ts b/packages/compass-generative-ai/src/atlas-ai-service.spec.ts index 193a437acff..be807527b82 100644 --- a/packages/compass-generative-ai/src/atlas-ai-service.spec.ts +++ b/packages/compass-generative-ai/src/atlas-ai-service.spec.ts @@ -327,13 +327,6 @@ describe('AtlasAiService', function () { // Reset preferences await preferences.savePreferences({ optInGenAIFeatures: false, - enableUnauthenticatedGenAI: true, - }); - }); - - afterEach(async function () { - await preferences.savePreferences({ - enableUnauthenticatedGenAI: false, }); }); diff --git a/packages/compass-generative-ai/src/atlas-ai-service.ts b/packages/compass-generative-ai/src/atlas-ai-service.ts index 8c5a39b1aa1..c1270cf2b4a 100644 --- a/packages/compass-generative-ai/src/atlas-ai-service.ts +++ b/packages/compass-generative-ai/src/atlas-ai-service.ts @@ -11,7 +11,6 @@ import type { Logger } from '@mongodb-js/compass-logging'; import { EJSON } from 'bson'; import { getStore } from './store/atlas-ai-store'; import { optIntoGenAIWithModalPrompt } from './store/atlas-optin-reducer'; -import { signIntoAtlasWithModalPrompt } from './store/atlas-signin-reducer'; type GenerativeAiInput = { userInput: string; @@ -197,9 +196,11 @@ const aiURLConfig = { // There are two different sets of endpoints we use for our requests. // Down the line we'd like to only use the admin api, however, // we cannot currently call that from the Atlas UI. Pending CLOUDP-251201 + // NOTE: The unauthenticated endpoints are also rate limited by IP address + // rather than by logged in user. 'admin-api': { - aggregation: 'ai/api/v1/mql-aggregation', - query: 'ai/api/v1/mql-query', + aggregation: 'unauth/ai/api/v1/mql-aggregation', + query: 'unauth/ai/api/v1/mql-query', }, cloud: { aggregation: (groupId: string) => `ai/v1/groups/${groupId}/mql-aggregation`, @@ -277,17 +278,7 @@ export class AtlasAiService { } async ensureAiFeatureAccess({ signal }: { signal?: AbortSignal } = {}) { - if (this.preferences.getPreferences().enableUnauthenticatedGenAI) { - return getStore().dispatch(optIntoGenAIWithModalPrompt({ signal })); - } - - // When the ai feature is attempted to be opened we make sure - // the user is signed into Atlas and opted in. - - if (this.apiURLPreset === 'cloud') { - return getStore().dispatch(optIntoGenAIWithModalPrompt({ signal })); - } - return getStore().dispatch(signIntoAtlasWithModalPrompt({ signal })); + return getStore().dispatch(optIntoGenAIWithModalPrompt({ signal })); } private getQueryOrAggregationFromUserInput = async ( diff --git a/packages/compass-preferences-model/src/feature-flags.ts b/packages/compass-preferences-model/src/feature-flags.ts index b45be8e0e61..ca4d0fe0b2d 100644 --- a/packages/compass-preferences-model/src/feature-flags.ts +++ b/packages/compass-preferences-model/src/feature-flags.ts @@ -28,7 +28,6 @@ export type FeatureFlags = { showIndexesGuidanceVariant: boolean; enableContextMenus: boolean; enableSearchActivationProgramP1: boolean; - enableUnauthenticatedGenAI: boolean; }; export const featureFlags: Required<{ @@ -151,13 +150,6 @@ export const featureFlags: Required<{ }, }, - enableUnauthenticatedGenAI: { - stage: 'development', - description: { - short: 'Enable GenAI for unauthenticated users', - }, - }, - /** * Feature flag for CLOUDP-308952. */ From 9c28ce63047dd3794f309775e3b7a10751c92e0d Mon Sep 17 00:00:00 2001 From: Le Roux Bodenstein Date: Tue, 12 Aug 2025 16:15:00 +0100 Subject: [PATCH 2/4] released, then --- packages/compass-preferences-model/src/feature-flags.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/packages/compass-preferences-model/src/feature-flags.ts b/packages/compass-preferences-model/src/feature-flags.ts index ca4d0fe0b2d..864bc21eba1 100644 --- a/packages/compass-preferences-model/src/feature-flags.ts +++ b/packages/compass-preferences-model/src/feature-flags.ts @@ -28,6 +28,7 @@ export type FeatureFlags = { showIndexesGuidanceVariant: boolean; enableContextMenus: boolean; enableSearchActivationProgramP1: boolean; + enableUnauthenticatedGenAI: boolean; }; export const featureFlags: Required<{ @@ -150,6 +151,13 @@ export const featureFlags: Required<{ }, }, + enableUnauthenticatedGenAI: { + stage: 'released', + description: { + short: 'Enable GenAI for unauthenticated users', + }, + }, + /** * Feature flag for CLOUDP-308952. */ From 146e5dfadcd580520c84eb989fffeb67006cf9e4 Mon Sep 17 00:00:00 2001 From: Le Roux Bodenstein Date: Tue, 12 Aug 2025 16:40:24 +0100 Subject: [PATCH 3/4] update expected endpoints in tests --- packages/compass-generative-ai/src/atlas-ai-service.spec.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/compass-generative-ai/src/atlas-ai-service.spec.ts b/packages/compass-generative-ai/src/atlas-ai-service.spec.ts index be807527b82..ed685a486a7 100644 --- a/packages/compass-generative-ai/src/atlas-ai-service.spec.ts +++ b/packages/compass-generative-ai/src/atlas-ai-service.spec.ts @@ -82,8 +82,8 @@ describe('AtlasAiService', function () { { apiURLPreset: 'admin-api', expectedEndpoints: { - 'mql-aggregation': `http://example.com/ai/api/v1/mql-aggregation?request_id=abc`, - 'mql-query': `http://example.com/ai/api/v1/mql-query?request_id=abc`, + 'mql-aggregation': `http://example.com/unauth/ai/api/v1/mql-aggregation?request_id=abc`, + 'mql-query': `http://example.com/unauth/ai/api/v1/mql-query?request_id=abc`, }, }, { From 0641bedd0b0140eac0f069a21996f260fc4bfa36 Mon Sep 17 00:00:00 2001 From: Le Roux Bodenstein Date: Tue, 12 Aug 2025 17:47:12 +0100 Subject: [PATCH 4/4] skip the atlas login tests for now --- packages/compass-e2e-tests/tests/atlas-login.test.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/packages/compass-e2e-tests/tests/atlas-login.test.ts b/packages/compass-e2e-tests/tests/atlas-login.test.ts index 0983a993503..f1cef57eb37 100644 --- a/packages/compass-e2e-tests/tests/atlas-login.test.ts +++ b/packages/compass-e2e-tests/tests/atlas-login.test.ts @@ -36,7 +36,8 @@ function getTestBrowserShellCommand() { )}`; } -describe('Atlas Login', function () { +// TODO: remove these when we remove atlas login +describe.skip('Atlas Login', function () { let compass: Compass; let browser: CompassBrowser; let oidcMockProvider: OIDCMockProvider; @@ -281,7 +282,8 @@ describe('Atlas Login', function () { ); }); - it('should not show AI input if sign in flow was not finished', async function () { + // TODO: remove once we remove atlas login + it.skip('should not show AI input if sign in flow was not finished', async function () { getTokenPayload = () => { return new Promise(() => {}); }; @@ -314,7 +316,8 @@ describe('Atlas Login', function () { ); }); - it('should not show AI input if sign in flow was not finished', async function () { + // TODO: remove once we remove atlas login + it.skip('should not show AI input if sign in flow was not finished', async function () { getTokenPayload = () => { return new Promise(() => {}); };