Skip to content

Commit ce2cccd

Browse files
fixing reducer type and entrypoint
1 parent 3803589 commit ce2cccd

File tree

4 files changed

+10
-18
lines changed

4 files changed

+10
-18
lines changed

packages/compass-generative-ai/src/store/atlas-ai-store.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ const reducer = combineReducers({
2323
optIn: optInReducer,
2424
});
2525

26+
export type RootState = ReturnType<typeof reducer>;
27+
2628
export type CompassGenerativeAIExtraArgs = {
2729
atlasAuthService: AtlasAuthService;
2830
atlasAiService: AtlasAiService;

packages/compass-generative-ai/src/store/atlas-optin-reducer.ts

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import type { ThunkAction } from 'redux-thunk';
33
import { throwIfAborted } from '@mongodb-js/compass-utils';
44
import type { AtlasAiService } from '../atlas-ai-service';
55
import type { PreferencesAccess } from 'compass-preferences-model';
6+
import type { RootState } from './atlas-ai-store';
67

78
function isAction<A extends AnyAction>(
89
action: AnyAction,
@@ -31,7 +32,7 @@ export type GenAIAtlasOptInThunkAction<
3132
A extends AnyAction = AnyAction
3233
> = ThunkAction<
3334
R,
34-
AtlasOptInState,
35+
RootState,
3536
{ atlasAiService: AtlasAiService; preferences: PreferencesAccess },
3637
A
3738
>;
@@ -199,7 +200,6 @@ const startAttempt = (
199200
fn: () => void
200201
): GenAIAtlasOptInThunkAction<AttemptState> => {
201202
return (dispatch, getState) => {
202-
// @ts-expect-error reducers were combined so these methods are nested one layer lower
203203
if (getState().optIn.attemptId) {
204204
throw new Error(
205205
"Can't start opt in with prompt while another opt in attempt is in progress"
@@ -231,7 +231,6 @@ export const optIntoGenAIWithModalPrompt = ({
231231
> => {
232232
return (dispatch, getState, { preferences }) => {
233233
// Nothing to do if we already opted in.
234-
// @ts-expect-error reducers were combined so these methods are nested one layer lower
235234
const { state } = getState().optIn;
236235
if (
237236
state === 'optin-success' ||
@@ -253,10 +252,9 @@ export const optIntoGenAIWithModalPrompt = ({
253252

254253
export const optIn = (): GenAIAtlasOptInThunkAction<Promise<void>> => {
255254
return async (dispatch, getState, { atlasAiService }) => {
256-
// @ts-expect-error reducers were combined so these methods are nested one layer lower
257255
if (['in-progress', 'optin-success'].includes(getState().optIn.state)) {
258256
return;
259-
} // @ts-expect-error reducers were combined so these methods are nested one layer lower
257+
}
260258
const { attemptId } = getState().optIn;
261259
if (attemptId === null) {
262260
return;
@@ -265,7 +263,6 @@ export const optIn = (): GenAIAtlasOptInThunkAction<Promise<void>> => {
265263
controller: { signal },
266264
resolve,
267265
reject,
268-
// @ts-expect-error reducers were combined so these methods are nested one layer lower
269266
} = getAttempt(getState().optIn.attemptId);
270267
dispatch({
271268
type: AtlasOptInActions.Start,
@@ -306,11 +303,9 @@ export const cancelOptIn = (reason?: any): GenAIAtlasOptInThunkAction<void> => {
306303
return (dispatch, getState) => {
307304
// Can't cancel opt in after the flow was finished indicated by current
308305
// attempt id being set to null.
309-
// @ts-expect-error reducers were combined so these methods are nested one layer lower
310306
if (getState().optIn.attemptId === null) {
311307
return;
312308
}
313-
// @ts-expect-error reducers were combined so these methods are nested one layer lower
314309
const attempt = getAttempt(getState().optIn.attemptId);
315310
attempt.controller.abort();
316311
attempt.reject(reason ?? attempt.controller.signal.reason);

packages/compass-generative-ai/src/store/atlas-signin-reducer.ts

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import type { Action, AnyAction, Reducer } from 'redux';
22
import type { ThunkAction } from 'redux-thunk';
33
import type { AtlasAuthService } from '@mongodb-js/atlas-service/provider';
44
import { throwIfAborted } from '@mongodb-js/compass-utils';
5+
import type { RootState } from './atlas-ai-store';
56

67
function isAction<A extends AnyAction>(
78
action: AnyAction,
@@ -32,7 +33,7 @@ export type AtlasSignInState = {
3233
export type GenAIAtlasSignInThunkAction<
3334
R,
3435
A extends AnyAction = AnyAction
35-
> = ThunkAction<R, AtlasSignInState, { atlasAuthService: AtlasAuthService }, A>;
36+
> = ThunkAction<R, RootState, { atlasAuthService: AtlasAuthService }, A>;
3637

3738
export const enum AtlasSignInActions {
3839
OpenSignInModal = 'compass-generative-ai/atlas-signin/OpenSignInModal',
@@ -227,7 +228,6 @@ const startAttempt = (
227228
fn: () => void
228229
): GenAIAtlasSignInThunkAction<AttemptState> => {
229230
return (dispatch, getState) => {
230-
// @ts-expect-error reducers were combined so these methods are nested one layer lower
231231
if (getState().signIn.attemptId) {
232232
throw new Error(
233233
"Can't start sign in with prompt while another sign in attempt is in progress"
@@ -258,7 +258,6 @@ export const signIntoAtlasWithModalPrompt = ({
258258
> => {
259259
return (dispatch, getState) => {
260260
// Nothing to do if we already signed in.
261-
// @ts-expect-error reducers were combined so these methods are nested one layer lower
262261
const { state } = getState().signIn;
263262
if (state === 'success') {
264263
return Promise.resolve();
@@ -277,11 +276,9 @@ export const signIntoAtlasWithModalPrompt = ({
277276

278277
export const signIn = (): GenAIAtlasSignInThunkAction<Promise<void>> => {
279278
return async (dispatch, getState, { atlasAuthService }) => {
280-
// @ts-expect-error reducers were combined so these methods are nested one layer lower
281279
if (['in-progress', 'authenticated'].includes(getState().signIn.state)) {
282280
return;
283281
}
284-
// @ts-expect-error reducers were combined so these methods are nested one layer lower
285282
const { attemptId } = getState().signIn;
286283
if (attemptId === null) {
287284
return;
@@ -290,7 +287,6 @@ export const signIn = (): GenAIAtlasSignInThunkAction<Promise<void>> => {
290287
controller: { signal },
291288
resolve,
292289
reject,
293-
// @ts-expect-error reducers were combined so these methods are nested one layer lower
294290
} = getAttempt(getState().signIn.attemptId);
295291
dispatch({
296292
type: AtlasSignInActions.Start,
@@ -337,10 +333,9 @@ export const cancelSignIn = (
337333
return (dispatch, getState) => {
338334
// Can't cancel sign in after the flow was finished indicated by current
339335
// attempt id being set to null
340-
// @ts-expect-error reducers were combined so these methods are nested one layer lower
341336
if (getState().signIn.attemptId === null) {
342337
return;
343-
} // @ts-expect-error reducers were combined so these methods are nested one layer lower
338+
}
344339
const attempt = getAttempt(getState().signIn.attemptId);
345340
attempt.controller.abort();
346341
attempt.reject(reason ?? attempt.controller.signal.reason);

packages/compass-web/src/entrypoint.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ const CompassWeb = ({
276276
enableMultipleConnectionSystem: true,
277277
enablePerformanceAdvisorBanner: true,
278278
cloudFeatureRolloutAccess: {
279-
GEN_AI_COMPASS: true,
279+
GEN_AI_COMPASS: false,
280280
},
281281
maximumNumberOfActiveConnections: 10,
282282
trackUsageStatistics: true,
@@ -371,8 +371,8 @@ const CompassWeb = ({
371371
}
372372
onOpenConnectViaModal={onOpenConnectViaModal}
373373
></CompassWorkspace>
374-
<CompassGenerativeAIPlugin />
375374
</WithConnectionsStore>
375+
<CompassGenerativeAIPlugin />
376376
</FieldStorePlugin>
377377
</CompassInstanceStorePlugin>
378378
</CompassConnections>

0 commit comments

Comments
 (0)