@@ -47,6 +47,7 @@ import type { GKCheckInResponse } from '../checkin';
47
47
import { getSubscriptionFromCheckIn } from '../checkin' ;
48
48
import type { ServerConnection } from '../serverConnection' ;
49
49
import { ensurePlusFeaturesEnabled } from '../utils' ;
50
+ import { AuthenticationContext } from './authenticationConnection' ;
50
51
import { authenticationProviderId , authenticationProviderScopes } from './authenticationProvider' ;
51
52
import type { Organization } from './organization' ;
52
53
import type { Subscription } from './subscription' ;
@@ -361,7 +362,31 @@ export class SubscriptionService implements Disposable {
361
362
) ;
362
363
}
363
364
364
- return this . loginCore ( { signUp : signUp , source : source } ) ;
365
+ let context : AuthenticationContext | undefined ;
366
+ switch ( source ?. source ) {
367
+ case 'graph' :
368
+ context = AuthenticationContext . Graph ;
369
+ break ;
370
+ case 'timeline' :
371
+ context = AuthenticationContext . VisualFileHistory ;
372
+ break ;
373
+ case 'git-commands' :
374
+ if (
375
+ source . detail != null &&
376
+ typeof source . detail !== 'string' &&
377
+ ( source . detail [ 'action' ] === 'worktree' ||
378
+ source . detail [ 'step.title' ] === 'Create Worktree' ||
379
+ source . detail [ 'step.title' ] === 'Open Worktree' )
380
+ ) {
381
+ context = AuthenticationContext . Worktrees ;
382
+ }
383
+ break ;
384
+ case 'worktrees' :
385
+ context = AuthenticationContext . Worktrees ;
386
+ break ;
387
+ }
388
+
389
+ return this . loginCore ( { signUp : signUp , source : source , context : context } ) ;
365
390
}
366
391
367
392
async loginWithCode ( authentication : { code : string ; state ?: string } , source ?: Source ) : Promise < boolean > {
@@ -382,6 +407,7 @@ export class SubscriptionService implements Disposable {
382
407
signUp ?: boolean ;
383
408
source ?: Source ;
384
409
signIn ?: { code : string ; state ?: string } ;
410
+ context ?: AuthenticationContext ;
385
411
} ) : Promise < boolean > {
386
412
// Abort any waiting authentication to ensure we can start a new flow
387
413
await this . container . accountAuthentication . abort ( ) ;
@@ -390,6 +416,7 @@ export class SubscriptionService implements Disposable {
390
416
const session = await this . ensureSession ( true , {
391
417
signIn : options ?. signIn ,
392
418
signUp : options ?. signUp ,
419
+ context : options ?. context ,
393
420
} ) ;
394
421
const loggedIn = Boolean ( session ) ;
395
422
if ( loggedIn ) {
@@ -941,7 +968,12 @@ export class SubscriptionService implements Disposable {
941
968
@debug ( )
942
969
private async ensureSession (
943
970
createIfNeeded : boolean ,
944
- options ?: { force ?: boolean ; signUp ?: boolean ; signIn ?: { code : string ; state ?: string } } ,
971
+ options ?: {
972
+ force ?: boolean ;
973
+ signUp ?: boolean ;
974
+ signIn ?: { code : string ; state ?: string } ;
975
+ context ?: AuthenticationContext ;
976
+ } ,
945
977
) : Promise < AuthenticationSession | undefined > {
946
978
if ( this . _sessionPromise != null ) {
947
979
void ( await this . _sessionPromise ) ;
@@ -954,6 +986,7 @@ export class SubscriptionService implements Disposable {
954
986
this . _sessionPromise = this . getOrCreateSession ( createIfNeeded , {
955
987
signUp : options ?. signUp ,
956
988
signIn : options ?. signIn ,
989
+ context : options ?. context ,
957
990
} ) . then (
958
991
s => {
959
992
this . _session = s ;
@@ -975,7 +1008,7 @@ export class SubscriptionService implements Disposable {
975
1008
@debug ( )
976
1009
private async getOrCreateSession (
977
1010
createIfNeeded : boolean ,
978
- options ?: { signUp ?: boolean ; signIn ?: { code : string ; state ?: string } } ,
1011
+ options ?: { signUp ?: boolean ; signIn ?: { code : string ; state ?: string } ; context ?: AuthenticationContext } ,
979
1012
) : Promise < AuthenticationSession | null > {
980
1013
const scope = getLogScope ( ) ;
981
1014
0 commit comments