feat: show disableIndexing in More

This commit is contained in:
Test 2024-12-27 15:34:49 -06:00
parent a005aa78ac
commit 5d95b62e68
7 changed files with 59 additions and 41 deletions

View file

@ -113,7 +113,7 @@ function loadSerializedConfig(
ideSettings: IdeSettings,
ideType: IdeType,
overrideConfigJson: SerializedContinueConfig | undefined,
ide: IDE
ide: IDE,
): ConfigResult<SerializedContinueConfig> {
const configPath = getConfigJsonPath(ideType);
let config: SerializedContinueConfig = overrideConfigJson!;
@ -135,10 +135,6 @@ function loadSerializedConfig(
};
}
if (config.allowAnonymousTelemetry === undefined) {
config.allowAnonymousTelemetry = true;
}
if (config.ui?.getChatTitles === undefined) {
config.ui = {
...config.ui,
@ -773,7 +769,7 @@ async function loadFullConfigNode(
ideSettings,
ideType,
overrideConfigJson,
ide
ide,
);
if (!serialized || configLoadInterrupted) {

View file

@ -102,8 +102,15 @@ export function getModelByRole<T extends keyof ModelRoles>(
return matchingModel;
}
// https://github.com/continuedev/continue/issues/940
export async function isSupportedLanceDbCpuTarget(ide: IDE) {
/**
* This check is to determine if the user is on an unsupported CPU
* target for our Lance DB binaries.
*
* See here for details: https://github.com/continuedev/continue/issues/940
*/
export function isSupportedLanceDbCpuTarget(ide: IDE) {
const CPU_FEATURES_TO_CHECK = ["avx", "fma"] as const;
const globalContext = new GlobalContext();
const globalContextVal = globalContext.get("isSupportedLanceDbCpuTarget");
@ -115,15 +122,14 @@ export async 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
// Only applies to x64
if (arch !== "x64") {
globalContext.update("isSupportedLanceDbCpuTarget", true);
return true;
}
try {
const CPU_FEATURES_TO_CHECK = ["avx", "fma"] as const;
const cpuFlags = (() => {
switch (platform) {
case "darwin":
@ -141,24 +147,16 @@ export async function isSupportedLanceDbCpuTarget(ide: IDE) {
}
})();
// TODO: Remvoe !
const isSupportedLanceDbCpuTarget = cpuFlags
? !CPU_FEATURES_TO_CHECK.every((feature) => cpuFlags.includes(feature))
? 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) {
const shouldOpenLink = await ide.showToast(
"warning",
"Cdoebase indexing is disabled due to CPU incompatibility",
"View details",
);
if (shouldOpenLink) {
// TODO
void ide.openUrl("https://continue.dev");
}
// We offload our async toast to `showUnsupportedCpuToast` to prevent making
// our config loading async upstream of `isSupportedLanceDbCpuTarget`
void showUnsupportedCpuToast(ide);
}
globalContext.update(
@ -172,3 +170,15 @@ export async function isSupportedLanceDbCpuTarget(ide: IDE) {
return true;
}
}
async function showUnsupportedCpuToast(ide: IDE) {
const shouldOpenLink = await ide.showToast(
"warning",
"Codebase indexing is disabled due to CPU incompatibility",
"Learn more",
);
if (shouldOpenLink) {
void ide.openUrl("https://github.com/continuedev/continue/pull/3551");
}
}

View file

@ -78,10 +78,11 @@ function DocsIndexingStatus({ docConfig }: IndexingStatusViewerProps) {
if (!status) {
return 0;
}
return Math.min(100, Math.max(0, status.progress * 100));
return Math.min(100, Math.max(0, status.progress * 100)).toFixed(0);
}, [status?.progress]);
const Icon = STATUS_TO_ICON[status?.status];
const showProgressPercentage = progressPercentage !== "100";
if (hasDeleted) return null;
@ -115,7 +116,15 @@ function DocsIndexingStatus({ docConfig }: IndexingStatusViewerProps) {
<div className="text-xs text-stone-500">Pending...</div>
) : (
<div className="flex flex-row items-center gap-1 text-stone-500">
<span className="text-xs">{progressPercentage.toFixed(0)}%</span>
{showProgressPercentage && (
<span className="text-xs">{progressPercentage}%</span>
)}
{status?.status !== "indexing" ? (
<TrashIcon
className="h-4 w-4 cursor-pointer text-stone-500 hover:brightness-125"
onClick={onDelete}
/>
) : null}
{Icon ? (
<Icon
className={`inline-block h-4 w-4 text-stone-500 ${
@ -123,12 +132,6 @@ function DocsIndexingStatus({ docConfig }: IndexingStatusViewerProps) {
}`}
></Icon>
) : null}
{status?.status !== "indexing" ? (
<TrashIcon
className="h-4 w-4 cursor-pointer text-stone-500"
onClick={onDelete}
/>
) : null}
</div>
)}
</div>

View file

@ -13,10 +13,10 @@ function DocsIndexingStatuses() {
return (
<div className="flex flex-col gap-1">
<div className="flex flex-row items-center justify-between">
<h3 className="mb-1 mt-0 text-xl">@docs indexes</h3>
<h3 className="mb-0 mt-0 text-xl">@docs indexes</h3>
{configDocs.length ? (
<SecondaryButton
className="flex h-7 flex-col items-center justify-center"
className="!my-0 flex h-7 flex-col items-center justify-center"
onClick={() => {
dispatch(setShowDialog(true));
dispatch(setDialogMessage(<AddDocsDialog />));

View file

@ -107,7 +107,7 @@ function IndexingProgress() {
}
return (
<div className="mt-6 flex flex-col">
<div className="mt-4 flex flex-col">
<div className="mb-0 flex justify-between text-sm">
<IndexingProgressTitleText update={update} />
{update.status !== "loading" && (

View file

@ -21,16 +21,15 @@ const STATUS_TO_ICON: Record<IndexingProgressUpdate["status"], any> = {
};
function IndexingProgressIndicator({ update }: IndexingProgressIndicatorProps) {
const progressPercentage = getProgressPercentage(update.progress);
const progressPercentage = getProgressPercentage(update.progress).toFixed(0);
const Icon = STATUS_TO_ICON[update.status];
const animateIcon = update.status === "indexing";
const showProgress = update.status !== "disabled";
const showProgress =
update.status !== "disabled" && progressPercentage !== "100";
return (
<div className="flex items-center justify-between gap-1 text-stone-500">
{showProgress && (
<span className="text-xs">{progressPercentage.toFixed(0)}%</span>
)}
{showProgress && <span className="text-xs">{progressPercentage}%</span>}
{Icon && (
<div className="flex items-center">

View file

@ -13,7 +13,7 @@ import MoreHelpRow from "./MoreHelpRow";
import IndexingProgress from "./IndexingProgress";
import DocsIndexingStatuses from "../../components/indexing/DocsIndexingStatuses";
import PageHeader from "../../components/PageHeader";
import { useAppDispatch } from "../../redux/hooks";
import { useAppDispatch, useAppSelector } from "../../redux/hooks";
import { saveCurrentSession } from "../../redux/thunks/session";
function MorePage() {
@ -21,6 +21,9 @@ function MorePage() {
const dispatch = useAppDispatch();
const navigate = useNavigate();
const ideMessenger = useContext(IdeMessengerContext);
const disableIndexing = useAppSelector(
(state) => state.config.config.disableIndexing,
);
return (
<div className="overflow-y-scroll">
@ -34,8 +37,15 @@ function MorePage() {
Local embeddings of your codebase
</span>
</div>
<IndexingProgress />
{disableIndexing ? (
<div className="pb-2 pt-5 text-center font-semibold">
Indexing is disabled
</div>
) : (
<IndexingProgress />
)}
</div>
<div className="flex flex-col py-5">
<DocsIndexingStatuses />
</div>