Skip to content

Commit d55c864

Browse files
authored
chore(atlas-service): update atlas service sign in naming COMPASS-8493 (#6544)
1 parent fc2fb65 commit d55c864

File tree

7 files changed

+25
-23
lines changed

7 files changed

+25
-23
lines changed

packages/atlas-service/src/atlas-auth-service.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import type { AtlasUserInfo } from './util';
44
export type ArgsWithSignal<T = Record<string, unknown>> = T & {
55
signal?: AbortSignal;
66
};
7-
export type SignInPrompt = 'none';
87

98
type AtlasAuthServiceEvents = {
109
'signed-in': [];
@@ -19,7 +18,7 @@ type AtlasAuthEventListener<T extends AtlasAuthEventNames> = (
1918

2019
export abstract class AtlasAuthService extends EventEmitter {
2120
abstract signIn(
22-
opts?: ArgsWithSignal<{ promptType?: SignInPrompt }>
21+
opts?: ArgsWithSignal<{ mainProcessSignIn?: boolean }>
2322
): Promise<AtlasUserInfo>;
2423
abstract signOut(): Promise<void>;
2524
abstract isAuthenticated(opts?: ArgsWithSignal): Promise<boolean>;

packages/atlas-service/src/compass-atlas-auth-service.spec.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,10 @@ describe('CompassAtlasAuthService', function () {
4343
const atlasAuthService = getAtlasAuthService({
4444
signIn: signInStub,
4545
});
46-
await atlasAuthService.signIn({ signal: c.signal });
46+
await atlasAuthService.signIn({
47+
mainProcessSignIn: true,
48+
signal: c.signal,
49+
});
4750
expect(signInStub.calledOnce).to.be.true;
4851
expect(signInStub.firstCall.firstArg).to.deep.equal({ signal: c.signal });
4952
});

packages/atlas-service/src/compass-atlas-auth-service.ts

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import { ipcRenderer } from 'hadron-ipc';
22
import type { CompassAuthService as AtlasServiceMain } from './main';
3-
import { signInWithoutPrompt } from './store/atlas-signin-reducer';
3+
import { performSignInAttempt } from './store/atlas-signin-reducer';
44
import { getStore } from './store/atlas-signin-store';
55
import { AtlasAuthService } from './atlas-auth-service';
6-
import type { ArgsWithSignal, SignInPrompt } from './atlas-auth-service';
6+
import type { ArgsWithSignal } from './atlas-auth-service';
77

88
export class CompassAtlasAuthService extends AtlasAuthService {
99
private _ipc = ipcRenderer?.createInvoke<
@@ -37,15 +37,14 @@ export class CompassAtlasAuthService extends AtlasAuthService {
3737
return this.ipc.signOut();
3838
}
3939
signIn({
40-
promptType,
40+
mainProcessSignIn,
4141
signal,
42-
}: ArgsWithSignal<{ promptType?: SignInPrompt }> = {}) {
43-
switch (promptType) {
44-
case 'none':
45-
return getStore().dispatch(signInWithoutPrompt({ signal }));
46-
default:
47-
return this.ipc.signIn({ signal });
42+
}: ArgsWithSignal<{ mainProcessSignIn?: boolean }> = {}) {
43+
if (mainProcessSignIn) {
44+
return this.ipc.signIn({ signal });
4845
}
46+
47+
return getStore().dispatch(performSignInAttempt({ signal }));
4948
}
5049
getUserInfo(opts?: ArgsWithSignal) {
5150
return this.ipc.getUserInfo(opts);

packages/atlas-service/src/store/atlas-signin-reducer.spec.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import {
55
cancelSignIn,
66
attemptId,
77
AttemptStateMap,
8-
signInWithoutPrompt,
8+
performSignInAttempt,
99
} from './atlas-signin-reducer';
1010
import { expect } from 'chai';
1111
import { configureStore } from './atlas-signin-store';
@@ -174,7 +174,7 @@ describe('atlasSignInReducer', function () {
174174
atlasAuthService: mockAtlasService as any,
175175
});
176176

177-
void store.dispatch(signInWithoutPrompt()).catch(() => {});
177+
void store.dispatch(performSignInAttempt()).catch(() => {});
178178

179179
await Promise.all([
180180
store.dispatch(signIn()),
@@ -184,7 +184,7 @@ describe('atlasSignInReducer', function () {
184184
});
185185
});
186186

187-
describe('signInWithoutPrompt', function () {
187+
describe('performSignInAttempt', function () {
188188
it('should resolve when sign in flow finishes', async function () {
189189
const mockAtlasService = {
190190
isAuthenticated: sandbox.stub().resolves(false),
@@ -195,7 +195,7 @@ describe('atlasSignInReducer', function () {
195195
const store = configureStore({
196196
atlasAuthService: mockAtlasService as any,
197197
});
198-
await store.dispatch(signInWithoutPrompt());
198+
await store.dispatch(performSignInAttempt());
199199
expect(store.getState()).to.have.property('state', 'success');
200200
});
201201

@@ -210,8 +210,8 @@ describe('atlasSignInReducer', function () {
210210
atlasAuthService: mockAtlasService as any,
211211
});
212212
try {
213-
await store.dispatch(signInWithoutPrompt());
214-
expect.fail('Expected signInWithoutPrompt action to throw');
213+
await store.dispatch(performSignInAttempt());
214+
expect.fail('Expected performSignInAttempt action to throw');
215215
} catch (err) {
216216
expect(err).to.have.property('message', 'Sign in failed');
217217
}
@@ -237,7 +237,7 @@ describe('atlasSignInReducer', function () {
237237
});
238238
const c = new AbortController();
239239
const signInPromise = store.dispatch(
240-
signInWithoutPrompt({ signal: c.signal })
240+
performSignInAttempt({ signal: c.signal })
241241
);
242242
c.abort(new Error('Aborted from outside'));
243243
try {

packages/atlas-service/src/store/atlas-signin-reducer.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,7 @@ const startAttempt = (fn: () => void): AtlasSignInThunkAction<AttemptState> => {
308308
};
309309
};
310310

311-
export const signInWithoutPrompt = ({
311+
export const performSignInAttempt = ({
312312
signal,
313313
}: { signal?: AbortSignal } = {}): AtlasSignInThunkAction<
314314
Promise<AtlasUserInfo>
@@ -348,7 +348,10 @@ export const signIn = (): AtlasSignInThunkAction<Promise<void>> => {
348348
if (await atlasAuthService.isAuthenticated({ signal })) {
349349
userInfo = await atlasAuthService.getUserInfo({ signal });
350350
} else {
351-
userInfo = await atlasAuthService.signIn({ signal });
351+
userInfo = await atlasAuthService.signIn({
352+
mainProcessSignIn: true,
353+
signal,
354+
});
352355
}
353356
openToast('atlas-sign-in-success', {
354357
variant: 'success',

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,6 @@ export const signIn = (): GenAIAtlasSignInThunkAction<Promise<void>> => {
291291

292292
await atlasAuthService.signIn({
293293
signal,
294-
promptType: 'none',
295294
});
296295
dispatch(atlasServiceSignedIn());
297296
resolve();

packages/compass-settings/src/stores/atlas-login.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,6 @@ export const signIn = (): SettingsThunkAction<Promise<void>> => {
171171
});
172172
const userInfo = await atlasAuthService.signIn({
173173
signal,
174-
promptType: 'none',
175174
});
176175
dispatch({ type: AtlasLoginSettingsActionTypes.SignInSuccess, userInfo });
177176
} catch (err) {

0 commit comments

Comments
 (0)