show deprecation message as toast

This commit is contained in:
uinstinct 2025-07-24 20:24:39 +05:30
parent 79b547bfe4
commit b28d78ccc7
6 changed files with 58 additions and 18 deletions

View file

@ -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 (

View file

@ -31,4 +31,8 @@ export abstract class BaseContextProvider implements IContextProvider {
): Promise<ContextSubmenuItem[]> {
return [];
}
isDeprecated(): boolean {
return false;
}
}

View file

@ -30,6 +30,10 @@ class CustomContextProviderClass implements IContextProvider {
async loadSubmenuItems(args: LoadSubmenuItemsArgs) {
return this.custom.loadSubmenuItems?.(args) ?? [];
}
isDeprecated() {
return false;
}
}
export default CustomContextProviderClass;

View file

@ -132,6 +132,10 @@ LIMIT ${sampleRows}`);
throw new Error(`Failed to query PostgreSQL database: ${error}`);
}
}
isDeprecated() {
return true;
}
}
export default PostgresContextProvider;

2
core/index.d.ts vendored
View file

@ -256,6 +256,8 @@ export interface IContextProvider {
): Promise<ContextItem[]>;
loadSubmenuItems(args: LoadSubmenuItemsArgs): Promise<ContextSubmenuItem[]>;
isDeprecated(): boolean;
}
export interface Session {

View file

@ -39,6 +39,9 @@ export type GlobalContextType = {
isSupportedLanceDbCpuTargetForLinux: boolean;
sharedConfig: SharedConfigSchema;
failedDocs: SiteIndexingConfig[];
shownDeprecatedProviderWarnings: {
[providerTitle: string]: boolean;
};
};
/**