From 693f2c060bdade8c4479a411a38223de1ff3af9c Mon Sep 17 00:00:00 2001 From: Steph Milovic Date: Thu, 24 Oct 2024 13:08:17 -0600 Subject: [PATCH 1/4] logs and getInitializedResources fixing --- .../conversations/create_conversation.ts | 2 + .../create_resource_installation_helper.ts | 40 +++++++++++-------- .../server/ai_assistant_service/index.ts | 5 +++ .../server/routes/helpers.ts | 2 + .../routes/prompts/bulk_actions_route.ts | 3 ++ .../routes/user_conversations/create_route.ts | 2 + .../public/assistant/provider.tsx | 8 ++++ 7 files changed, 46 insertions(+), 16 deletions(-) diff --git a/x-pack/plugins/elastic_assistant/server/ai_assistant_data_clients/conversations/create_conversation.ts b/x-pack/plugins/elastic_assistant/server/ai_assistant_data_clients/conversations/create_conversation.ts index b98b8a1f4cc27..aeed0f74ef9ee 100644 --- a/x-pack/plugins/elastic_assistant/server/ai_assistant_data_clients/conversations/create_conversation.ts +++ b/x-pack/plugins/elastic_assistant/server/ai_assistant_data_clients/conversations/create_conversation.ts @@ -43,6 +43,7 @@ export const createConversation = async ({ refresh: 'wait_for', }); + console.log('===> response', response); const createdConversation = await getConversation({ esClient, conversationIndex, @@ -50,6 +51,7 @@ export const createConversation = async ({ logger, user, }); + console.log('===> getConversation', getConversation); return createdConversation; } catch (err) { logger.error(`Error creating conversation: ${err} with title: ${conversation.title}`); diff --git a/x-pack/plugins/elastic_assistant/server/ai_assistant_service/create_resource_installation_helper.ts b/x-pack/plugins/elastic_assistant/server/ai_assistant_service/create_resource_installation_helper.ts index 39e0e69a8fc49..2290024cf219c 100644 --- a/x-pack/plugins/elastic_assistant/server/ai_assistant_service/create_resource_installation_helper.ts +++ b/x-pack/plugins/elastic_assistant/server/ai_assistant_service/create_resource_installation_helper.ts @@ -8,7 +8,7 @@ import { DEFAULT_NAMESPACE_STRING } from '@kbn/core-saved-objects-utils-server'; import { Logger } from '@kbn/core/server'; -export interface InitializationPromise { +export interface InitializationState { result: boolean; error?: string; } @@ -23,10 +23,10 @@ export interface ResourceInstallationHelper { add: (namespace?: string, timeoutMs?: number) => void; retry: ( namespace?: string, - initPromise?: Promise, + initPromise?: Promise, timeoutMs?: number ) => void; - getInitializedResources: (namespace: string) => Promise; + getInitializedResources: (namespace: string) => Promise; } /** @@ -42,30 +42,33 @@ export interface ResourceInstallationHelper { */ export function createResourceInstallationHelper( logger: Logger, - commonResourcesInitPromise: Promise, + commonResourcesInitPromise: Promise, installFn: (namespace: string, timeoutMs?: number) => Promise ): ResourceInstallationHelper { - let commonInitPromise: Promise = commonResourcesInitPromise; - const initializedResources: Map> = new Map(); + let commonInitPromise: Promise = commonResourcesInitPromise; + const initializedResources: Map> = new Map(); const lastRetry: Map = new Map(); const waitUntilResourcesInstalled = async ( namespace: string = DEFAULT_NAMESPACE_STRING, timeoutMs?: number - ): Promise => { + ): Promise => { try { const { result: commonInitResult, error: commonInitError } = await commonInitPromise; if (commonInitResult) { await installFn(namespace, timeoutMs); + console.log('===> installer case 1'); return successResult(); } else { logger.warn( `Common resources were not initialized, cannot initialize resources for ${namespace}` ); + console.log('===> installer case 2'); return errorResult(commonInitError); } } catch (err) { logger.error(`Error initializing resources ${namespace} - ${err.message}`); + console.log('===> installer case 3'); return errorResult(err.message); } }; @@ -81,7 +84,7 @@ export function createResourceInstallationHelper( }, retry: ( namespace: string = DEFAULT_NAMESPACE_STRING, - initPromise?: Promise, + initPromise?: Promise, timeoutMs?: number ) => { const key = namespace; @@ -109,19 +112,24 @@ export function createResourceInstallationHelper( ); } }, - getInitializedResources: async (namespace: string): Promise => { - const key = namespace; - return ( - initializedResources.has(key) - ? initializedResources.get(key) - : errorResult(`Unrecognized spaceId ${key}`) - ) as InitializationPromise; + getInitializedResources: async (namespace: string): Promise => { + try { + const key = namespace; + if (!initializedResources.has(key)) { + return errorResult(`Unrecognized spaceId ${key}`); + } + const initializationState = await initializedResources.get(key); + console.log('===> initializationState promise', initializationState); + return initializationState ?? errorResult(`Initialize state returned undefined`); + } catch (e) { + return errorResult(`Initialize resources encountered an error: ${e.message}`); + } }, }; } export const successResult = () => ({ result: true }); -export const errorResult = (error?: string) => ({ result: false, error }); +export const errorResult = (error?: string): InitializationState => ({ result: false, error }); export const getShouldRetry = ({ time, attempts }: Retry) => { const now = new Date().valueOf(); diff --git a/x-pack/plugins/elastic_assistant/server/ai_assistant_service/index.ts b/x-pack/plugins/elastic_assistant/server/ai_assistant_service/index.ts index bfdf8b96f44b0..4ed787c5c23d5 100644 --- a/x-pack/plugins/elastic_assistant/server/ai_assistant_service/index.ts +++ b/x-pack/plugins/elastic_assistant/server/ai_assistant_service/index.ts @@ -171,6 +171,7 @@ export class AIAssistantService { private async initializeResources(): Promise { this.isInitializing = true; try { + console.trace('===> initializeResources'); this.options.logger.debug(`Initializing resources for AIAssistantService`); const esClient = await this.options.elasticsearchClientPromise; @@ -286,6 +287,7 @@ export class AIAssistantService { const { result: initialized, error } = await this.getSpaceResourcesInitializationPromise( opts.spaceId ); + console.log('===> checkResourcesInstallation', { initialized, error }); // If space level resources initialization failed, retry if (!initialized && error) { @@ -331,6 +333,7 @@ export class AIAssistantService { opts: CreateAIAssistantClientParams ): Promise { const res = await this.checkResourcesInstallation(opts); + console.log('===> conversations data client resources check', res); if (res === null) { return null; @@ -419,6 +422,7 @@ export class AIAssistantService { opts: CreateAIAssistantClientParams ): Promise { const res = await this.checkResourcesInstallation(opts); + console.log('===> res createAIAssistantPromptsDataClient', res); if (res === null) { return null; @@ -459,6 +463,7 @@ export class AIAssistantService { const result = await this.resourceInitializationHelper.getInitializedResources(spaceId); // If the spaceId is unrecognized and spaceId is not the default, we // need to kick off resource installation and return the promise + console.log('===> getSpaceResourcesInitializationPromise', result); if ( result.error && result.error.includes(`Unrecognized spaceId`) && diff --git a/x-pack/plugins/elastic_assistant/server/routes/helpers.ts b/x-pack/plugins/elastic_assistant/server/routes/helpers.ts index 5c177410b0388..e26b5415ed948 100644 --- a/x-pack/plugins/elastic_assistant/server/routes/helpers.ts +++ b/x-pack/plugins/elastic_assistant/server/routes/helpers.ts @@ -594,6 +594,7 @@ export const performChecks = ({ const assistantResponse = buildResponse(response); if (license) { + console.log('===> create license', context.licensing.license); if (!hasAIAssistantLicense(context.licensing.license)) { return response.forbidden({ body: { @@ -604,6 +605,7 @@ export const performChecks = ({ } if (authenticatedUser) { + console.log('===> getCurrentUser', context.elasticAssistant.getCurrentUser()); if (context.elasticAssistant.getCurrentUser() == null) { return assistantResponse.error({ body: `Authenticated user not found`, diff --git a/x-pack/plugins/elastic_assistant/server/routes/prompts/bulk_actions_route.ts b/x-pack/plugins/elastic_assistant/server/routes/prompts/bulk_actions_route.ts index 44a949cd22eeb..1f8b5a3e0bc2a 100644 --- a/x-pack/plugins/elastic_assistant/server/routes/prompts/bulk_actions_route.ts +++ b/x-pack/plugins/elastic_assistant/server/routes/prompts/bulk_actions_route.ts @@ -157,6 +157,7 @@ export const bulkPromptsRoute = (router: ElasticAssistantPluginRouter, logger: L try { const ctx = await context.resolve(['core', 'elasticAssistant', 'licensing']); const license = ctx.licensing.license; + console.log('===> bulk license', license); if (!hasAIAssistantLicense(license)) { return response.forbidden({ body: { @@ -173,6 +174,7 @@ export const bulkPromptsRoute = (router: ElasticAssistantPluginRouter, logger: L }); } const dataClient = await ctx.elasticAssistant.getAIAssistantPromptsDataClient(); + console.log('===> bulk dataClient', dataClient); if (body.create && body.create.length > 0) { const result = await dataClient?.findDocuments({ @@ -194,6 +196,7 @@ export const bulkPromptsRoute = (router: ElasticAssistantPluginRouter, logger: L } const writer = await dataClient?.getWriter(); + console.log('===> writer', writer); const changedAt = new Date().toISOString(); const { errors, diff --git a/x-pack/plugins/elastic_assistant/server/routes/user_conversations/create_route.ts b/x-pack/plugins/elastic_assistant/server/routes/user_conversations/create_route.ts index b92ad5462963e..8f705a35b32d9 100644 --- a/x-pack/plugins/elastic_assistant/server/routes/user_conversations/create_route.ts +++ b/x-pack/plugins/elastic_assistant/server/routes/user_conversations/create_route.ts @@ -50,10 +50,12 @@ export const createConversationRoute = (router: ElasticAssistantPluginRouter): v request, response, }); + console.log('===> checkResponse', checkResponse); if (checkResponse) { return checkResponse; } const dataClient = await ctx.elasticAssistant.getAIAssistantConversationsDataClient(); + console.log('===> create dataClient', dataClient); const createdConversation = await dataClient?.createConversation({ conversation: request.body, diff --git a/x-pack/plugins/security_solution/public/assistant/provider.tsx b/x-pack/plugins/security_solution/public/assistant/provider.tsx index f4161fccbc1c2..e4b66bfa9c716 100644 --- a/x-pack/plugins/security_solution/public/assistant/provider.tsx +++ b/x-pack/plugins/security_solution/public/assistant/provider.tsx @@ -153,6 +153,10 @@ export const AssistantProvider: FC> = ({ children }) const hasEnterpriseLicence = licenseService.isEnterprise(); useEffect(() => { const migrateConversationsFromLocalStorage = once(async () => { + console.log('conversations useEffect', { + hasEnterpriseLicence, + assistantAvailability, + }); if ( hasEnterpriseLicence && assistantAvailability.isAssistantEnabled && @@ -178,6 +182,10 @@ export const AssistantProvider: FC> = ({ children }) useEffect(() => { const createSecurityPrompts = once(async () => { + console.log('prompts useEffect', { + hasEnterpriseLicence, + assistantAvailability, + }); if ( hasEnterpriseLicence && assistantAvailability.isAssistantEnabled && From ac0ad4d81263346e99e2412baa76a874d25ca88c Mon Sep 17 00:00:00 2001 From: Steph Milovic Date: Fri, 25 Oct 2024 12:48:30 -0600 Subject: [PATCH 2/4] rm logs --- .../conversations/create_conversation.ts | 2 -- .../create_resource_installation_helper.ts | 4 ---- .../server/ai_assistant_service/index.ts | 5 ----- x-pack/plugins/elastic_assistant/server/routes/helpers.ts | 2 -- .../server/routes/prompts/bulk_actions_route.ts | 3 --- .../server/routes/user_conversations/create_route.ts | 3 +-- .../security_solution/public/assistant/provider.tsx | 8 -------- 7 files changed, 1 insertion(+), 26 deletions(-) diff --git a/x-pack/plugins/elastic_assistant/server/ai_assistant_data_clients/conversations/create_conversation.ts b/x-pack/plugins/elastic_assistant/server/ai_assistant_data_clients/conversations/create_conversation.ts index aeed0f74ef9ee..b98b8a1f4cc27 100644 --- a/x-pack/plugins/elastic_assistant/server/ai_assistant_data_clients/conversations/create_conversation.ts +++ b/x-pack/plugins/elastic_assistant/server/ai_assistant_data_clients/conversations/create_conversation.ts @@ -43,7 +43,6 @@ export const createConversation = async ({ refresh: 'wait_for', }); - console.log('===> response', response); const createdConversation = await getConversation({ esClient, conversationIndex, @@ -51,7 +50,6 @@ export const createConversation = async ({ logger, user, }); - console.log('===> getConversation', getConversation); return createdConversation; } catch (err) { logger.error(`Error creating conversation: ${err} with title: ${conversation.title}`); diff --git a/x-pack/plugins/elastic_assistant/server/ai_assistant_service/create_resource_installation_helper.ts b/x-pack/plugins/elastic_assistant/server/ai_assistant_service/create_resource_installation_helper.ts index 2290024cf219c..371974ac9a20a 100644 --- a/x-pack/plugins/elastic_assistant/server/ai_assistant_service/create_resource_installation_helper.ts +++ b/x-pack/plugins/elastic_assistant/server/ai_assistant_service/create_resource_installation_helper.ts @@ -57,18 +57,15 @@ export function createResourceInstallationHelper( const { result: commonInitResult, error: commonInitError } = await commonInitPromise; if (commonInitResult) { await installFn(namespace, timeoutMs); - console.log('===> installer case 1'); return successResult(); } else { logger.warn( `Common resources were not initialized, cannot initialize resources for ${namespace}` ); - console.log('===> installer case 2'); return errorResult(commonInitError); } } catch (err) { logger.error(`Error initializing resources ${namespace} - ${err.message}`); - console.log('===> installer case 3'); return errorResult(err.message); } }; @@ -119,7 +116,6 @@ export function createResourceInstallationHelper( return errorResult(`Unrecognized spaceId ${key}`); } const initializationState = await initializedResources.get(key); - console.log('===> initializationState promise', initializationState); return initializationState ?? errorResult(`Initialize state returned undefined`); } catch (e) { return errorResult(`Initialize resources encountered an error: ${e.message}`); diff --git a/x-pack/plugins/elastic_assistant/server/ai_assistant_service/index.ts b/x-pack/plugins/elastic_assistant/server/ai_assistant_service/index.ts index 4ed787c5c23d5..bfdf8b96f44b0 100644 --- a/x-pack/plugins/elastic_assistant/server/ai_assistant_service/index.ts +++ b/x-pack/plugins/elastic_assistant/server/ai_assistant_service/index.ts @@ -171,7 +171,6 @@ export class AIAssistantService { private async initializeResources(): Promise { this.isInitializing = true; try { - console.trace('===> initializeResources'); this.options.logger.debug(`Initializing resources for AIAssistantService`); const esClient = await this.options.elasticsearchClientPromise; @@ -287,7 +286,6 @@ export class AIAssistantService { const { result: initialized, error } = await this.getSpaceResourcesInitializationPromise( opts.spaceId ); - console.log('===> checkResourcesInstallation', { initialized, error }); // If space level resources initialization failed, retry if (!initialized && error) { @@ -333,7 +331,6 @@ export class AIAssistantService { opts: CreateAIAssistantClientParams ): Promise { const res = await this.checkResourcesInstallation(opts); - console.log('===> conversations data client resources check', res); if (res === null) { return null; @@ -422,7 +419,6 @@ export class AIAssistantService { opts: CreateAIAssistantClientParams ): Promise { const res = await this.checkResourcesInstallation(opts); - console.log('===> res createAIAssistantPromptsDataClient', res); if (res === null) { return null; @@ -463,7 +459,6 @@ export class AIAssistantService { const result = await this.resourceInitializationHelper.getInitializedResources(spaceId); // If the spaceId is unrecognized and spaceId is not the default, we // need to kick off resource installation and return the promise - console.log('===> getSpaceResourcesInitializationPromise', result); if ( result.error && result.error.includes(`Unrecognized spaceId`) && diff --git a/x-pack/plugins/elastic_assistant/server/routes/helpers.ts b/x-pack/plugins/elastic_assistant/server/routes/helpers.ts index e26b5415ed948..5c177410b0388 100644 --- a/x-pack/plugins/elastic_assistant/server/routes/helpers.ts +++ b/x-pack/plugins/elastic_assistant/server/routes/helpers.ts @@ -594,7 +594,6 @@ export const performChecks = ({ const assistantResponse = buildResponse(response); if (license) { - console.log('===> create license', context.licensing.license); if (!hasAIAssistantLicense(context.licensing.license)) { return response.forbidden({ body: { @@ -605,7 +604,6 @@ export const performChecks = ({ } if (authenticatedUser) { - console.log('===> getCurrentUser', context.elasticAssistant.getCurrentUser()); if (context.elasticAssistant.getCurrentUser() == null) { return assistantResponse.error({ body: `Authenticated user not found`, diff --git a/x-pack/plugins/elastic_assistant/server/routes/prompts/bulk_actions_route.ts b/x-pack/plugins/elastic_assistant/server/routes/prompts/bulk_actions_route.ts index 1f8b5a3e0bc2a..44a949cd22eeb 100644 --- a/x-pack/plugins/elastic_assistant/server/routes/prompts/bulk_actions_route.ts +++ b/x-pack/plugins/elastic_assistant/server/routes/prompts/bulk_actions_route.ts @@ -157,7 +157,6 @@ export const bulkPromptsRoute = (router: ElasticAssistantPluginRouter, logger: L try { const ctx = await context.resolve(['core', 'elasticAssistant', 'licensing']); const license = ctx.licensing.license; - console.log('===> bulk license', license); if (!hasAIAssistantLicense(license)) { return response.forbidden({ body: { @@ -174,7 +173,6 @@ export const bulkPromptsRoute = (router: ElasticAssistantPluginRouter, logger: L }); } const dataClient = await ctx.elasticAssistant.getAIAssistantPromptsDataClient(); - console.log('===> bulk dataClient', dataClient); if (body.create && body.create.length > 0) { const result = await dataClient?.findDocuments({ @@ -196,7 +194,6 @@ export const bulkPromptsRoute = (router: ElasticAssistantPluginRouter, logger: L } const writer = await dataClient?.getWriter(); - console.log('===> writer', writer); const changedAt = new Date().toISOString(); const { errors, diff --git a/x-pack/plugins/elastic_assistant/server/routes/user_conversations/create_route.ts b/x-pack/plugins/elastic_assistant/server/routes/user_conversations/create_route.ts index 8f705a35b32d9..eff0860d4c65c 100644 --- a/x-pack/plugins/elastic_assistant/server/routes/user_conversations/create_route.ts +++ b/x-pack/plugins/elastic_assistant/server/routes/user_conversations/create_route.ts @@ -50,12 +50,11 @@ export const createConversationRoute = (router: ElasticAssistantPluginRouter): v request, response, }); - console.log('===> checkResponse', checkResponse); + if (checkResponse) { return checkResponse; } const dataClient = await ctx.elasticAssistant.getAIAssistantConversationsDataClient(); - console.log('===> create dataClient', dataClient); const createdConversation = await dataClient?.createConversation({ conversation: request.body, diff --git a/x-pack/plugins/security_solution/public/assistant/provider.tsx b/x-pack/plugins/security_solution/public/assistant/provider.tsx index e4b66bfa9c716..f4161fccbc1c2 100644 --- a/x-pack/plugins/security_solution/public/assistant/provider.tsx +++ b/x-pack/plugins/security_solution/public/assistant/provider.tsx @@ -153,10 +153,6 @@ export const AssistantProvider: FC> = ({ children }) const hasEnterpriseLicence = licenseService.isEnterprise(); useEffect(() => { const migrateConversationsFromLocalStorage = once(async () => { - console.log('conversations useEffect', { - hasEnterpriseLicence, - assistantAvailability, - }); if ( hasEnterpriseLicence && assistantAvailability.isAssistantEnabled && @@ -182,10 +178,6 @@ export const AssistantProvider: FC> = ({ children }) useEffect(() => { const createSecurityPrompts = once(async () => { - console.log('prompts useEffect', { - hasEnterpriseLicence, - assistantAvailability, - }); if ( hasEnterpriseLicence && assistantAvailability.isAssistantEnabled && From 4fe06f34fdc737c7691d53647a6d5679d1f4401f Mon Sep 17 00:00:00 2001 From: Steph Milovic Date: Fri, 25 Oct 2024 13:21:56 -0600 Subject: [PATCH 3/4] fix --- .../create_resource_installation_helper.test.ts | 4 ++-- .../server/routes/user_conversations/create_route.ts | 1 - 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/x-pack/plugins/elastic_assistant/server/ai_assistant_service/create_resource_installation_helper.test.ts b/x-pack/plugins/elastic_assistant/server/ai_assistant_service/create_resource_installation_helper.test.ts index 8e34581332ff6..0316a33b1d7c2 100644 --- a/x-pack/plugins/elastic_assistant/server/ai_assistant_service/create_resource_installation_helper.test.ts +++ b/x-pack/plugins/elastic_assistant/server/ai_assistant_service/create_resource_installation_helper.test.ts @@ -11,7 +11,7 @@ import { loggingSystemMock } from '@kbn/core/server/mocks'; import { createResourceInstallationHelper, errorResult, - InitializationPromise, + InitializationState, ResourceInstallationHelper, successResult, calculateDelay, @@ -54,7 +54,7 @@ const getCommonInitPromise = async ( resolution: boolean, timeoutMs: number = 1, customLogString: string = '' -): Promise => { +): Promise => { if (timeoutMs < 0) { throw new Error('fail'); } diff --git a/x-pack/plugins/elastic_assistant/server/routes/user_conversations/create_route.ts b/x-pack/plugins/elastic_assistant/server/routes/user_conversations/create_route.ts index eff0860d4c65c..b92ad5462963e 100644 --- a/x-pack/plugins/elastic_assistant/server/routes/user_conversations/create_route.ts +++ b/x-pack/plugins/elastic_assistant/server/routes/user_conversations/create_route.ts @@ -50,7 +50,6 @@ export const createConversationRoute = (router: ElasticAssistantPluginRouter): v request, response, }); - if (checkResponse) { return checkResponse; } From 12a04ba3ab9a733d424d18cf83230f5e3d684dd9 Mon Sep 17 00:00:00 2001 From: Steph Milovic Date: Fri, 25 Oct 2024 14:31:28 -0600 Subject: [PATCH 4/4] fix type --- .../server/ai_assistant_service/index.ts | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/x-pack/plugins/elastic_assistant/server/ai_assistant_service/index.ts b/x-pack/plugins/elastic_assistant/server/ai_assistant_service/index.ts index bfdf8b96f44b0..f26ce8b7c1189 100644 --- a/x-pack/plugins/elastic_assistant/server/ai_assistant_service/index.ts +++ b/x-pack/plugins/elastic_assistant/server/ai_assistant_service/index.ts @@ -16,7 +16,7 @@ import { getDefaultAnonymizationFields } from '../../common/anonymization'; import { AssistantResourceNames, GetElser } from '../types'; import { AIAssistantConversationsDataClient } from '../ai_assistant_data_clients/conversations'; import { - InitializationPromise, + InitializationState, ResourceInstallationHelper, createResourceInstallationHelper, errorResult, @@ -80,7 +80,7 @@ export class AIAssistantService { private anonymizationFieldsDataStream: DataStreamSpacesAdapter; private attackDiscoveryDataStream: DataStreamSpacesAdapter; private resourceInitializationHelper: ResourceInstallationHelper; - private initPromise: Promise; + private initPromise: Promise; private isKBSetupInProgress: boolean = false; // Temporary 'feature flag' to determine if we should initialize the new kb mappings, toggled when accessing kbDataClient private v2KnowledgeBaseEnabled: boolean = false; @@ -168,7 +168,7 @@ export class AIAssistantService { return newDataStream; }; - private async initializeResources(): Promise { + private async initializeResources(): Promise { this.isInitializing = true; try { this.options.logger.debug(`Initializing resources for AIAssistantService`); @@ -283,13 +283,13 @@ export class AIAssistantService { private async checkResourcesInstallation(opts: CreateAIAssistantClientParams) { // Check if resources installation has succeeded - const { result: initialized, error } = await this.getSpaceResourcesInitializationPromise( + const { result: initialized, error } = await this.getSpaceResourcesInitializationState( opts.spaceId ); // If space level resources initialization failed, retry if (!initialized && error) { - let initRetryPromise: Promise | undefined; + let initRetryPromise: Promise | undefined; // If !this.initialized, we know that resource initialization failed // and we need to retry this before retrying the spaceId specific resources @@ -453,9 +453,9 @@ export class AIAssistantService { }); } - public async getSpaceResourcesInitializationPromise( + public async getSpaceResourcesInitializationState( spaceId: string | undefined = DEFAULT_NAMESPACE_STRING - ): Promise { + ): Promise { const result = await this.resourceInitializationHelper.getInitializedResources(spaceId); // If the spaceId is unrecognized and spaceId is not the default, we // need to kick off resource installation and return the promise