diff --git a/core/config/load.ts b/core/config/load.ts index 5afbcb007..ed33eb0e7 100644 --- a/core/config/load.ts +++ b/core/config/load.ts @@ -485,7 +485,6 @@ function finalToBrowserConfig( contextProviders: final.contextProviders?.map((c) => c.description), disableIndexing: final.disableIndexing, disableSessionTitles: final.disableSessionTitles, - disableHeadlessCrawling: final.disableHeadlessCrawling, userToken: final.userToken, embeddingsProvider: final.embeddingsProvider?.id, ui: final.ui, diff --git a/core/index.d.ts b/core/index.d.ts index adf0e9760..2ed65799f 100644 --- a/core/index.d.ts +++ b/core/index.d.ts @@ -933,7 +933,6 @@ export interface SerializedContinueConfig { contextProviders?: ContextProviderWithParams[]; disableIndexing?: boolean; disableSessionTitles?: boolean; - disableHeadlessCrawling?: boolean; userToken?: string; embeddingsProvider?: EmbeddingsProviderDescription; tabAutocompleteModel?: ModelDescription | ModelDescription[]; @@ -976,8 +975,6 @@ export interface Config { disableIndexing?: boolean; /** If set to true, Continue will not make extra requests to the LLM to generate a summary title of each session. */ disableSessionTitles?: boolean; - /** Disable headless crawling. This is useful if you're running into issues with Chromium or Playwright, or do not want to install Chromium. */ - disableHeadlessCrawling?: boolean; /** An optional token to identify a user. Not used by Continue unless you write custom coniguration that requires such a token */ userToken?: string; /** The provider used to calculate embeddings. If left empty, Continue will use transformers.js to calculate the embeddings with all-MiniLM-L6-v2 */ @@ -1009,7 +1006,6 @@ export interface ContinueConfig { slashCommands?: SlashCommand[]; contextProviders?: IContextProvider[]; disableSessionTitles?: boolean; - disableHeadlessCrawling?: boolean; disableIndexing?: boolean; userToken?: string; embeddingsProvider: EmbeddingsProvider; @@ -1032,7 +1028,6 @@ export interface BrowserSerializedContinueConfig { contextProviders?: ContextProviderDescription[]; disableIndexing?: boolean; disableSessionTitles?: boolean; - disableHeadlessCrawling?: boolean; userToken?: string; embeddingsProvider?: string; ui?: ContinueUIConfig; diff --git a/core/indexing/docs/DocsCrawler.test.ts b/core/indexing/docs/DocsCrawler.test.ts index 932e0d250..42083634f 100644 --- a/core/indexing/docs/DocsCrawler.test.ts +++ b/core/indexing/docs/DocsCrawler.test.ts @@ -1,5 +1,7 @@ +import { SpiedFunction } from "jest-mock"; import DocsCrawler, { ChromiumCrawler, type PageData } from "./DocsCrawler"; import preIndexedDocs from "./preIndexedDocs"; +import { jest } from "@jest/globals"; // Temporary workaround until we have better caching of Chromium // download between test runs @@ -20,7 +22,7 @@ describe.skip("crawl", () => { let crawlResults: PageData[]; beforeAll(async () => { - const docsCrawler = new DocsCrawler(false); + const docsCrawler = new DocsCrawler(); crawlResults = []; @@ -69,7 +71,7 @@ describe.skip("crawl", () => { let pageFound = false; try { - const docsCrawler = new DocsCrawler(false); + const docsCrawler = new DocsCrawler(); for await (const page of docsCrawler.crawl(new URL(url), 1)) { if (page.url === url) { @@ -113,7 +115,7 @@ describe.skip("crawl", () => { for (const site of TEST_SITES) { const crawlResults: PageData[] = []; - const docsCrawler = new DocsCrawler(false); + const docsCrawler = new DocsCrawler(); for await (const page of docsCrawler.crawl( new URL(site), @@ -134,6 +136,18 @@ describe.skip("crawl", () => { }); describe("Cheerio Crawler", () => { + let mockVerifyOrInstallChromium: SpiedFunction<() => Promise>; + + beforeAll(() => { + mockVerifyOrInstallChromium = jest + .spyOn(ChromiumCrawler, "verifyOrInstallChromium") + .mockResolvedValue(false); + }); + + afterAll(() => { + mockVerifyOrInstallChromium.mockRestore(); + }); + it( "succeeds in crawling a basic site", async () => { @@ -141,7 +155,7 @@ describe.skip("crawl", () => { const site = "https://amplified.dev/"; const crawlResults: PageData[] = []; - const docsCrawler = new DocsCrawler(false); + const docsCrawler = new DocsCrawler(); for await (const page of docsCrawler.crawl( new URL(site), diff --git a/core/indexing/docs/DocsCrawler.ts b/core/indexing/docs/DocsCrawler.ts index 092d9ba84..05364f028 100644 --- a/core/indexing/docs/DocsCrawler.ts +++ b/core/indexing/docs/DocsCrawler.ts @@ -12,7 +12,7 @@ import { import PCR from "puppeteer-chromium-resolver"; import * as cheerio from "cheerio"; import fetch from "node-fetch"; -import { ContinueConfig } from "../.."; +import { GlobalContext } from "../../util/GlobalContext"; export type PageData = { url: string; @@ -25,12 +25,8 @@ class DocsCrawler { private readonly GITHUB_HOST = "github.com"; private useChromiumPromise: Promise | undefined = undefined; - constructor( - private readonly disableHeadlessCrawling: ContinueConfig["disableHeadlessCrawling"], - ) { - if (!disableHeadlessCrawling) { - this.useChromiumPromise = ChromiumCrawler.verifyOrInstallChromium(); - } + constructor() { + this.useChromiumPromise = ChromiumCrawler.verifyOrInstallChromium(); } async *crawl( @@ -401,6 +397,13 @@ class ChromiumCrawler { } static async verifyOrInstallChromium() { + const globalContext = new GlobalContext(); + + // If we previously failed to install Chromium, don't try again + if (globalContext.get("didPrevChromiumInstallFail")) { + return false; + } + if (fs.existsSync(getChromiumPath())) { return true; } @@ -411,13 +414,10 @@ class ChromiumCrawler { } catch (error) { console.debug("Error installing Chromium : ", error); console.debug( - "Setting `disableHeadlessCrawling` to `true` in config.json", + `Setting 'didPrevChromiumInstallFail' to 'true' in ${globalContext.constructor.name}`, ); - editConfigJson((config) => ({ - ...config, - disableHeadlessCrawling: true, - })); + globalContext.update("didPrevChromiumInstallFail", true); return false; } diff --git a/core/indexing/docs/DocsService.ts b/core/indexing/docs/DocsService.ts index b8505abf1..8859806ab 100644 --- a/core/indexing/docs/DocsService.ts +++ b/core/indexing/docs/DocsService.ts @@ -383,7 +383,7 @@ export default class DocsService { private async init(configHandler: ConfigHandler) { this.config = await configHandler.loadConfig(); - this.docsCrawler = new DocsCrawler(this.config.disableHeadlessCrawling); + this.docsCrawler = new DocsCrawler(); const embeddingsProvider = await this.getEmbeddingsProvider(); diff --git a/core/util/GlobalContext.ts b/core/util/GlobalContext.ts index 3880b4609..a66d8d6cf 100644 --- a/core/util/GlobalContext.ts +++ b/core/util/GlobalContext.ts @@ -5,6 +5,7 @@ import { EmbeddingsProvider } from "../index.js"; export type GlobalContextType = { indexingPaused: boolean; selectedTabAutocompleteModel: string; + didPrevChromiumInstallFail: boolean; lastSelectedProfileForWorkspace: { [workspaceIdentifier: string]: string }; /** * This is needed to handle the case where a JetBrains user has created diff --git a/docs/static/schemas/config.json b/docs/static/schemas/config.json index 46e3fe5ca..7166520e1 100644 --- a/docs/static/schemas/config.json +++ b/docs/static/schemas/config.json @@ -1881,12 +1881,6 @@ "title": "config.json", "type": "object", "properties": { - "disableHeadlessCrawling": { - "title": "Disable Headless Crawling", - "description": "Disable headless crawling. This is useful if you're running into issues with Chromium or Playwright, or do not want to install Chromium.", - "default": false, - "type": "boolean" - }, "docs": { "title": "Docs", "description": "A list of documentation sites to be indexed", diff --git a/extensions/intellij/src/main/resources/config_schema.json b/extensions/intellij/src/main/resources/config_schema.json index 46e3fe5ca..7166520e1 100644 --- a/extensions/intellij/src/main/resources/config_schema.json +++ b/extensions/intellij/src/main/resources/config_schema.json @@ -1881,12 +1881,6 @@ "title": "config.json", "type": "object", "properties": { - "disableHeadlessCrawling": { - "title": "Disable Headless Crawling", - "description": "Disable headless crawling. This is useful if you're running into issues with Chromium or Playwright, or do not want to install Chromium.", - "default": false, - "type": "boolean" - }, "docs": { "title": "Docs", "description": "A list of documentation sites to be indexed", diff --git a/extensions/vscode/config_schema.json b/extensions/vscode/config_schema.json index 46e3fe5ca..7166520e1 100644 --- a/extensions/vscode/config_schema.json +++ b/extensions/vscode/config_schema.json @@ -1881,12 +1881,6 @@ "title": "config.json", "type": "object", "properties": { - "disableHeadlessCrawling": { - "title": "Disable Headless Crawling", - "description": "Disable headless crawling. This is useful if you're running into issues with Chromium or Playwright, or do not want to install Chromium.", - "default": false, - "type": "boolean" - }, "docs": { "title": "Docs", "description": "A list of documentation sites to be indexed", diff --git a/extensions/vscode/continue_rc_schema.json b/extensions/vscode/continue_rc_schema.json index 767757074..70c584b9e 100644 --- a/extensions/vscode/continue_rc_schema.json +++ b/extensions/vscode/continue_rc_schema.json @@ -2105,12 +2105,6 @@ "title": "config.json", "type": "object", "properties": { - "disableHeadlessCrawling": { - "title": "Disable Headless Crawling", - "description": "Disable headless crawling. This is useful if you're running into issues with Chromium or Playwright, or do not want to install Chromium.", - "default": false, - "type": "boolean" - }, "docs": { "title": "Docs", "description": "A list of documentation sites to be indexed",