From b28d78ccc7eb56911fdb597315f4cae00f5d6b2f Mon Sep 17 00:00:00 2001 From: uinstinct <61635505+uinstinct@users.noreply.github.com> Date: Thu, 24 Jul 2025 20:24:39 +0530 Subject: [PATCH] show deprecation message as toast --- core/config/yaml/loadYaml.ts | 59 +++++++++++++------ core/context/index.ts | 4 ++ .../providers/CustomContextProvider.ts | 4 ++ .../providers/PostgresContextProvider.ts | 4 ++ core/index.d.ts | 2 + core/util/GlobalContext.ts | 3 + 6 files changed, 58 insertions(+), 18 deletions(-) diff --git a/core/config/yaml/loadYaml.ts b/core/config/yaml/loadYaml.ts index b1682e751..051784056 100644 --- a/core/config/yaml/loadYaml.ts +++ b/core/config/yaml/loadYaml.ts @@ -394,25 +394,48 @@ async function configYamlToContinueConfig(options: { ({ description: { title } }) => title, ); - continueConfig.contextProviders = (config.context - ?.map((context) => { - const cls = contextProviderClassFromName(context.provider) as any; - if (!cls) { - if (!DEFAULT_CONTEXT_PROVIDERS_TITLES.includes(context.provider)) { - localErrors.push({ - fatal: false, - message: `Unknown context provider ${context.provider}`, - }); + const globalContext = new GlobalContext(); + + continueConfig.contextProviders = + config.context + ?.map((context) => { + const cls = contextProviderClassFromName(context.provider) as any; + if (!cls) { + if (!DEFAULT_CONTEXT_PROVIDERS_TITLES.includes(context.provider)) { + localErrors.push({ + fatal: false, + message: `Unknown context provider ${context.provider}`, + }); + } + return undefined; } - return undefined; - } - const instance: IContextProvider = new cls({ - name: context.name, - ...context.params, - }); - return instance; - }) - .filter((p) => !!p) ?? []) as IContextProvider[]; + const instance: IContextProvider = new cls({ + name: context.name, + ...context.params, + }); + return instance; + }) + .filter((p) => !!p) + .filter((p) => { + if (p.isDeprecated()) { + const providerTitle = p.description.title; + const shownWarnings = + globalContext.get("shownDeprecatedProviderWarnings") ?? {}; + if (!shownWarnings[providerTitle]) { + ide.showToast( + "warning", + `Context provider ${providerTitle} is deprecated and will be removed in a future version.`, + ); + globalContext.update("shownDeprecatedProviderWarnings", { + ...shownWarnings, + [providerTitle]: true, + }); + } + return true; + } + return false; + }) ?? []; + continueConfig.contextProviders.push(...DEFAULT_CONTEXT_PROVIDERS); if ( diff --git a/core/context/index.ts b/core/context/index.ts index 7ad48f112..c00d611aa 100644 --- a/core/context/index.ts +++ b/core/context/index.ts @@ -31,4 +31,8 @@ export abstract class BaseContextProvider implements IContextProvider { ): Promise { return []; } + + isDeprecated(): boolean { + return false; + } } diff --git a/core/context/providers/CustomContextProvider.ts b/core/context/providers/CustomContextProvider.ts index f87a4554f..150e22e58 100644 --- a/core/context/providers/CustomContextProvider.ts +++ b/core/context/providers/CustomContextProvider.ts @@ -30,6 +30,10 @@ class CustomContextProviderClass implements IContextProvider { async loadSubmenuItems(args: LoadSubmenuItemsArgs) { return this.custom.loadSubmenuItems?.(args) ?? []; } + + isDeprecated() { + return false; + } } export default CustomContextProviderClass; diff --git a/core/context/providers/PostgresContextProvider.ts b/core/context/providers/PostgresContextProvider.ts index 55c00ae3c..70406e3d2 100644 --- a/core/context/providers/PostgresContextProvider.ts +++ b/core/context/providers/PostgresContextProvider.ts @@ -132,6 +132,10 @@ LIMIT ${sampleRows}`); throw new Error(`Failed to query PostgreSQL database: ${error}`); } } + + isDeprecated() { + return true; + } } export default PostgresContextProvider; diff --git a/core/index.d.ts b/core/index.d.ts index f9fdc34cf..b3524da73 100644 --- a/core/index.d.ts +++ b/core/index.d.ts @@ -256,6 +256,8 @@ export interface IContextProvider { ): Promise; loadSubmenuItems(args: LoadSubmenuItemsArgs): Promise; + + isDeprecated(): boolean; } export interface Session { diff --git a/core/util/GlobalContext.ts b/core/util/GlobalContext.ts index 6885edde2..7466718b6 100644 --- a/core/util/GlobalContext.ts +++ b/core/util/GlobalContext.ts @@ -39,6 +39,9 @@ export type GlobalContextType = { isSupportedLanceDbCpuTargetForLinux: boolean; sharedConfig: SharedConfigSchema; failedDocs: SiteIndexingConfig[]; + shownDeprecatedProviderWarnings: { + [providerTitle: string]: boolean; + }; }; /**