@@ -1256,7 +1256,7 @@ export class GitpodServerImpl implements GitpodServerWithTracing, Disposable {
1256
1256
1257
1257
public async getSuggestedContextURLs ( ctx : TraceContext ) : Promise < string [ ] > {
1258
1258
const user = this . checkAndBlockUser ( "getSuggestedContextURLs" ) ;
1259
- const suggestions : Array < { url : string ; lastUse ?: string } > = [ ] ;
1259
+ const suggestions : Array < { url : string ; lastUse ?: string ; priority : number } > = [ ] ;
1260
1260
const logCtx : LogContext = { userId : user . id } ;
1261
1261
1262
1262
// Fetch all data sources in parallel for maximum speed (don't await in this scope before `Promise.allSettled(promises)` below!)
@@ -1266,7 +1266,7 @@ export class GitpodServerImpl implements GitpodServerWithTracing, Disposable {
1266
1266
promises . push (
1267
1267
this . getFeaturedRepositories ( ctx )
1268
1268
. then ( ( exampleRepos ) => {
1269
- exampleRepos . forEach ( ( r ) => suggestions . push ( { url : r . url } ) ) ;
1269
+ exampleRepos . forEach ( ( r ) => suggestions . push ( { url : r . url , priority : 0 } ) ) ;
1270
1270
} )
1271
1271
. catch ( ( error ) => {
1272
1272
log . error ( logCtx , "Could not get example repositories" , error ) ;
@@ -1281,7 +1281,9 @@ export class GitpodServerImpl implements GitpodServerWithTracing, Disposable {
1281
1281
authProviders . map ( async ( p ) => {
1282
1282
try {
1283
1283
const userRepos = await this . getProviderRepositoriesForUser ( ctx , { provider : p . host } ) ;
1284
- userRepos . forEach ( ( r ) => suggestions . push ( { url : r . cloneUrl . replace ( / \. g i t $ / , "" ) } ) ) ;
1284
+ userRepos . forEach ( ( r ) =>
1285
+ suggestions . push ( { url : r . cloneUrl . replace ( / \. g i t $ / , "" ) , priority : 5 } ) ,
1286
+ ) ;
1285
1287
} catch ( error ) {
1286
1288
log . debug ( logCtx , "Could not get user repositories from App for " + p . host , error ) ;
1287
1289
}
@@ -1307,7 +1309,9 @@ export class GitpodServerImpl implements GitpodServerWithTracing, Disposable {
1307
1309
return ;
1308
1310
}
1309
1311
const userRepos = await services . repositoryProvider . getUserRepos ( user ) ;
1310
- userRepos . forEach ( ( r ) => suggestions . push ( { url : r . replace ( / \. g i t $ / , "" ) } ) ) ;
1312
+ userRepos . forEach ( ( r ) =>
1313
+ suggestions . push ( { url : r . replace ( / \. g i t $ / , "" ) , priority : 5 } ) ,
1314
+ ) ;
1311
1315
} catch ( error ) {
1312
1316
log . debug ( logCtx , "Could not get user repositories from host " + p . host , error ) ;
1313
1317
}
@@ -1329,7 +1333,7 @@ export class GitpodServerImpl implements GitpodServerWithTracing, Disposable {
1329
1333
const repoUrl = Workspace . getFullRepositoryUrl ( ws . workspace ) ;
1330
1334
if ( repoUrl ) {
1331
1335
const lastUse = WorkspaceInfo . lastActiveISODate ( ws ) ;
1332
- suggestions . push ( { url : repoUrl , lastUse } ) ;
1336
+ suggestions . push ( { url : repoUrl , lastUse, priority : 10 } ) ;
1333
1337
}
1334
1338
} ) ;
1335
1339
} )
@@ -1343,7 +1347,11 @@ export class GitpodServerImpl implements GitpodServerWithTracing, Disposable {
1343
1347
const uniqueURLs = new Set ( ) ;
1344
1348
return suggestions
1345
1349
. sort ( ( a , b ) => {
1346
- // Most recently used first
1350
+ // priority first
1351
+ if ( a . priority !== b . priority ) {
1352
+ return a . priority < b . priority ? 1 : - 1 ;
1353
+ }
1354
+ // Most recently used second
1347
1355
if ( b . lastUse || a . lastUse ) {
1348
1356
const la = a . lastUse || "" ;
1349
1357
const lb = b . lastUse || "" ;
0 commit comments