diff --git a/core/config/load.ts b/core/config/load.ts index af71ca172..e856c04c4 100644 --- a/core/config/load.ts +++ b/core/config/load.ts @@ -3,6 +3,7 @@ import * as fs from "fs"; import os from "os"; import path from "path"; +import { ConfigResult, ConfigValidationError } from "@continuedev/config-yaml"; import { fetchwithRequestOptions } from "@continuedev/fetch"; import * as JSONC from "comment-json"; import * as tar from "tar"; @@ -38,6 +39,7 @@ import CustomContextProviderClass from "../context/providers/CustomContextProvid import FileContextProvider from "../context/providers/FileContextProvider"; import { contextProviderClassFromName } from "../context/providers/index"; import PromptFilesContextProvider from "../context/providers/PromptFilesContextProvider"; +import { useHub } from "../control-plane/env"; import { allEmbeddingsProviders } from "../indexing/allEmbeddingsProviders"; import { BaseLLM } from "../llm"; import { llmFromDescription } from "../llm/llms"; @@ -61,8 +63,8 @@ import { getContinueDotEnv, getEsbuildBinaryPath, } from "../util/paths"; +import { localPathToUri } from "../util/pathToUri"; -import { ConfigResult, ConfigValidationError } from "@continuedev/config-yaml"; import { defaultContextProvidersJetBrains, defaultContextProvidersVsCode, @@ -70,9 +72,7 @@ import { defaultSlashCommandsVscode, } from "./default"; import { getSystemPromptDotFile } from "./getSystemPromptDotFile"; -// import { isSupportedLanceDbCpuTarget } from "./util"; -import { useHub } from "../control-plane/env"; -import { localPathToUri } from "../util/pathToUri"; +import { isSupportedLanceDbCpuTargetForLinux } from "./util"; import { validateConfig } from "./validation.js"; function resolveSerializedConfig(filepath: string): SerializedContinueConfig { @@ -175,10 +175,9 @@ function loadSerializedConfig( ? [...defaultSlashCommandsVscode] : [...defaultSlashCommandsJetBrains]; - // Temporarily disabling this check until we can verify the commands are accuarate - // if (!isSupportedLanceDbCpuTarget(ide)) { - // config.disableIndexing = true; - // } + if (os.platform() === "linux" && !isSupportedLanceDbCpuTargetForLinux(ide)) { + config.disableIndexing = true; + } return { config, errors, configLoadInterrupted: false }; } diff --git a/core/config/util.ts b/core/config/util.ts index 6d28dcbcb..0dfd97667 100644 --- a/core/config/util.ts +++ b/core/config/util.ts @@ -108,11 +108,13 @@ export function getModelByRole( * * See here for details: https://github.com/continuedev/continue/issues/940 */ -export function isSupportedLanceDbCpuTarget(ide: IDE) { +export function isSupportedLanceDbCpuTargetForLinux(ide: IDE) { const CPU_FEATURES_TO_CHECK = ["avx2", "fma"] as const; const globalContext = new GlobalContext(); - const globalContextVal = globalContext.get("isSupportedLanceDbCpuTarget"); + const globalContextVal = globalContext.get( + "isSupportedLanceDbCpuTargetForLinux", + ); // If we've already checked the CPU target, return the cached value if (globalContextVal !== undefined) { @@ -120,51 +122,35 @@ export function isSupportedLanceDbCpuTarget(ide: IDE) { } const arch = os.arch(); - const platform = os.platform(); // This check only applies to x64 //https://github.com/lancedb/lance/issues/2195#issuecomment-2057841311 if (arch !== "x64") { - globalContext.update("isSupportedLanceDbCpuTarget", true); + globalContext.update("isSupportedLanceDbCpuTargetForLinux", true); return true; } try { - const cpuFlags = (() => { - switch (platform) { - case "darwin": - return execSync("sysctl -n machdep.cpu.features") - .toString() - .toLowerCase(); - case "linux": - return execSync("cat /proc/cpuinfo").toString().toLowerCase(); - case "win32": - return execSync("wmic cpu get caption /format:list") - .toString() - .toLowerCase(); - default: - return ""; - } - })(); + const cpuFlags = execSync("cat /proc/cpuinfo").toString().toLowerCase(); - const isSupportedLanceDbCpuTarget = cpuFlags + const isSupportedLanceDbCpuTargetForLinux = cpuFlags ? CPU_FEATURES_TO_CHECK.every((feature) => cpuFlags.includes(feature)) : true; // If it's not a supported CPU target, and it's the first time we are checking, // show a toast to inform the user that we are going to disable indexing. - if (!isSupportedLanceDbCpuTarget) { + if (!isSupportedLanceDbCpuTargetForLinux) { // We offload our async toast to `showUnsupportedCpuToast` to prevent making - // our config loading async upstream of `isSupportedLanceDbCpuTarget` + // our config loading async upstream of `isSupportedLanceDbCpuTargetForLinux` void showUnsupportedCpuToast(ide); } globalContext.update( - "isSupportedLanceDbCpuTarget", - isSupportedLanceDbCpuTarget, + "isSupportedLanceDbCpuTargetForLinux", + isSupportedLanceDbCpuTargetForLinux, ); - return isSupportedLanceDbCpuTarget; + return isSupportedLanceDbCpuTargetForLinux; } catch (error) { // If we can't determine CPU features, default to true return true; diff --git a/core/util/GlobalContext.ts b/core/util/GlobalContext.ts index 336dc8293..9f452a90f 100644 --- a/core/util/GlobalContext.ts +++ b/core/util/GlobalContext.ts @@ -15,7 +15,7 @@ export type GlobalContextType = { hasDismissedConfigTsNoticeJetBrains: boolean; hasAlreadyCreatedAPromptFile: boolean; showConfigUpdateToast: boolean; - isSupportedLanceDbCpuTarget: boolean; + isSupportedLanceDbCpuTargetForLinux: boolean; }; /**