From b5705c1d5fc0103b7ab849855cd8b90041551ff1 Mon Sep 17 00:00:00 2001 From: Dallin Romney Date: Thu, 9 Jan 2025 10:10:24 +0000 Subject: [PATCH 001/146] docs/getDetails --- core/core.ts | 3 + core/index.d.ts | 8 + core/indexing/docs/DocsService.ts | 108 ++++++++--- core/protocol/core.ts | 3 +- core/protocol/passThrough.ts | 1 + .../toolWindow/ContinueBrowser.kt | 1 + .../components/indexing/DocsDetailsDialog.tsx | 176 ++++++++++++++++++ .../indexing/DocsIndexingStatus.tsx | 26 ++- gui/src/index.css | 10 + 9 files changed, 305 insertions(+), 31 deletions(-) create mode 100644 gui/src/components/indexing/DocsDetailsDialog.tsx diff --git a/core/core.ts b/core/core.ts index af05f7d96..8122636dd 100644 --- a/core/core.ts +++ b/core/core.ts @@ -843,6 +843,9 @@ export class Core { on("docs/initStatuses", async (msg) => { void this.docsService.initStatuses(); }); + on("docs/getDetails", async (msg) => { + return await this.docsService.getDetails(msg.data.startUrl); + }); // on("didChangeSelectedProfile", (msg) => { diff --git a/core/index.d.ts b/core/index.d.ts index e4f3ff143..bbdc02658 100644 --- a/core/index.d.ts +++ b/core/index.d.ts @@ -231,6 +231,14 @@ export interface SiteIndexingConfig { maxDepth?: number; } +export interface DocsIndexingDetails { + startUrl: string; + config: SiteIndexingConfig; + indexingStatus: IndexingStatus | undefined; + chunks: Chunk[]; + isPreIndexedDoc: boolean; +} + export interface IContextProvider { get description(): ContextProviderDescription; diff --git a/core/indexing/docs/DocsService.ts b/core/indexing/docs/DocsService.ts index 1f56de495..0bed5571e 100644 --- a/core/indexing/docs/DocsService.ts +++ b/core/indexing/docs/DocsService.ts @@ -5,6 +5,7 @@ import lancedb, { Connection } from "vectordb"; import { Chunk, ContinueConfig, + DocsIndexingDetails, IDE, IdeInfo, ILLM, @@ -322,7 +323,7 @@ export default class DocsService { } // Returns true if startUrl has been indexed with current embeddingsProvider - async hasMetadata(startUrl: string): Promise> { + async hasMetadata(startUrl: string): Promise { const db = await this.getOrCreateSqliteDb(); const title = await db.get( `SELECT title FROM ${DocsService.sqlitebTableName} WHERE startUrl = ? AND embeddingsProviderId = ?`, @@ -660,6 +661,64 @@ export default class DocsService { return await this.retrieveChunks(startUrl, vector, nRetrieve); } + private lanceDBRowToChunk(row: LanceDbDocsRow): Chunk { + return { + digest: row.path, + filepath: row.path, + startLine: row.startline, + endLine: row.endline, + index: 0, + content: row.content, + otherMetadata: { + title: row.title, + }, + }; + } + async getDetails(startUrl: string): Promise { + const db = await this.getOrCreateSqliteDb(); + + try { + const preIndexedDoc = preIndexedDocs[startUrl]; + const isPreIndexedDoc = !!preIndexedDoc; + + const embeddingsProvider = + await this.getEmbeddingsProvider(isPreIndexedDoc); + const result = await db.get( + `SELECT startUrl, title, favicon FROM ${DocsService.sqlitebTableName} WHERE startUrl = ? AND embeddingsProviderId = ?`, + startUrl, + embeddingsProvider.embeddingId, + ); + + if (!result) { + throw new Error(`${startUrl} not found in sqlite`); + } + const siteIndexingConfig: SiteIndexingConfig = { + startUrl, + faviconUrl: result.favicon, + title: result.title, + }; + + const table = await this.getOrCreateLanceTable({ + initializationVector: [], + isPreIndexedDoc, + }); + const rows = (await table + .filter(`starturl = '${startUrl}'`) + .limit(1000) + .execute()) as LanceDbDocsRow[]; + + return { + startUrl, + config: siteIndexingConfig, + indexingStatus: this.statuses.get(startUrl), + chunks: rows.map(this.lanceDBRowToChunk), + isPreIndexedDoc, + }; + } catch (e) { + console.warn("Error getting details", e); + throw e; + } + } // This is split into its own function so that it can be recursive // in the case of fetching preindexed docs from s3 async retrieveChunks( @@ -703,17 +762,7 @@ export default class DocsService { }); } - return docs.map((doc) => ({ - digest: doc.path, - filepath: doc.path, - startLine: doc.startline, - endLine: doc.endline, - index: 0, - content: doc.content, - otherMetadata: { - title: doc.title, - }, - })); + return docs.map(this.lanceDBRowToChunk); } // SQLITE DB @@ -769,7 +818,7 @@ export default class DocsService { private async syncDocs( oldConfig: ContinueConfig | undefined, newConfig: ContinueConfig, - reindex: boolean, + forceReindex: boolean, ) { try { this.isSyncing = true; @@ -812,20 +861,25 @@ export default class DocsService { ) { changedDocs.push(doc); } else { - // if get's here, not changed, no update needed, mark as complete - this.handleStatusUpdate({ - type: "docs", - id: doc.startUrl, - embeddingsProviderId: this.config.embeddingsProvider.embeddingId, - isReindexing: false, - title: doc.title, - debugInfo: "Config sync: not changed", - icon: doc.faviconUrl, - url: doc.startUrl, - progress: 1, - description: "Complete", - status: "complete", - }); + if (forceReindex) { + changedDocs.push(doc); + } else { + // if get's here, not changed, no update needed, mark as complete + this.handleStatusUpdate({ + type: "docs", + id: doc.startUrl, + embeddingsProviderId: + this.config.embeddingsProvider.embeddingId, + isReindexing: false, + title: doc.title, + debugInfo: "Config sync: not changed", + icon: doc.faviconUrl, + url: doc.startUrl, + progress: 1, + description: "Complete", + status: "complete", + }); + } } } else { newDocs.push(doc); diff --git a/core/protocol/core.ts b/core/protocol/core.ts index 9495dc3b2..63474514f 100644 --- a/core/protocol/core.ts +++ b/core/protocol/core.ts @@ -9,6 +9,7 @@ import type { ContextProviderWithParams, ContextSubmenuItem, DiffLine, + DocsIndexingDetails, FileSymbolMap, IdeSettings, LLMFullCompletionOptions, @@ -201,7 +202,7 @@ export type ToCoreFromIdeOrWebviewProtocol = { "indexing/setPaused": [{ type: string; id: string; paused: boolean }, void]; "docs/getSuggestedDocs": [undefined, void]; "docs/initStatuses": [undefined, void]; - + "docs/getDetails": [{ startUrl: string }, DocsIndexingDetails]; addAutocompleteModel: [{ model: ModelDescription }, void]; "profiles/switch": [{ id: string }, undefined]; diff --git a/core/protocol/passThrough.ts b/core/protocol/passThrough.ts index 756b3db54..c7f6822bf 100644 --- a/core/protocol/passThrough.ts +++ b/core/protocol/passThrough.ts @@ -52,6 +52,7 @@ export const WEBVIEW_TO_CORE_PASS_THROUGH: (keyof ToCoreFromWebviewProtocol)[] = "indexing/setPaused", "docs/getSuggestedDocs", "docs/initStatuses", + "docs/getDetails", // "completeOnboarding", "addAutocompleteModel", diff --git a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/toolWindow/ContinueBrowser.kt b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/toolWindow/ContinueBrowser.kt index 5523bdeff..c670ec862 100644 --- a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/toolWindow/ContinueBrowser.kt +++ b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/toolWindow/ContinueBrowser.kt @@ -62,6 +62,7 @@ class ContinueBrowser(val project: Project, url: String) { "indexing/setPaused", "docs/getSuggestedDocs", "docs/initStatuses", + "docs/getDetails", // "completeOnboarding", "addAutocompleteModel", diff --git a/gui/src/components/indexing/DocsDetailsDialog.tsx b/gui/src/components/indexing/DocsDetailsDialog.tsx new file mode 100644 index 000000000..7b824291a --- /dev/null +++ b/gui/src/components/indexing/DocsDetailsDialog.tsx @@ -0,0 +1,176 @@ +import { + CheckIcon, + InformationCircleIcon, + PencilIcon, + PlusIcon, +} from "@heroicons/react/24/outline"; +import { + DocsIndexingDetails, + IndexingStatus, + PackageDocsResult, + SiteIndexingConfig, +} from "core"; +import preIndexedDocs from "core/indexing/docs/preIndexedDocs"; +import { usePostHog } from "posthog-js/react"; +import { + useCallback, + useContext, + useEffect, + useLayoutEffect, + useMemo, + useRef, + useState, +} from "react"; +import { useDispatch } from "react-redux"; +import { Input, SecondaryButton } from ".."; +import { IdeMessengerContext } from "../../context/IdeMessenger"; +import { useAppSelector } from "../../redux/hooks"; +import { updateConfig } from "../../redux/slices/configSlice"; +import { updateIndexingStatus } from "../../redux/slices/indexingSlice"; +import { setDialogMessage, setShowDialog } from "../../redux/slices/uiSlice"; +import FileIcon from "../FileIcon"; +import { ToolTip } from "../gui/Tooltip"; +import DocsIndexingPeeks from "../indexing/DocsIndexingPeeks"; +import { Tooltip } from "react-tooltip"; + +interface DocsDetailsDialogProps { + startUrl: string; +} +function DocsDetailsDialog({ startUrl }: DocsDetailsDialogProps) { + const config = useAppSelector((store) => store.config.config); + const posthog = usePostHog(); + const dispatch = useDispatch(); + + const ideMessenger = useContext(IdeMessengerContext); + + const closeDialog = () => { + dispatch(setShowDialog(false)); + dispatch(setDialogMessage(undefined)); + }; + + const [isLoading, setIsLoading] = useState(false); + const [isError, setIsError] = useState(false); + const [data, setData] = useState(undefined); + + const fetchData = useCallback(async () => { + setIsLoading(true); + setIsError(false); + + try { + const response = await ideMessenger.request("docs/getDetails", { + startUrl, + }); + if (response.status === "error") { + throw new Error(response.error); + } + setData(response.content); + } catch (error) { + setIsError(true); + } finally { + setIsLoading(false); + } + }, []); + + useEffect(() => { + fetchData(); + }, []); + + let comp =
Loading...
; + if (!isLoading) { + if (isError) { + comp = ( +
+
Error fetching docs details
+ Try again +
+ ); + } + if (data) { + comp = ( +
+

{`Title: ${data.config.title}`}

+

{`Pre-indexed doc: ${data.isPreIndexedDoc}`}

+ {!data.chunks?.length ? ( +
No article chunks
+ ) : ( +
+ + + + + + + + + {data.chunks.map((chunk, i) => { + const contentToolTipId = `docs-content-peek-${i}`; + const urlToolTipId = `docs-url-peek-${i}`; + return ( + <> + + + + + + {chunk.filepath} + + + {chunk.content} + + + ); + })} + +
FilepathContent
+ + {chunk.filepath} + + + + {chunk.content} + +
+
+ )} +
+ ); + } + } + + return ( +
+

Docs index

+

{ + e.stopPropagation(); + ideMessenger.post("openUrl", startUrl); + }} + > + {startUrl} +

+ {comp} +
+ Close +
+
+ ); +} + +export default DocsDetailsDialog; diff --git a/gui/src/components/indexing/DocsIndexingStatus.tsx b/gui/src/components/indexing/DocsIndexingStatus.tsx index 9fbd0f9fe..125bb202b 100644 --- a/gui/src/components/indexing/DocsIndexingStatus.tsx +++ b/gui/src/components/indexing/DocsIndexingStatus.tsx @@ -6,6 +6,7 @@ import { ArrowTopRightOnSquareIcon, CheckCircleIcon, ExclamationTriangleIcon, + EyeIcon, PauseCircleIcon, TrashIcon, } from "@heroicons/react/24/outline"; @@ -13,6 +14,7 @@ import { useAppDispatch, useAppSelector } from "../../redux/hooks"; import { updateIndexingStatus } from "../../redux/slices/indexingSlice"; import { setDialogMessage, setShowDialog } from "../../redux/slices/uiSlice"; import ConfirmationDialog from "../dialogs/ConfirmationDialog"; +import DocsDetailsDialog from "./DocsDetailsDialog"; interface IndexingStatusViewerProps { docConfig: SiteIndexingConfig; @@ -173,9 +175,27 @@ function DocsIndexingStatus({ docConfig }: IndexingStatusViewerProps) { }[status?.status]} - - {status?.description} - +
+ + {status?.description} + + {process.env.NODE_ENV === "development" && + status?.status === "complete" ? ( + { + dispatch(setShowDialog(true)); + dispatch( + setDialogMessage( + , + ), + ); + }} + > + Add Docs + + ) : null} +
); diff --git a/gui/src/index.css b/gui/src/index.css index ba8454b7b..93ccd384f 100644 --- a/gui/src/index.css +++ b/gui/src/index.css @@ -92,3 +92,13 @@ body { -webkit-line-clamp: 1; -webkit-box-orient: vertical; } + +.truncate-start { + display: inline-block; + vertical-align: middle; + overflow: hidden; + white-space: nowrap; + text-overflow: ellipsis; + direction: rtl; + width: 100%; +} From 8a71cc603288f7badb4b82521c19fc22b2d30165 Mon Sep 17 00:00:00 2001 From: Dallin Romney Date: Thu, 9 Jan 2025 11:41:52 +0000 Subject: [PATCH 002/146] docs crawler logging --- core/context/providers/DocsContextProvider.ts | 1 + core/indexing/docs/DocsCrawler.ts | 15 +++++++++------ gui/src/components/mainInput/resolveInput.ts | 4 +++- 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/core/context/providers/DocsContextProvider.ts b/core/context/providers/DocsContextProvider.ts index 9ee50c256..0d296c71d 100644 --- a/core/context/providers/DocsContextProvider.ts +++ b/core/context/providers/DocsContextProvider.ts @@ -88,6 +88,7 @@ class DocsContextProvider extends BaseContextProvider { } await docsService.isInitialized; + console.log("DOCS REQUEST", extras.fullInput, query); // Get chunks let chunks = await docsService.retrieveChunksFromQuery( extras.fullInput, // confusing: fullInput = the query, query = startUrl in this case diff --git a/core/indexing/docs/DocsCrawler.ts b/core/indexing/docs/DocsCrawler.ts index 8854d8e87..d8a13e80f 100644 --- a/core/indexing/docs/DocsCrawler.ts +++ b/core/indexing/docs/DocsCrawler.ts @@ -39,11 +39,13 @@ class DocsCrawler { maxRequestsPerCrawl: number = this.MAX_REQUESTS_PER_CRAWL, ): AsyncGenerator { if (startUrl.host === this.GITHUB_HOST) { + console.log("GITHUB DETECTED: Using Github"); yield* new GitHubCrawler(startUrl).crawl(); return; } try { + console.log(`Crawling ${startUrl.toString()}: Trying default crawler`); const pageData = await new DefaultCrawler(startUrl).crawl(); if (pageData.length > 0) { yield* pageData; @@ -54,9 +56,11 @@ class DocsCrawler { } if (this.shouldUseChromium()) { + console.log(`Crawling ${startUrl.toString()}: Trying chromium crawler`); yield* new ChromiumCrawler(startUrl, maxRequestsPerCrawl).crawl(); } else { let didCrawlSinglePage = false; + console.log(`Crawling ${startUrl.toString()}: Trying cheerio crawler`); for await (const pageData of new CheerioCrawler( startUrl, @@ -73,6 +77,10 @@ class DocsCrawler { this.chromiumInstaller.shouldProposeUseChromiumOnCrawlFailure(); if (shouldProposeUseChromium) { + console.log( + `Crawling ${startUrl.toString()}: Cheerio failed: proposing chromium crawler`, + ); + const didInstall = await this.chromiumInstaller.proposeAndAttemptInstall( startUrl.toString(), @@ -92,9 +100,4 @@ class DocsCrawler { } export default DocsCrawler; -export { - CheerioCrawler, - ChromiumCrawler, - ChromiumInstaller, - GitHubCrawler, -}; +export { CheerioCrawler, ChromiumCrawler, ChromiumInstaller, GitHubCrawler }; diff --git a/gui/src/components/mainInput/resolveInput.ts b/gui/src/components/mainInput/resolveInput.ts index 535a3074f..1707dfe21 100644 --- a/gui/src/components/mainInput/resolveInput.ts +++ b/gui/src/components/mainInput/resolveInput.ts @@ -128,7 +128,9 @@ async function resolveEditorContent({ selectedCode, selectedModelTitle, }); + console.log(item, stripImages(parts)); if (result.status === "success") { + console.log("SUCCESS", result); const resolvedItems = result.content; contextItems.push(...resolvedItems); for (const resolvedItem of resolvedItems) { @@ -238,7 +240,7 @@ function resolveParagraph( export function hasSlashCommandOrContextProvider( editorState: JSONContent, ): boolean { - if (!editorState.content) { + if (!editorState?.content) { return false; } From d6051f307c07835b6e9270a09a6eb1db13a927bf Mon Sep 17 00:00:00 2001 From: Dallin Romney Date: Thu, 9 Jan 2025 16:34:37 -0800 Subject: [PATCH 003/146] minor mentionlist updates --- core/context/providers/DocsContextProvider.ts | 6 ++++-- gui/src/components/mainInput/AddCodeToEditExtension.ts | 2 +- gui/src/components/mainInput/MentionExtension.ts | 3 ++- gui/src/components/mainInput/resolveInput.ts | 6 +++--- 4 files changed, 10 insertions(+), 7 deletions(-) diff --git a/core/context/providers/DocsContextProvider.ts b/core/context/providers/DocsContextProvider.ts index 0d296c71d..d014b4b9a 100644 --- a/core/context/providers/DocsContextProvider.ts +++ b/core/context/providers/DocsContextProvider.ts @@ -20,6 +20,7 @@ class DocsContextProvider extends BaseContextProvider { displayTitle: "Docs", description: "Type to search docs", type: "submenu", + renderInlineAs: "", }; constructor(options: any) { @@ -80,6 +81,8 @@ class DocsContextProvider extends BaseContextProvider { query: string, extras: ContextProviderExtras, ): Promise { + const nRetrieve = this.options?.nRetrieve ?? DocsContextProvider.nRetrieve; + // Get docs service const docsService = DocsService.getSingleton(); if (!docsService) { @@ -88,12 +91,11 @@ class DocsContextProvider extends BaseContextProvider { } await docsService.isInitialized; - console.log("DOCS REQUEST", extras.fullInput, query); // Get chunks let chunks = await docsService.retrieveChunksFromQuery( extras.fullInput, // confusing: fullInput = the query, query = startUrl in this case query, - this.options?.nRetrieve ?? DocsContextProvider.nRetrieve, + nRetrieve, ); if (!chunks?.length) { return []; diff --git a/gui/src/components/mainInput/AddCodeToEditExtension.ts b/gui/src/components/mainInput/AddCodeToEditExtension.ts index 795b7a2e4..f633c342b 100644 --- a/gui/src/components/mainInput/AddCodeToEditExtension.ts +++ b/gui/src/components/mainInput/AddCodeToEditExtension.ts @@ -89,7 +89,7 @@ export const AddCodeToEdit = Node.create({ default: null, parseHTML: (element) => element.getAttribute("data-renderInlineAs"), renderHTML: (attributes) => { - if (!attributes.renderInlineAs) { + if (typeof attributes.renderInlineAs !== "string") { return {}; } diff --git a/gui/src/components/mainInput/MentionExtension.ts b/gui/src/components/mainInput/MentionExtension.ts index 71d282d46..b17f2ee76 100644 --- a/gui/src/components/mainInput/MentionExtension.ts +++ b/gui/src/components/mainInput/MentionExtension.ts @@ -31,6 +31,7 @@ export const Mention = Node.create({ char: "@", pluginKey: MentionPluginKey, command: ({ editor, range, props }) => { + console.log(props); // increase range.to by one when the next node is of type "text" // and starts with a space character const nodeAfter = editor.view.state.selection.$to.nodeAfter; @@ -116,7 +117,7 @@ export const Mention = Node.create({ default: null, parseHTML: (element) => element.getAttribute("data-renderInlineAs"), renderHTML: (attributes) => { - if (!attributes.renderInlineAs) { + if (typeof attributes.renderInlineAs !== "string") { return {}; } diff --git a/gui/src/components/mainInput/resolveInput.ts b/gui/src/components/mainInput/resolveInput.ts index 1707dfe21..ae1a97cea 100644 --- a/gui/src/components/mainInput/resolveInput.ts +++ b/gui/src/components/mainInput/resolveInput.ts @@ -52,7 +52,7 @@ async function resolveEditorContent({ for (const p of editorState.content) { if (p.type === "paragraph") { const [text, ctxItems, foundSlashCommand] = resolveParagraph(p); - + console.log("PARAGRAPH RESOLVE", ctxItems); // Only take the first slash command\ if (foundSlashCommand && typeof slashCommand === "undefined") { slashCommand = foundSlashCommand; @@ -128,9 +128,7 @@ async function resolveEditorContent({ selectedCode, selectedModelTitle, }); - console.log(item, stripImages(parts)); if (result.status === "success") { - console.log("SUCCESS", result); const resolvedItems = result.content; contextItems.push(...resolvedItems); for (const resolvedItem of resolvedItems) { @@ -139,6 +137,7 @@ async function resolveEditorContent({ } } + console.log(stripImages(parts), contextItems); // cmd+enter to use codebase if (modifiers.useCodebase) { const result = await ideMessenger.request("context/getContextItems", { @@ -219,6 +218,7 @@ function resolveParagraph( if (child.type === "text") { text += text === "" ? child.text?.trimStart() : child.text; } else if (child.type === "mention") { + console.log("CHILD", child); text += typeof child.attrs?.renderInlineAs === "string" ? child.attrs.renderInlineAs From ae8ab99bf3e18683a1ab850bea9522339d9d9fd7 Mon Sep 17 00:00:00 2001 From: Fred Bricon Date: Mon, 13 Jan 2025 16:40:25 +0100 Subject: [PATCH 004/146] Fix syntax highlighting for .class files Signed-off-by: Fred Bricon --- core/util/index.test.ts | 11 ++++++++--- core/util/index.ts | 16 ++++++++++++++-- 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/core/util/index.test.ts b/core/util/index.test.ts index 74ee3ccc8..fc48a49b2 100644 --- a/core/util/index.test.ts +++ b/core/util/index.test.ts @@ -207,7 +207,7 @@ World it("should handle strings with only whitespace", () => { const result = dedent` - + `; expect(result).toBe(""); }); @@ -249,9 +249,9 @@ World it("should handle a string with only one non-empty line", () => { const result = dedent` - + Hello World! - + `; expect(result).toBe("Hello World!"); }); @@ -373,11 +373,16 @@ describe("getMarkdownLanguageTagForFile", () => { expect(getMarkdownLanguageTagForFile("test.py")).toBe("python"); expect(getMarkdownLanguageTagForFile("test.tsx")).toBe("tsx"); expect(getMarkdownLanguageTagForFile("test.java")).toBe("java"); + expect(getMarkdownLanguageTagForFile("test.class")).toBe("java"); expect(getMarkdownLanguageTagForFile("test.md")).toBe("markdown"); expect(getMarkdownLanguageTagForFile("test.sh")).toBe("shell"); expect(getMarkdownLanguageTagForFile("test.sql")).toBe("sql"); }); + it("should sanitize ranges from the extension", () => { + expect(getMarkdownLanguageTagForFile("test.java (1-5)")).toBe("java"); + }); + it("should return the extension if not in the known list", () => { expect(getMarkdownLanguageTagForFile("file.unknownext")).toBe("unknownext"); }); diff --git a/core/util/index.ts b/core/util/index.ts index 04dc6d567..4cb0f4920 100644 --- a/core/util/index.ts +++ b/core/util/index.ts @@ -74,6 +74,7 @@ export function getMarkdownLanguageTagForFile(filepath: string): string { tsx: "tsx", ts: "typescript", java: "java", + class:"java", //.class files decompile to Java go: "go", rb: "ruby", rs: "rust", @@ -96,17 +97,28 @@ export function getMarkdownLanguageTagForFile(filepath: string): string { ps1: "powershell", }; - const ext = filepath.split(".").pop(); + const ext = sanitizeExtension(filepath.split(".").pop()); return ext ? (extToLangMap[ext] ?? ext) : ""; } + +function sanitizeExtension(ext?: string): string|undefined { + if (ext) { + //ignore ranges in extension eg. "java (11-23)" + const match = ext.match(/^(\S+)\s*(\(.*\))?$/); + if (match) { + ext = match[1]; + } + } + return ext; +} + export function copyOf(obj: any): any { if (obj === null || obj === undefined) { return obj; } return JSON.parse(JSON.stringify(obj)); } -``; export function deduplicateArray( array: T[], From fe231a23a31e4d6f3f2b18f2554e17e9c21f27b2 Mon Sep 17 00:00:00 2001 From: Dallin Romney Date: Tue, 14 Jan 2025 18:36:23 -0800 Subject: [PATCH 005/146] replace trash context provider icon --- gui/src/components/mainInput/MentionList.tsx | 537 +++++++++--------- gui/src/components/mainInput/getSuggestion.ts | 2 +- 2 files changed, 272 insertions(+), 267 deletions(-) diff --git a/gui/src/components/mainInput/MentionList.tsx b/gui/src/components/mainInput/MentionList.tsx index aae963779..194f7415e 100644 --- a/gui/src/components/mainInput/MentionList.tsx +++ b/gui/src/components/mainInput/MentionList.tsx @@ -71,6 +71,7 @@ const ICONS_FOR_DROPDOWN: { [key: string]: any } = { debugger: BugAntIcon, os: CpuChipIcon, tree: Bars3BottomLeftIcon, + trash: TrashIcon, "prompt-files": DocumentTextIcon, "repo-map": FolderIcon, "/clear": TrashIcon, @@ -189,294 +190,298 @@ interface MentionListProps { onClose: () => void; } -const MentionList = forwardRef((props: MentionListProps, ref) => { - const dispatch = useDispatch(); +export const MentionList = forwardRef( + (props: MentionListProps, ref) => { + const dispatch = useDispatch(); - const ideMessenger = useContext(IdeMessengerContext); + const ideMessenger = useContext(IdeMessengerContext); - const [selectedIndex, setSelectedIndex] = useState(0); + const [selectedIndex, setSelectedIndex] = useState(0); - const [subMenuTitle, setSubMenuTitle] = useState( - undefined, - ); - const [querySubmenuItem, setQuerySubmenuItem] = useState< - ComboBoxItem | undefined - >(undefined); + const [subMenuTitle, setSubMenuTitle] = useState( + undefined, + ); + const [querySubmenuItem, setQuerySubmenuItem] = useState< + ComboBoxItem | undefined + >(undefined); - const [allItems, setAllItems] = useState([]); + const [allItems, setAllItems] = useState([]); - useEffect(() => { - const items = [...props.items]; - if (subMenuTitle === "Type to search docs") { - items.push({ - title: "Add Docs", - type: "action", - action: () => { - dispatch(setShowDialog(true)); - dispatch(setDialogMessage()); + useEffect(() => { + const items = [...props.items]; + if (subMenuTitle === "Type to search docs") { + items.push({ + title: "Add Docs", + type: "action", + action: () => { + dispatch(setShowDialog(true)); + dispatch(setDialogMessage()); - // Delete back to last '@' - const { tr } = props.editor.view.state; - const text = tr.doc.textBetween(0, tr.selection.from); - const start = text.lastIndexOf("@"); - props.editor.view.dispatch( - tr.delete(start, tr.selection.from).scrollIntoView(), - ); - }, - description: "Add a new documentation source", - }); - } else if (subMenuTitle === ".prompt files") { - items.push({ - title: "New .prompt file", - type: "action", - action: () => { - ideMessenger.post("config/newPromptFile", undefined); - const { tr } = props.editor.view.state; - const text = tr.doc.textBetween(0, tr.selection.from); - const start = text.lastIndexOf("@"); - if (start !== -1) { + // Delete back to last '@' + const { tr } = props.editor.view.state; + const text = tr.doc.textBetween(0, tr.selection.from); + const start = text.lastIndexOf("@"); props.editor.view.dispatch( tr.delete(start, tr.selection.from).scrollIntoView(), ); - } - props.onClose(); // Escape the mention list after creating a new prompt file - }, - description: "Create a new .prompt file", + }, + description: "Add a new documentation source", + }); + } else if (subMenuTitle === ".prompt files") { + items.push({ + title: "New .prompt file", + type: "action", + action: () => { + ideMessenger.post("config/newPromptFile", undefined); + const { tr } = props.editor.view.state; + const text = tr.doc.textBetween(0, tr.selection.from); + const start = text.lastIndexOf("@"); + if (start !== -1) { + props.editor.view.dispatch( + tr.delete(start, tr.selection.from).scrollIntoView(), + ); + } + props.onClose(); // Escape the mention list after creating a new prompt file + }, + description: "Create a new .prompt file", + }); + } + + setAllItems(items); + }, [subMenuTitle, props.items, props.editor]); + + const queryInputRef = useRef(null); + + useEffect(() => { + if (queryInputRef.current) { + queryInputRef.current.focus(); + } + }, [querySubmenuItem]); + + const selectItem = (index: number) => { + const item = allItems[index]; + + if (item.type === "action" && item.action) { + item.action(); + return; + } + + if ( + item.type === "contextProvider" && + item.contextProvider?.type === "submenu" + ) { + setSubMenuTitle(item.description); + if (item.id) { + props.enterSubmenu?.(props.editor, item.id); + } + return; + } + + if (item.contextProvider?.type === "query") { + // update editor to complete context provider title + const { tr } = props.editor.view.state; + const text = tr.doc.textBetween(0, tr.selection.from); + const partialText = text.slice(text.lastIndexOf("@") + 1); + const remainingText = item.title.slice(partialText.length); + props.editor.view.dispatch( + tr.insertText(remainingText, tr.selection.from), + ); + + setSubMenuTitle(item.description); + setQuerySubmenuItem(item); + return; + } + + if (item) { + props.command({ ...item, itemType: item.type }); + } + }; + + const totalItems = allItems.length; + + const itemRefs = useRef>([]); + + const upHandler = () => { + setSelectedIndex((prevIndex) => { + const newIndex = prevIndex - 1 >= 0 ? prevIndex - 1 : 0; + itemRefs.current[newIndex]?.scrollIntoView({ + behavior: "instant" as ScrollBehavior, + block: "nearest", + }); + return newIndex; }); - } + }; - setAllItems(items); - }, [subMenuTitle, props.items, props.editor]); - - const queryInputRef = useRef(null); - - useEffect(() => { - if (queryInputRef.current) { - queryInputRef.current.focus(); - } - }, [querySubmenuItem]); - - const selectItem = (index: number) => { - const item = allItems[index]; - - if (item.type === "action" && item.action) { - item.action(); - return; - } - - if ( - item.type === "contextProvider" && - item.contextProvider?.type === "submenu" - ) { - setSubMenuTitle(item.description); - if (item.id) { - props.enterSubmenu?.(props.editor, item.id); - } - return; - } - - if (item.contextProvider?.type === "query") { - // update editor to complete context provider title - const { tr } = props.editor.view.state; - const text = tr.doc.textBetween(0, tr.selection.from); - const partialText = text.slice(text.lastIndexOf("@") + 1); - const remainingText = item.title.slice(partialText.length); - props.editor.view.dispatch( - tr.insertText(remainingText, tr.selection.from), - ); - - setSubMenuTitle(item.description); - setQuerySubmenuItem(item); - return; - } - - if (item) { - props.command({ ...item, itemType: item.type }); - } - }; - - const totalItems = allItems.length; - - const itemRefs = useRef>([]); - - const upHandler = () => { - setSelectedIndex((prevIndex) => { - const newIndex = prevIndex - 1 >= 0 ? prevIndex - 1 : 0; - itemRefs.current[newIndex]?.scrollIntoView({ - behavior: "instant" as ScrollBehavior, - block: "nearest", + const downHandler = () => { + setSelectedIndex((prevIndex) => { + const newIndex = prevIndex + 1 < totalItems ? prevIndex + 1 : prevIndex; + itemRefs.current[newIndex]?.scrollIntoView({ + behavior: "instant" as ScrollBehavior, + block: "nearest", + }); + return newIndex; }); - return newIndex; - }); - }; + }; - const downHandler = () => { - setSelectedIndex((prevIndex) => { - const newIndex = prevIndex + 1 < totalItems ? prevIndex + 1 : prevIndex; - itemRefs.current[newIndex]?.scrollIntoView({ - behavior: "instant" as ScrollBehavior, - block: "nearest", - }); - return newIndex; - }); - }; + const enterHandler = () => { + selectItem(selectedIndex); + }; - const enterHandler = () => { - selectItem(selectedIndex); - }; + useEffect(() => setSelectedIndex(0), [allItems]); - useEffect(() => setSelectedIndex(0), [allItems]); - - useImperativeHandle(ref, () => ({ - onKeyDown: ({ event }: { event: KeyboardEvent }) => { - if (event.key === "ArrowUp") { - upHandler(); - return true; - } - - if (event.key === "ArrowDown") { - downHandler(); - return true; - } - - if (event.key === "Enter" || event.key === "Tab") { - enterHandler(); - event.stopPropagation(); - event.preventDefault(); - return true; - } - - if (event.key === "Escape") { - event.preventDefault(); - event.stopPropagation(); - return true; - } - - if (event.key === " ") { - if (allItems.length === 1) { - enterHandler(); + useImperativeHandle(ref, () => ({ + onKeyDown: ({ event }: { event: KeyboardEvent }) => { + if (event.key === "ArrowUp") { + upHandler(); return true; } - } - return false; - }, - })); + if (event.key === "ArrowDown") { + downHandler(); + return true; + } - const showFileIconForItem = (item: ComboBoxItem) => { - return ["file", "code"].includes(item.type); - }; + if (event.key === "Enter" || event.key === "Tab") { + enterHandler(); + event.stopPropagation(); + event.preventDefault(); + return true; + } - useEffect(() => { - itemRefs.current = itemRefs.current.slice(0, allItems.length); - }, [allItems]); + if (event.key === "Escape") { + event.preventDefault(); + event.stopPropagation(); + return true; + } - return ( - - {querySubmenuItem ? ( - { - if (!queryInputRef.current) { - return; - } - if (e.key === "Enter") { - if (e.shiftKey) { - queryInputRef.current.innerText += "\n"; - } else { - props.command({ - ...querySubmenuItem, - itemType: querySubmenuItem.type, - query: queryInputRef.current.value, - label: `${querySubmenuItem.label}: ${queryInputRef.current.value}`, - }); + if (event.key === " ") { + if (allItems.length === 1) { + enterHandler(); + return true; + } + } + + return false; + }, + })); + + const showFileIconForItem = (item: ComboBoxItem) => { + return ["file", "code"].includes(item.type); + }; + + useEffect(() => { + itemRefs.current = itemRefs.current.slice(0, allItems.length); + }, [allItems]); + + return ( + + {querySubmenuItem ? ( + { + if (!queryInputRef.current) { + return; } - } else if (e.key === "Escape") { - setQuerySubmenuItem(undefined); - setSubMenuTitle(undefined); - } - }} - /> - ) : ( - <> - {subMenuTitle && {subMenuTitle}} - {allItems.length ? ( - allItems.map((item, index) => ( - (itemRefs.current[index] = el)} - className={`item ${ - index === selectedIndex ? "is-selected" : "" - }`} - key={index} - onClick={() => selectItem(index)} - onMouseEnter={() => setSelectedIndex(index)} - > - -
- {showFileIconForItem(item) && ( - - )} - {!showFileIconForItem(item) && ( - <> - - - )} - {item.title} - {" "} -
- - {item.description} - {item.type === "contextProvider" && - item.contextProvider?.type === "submenu" && ( - + ) : ( + <> + {subMenuTitle && {subMenuTitle}} + {allItems.length ? ( + allItems.map((item, index) => ( + (itemRefs.current[index] = el)} + className={`item ${ + index === selectedIndex ? "is-selected" : "" + }`} + key={index} + onClick={() => selectItem(index)} + onMouseEnter={() => setSelectedIndex(index)} + > + +
+ {showFileIconForItem(item) && ( + )} - {item.subActions?.map((subAction) => { - const Icon = ICONS_FOR_DROPDOWN[subAction.icon]; - return ( - { - subAction.action(item); - e.stopPropagation(); - e.preventDefault(); - props.onClose(); - }} - text={undefined} - > - - - ); - })} + {!showFileIconForItem(item) && ( + <> + + + )} + {item.title} + {" "} +
+ + {item.description} + {item.type === "contextProvider" && + item.contextProvider?.type === "submenu" && ( + + )} + {item.subActions?.map((subAction) => { + const Icon = getIconFromDropdownItem( + subAction.icon, + "action", + ); + return ( + { + subAction.action(item); + e.stopPropagation(); + e.preventDefault(); + props.onClose(); + }} + text={undefined} + > + + + ); + })} +
-
-
- )) - ) : ( - No results - )} - {/* */} - - )} -
- ); -}); -export default MentionList; + + )) + ) : ( + No results + )} + {/* */} + + )} +
+ ); + }, +); diff --git a/gui/src/components/mainInput/getSuggestion.ts b/gui/src/components/mainInput/getSuggestion.ts index ecc7b835e..4d3590c19 100644 --- a/gui/src/components/mainInput/getSuggestion.ts +++ b/gui/src/components/mainInput/getSuggestion.ts @@ -7,7 +7,7 @@ import { import { MutableRefObject } from "react"; import tippy from "tippy.js"; import { IIdeMessenger } from "../../context/IdeMessenger"; -import MentionList from "./MentionList"; +import { MentionList } from "./MentionList"; import { ComboBoxItem, ComboBoxItemType, ComboBoxSubAction } from "./types"; import { TIPPY_DIV_ID } from "./TipTapEditor"; From 8c49bd8e848fe85c72e058fa660e788c452add8d Mon Sep 17 00:00:00 2001 From: Dallin Romney Date: Wed, 15 Jan 2025 08:50:38 -0800 Subject: [PATCH 006/146] docs comment --- core/context/providers/DocsContextProvider.ts | 5 ++++- core/indexing/docs/crawlers/GithubCrawler.test.ts | 0 2 files changed, 4 insertions(+), 1 deletion(-) create mode 100644 core/indexing/docs/crawlers/GithubCrawler.test.ts diff --git a/core/context/providers/DocsContextProvider.ts b/core/context/providers/DocsContextProvider.ts index dcc5000b7..5d79f989f 100644 --- a/core/context/providers/DocsContextProvider.ts +++ b/core/context/providers/DocsContextProvider.ts @@ -20,7 +20,10 @@ class DocsContextProvider extends BaseContextProvider { displayTitle: "Docs", description: "Type to search docs", type: "submenu", - renderInlineAs: "", + // Todo: consider a different renderInline so that when multiple docs are referenced in one message, + // Or the doc has an odd name unrelated to the content + // The name of the doc itself doesn't skew the embedding results + // renderInlineAs: "", }; constructor(options: any) { diff --git a/core/indexing/docs/crawlers/GithubCrawler.test.ts b/core/indexing/docs/crawlers/GithubCrawler.test.ts new file mode 100644 index 000000000..e69de29bb From c837378c2ef591cd0ef3da1b4bede3141b36d535 Mon Sep 17 00:00:00 2001 From: Dallin Romney Date: Wed, 15 Jan 2025 09:07:53 -0800 Subject: [PATCH 007/146] cleanup --- core/indexing/docs/DocsCrawler.ts | 8 -------- core/indexing/docs/crawlers/GithubCrawler.test.ts | 0 gui/src/components/mainInput/MentionExtension.ts | 1 - gui/src/components/mainInput/resolveInput.ts | 3 --- 4 files changed, 12 deletions(-) delete mode 100644 core/indexing/docs/crawlers/GithubCrawler.test.ts diff --git a/core/indexing/docs/DocsCrawler.ts b/core/indexing/docs/DocsCrawler.ts index d8a13e80f..24f937019 100644 --- a/core/indexing/docs/DocsCrawler.ts +++ b/core/indexing/docs/DocsCrawler.ts @@ -39,13 +39,11 @@ class DocsCrawler { maxRequestsPerCrawl: number = this.MAX_REQUESTS_PER_CRAWL, ): AsyncGenerator { if (startUrl.host === this.GITHUB_HOST) { - console.log("GITHUB DETECTED: Using Github"); yield* new GitHubCrawler(startUrl).crawl(); return; } try { - console.log(`Crawling ${startUrl.toString()}: Trying default crawler`); const pageData = await new DefaultCrawler(startUrl).crawl(); if (pageData.length > 0) { yield* pageData; @@ -56,11 +54,9 @@ class DocsCrawler { } if (this.shouldUseChromium()) { - console.log(`Crawling ${startUrl.toString()}: Trying chromium crawler`); yield* new ChromiumCrawler(startUrl, maxRequestsPerCrawl).crawl(); } else { let didCrawlSinglePage = false; - console.log(`Crawling ${startUrl.toString()}: Trying cheerio crawler`); for await (const pageData of new CheerioCrawler( startUrl, @@ -77,10 +73,6 @@ class DocsCrawler { this.chromiumInstaller.shouldProposeUseChromiumOnCrawlFailure(); if (shouldProposeUseChromium) { - console.log( - `Crawling ${startUrl.toString()}: Cheerio failed: proposing chromium crawler`, - ); - const didInstall = await this.chromiumInstaller.proposeAndAttemptInstall( startUrl.toString(), diff --git a/core/indexing/docs/crawlers/GithubCrawler.test.ts b/core/indexing/docs/crawlers/GithubCrawler.test.ts deleted file mode 100644 index e69de29bb..000000000 diff --git a/gui/src/components/mainInput/MentionExtension.ts b/gui/src/components/mainInput/MentionExtension.ts index b17f2ee76..364b241ee 100644 --- a/gui/src/components/mainInput/MentionExtension.ts +++ b/gui/src/components/mainInput/MentionExtension.ts @@ -31,7 +31,6 @@ export const Mention = Node.create({ char: "@", pluginKey: MentionPluginKey, command: ({ editor, range, props }) => { - console.log(props); // increase range.to by one when the next node is of type "text" // and starts with a space character const nodeAfter = editor.view.state.selection.$to.nodeAfter; diff --git a/gui/src/components/mainInput/resolveInput.ts b/gui/src/components/mainInput/resolveInput.ts index ae1a97cea..c9e1b698a 100644 --- a/gui/src/components/mainInput/resolveInput.ts +++ b/gui/src/components/mainInput/resolveInput.ts @@ -52,7 +52,6 @@ async function resolveEditorContent({ for (const p of editorState.content) { if (p.type === "paragraph") { const [text, ctxItems, foundSlashCommand] = resolveParagraph(p); - console.log("PARAGRAPH RESOLVE", ctxItems); // Only take the first slash command\ if (foundSlashCommand && typeof slashCommand === "undefined") { slashCommand = foundSlashCommand; @@ -137,7 +136,6 @@ async function resolveEditorContent({ } } - console.log(stripImages(parts), contextItems); // cmd+enter to use codebase if (modifiers.useCodebase) { const result = await ideMessenger.request("context/getContextItems", { @@ -218,7 +216,6 @@ function resolveParagraph( if (child.type === "text") { text += text === "" ? child.text?.trimStart() : child.text; } else if (child.type === "mention") { - console.log("CHILD", child); text += typeof child.attrs?.renderInlineAs === "string" ? child.attrs.renderInlineAs From 16b9a21a34f4f91b2758458e16d35252eafeb1f0 Mon Sep 17 00:00:00 2001 From: Fred Bricon Date: Wed, 15 Jan 2025 19:07:24 +0100 Subject: [PATCH 008/146] Intercept Ollama errors before Webview, to display Download/Start options Signed-off-by: Fred Bricon --- core/util/ollamaHelper.ts | 8 +++--- .../src/autocomplete/completionProvider.ts | 6 ++--- extensions/vscode/src/commands.ts | 4 +++ extensions/vscode/src/webviewProtocol.ts | 25 ++++++++++++++++++- 4 files changed, 35 insertions(+), 8 deletions(-) diff --git a/core/util/ollamaHelper.ts b/core/util/ollamaHelper.ts index 1e9c52490..a00e869dd 100644 --- a/core/util/ollamaHelper.ts +++ b/core/util/ollamaHelper.ts @@ -11,7 +11,7 @@ export async function isOllamaInstalled(): Promise { }); } -export async function startLocalOllama(ide: IDE): Promise { +export async function startLocalOllama(ide: IDE): Promise { let startCommand: string | undefined; switch (process.platform) { @@ -20,16 +20,16 @@ export async function startLocalOllama(ide: IDE): Promise { break; case "win32"://Windows - startCommand = `& "ollama app.exe"\n`; + startCommand = "& \"ollama app.exe\"\n"; break; default: //Linux... - const start_script_path = path.resolve(__dirname, './start_ollama.sh'); + const start_script_path = path.resolve(__dirname, "./start_ollama.sh"); if (await ide.fileExists(`file:/${start_script_path}`)) { startCommand = `set -e && chmod +x ${start_script_path} && ${start_script_path}\n`; console.log(`Ollama Linux startup script at : ${start_script_path}`); } else { - ide.showToast("error", `Cannot start Ollama: could not find ${start_script_path}!`) + return ide.showToast("error", `Cannot start Ollama: could not find ${start_script_path}!`) } } if (startCommand) { diff --git a/extensions/vscode/src/autocomplete/completionProvider.ts b/extensions/vscode/src/autocomplete/completionProvider.ts index c10d4d5f1..b7680b686 100644 --- a/extensions/vscode/src/autocomplete/completionProvider.ts +++ b/extensions/vscode/src/autocomplete/completionProvider.ts @@ -44,11 +44,11 @@ export class ContinueCompletionProvider implements vscode.InlineCompletionItemProvider { private onError(e: any) { - const options = ["Documentation"]; + let options = ["Documentation"]; if (e.message.includes("Ollama may not be installed")) { options.push("Download Ollama"); } else if (e.message.includes("Ollama may not be running")) { - options.unshift("Start Ollama"); // We want "Start" to be the default choice + options = ["Start Ollama"]; // We want "Start" to be the only choice } if (e.message.includes("Please sign in with GitHub")) { @@ -70,7 +70,7 @@ export class ContinueCompletionProvider ); } else if (val === "Download Ollama") { vscode.env.openExternal(vscode.Uri.parse("https://ollama.ai/download")); - } else if (val == "Start Ollama") { + } else if (val === "Start Ollama") { startLocalOllama(this.ide); } }); diff --git a/extensions/vscode/src/commands.ts b/extensions/vscode/src/commands.ts index d8019cfe1..bbf1cfd74 100644 --- a/extensions/vscode/src/commands.ts +++ b/extensions/vscode/src/commands.ts @@ -33,6 +33,7 @@ import { Battery } from "./util/battery"; import { VsCodeIde } from "./VsCodeIde"; import type { VsCodeWebviewProtocol } from "./webviewProtocol"; +import { startLocalOllama } from "core/util/ollamaHelper"; let fullScreenPanel: vscode.WebviewPanel | undefined; @@ -1000,6 +1001,9 @@ const getCommandsMap: ( "continue.openAccountDialog": () => { sidebar.webviewProtocol?.request("openDialogMessage", "account"); }, + "continue.startLocalOllama": () => { + startLocalOllama(ide); + }, }; }; diff --git a/extensions/vscode/src/webviewProtocol.ts b/extensions/vscode/src/webviewProtocol.ts index bfbb37ce6..c5853d12a 100644 --- a/extensions/vscode/src/webviewProtocol.ts +++ b/extensions/vscode/src/webviewProtocol.ts @@ -81,6 +81,30 @@ export class VsCodeWebviewProtocol respond({ done: true, content: response ?? {}, status: "success" }); } } catch (e: any) { + let message = e.message; + //Intercept Ollama errors for special handling + if (message.includes("Ollama may not")) { + const options = []; + if (message.includes("be installed")) { + options.push("Download Ollama"); + } else if (message.includes("be running")) { + options.push("Start Ollama"); + } + if (options.length > 0) { + // Respond without an error, so the UI doesn't show the error component + respond({ done: true, status: "error" }); + // Show native vscode error message instead, with options to download/start Ollama + vscode.window.showErrorMessage(e.message, ...options).then(async (val) => { + if (val === "Download Ollama") { + vscode.env.openExternal(vscode.Uri.parse("https://ollama.ai/download")); + } else if (val === "Start Ollama") { + vscode.commands.executeCommand("continue.startLocalOllama"); + } + }); + return; + } + } + respond({ done: true, error: e.message, status: "error" }); const stringified = JSON.stringify({ msg }, null, 2); @@ -96,7 +120,6 @@ export class VsCodeWebviewProtocol return; } - let message = e.message; if (e.cause) { if (e.cause.name === "ConnectTimeoutError") { message = `Connection timed out. If you expect it to take a long time to connect, you can increase the timeout in config.json by setting "requestOptions": { "timeout": 10000 }. You can find the full config reference here: https://docs.continue.dev/reference/config`; From 3b7029350ba265ea1dcd70b7cbbdcdadac3a160a Mon Sep 17 00:00:00 2001 From: henry Date: Wed, 15 Jan 2025 17:54:05 -0600 Subject: [PATCH 009/146] full screen opens in front of vscode --- extensions/vscode/src/commands.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/extensions/vscode/src/commands.ts b/extensions/vscode/src/commands.ts index d8019cfe1..b322d6afb 100644 --- a/extensions/vscode/src/commands.ts +++ b/extensions/vscode/src/commands.ts @@ -776,6 +776,7 @@ const getCommandsMap: ( sessionId, ); } + panel.reveal(); sessionLoader.dispose(); }); From 6a93bd991362be2df2155873b453785f08bdef42 Mon Sep 17 00:00:00 2001 From: Dallin Romney Date: Sun, 19 Jan 2025 22:08:13 -0800 Subject: [PATCH 010/146] fix import --- gui/src/components/mainInput/MentionList.tsx | 393 +++++++++--------- gui/src/components/mainInput/getSuggestion.ts | 2 +- 2 files changed, 203 insertions(+), 192 deletions(-) diff --git a/gui/src/components/mainInput/MentionList.tsx b/gui/src/components/mainInput/MentionList.tsx index 74c074b1a..530144e4a 100644 --- a/gui/src/components/mainInput/MentionList.tsx +++ b/gui/src/components/mainInput/MentionList.tsx @@ -71,7 +71,6 @@ const ICONS_FOR_DROPDOWN: { [key: string]: any } = { debugger: BugAntIcon, os: CpuChipIcon, tree: Bars3BottomLeftIcon, - trash: TrashIcon, "prompt-files": DocumentTextIcon, "repo-map": FolderIcon, "/clear": TrashIcon, @@ -82,6 +81,7 @@ const ICONS_FOR_DROPDOWN: { [key: string]: any } = { google: GoogleIcon, "gitlab-mr": GitlabIcon, http: GlobeAltIcon, + trash: TrashIcon, }; export function getIconFromDropdownItem( @@ -190,199 +190,209 @@ interface MentionListProps { onClose: () => void; } -export const MentionList = forwardRef( - (props: MentionListProps, ref) => { - const dispatch = useDispatch(); +const MentionList = forwardRef((props: MentionListProps, ref) => { + const dispatch = useDispatch(); - const ideMessenger = useContext(IdeMessengerContext); + const ideMessenger = useContext(IdeMessengerContext); - const [selectedIndex, setSelectedIndex] = useState(0); + const [selectedIndex, setSelectedIndex] = useState(0); - const [subMenuTitle, setSubMenuTitle] = useState( - undefined, - ); - const [querySubmenuItem, setQuerySubmenuItem] = useState< - ComboBoxItem | undefined - >(undefined); + const [subMenuTitle, setSubMenuTitle] = useState( + undefined, + ); + const [querySubmenuItem, setQuerySubmenuItem] = useState< + ComboBoxItem | undefined + >(undefined); - const [allItems, setAllItems] = useState([]); + const [allItems, setAllItems] = useState([]); - useEffect(() => { - const items = [...props.items]; - if (subMenuTitle === "Type to search docs") { - items.push({ - title: "Add Docs", - type: "action", - action: () => { - dispatch(setShowDialog(true)); - dispatch(setDialogMessage()); + useEffect(() => { + const items = [...props.items]; + if (subMenuTitle === "Type to search docs") { + items.push({ + title: "Add Docs", + type: "action", + action: () => { + dispatch(setShowDialog(true)); + dispatch(setDialogMessage()); - // Delete back to last '@' - const { tr } = props.editor.view.state; - const text = tr.doc.textBetween(0, tr.selection.from); - const start = text.lastIndexOf("@"); + // Delete back to last '@' + const { tr } = props.editor.view.state; + const text = tr.doc.textBetween(0, tr.selection.from); + const start = text.lastIndexOf("@"); + props.editor.view.dispatch( + tr.delete(start, tr.selection.from).scrollIntoView(), + ); + }, + description: "Add a new documentation source", + }); + } else if (subMenuTitle === ".prompt files") { + items.push({ + title: "New .prompt file", + type: "action", + action: () => { + ideMessenger.post("config/newPromptFile", undefined); + const { tr } = props.editor.view.state; + const text = tr.doc.textBetween(0, tr.selection.from); + const start = text.lastIndexOf("@"); + if (start !== -1) { props.editor.view.dispatch( tr.delete(start, tr.selection.from).scrollIntoView(), ); - }, - description: "Add a new documentation source", - }); - } else if (subMenuTitle === ".prompt files") { - items.push({ - title: "New .prompt file", - type: "action", - action: () => { - ideMessenger.post("config/newPromptFile", undefined); - const { tr } = props.editor.view.state; - const text = tr.doc.textBetween(0, tr.selection.from); - const start = text.lastIndexOf("@"); - if (start !== -1) { - props.editor.view.dispatch( - tr.delete(start, tr.selection.from).scrollIntoView(), - ); - } - props.onClose(); // Escape the mention list after creating a new prompt file - }, - description: "Create a new .prompt file", - }); - } - - setAllItems(items); - }, [subMenuTitle, props.items, props.editor]); - - const queryInputRef = useRef(null); - - useEffect(() => { - if (queryInputRef.current) { - queryInputRef.current.focus(); - } - }, [querySubmenuItem]); - - const selectItem = (index: number) => { - const item = allItems[index]; - - if (item.type === "action" && item.action) { - item.action(); - return; - } - - if ( - item.type === "contextProvider" && - item.contextProvider?.type === "submenu" - ) { - setSubMenuTitle(item.description); - if (item.id) { - props.enterSubmenu?.(props.editor, item.id); - } - return; - } - - if (item.contextProvider?.type === "query") { - // update editor to complete context provider title - const { tr } = props.editor.view.state; - const text = tr.doc.textBetween(0, tr.selection.from); - const partialText = text.slice(text.lastIndexOf("@") + 1); - const remainingText = item.title.slice(partialText.length); - props.editor.view.dispatch( - tr.insertText(remainingText, tr.selection.from), - ); - - setSubMenuTitle(item.description); - setQuerySubmenuItem(item); - return; - } - - if (item) { - props.command({ ...item, itemType: item.type }); - } - }; - - const totalItems = allItems.length; - - const itemRefs = useRef>([]); - - const upHandler = () => { - setSelectedIndex((prevIndex) => { - const newIndex = prevIndex - 1 >= 0 ? prevIndex - 1 : 0; - itemRefs.current[newIndex]?.scrollIntoView({ - behavior: "instant" as ScrollBehavior, - block: "nearest", - }); - return newIndex; - }); - }; - - const downHandler = () => { - setSelectedIndex((prevIndex) => { - const newIndex = prevIndex + 1 < totalItems ? prevIndex + 1 : prevIndex; - itemRefs.current[newIndex]?.scrollIntoView({ - behavior: "instant" as ScrollBehavior, - block: "nearest", - }); - return newIndex; - }); - }; - - const enterHandler = () => { - selectItem(selectedIndex); - }; - - useEffect(() => setSelectedIndex(0), [allItems]); - - useImperativeHandle(ref, () => ({ - onKeyDown: ({ event }: { event: KeyboardEvent }) => { - if (event.key === "ArrowUp") { - upHandler(); - return true; - } - - if (event.key === "ArrowDown") { - downHandler(); - return true; - } - - if (event.key === "Enter" || event.key === "Tab") { - enterHandler(); - event.stopPropagation(); - event.preventDefault(); - return true; - } - - if (event.key === "Escape") { - event.preventDefault(); - event.stopPropagation(); - return true; - } - - if (event.key === " ") { - if (allItems.length === 1) { - enterHandler(); - return true; } + props.onClose(); // Escape the mention list after creating a new prompt file + }, + description: "Create a new .prompt file", + }); + } + + setAllItems(items); + }, [subMenuTitle, props.items, props.editor]); + + const queryInputRef = useRef(null); + + useEffect(() => { + if (queryInputRef.current) { + queryInputRef.current.focus(); + } + }, [querySubmenuItem]); + + const selectItem = (index: number) => { + const item = allItems[index]; + + if (item.type === "action" && item.action) { + item.action(); + return; + } + + if ( + item.type === "contextProvider" && + item.contextProvider?.type === "submenu" + ) { + setSubMenuTitle(item.description); + if (item.id) { + props.enterSubmenu?.(props.editor, item.id); + } + return; + } + + if (item.contextProvider?.type === "query") { + // update editor to complete context provider title + const { tr } = props.editor.view.state; + const text = tr.doc.textBetween(0, tr.selection.from); + const partialText = text.slice(text.lastIndexOf("@") + 1); + const remainingText = item.title.slice(partialText.length); + props.editor.view.dispatch( + tr.insertText(remainingText, tr.selection.from), + ); + + setSubMenuTitle(item.description); + setQuerySubmenuItem(item); + return; + } + + if (item) { + props.command({ ...item, itemType: item.type }); + } + }; + + const totalItems = allItems.length; + + const itemRefs = useRef>([]); + + const upHandler = () => { + setSelectedIndex((prevIndex) => { + const newIndex = prevIndex - 1 >= 0 ? prevIndex - 1 : 0; + itemRefs.current[newIndex]?.scrollIntoView({ + behavior: "instant" as ScrollBehavior, + block: "nearest", + }); + return newIndex; + }); + }; + + const downHandler = () => { + setSelectedIndex((prevIndex) => { + const newIndex = prevIndex + 1 < totalItems ? prevIndex + 1 : prevIndex; + itemRefs.current[newIndex]?.scrollIntoView({ + behavior: "instant" as ScrollBehavior, + block: "nearest", + }); + return newIndex; + }); + }; + + const enterHandler = () => { + selectItem(selectedIndex); + }; + + useEffect(() => setSelectedIndex(0), [allItems]); + + useImperativeHandle(ref, () => ({ + onKeyDown: ({ event }: { event: KeyboardEvent }) => { + if (event.key === "ArrowUp") { + upHandler(); + return true; + } + + if (event.key === "ArrowDown") { + downHandler(); + return true; + } + + if (event.key === "Enter" || event.key === "Tab") { + enterHandler(); + event.stopPropagation(); + event.preventDefault(); + return true; + } + + if (event.key === "Escape") { + event.preventDefault(); + event.stopPropagation(); + return true; + } + + if (event.key === " ") { + if (allItems.length === 1) { + enterHandler(); + return true; } + } - return false; - }, - })); + return false; + }, + })); - const showFileIconForItem = (item: ComboBoxItem) => { - return ["file", "code"].includes(item.type); - }; + const showFileIconForItem = (item: ComboBoxItem) => { + return ["file", "code"].includes(item.type); + }; - useEffect(() => { - itemRefs.current = itemRefs.current.slice(0, allItems.length); - }, [allItems]); + useEffect(() => { + itemRefs.current = itemRefs.current.slice(0, allItems.length); + }, [allItems]); - return ( - - {querySubmenuItem ? ( - { - if (!queryInputRef.current) { - return; + return ( + + {querySubmenuItem ? ( + { + if (!queryInputRef.current) { + return; + } + if (e.key === "Enter") { + if (e.shiftKey) { + queryInputRef.current.innerText += "\n"; + } else { + props.command({ + ...querySubmenuItem, + itemType: querySubmenuItem.type, + query: queryInputRef.current.value, + label: `${querySubmenuItem.label}: ${queryInputRef.current.value}`, + }); } } else if (e.key === "Escape") { setQuerySubmenuItem(undefined); @@ -462,15 +472,16 @@ export const MentionList = forwardRef( ); })} - - )) - ) : ( - No results - )} - {/* */} - - )} - - ); - }, -); + + + )) + ) : ( + No results + )} + {/* */} + + )} + + ); +}); +export default MentionList; diff --git a/gui/src/components/mainInput/getSuggestion.ts b/gui/src/components/mainInput/getSuggestion.ts index 4d3590c19..ecc7b835e 100644 --- a/gui/src/components/mainInput/getSuggestion.ts +++ b/gui/src/components/mainInput/getSuggestion.ts @@ -7,7 +7,7 @@ import { import { MutableRefObject } from "react"; import tippy from "tippy.js"; import { IIdeMessenger } from "../../context/IdeMessenger"; -import { MentionList } from "./MentionList"; +import MentionList from "./MentionList"; import { ComboBoxItem, ComboBoxItemType, ComboBoxSubAction } from "./types"; import { TIPPY_DIV_ID } from "./TipTapEditor"; From c637b7ba3d9fc175052f5499623dfc7ec3d328d7 Mon Sep 17 00:00:00 2001 From: Dallin Romney Date: Sun, 19 Jan 2025 22:17:59 -0800 Subject: [PATCH 011/146] don't persist indexing status --- gui/src/redux/store.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/gui/src/redux/store.ts b/gui/src/redux/store.ts index 4432b3be6..b1c74f34b 100644 --- a/gui/src/redux/store.ts +++ b/gui/src/redux/store.ts @@ -36,6 +36,7 @@ const saveSubsetFilters = [ createFilter("editModeState", []), createFilter("config", ["defaultModelTitle"]), createFilter("ui", ["toolSettings", "useTools"]), + createFilter("indexing", []), ]; const migrations: MigrationManifest = { From 3286a93d738613688e9d5996652457f20c6dc5a2 Mon Sep 17 00:00:00 2001 From: Dallin Romney Date: Sun, 19 Jan 2025 23:08:33 -0800 Subject: [PATCH 012/146] remove unused useFilePrefix --- core/config/types.ts | 1 - core/util/parameters.ts | 1 - docs/docs/customize/deep-dives/autocomplete.md | 1 - docs/docs/reference.md | 1 - .../current/customize/deep-dives/autocomplete.md | 1 - .../zh-CN/docusaurus-plugin-content-docs/current/reference.md | 1 - extensions/vscode/config_schema.json | 4 ---- packages/config-types/src/index.ts | 1 - 8 files changed, 11 deletions(-) diff --git a/core/config/types.ts b/core/config/types.ts index e5797bdb7..6d2847c11 100644 --- a/core/config/types.ts +++ b/core/config/types.ts @@ -902,7 +902,6 @@ declare global { export interface TabAutocompleteOptions { disable: boolean; - useFileSuffix: boolean; maxPromptTokens: number; debounceDelay: number; maxSuffixPercentage: number; diff --git a/core/util/parameters.ts b/core/util/parameters.ts index a7a11b503..648253712 100644 --- a/core/util/parameters.ts +++ b/core/util/parameters.ts @@ -2,7 +2,6 @@ import { TabAutocompleteOptions } from "../index.js"; export const DEFAULT_AUTOCOMPLETE_OPTS: TabAutocompleteOptions = { disable: false, - useFileSuffix: true, maxPromptTokens: 1024, prefixPercentage: 0.3, maxSuffixPercentage: 0.2, diff --git a/docs/docs/customize/deep-dives/autocomplete.md b/docs/docs/customize/deep-dives/autocomplete.md index 221a6d49f..a5e143e23 100644 --- a/docs/docs/customize/deep-dives/autocomplete.md +++ b/docs/docs/customize/deep-dives/autocomplete.md @@ -60,7 +60,6 @@ This object allows you to customize the behavior of tab-autocomplete. The availa - `disable`: Disable autocomplete (can also be done from IDE settings) - `template`: An optional template string to be used for autocomplete. It will be rendered with the Mustache templating language, and is passed the 'prefix' and 'suffix' variables. (String) -- `useFileSuffix`: Determines whether to use the file suffix in the prompt. (Boolean) - `maxPromptTokens`: The maximum number of prompt tokens to use. A smaller number will yield faster completions, but less context. (Number) - `prefixPercentage`: The percentage of the input that should be dedicated to the prefix. (Number) - `maxSuffixPercentage`: The maximum percentage of the prompt that can be dedicated to the suffix. (Number) diff --git a/docs/docs/reference.md b/docs/docs/reference.md index d3c491f4c..3e2ab48da 100644 --- a/docs/docs/reference.md +++ b/docs/docs/reference.md @@ -83,7 +83,6 @@ Specifies options for tab autocompletion behavior. **Properties:** - `disable`: If `true`, disables tab autocomplete (default: `false`). -- `useFileSuffix`: If `true`, includes file suffix in the prompt. - `maxPromptTokens`: Maximum number of tokens for the prompt. - `debounceDelay`: Delay (in ms) before triggering autocomplete. - `maxSuffixPercentage`: Maximum percentage of prompt for suffix. diff --git a/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/customize/deep-dives/autocomplete.md b/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/customize/deep-dives/autocomplete.md index 15cb94c4d..985a66809 100644 --- a/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/customize/deep-dives/autocomplete.md +++ b/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/customize/deep-dives/autocomplete.md @@ -60,7 +60,6 @@ ollama run starcoder2:3b - `disable`: 禁用自动补全(也可以在 IDE 配置中完成) - `template`: 一个用来自动补全的可选的模板字符串。它使用 Mustache 模板语言渲染,并且传递 'prefix' 和 'suffix' 变量。(字符串) -- `useFileSuffix`: 决定是否使用文件后缀在提示词中。(布尔型) - `maxPromptTokens`: 提示词使用的 token 的最大数量。一个较小的数字生成较快的补全,但是较少的上下文。(数字) - `prefixPercentage`: 输入专注于前缀的百分比。(数字) - `maxSuffixPercentage`: The maximum percentage of the prompt that can be dedicated to the suffix. (Number) diff --git a/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/reference.md b/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/reference.md index 0eeacafec..f7ba51cbf 100644 --- a/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/reference.md +++ b/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/reference.md @@ -83,7 +83,6 @@ Specifies options for tab autocompletion behavior. **Properties:** - `disable`: If `true`, disables tab autocomplete (default: `false`). -- `useFileSuffix`: If `true`, includes file suffix in the prompt. - `maxPromptTokens`: Maximum number of tokens for the prompt. - `debounceDelay`: Delay (in ms) before triggering autocomplete. - `maxSuffixPercentage`: Maximum percentage of prompt for suffix. diff --git a/extensions/vscode/config_schema.json b/extensions/vscode/config_schema.json index 1273a7c40..2b12cf21e 100644 --- a/extensions/vscode/config_schema.json +++ b/extensions/vscode/config_schema.json @@ -3080,10 +3080,6 @@ "description": "Disable tab autocomplete. This can also be done from the IDE settings.", "default": false }, - "useFileSuffix": { - "type": "boolean", - "description": "Determines whether to use the file suffix in the prompt." - }, "maxPromptTokens": { "type": "number", "description": "The maximum number of prompt tokens to use. A smaller number will yield faster completions, but less context." diff --git a/packages/config-types/src/index.ts b/packages/config-types/src/index.ts index 5ba03b8cc..8a0806d7b 100644 --- a/packages/config-types/src/index.ts +++ b/packages/config-types/src/index.ts @@ -133,7 +133,6 @@ export type UiOptions = z.infer; export const tabAutocompleteOptionsSchema = z.object({ disable: z.boolean(), - useFileSuffix: z.boolean(), maxPromptTokens: z.number(), debounceDelay: z.number(), maxSuffixPercentage: z.number(), From f162286f2359c20b2af987693a3623846e153172 Mon Sep 17 00:00:00 2001 From: Dallin Romney Date: Mon, 20 Jan 2025 01:09:23 -0800 Subject: [PATCH 013/146] use file suffix removal p2 --- core/index.d.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/core/index.d.ts b/core/index.d.ts index 098628c0f..7f98129f2 100644 --- a/core/index.d.ts +++ b/core/index.d.ts @@ -940,7 +940,6 @@ export interface RerankerDescription { export interface TabAutocompleteOptions { disable: boolean; - useFileSuffix: boolean; maxPromptTokens: number; debounceDelay: number; maxSuffixPercentage: number; From d166bcd8354a835fded45aa3eff82f34f7e769b9 Mon Sep 17 00:00:00 2001 From: Patrick Erichsen Date: Tue, 21 Jan 2025 09:54:21 -0800 Subject: [PATCH 014/146] Update Edit.test.ts --- extensions/vscode/e2e/tests/Edit.test.ts | 80 ++++++++++++++---------- 1 file changed, 47 insertions(+), 33 deletions(-) diff --git a/extensions/vscode/e2e/tests/Edit.test.ts b/extensions/vscode/e2e/tests/Edit.test.ts index e79dd010c..66b82aaf3 100644 --- a/extensions/vscode/e2e/tests/Edit.test.ts +++ b/extensions/vscode/e2e/tests/Edit.test.ts @@ -1,19 +1,15 @@ +import { expect } from "chai"; import { - EditorView, WebView, - WebDriver, - Key, VSBrowser, - InputBox, TextEditor, - Workbench, + CodeLens, } from "vscode-extension-tester"; import { EditActions } from "../actions/Edit.actions"; import { GlobalActions } from "../actions/Global.actions"; import { GUIActions } from "../actions/GUI.actions"; import { DEFAULT_TIMEOUT } from "../constants"; -import { EditSelectors } from "../selectors/Edit.selectors"; import { GUISelectors } from "../selectors/GUI.selectors"; import { TestUtils } from "../TestUtils"; @@ -58,9 +54,27 @@ describe("Edit Test", () => { afterEach(async function () { this.timeout(DEFAULT_TIMEOUT.XL); + await editor.clearText(); + + ({ view } = await GUIActions.switchToReactIframe()); + + const tipTapEditor = await GUISelectors.getMessageInputFieldAtIndex( + view, + 0, + ); + await tipTapEditor.clear(); }); + async function getCodeLensWithRetry(editor: TextEditor, text: string) { + let codeLens: CodeLens | undefined; + await TestUtils.waitForSuccess(async () => { + codeLens = await editor.getCodeLens(text); + expect(codeLens).to.not.be.undefined; + }, DEFAULT_TIMEOUT.SM); + return codeLens; + } + it("Accepts an Edit in the GUI", async () => { ({ view } = await GUIActions.switchToReactIframe()); @@ -68,14 +82,14 @@ describe("Edit Test", () => { await view.switchBack(); - const editorText = await editor.getText(); + await TestUtils.waitForSuccess(async () => { + const editorText = await editor.getText(); - await TestUtils.waitForSuccess( - async () => + expect( !editorText.includes(originalEditorText) && - editorText.includes(llmResponse), - DEFAULT_TIMEOUT.SM, - ); + editorText.includes(llmResponse), + ).to.be.true; + }, DEFAULT_TIMEOUT.SM); }).timeout(DEFAULT_TIMEOUT.XL); it("Rejects an Edit in the GUI", async () => { @@ -85,41 +99,41 @@ describe("Edit Test", () => { await view.switchBack(); - const editorText = await editor.getText(); + await TestUtils.waitForSuccess(async () => { + const editorText = await editor.getText(); - await TestUtils.waitForSuccess( - async () => + expect( editorText.includes(originalEditorText) && - !editorText.includes(llmResponse), - DEFAULT_TIMEOUT.SM, - ); + !editorText.includes(llmResponse), + ).to.be.true; + }, DEFAULT_TIMEOUT.SM); }).timeout(DEFAULT_TIMEOUT.XL); it("Accepts an Edit using CodeLens buttons", async () => { const acceptCodeLens = await editor.getCodeLens("Accept"); await acceptCodeLens?.click(); - const editorText = await editor.getText(); + await TestUtils.waitForSuccess(async () => { + const editorText = await editor.getText(); - await TestUtils.waitForSuccess( - async () => + expect( !editorText.includes(originalEditorText) && - editorText.includes(llmResponse), - DEFAULT_TIMEOUT.SM, - ); + editorText.includes(llmResponse), + ).to.be.true; + }, DEFAULT_TIMEOUT.SM); }).timeout(DEFAULT_TIMEOUT.XL); - it("Rejects an Edit using CodeLens buttons", async () => { - const rejectCodeLens = await editor.getCodeLens("Reject"); + it.only("Rejects an Edit using CodeLens buttons", async () => { + const rejectCodeLens = await getCodeLensWithRetry(editor, "Reject"); await rejectCodeLens?.click(); - const editorText = await editor.getText(); + await TestUtils.waitForSuccess(async () => { + const editorText = await editor.getText(); - await TestUtils.waitForSuccess( - async () => - !editorText.includes(originalEditorText) && - editorText.includes(llmResponse), - DEFAULT_TIMEOUT.SM, - ); + expect( + editorText.includes(originalEditorText) && + !editorText.includes(llmResponse), + ).to.be.true; + }, DEFAULT_TIMEOUT.SM); }).timeout(DEFAULT_TIMEOUT.XL); }); From c929865f6cf16b51f3faa6d32a132f203fb87947 Mon Sep 17 00:00:00 2001 From: Nate Date: Tue, 21 Jan 2025 15:10:08 -0800 Subject: [PATCH 015/146] pr_checks require all --- .github/workflows/pr_checks.yaml | 48 +++++++++++++++++++++++++------- 1 file changed, 38 insertions(+), 10 deletions(-) diff --git a/.github/workflows/pr_checks.yaml b/.github/workflows/pr_checks.yaml index f629f9331..5edabf18c 100644 --- a/.github/workflows/pr_checks.yaml +++ b/.github/workflows/pr_checks.yaml @@ -97,7 +97,7 @@ jobs: OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }} install-gui: - needs: [ install-root, install-core ] + needs: [install-root, install-core] runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 @@ -158,7 +158,7 @@ jobs: npx tsc --noEmit binary-checks: - needs: [ install-root, install-core ] + needs: [install-root, install-core] runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 @@ -194,7 +194,7 @@ jobs: npx tsc --noEmit install-vscode: - needs: [ install-root, install-core ] + needs: [install-root, install-core] runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 @@ -283,7 +283,7 @@ jobs: vscode-get-test-file-matrix: runs-on: ubuntu-latest - needs: [ install-root, install-vscode ] + needs: [install-root, install-vscode] outputs: test_file_matrix: ${{ steps.vscode-get-test-file-matrix.outputs.test_file_matrix }} steps: @@ -312,7 +312,7 @@ jobs: vscode-package-extension: runs-on: ubuntu-latest - needs: [ install-vscode, install-core ] + needs: [install-vscode, install-core] steps: - uses: actions/checkout@v4 - uses: actions/setup-node@v4 @@ -344,7 +344,7 @@ jobs: vscode-download-e2e-dependencies: runs-on: ubuntu-latest - needs: [ install-vscode, install-core ] + needs: [install-vscode, install-core] steps: - uses: actions/checkout@v4 - uses: actions/setup-node@v4 @@ -390,7 +390,7 @@ jobs: fail-fast: false matrix: test_file: ${{ fromJson(needs.vscode-get-test-file-matrix.outputs.test_file_matrix) }} - command: [ "e2e:ci:run", "e2e:ci:run-yaml" ] + command: ["e2e:ci:run", "e2e:ci:run-yaml"] steps: - uses: actions/checkout@v4 - uses: actions/setup-node@v4 @@ -451,7 +451,7 @@ jobs: path: extensions/vscode/e2e/storage/screenshots gui-tests: - needs: [ install-gui, install-core ] + needs: [install-gui, install-core] runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 @@ -482,7 +482,7 @@ jobs: npm test jetbrains-tests: - needs: [ install-root, core-checks ] + needs: [install-root, core-checks] runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 @@ -578,4 +578,32 @@ jobs: with: name: jb-failure-report path: | - ${{ github.workspace }}/extensions/intellij/build/reports \ No newline at end of file + ${{ github.workspace }}/extensions/intellij/build/reports + + check: + if: always() + runs-on: ubuntu-latest + needs: + - install-root + - install-core + - core-checks + - install-gui + - gui-checks + - binary-checks + - install-vscode + - vscode-checks + - core-tests + - vscode-get-test-file-matrix + - vscode-package-extension + - vscode-download-e2e-dependencies + - vscode-e2e-tests + - gui-tests + - jetbrains-tests + + steps: + - name: Decide whether the needed jobs succeeded or failed + uses: re-actors/alls-green@release/v1 + with: + allowed-failures: [] + allowed-skips: [] + jobs: ${{ toJSON(needs) }} From 2260300d6478383aed22ad0e5399964dc2d8ac12 Mon Sep 17 00:00:00 2001 From: Nate Date: Tue, 21 Jan 2025 15:12:34 -0800 Subject: [PATCH 016/146] use production environment for core-checks --- .github/workflows/pr_checks.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/pr_checks.yaml b/.github/workflows/pr_checks.yaml index 5edabf18c..c01e2fe67 100644 --- a/.github/workflows/pr_checks.yaml +++ b/.github/workflows/pr_checks.yaml @@ -70,6 +70,7 @@ jobs: core-checks: needs: install-core runs-on: ubuntu-latest + environment: production steps: - uses: actions/checkout@v4 - uses: actions/setup-node@v4 From 97309a61faeb9475e3948665073036a7d01389d0 Mon Sep 17 00:00:00 2001 From: Nate Date: Tue, 21 Jan 2025 15:14:59 -0800 Subject: [PATCH 017/146] fix syntax --- .github/workflows/pr_checks.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/pr_checks.yaml b/.github/workflows/pr_checks.yaml index c01e2fe67..351b4707e 100644 --- a/.github/workflows/pr_checks.yaml +++ b/.github/workflows/pr_checks.yaml @@ -605,6 +605,6 @@ jobs: - name: Decide whether the needed jobs succeeded or failed uses: re-actors/alls-green@release/v1 with: - allowed-failures: [] - allowed-skips: [] + allowed-failures: + allowed-skips: jobs: ${{ toJSON(needs) }} From caca9a9612f50f362eee38263380a712a000e3e5 Mon Sep 17 00:00:00 2001 From: Nate Date: Tue, 21 Jan 2025 15:22:30 -0800 Subject: [PATCH 018/146] only require approval on forks --- .github/workflows/pr_checks.yaml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/pr_checks.yaml b/.github/workflows/pr_checks.yaml index 351b4707e..b9db610a8 100644 --- a/.github/workflows/pr_checks.yaml +++ b/.github/workflows/pr_checks.yaml @@ -70,8 +70,12 @@ jobs: core-checks: needs: install-core runs-on: ubuntu-latest - environment: production + environment: ${{ github.event.pull_request.head.repo.fork && 'production' || '' }} steps: + - name: Print whether fork + run: | + echo "Fork: ${github.event.pull_request.head.repo.fork}" + - uses: actions/checkout@v4 - uses: actions/setup-node@v4 with: From 4955a6fa1a58745bcd83d281489111f2faf775f6 Mon Sep 17 00:00:00 2001 From: Nate Date: Tue, 21 Jan 2025 15:24:09 -0800 Subject: [PATCH 019/146] fix syntax --- .github/workflows/pr_checks.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pr_checks.yaml b/.github/workflows/pr_checks.yaml index b9db610a8..483b782c0 100644 --- a/.github/workflows/pr_checks.yaml +++ b/.github/workflows/pr_checks.yaml @@ -74,7 +74,7 @@ jobs: steps: - name: Print whether fork run: | - echo "Fork: ${github.event.pull_request.head.repo.fork}" + echo "Fork: ${{ github.event.pull_request.head.repo.fork }}" - uses: actions/checkout@v4 - uses: actions/setup-node@v4 From 8ecff56c533072ce40bd3d09066da969cc766823 Mon Sep 17 00:00:00 2001 From: boowangoo Date: Tue, 21 Jan 2025 18:25:34 -0500 Subject: [PATCH 020/146] Add deepseek-reasoner (R1) --- gui/src/pages/AddNewModel/AddNewModel.tsx | 2 +- gui/src/pages/AddNewModel/configs/models.ts | 13 +++++++++++++ gui/src/pages/AddNewModel/configs/providers.ts | 2 +- 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/gui/src/pages/AddNewModel/AddNewModel.tsx b/gui/src/pages/AddNewModel/AddNewModel.tsx index 5b9687537..d74cbf25c 100644 --- a/gui/src/pages/AddNewModel/AddNewModel.tsx +++ b/gui/src/pages/AddNewModel/AddNewModel.tsx @@ -49,7 +49,7 @@ const modelsByProvider: Record = { models.mistralLarge, ], Cohere: [models.commandR, models.commandRPlus], - DeepSeek: [models.deepseekCoderApi, models.deepseekChatApi], + DeepSeek: [models.deepseekCoderApi, models.deepseekChatApi, models.deepseekReasonerApi], Gemini: [models.geminiPro, models.gemini15Pro, models.gemini15Flash], "Open Source": [models.llama3Chat, models.mistralOs, models.deepseek], }; diff --git a/gui/src/pages/AddNewModel/configs/models.ts b/gui/src/pages/AddNewModel/configs/models.ts index 8116c86ba..2761a725e 100644 --- a/gui/src/pages/AddNewModel/configs/models.ts +++ b/gui/src/pages/AddNewModel/configs/models.ts @@ -230,6 +230,19 @@ export const models: { [key: string]: ModelPackage } = { providerOptions: ["deepseek"], isOpenSource: false, }, + deepseekReasonerApi: { + title: "DeepSeek Reasoner", + description: + "An open-source reasoning model which generates a chain of thought to enhance the accuracy of its responses.", + params: { + title: "DeepSeek Reasoner", + model: "deepseek-reasoner", + contextLength: 64_000, + }, + icon: "deepseek.png", + providerOptions: ["deepseek"], + isOpenSource: true, + }, deepseekCoder2Lite: { title: "DeepSeek Coder 2 Lite", description: diff --git a/gui/src/pages/AddNewModel/configs/providers.ts b/gui/src/pages/AddNewModel/configs/providers.ts index 4890d5c2b..bf6fe735d 100644 --- a/gui/src/pages/AddNewModel/configs/providers.ts +++ b/gui/src/pages/AddNewModel/configs/providers.ts @@ -370,7 +370,7 @@ Select the \`GPT-4o\` model below to complete your provider configuration, but n required: true, }, ], - packages: [models.deepseekCoderApi, models.deepseekChatApi], + packages: [models.deepseekCoderApi, models.deepseekChatApi, models.deepseekReasonerApi], apiKeyUrl: "https://platform.deepseek.com/api_keys", }, together: { From c236b6c87c93dd720acaaad87d3f5cc5022587ae Mon Sep 17 00:00:00 2001 From: Nate Date: Tue, 21 Jan 2025 15:39:31 -0800 Subject: [PATCH 021/146] rename --- .github/workflows/pr_checks.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pr_checks.yaml b/.github/workflows/pr_checks.yaml index 483b782c0..e93302d09 100644 --- a/.github/workflows/pr_checks.yaml +++ b/.github/workflows/pr_checks.yaml @@ -585,7 +585,7 @@ jobs: path: | ${{ github.workspace }}/extensions/intellij/build/reports - check: + require-all-checks-to-pass: if: always() runs-on: ubuntu-latest needs: From b729174dff8cb8d172e23b0256abffa0fb54c106 Mon Sep 17 00:00:00 2001 From: Nate Date: Tue, 21 Jan 2025 15:57:00 -0800 Subject: [PATCH 022/146] change env --- .github/workflows/pr_checks.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pr_checks.yaml b/.github/workflows/pr_checks.yaml index e93302d09..e94065589 100644 --- a/.github/workflows/pr_checks.yaml +++ b/.github/workflows/pr_checks.yaml @@ -70,7 +70,7 @@ jobs: core-checks: needs: install-core runs-on: ubuntu-latest - environment: ${{ github.event.pull_request.head.repo.fork && 'production' || '' }} + environment: ${{ github.event.pull_request.head.repo.fork && 'tests-requiring-secrets' || '' }} steps: - name: Print whether fork run: | From 105bb380349e603467449c3f0d8b7016d5bed767 Mon Sep 17 00:00:00 2001 From: Nate Date: Tue, 21 Jan 2025 16:05:58 -0800 Subject: [PATCH 023/146] add comments and require environment at the top of the file --- .github/workflows/pr_checks.yaml | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/.github/workflows/pr_checks.yaml b/.github/workflows/pr_checks.yaml index e94065589..1e080a2d7 100644 --- a/.github/workflows/pr_checks.yaml +++ b/.github/workflows/pr_checks.yaml @@ -21,6 +21,9 @@ on: - "gui/**" - ".github/workflows/**" +# Tests requiring secrets need approval from maintainers +environment: ${{ github.event.pull_request.head.repo.fork && 'tests-requiring-secrets' || '' }} + jobs: install-root: runs-on: ubuntu-latest @@ -70,7 +73,6 @@ jobs: core-checks: needs: install-core runs-on: ubuntu-latest - environment: ${{ github.event.pull_request.head.repo.fork && 'tests-requiring-secrets' || '' }} steps: - name: Print whether fork run: | @@ -399,8 +401,7 @@ jobs: steps: - uses: actions/checkout@v4 - uses: actions/setup-node@v4 - with: - node-version-file: ".nvmrc" + with: node-version-k - uses: actions/cache@v4 id: vscode-node-modules-cache @@ -585,6 +586,9 @@ jobs: path: | ${{ github.workspace }}/extensions/intellij/build/reports + # GitHub does not have a way of requiring that all checks pass (you must manually select each job) + # This action at least lets us manage the list of required tests via source control + # so that creators of new jobs can add them to this list require-all-checks-to-pass: if: always() runs-on: ubuntu-latest From 06b3cb35a0b7d51152f0b75a051c5ada5aaba135 Mon Sep 17 00:00:00 2001 From: Nate Date: Tue, 21 Jan 2025 17:03:28 -0800 Subject: [PATCH 024/146] fix syntax error --- .github/workflows/pr_checks.yaml | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/.github/workflows/pr_checks.yaml b/.github/workflows/pr_checks.yaml index 1e080a2d7..9b5a858f8 100644 --- a/.github/workflows/pr_checks.yaml +++ b/.github/workflows/pr_checks.yaml @@ -21,9 +21,6 @@ on: - "gui/**" - ".github/workflows/**" -# Tests requiring secrets need approval from maintainers -environment: ${{ github.event.pull_request.head.repo.fork && 'tests-requiring-secrets' || '' }} - jobs: install-root: runs-on: ubuntu-latest @@ -73,11 +70,9 @@ jobs: core-checks: needs: install-core runs-on: ubuntu-latest + # Tests requiring secrets need approval from maintainers + environment: ${{ github.event.pull_request.head.repo.fork && 'tests-requiring-secrets' || '' }} steps: - - name: Print whether fork - run: | - echo "Fork: ${{ github.event.pull_request.head.repo.fork }}" - - uses: actions/checkout@v4 - uses: actions/setup-node@v4 with: @@ -393,6 +388,8 @@ jobs: install-core, ] runs-on: ubuntu-latest + # Tests requiring secrets need approval from maintainers + environment: ${{ github.event.pull_request.head.repo.fork && 'tests-requiring-secrets' || '' }} strategy: fail-fast: false matrix: From 23c595cf3d649a088f4e8832253ae0bdddadedf3 Mon Sep 17 00:00:00 2001 From: Nate Date: Tue, 21 Jan 2025 17:06:49 -0800 Subject: [PATCH 025/146] fix syntax again --- .github/workflows/pr_checks.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/pr_checks.yaml b/.github/workflows/pr_checks.yaml index 9b5a858f8..81fb93701 100644 --- a/.github/workflows/pr_checks.yaml +++ b/.github/workflows/pr_checks.yaml @@ -398,7 +398,8 @@ jobs: steps: - uses: actions/checkout@v4 - uses: actions/setup-node@v4 - with: node-version-k + with: + node-version-file: ".nvmrc" - uses: actions/cache@v4 id: vscode-node-modules-cache From 11c10639c9738c8557cdbbfe46f27ca22221f717 Mon Sep 17 00:00:00 2001 From: Dallin Romney Date: Tue, 21 Jan 2025 17:38:42 -0800 Subject: [PATCH 026/146] remove enabledebuglogs --- core/config/types.ts | 1 - core/index.d.ts | 1 - .../continueintellijextension/continue/IntelliJIde.kt | 1 - .../com/github/continuedev/continueintellijextension/types.kt | 1 - extensions/vscode/src/VsCodeIde.ts | 1 - 5 files changed, 5 deletions(-) diff --git a/core/config/types.ts b/core/config/types.ts index 6d2847c11..ee23ba49b 100644 --- a/core/config/types.ts +++ b/core/config/types.ts @@ -572,7 +572,6 @@ declare global { userToken: string; enableControlServerBeta: boolean; pauseCodebaseIndexOnStart: boolean; - enableDebugLogs: boolean; } export interface IDE { diff --git a/core/index.d.ts b/core/index.d.ts index 7f98129f2..ab7436b6c 100644 --- a/core/index.d.ts +++ b/core/index.d.ts @@ -584,7 +584,6 @@ export interface IdeSettings { userToken: string; enableControlServerBeta: boolean; pauseCodebaseIndexOnStart: boolean; - enableDebugLogs: boolean; } export interface FileStats { diff --git a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/IntelliJIde.kt b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/IntelliJIde.kt index d30a5d5fe..f871fc69e 100644 --- a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/IntelliJIde.kt +++ b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/IntelliJIde.kt @@ -94,7 +94,6 @@ class IntelliJIDE( userToken = settings.continueState.userToken ?: "", enableControlServerBeta = settings.continueState.enableContinueTeamsBeta, pauseCodebaseIndexOnStart = false, // TODO: Needs to be implemented - enableDebugLogs = false // TODO: Needs to be implemented ) } diff --git a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/types.kt b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/types.kt index 1400e5c54..201b259de 100644 --- a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/types.kt +++ b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/types.kt @@ -88,7 +88,6 @@ data class IdeSettings( val userToken: String, val enableControlServerBeta: Boolean, val pauseCodebaseIndexOnStart: Boolean, - val enableDebugLogs: Boolean ) data class ContinueRcJson( diff --git a/extensions/vscode/src/VsCodeIde.ts b/extensions/vscode/src/VsCodeIde.ts index 51008db8a..4cf619a3e 100644 --- a/extensions/vscode/src/VsCodeIde.ts +++ b/extensions/vscode/src/VsCodeIde.ts @@ -640,7 +640,6 @@ class VsCodeIde implements IDE { "pauseCodebaseIndexOnStart", false, ), - enableDebugLogs: false, // settings.get( // "enableControlServerBeta", // false, From 6c73ad2924bd7e1dca5e730ae44a7941e37410dc Mon Sep 17 00:00:00 2001 From: Dallin Romney Date: Tue, 21 Jan 2025 17:38:57 -0800 Subject: [PATCH 027/146] remove enabledebuglogs p2 --- core/indexing/docs/DocsService.skip.ts | 1 - core/util/filesystem.ts | 1 - 2 files changed, 2 deletions(-) diff --git a/core/indexing/docs/DocsService.skip.ts b/core/indexing/docs/DocsService.skip.ts index 6f9853afe..a57906012 100644 --- a/core/indexing/docs/DocsService.skip.ts +++ b/core/indexing/docs/DocsService.skip.ts @@ -45,7 +45,6 @@ describe.skip("DocsService Integration Tests", () => { enableControlServerBeta: false, pauseCodebaseIndexOnStart: false, ideSettings: {} as any, - enableDebugLogs: false, remoteConfigServerUrl: "", }), async () => {}, diff --git a/core/util/filesystem.ts b/core/util/filesystem.ts index ccb550ec9..f414a324b 100644 --- a/core/util/filesystem.ts +++ b/core/util/filesystem.ts @@ -54,7 +54,6 @@ class FileSystemIde implements IDE { userToken: "", enableControlServerBeta: false, pauseCodebaseIndexOnStart: false, - enableDebugLogs: false, }; } async getGitHubAuthToken(args: GetGhTokenArgs): Promise { From 344241bcdae4ce004d0eb4405bf8273988e4f0c5 Mon Sep 17 00:00:00 2001 From: Adam Shedivy Date: Wed, 22 Jan 2025 13:21:39 -0600 Subject: [PATCH 028/146] run config reload with additional context providers --- core/config/ConfigHandler.ts | 6 +++--- core/config/ProfileLifecycleManager.ts | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/core/config/ConfigHandler.ts b/core/config/ConfigHandler.ts index 24987528a..af454a4f0 100644 --- a/core/config/ConfigHandler.ts +++ b/core/config/ConfigHandler.ts @@ -286,11 +286,11 @@ export class ConfigHandler { this.updateListeners.push(listener); } - async reloadConfig() { + async reloadConfig(additionalContextProviders: IContextProvider[] = []) { // TODO: this isn't right, there are two different senses in which you want to "reload" const { config, errors, configLoadInterrupted } = - await this.currentProfile.reloadConfig(); + await this.currentProfile.reloadConfig(additionalContextProviders); if (config) { this.inactiveProfiles.forEach((profile) => profile.clearConfig()); @@ -340,6 +340,6 @@ export class ConfigHandler { registerCustomContextProvider(contextProvider: IContextProvider) { this.additionalContextProviders.push(contextProvider); - void this.reloadConfig(); + void this.reloadConfig(this.additionalContextProviders); } } diff --git a/core/config/ProfileLifecycleManager.ts b/core/config/ProfileLifecycleManager.ts index 88fc387c5..ea4e14a79 100644 --- a/core/config/ProfileLifecycleManager.ts +++ b/core/config/ProfileLifecycleManager.ts @@ -32,12 +32,12 @@ export class ProfileLifecycleManager { } // Clear saved config and reload - async reloadConfig(): Promise> { + async reloadConfig(additionalContextProviders: IContextProvider[] = []): Promise> { this.savedConfigResult = undefined; this.savedBrowserConfigResult = undefined; this.pendingConfigPromise = undefined; - return this.loadConfig([], true); + return this.loadConfig(additionalContextProviders, true); } async loadConfig( From 412a0b78fb4466e5712f2bb49b60be85517b6e34 Mon Sep 17 00:00:00 2001 From: Dallin Romney Date: Thu, 23 Jan 2025 10:47:10 -0800 Subject: [PATCH 029/146] show docs get details button on prod --- gui/src/components/indexing/DocsIndexingStatus.tsx | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/gui/src/components/indexing/DocsIndexingStatus.tsx b/gui/src/components/indexing/DocsIndexingStatus.tsx index 361005ba5..fe64ae2dc 100644 --- a/gui/src/components/indexing/DocsIndexingStatus.tsx +++ b/gui/src/components/indexing/DocsIndexingStatus.tsx @@ -195,8 +195,7 @@ function DocsIndexingStatus({ docConfig }: IndexingStatusViewerProps) { {status?.description} )} - {process.env.NODE_ENV === "development" && - status?.status === "complete" ? ( + {status?.status === "complete" ? ( { From fbee4a8aece2d4fc956b748761c9893053f6de41 Mon Sep 17 00:00:00 2001 From: Dallin Romney Date: Thu, 23 Jan 2025 11:11:20 -0800 Subject: [PATCH 030/146] import fix --- core/indexing/docs/DocsService.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/core/indexing/docs/DocsService.ts b/core/indexing/docs/DocsService.ts index 74f68af9b..f0d1e2f3c 100644 --- a/core/indexing/docs/DocsService.ts +++ b/core/indexing/docs/DocsService.ts @@ -40,7 +40,7 @@ import { SiteIndexingResults, } from "./preIndexed"; import preIndexedDocs from "./preIndexedDocs"; -import { ConfigResult } from "@continuedev/config-types"; +import { ConfigResult } from "@continuedev/config-yaml"; // Purposefully lowercase because lancedb converts export interface LanceDbDocsRow { @@ -713,8 +713,8 @@ export default class DocsService { const db = await this.getOrCreateSqliteDb(); try { - - const { isPreindexed, provider } = await this.getEmbeddingsProvider(startUrl); + const { isPreindexed, provider } = + await this.getEmbeddingsProvider(startUrl); const preIndexedDoc = preIndexedDocs[startUrl]; const isPreIndexedDoc = !!preIndexedDoc; From 3b335b6f8c7c3cc53cf7219cbfc1cef1c4b7ddb5 Mon Sep 17 00:00:00 2001 From: Dallin Romney Date: Thu, 23 Jan 2025 20:24:53 -0800 Subject: [PATCH 031/146] shared config --- .../StreamTransformPipeline.ts | 1 - core/config/load.ts | 7 +-- core/config/profile/doLoadConfig.ts | 6 +- core/config/sharedConfig.ts | 63 +++++++++++++++++++ core/config/yaml/loadYaml.ts | 28 +++++++-- core/core.ts | 5 ++ core/protocol/core.ts | 2 + core/util/GlobalContext.ts | 51 ++++++++++++--- core/util/paths.ts | 4 ++ 9 files changed, 145 insertions(+), 22 deletions(-) create mode 100644 core/config/sharedConfig.ts diff --git a/core/autocomplete/filtering/streamTransforms/StreamTransformPipeline.ts b/core/autocomplete/filtering/streamTransforms/StreamTransformPipeline.ts index 6bfc6cfe1..1bd90c503 100644 --- a/core/autocomplete/filtering/streamTransforms/StreamTransformPipeline.ts +++ b/core/autocomplete/filtering/streamTransforms/StreamTransformPipeline.ts @@ -76,7 +76,6 @@ export class StreamTransformPipeline { const timeoutValue = await Telemetry.getValueForFeatureFlag( PosthogFeatureFlag.AutocompleteTimeout, ); - // helper.options.showWhateverWeHaveAtXMs ?? DEFAULT_AUTOCOMPLETE_OPTS.showWhateverWeHaveAtXMs lineGenerator = showWhateverWeHaveAtXMs(lineGenerator, timeoutValue!); diff --git a/core/config/load.ts b/core/config/load.ts index c1c3c4261..52cb8cfb9 100644 --- a/core/config/load.ts +++ b/core/config/load.ts @@ -111,11 +111,10 @@ function loadSerializedConfig( overrideConfigJson: SerializedContinueConfig | undefined, ide: IDE, ): ConfigResult { - const configPath = getConfigJsonPath(ideType); let config: SerializedContinueConfig = overrideConfigJson!; if (!config) { try { - config = resolveSerializedConfig(configPath); + config = resolveSerializedConfig(getConfigJsonPath(ideType)); } catch (e) { throw new Error(`Failed to parse config.json: ${e}`); } @@ -766,7 +765,7 @@ async function buildConfigTsandReadConfigJs(ide: IDE, ideType: IdeType) { return readConfigJs(); } -async function loadFullConfigNode( +async function loadContinueConfigFromJson( ide: IDE, workspaceConfigs: ContinueRcJson[], ideSettings: IdeSettings, @@ -876,6 +875,6 @@ async function loadFullConfigNode( export { finalToBrowserConfig, intermediateToFinalConfig, - loadFullConfigNode, + loadContinueConfigFromJson, type BrowserSerializedContinueConfig, }; diff --git a/core/config/profile/doLoadConfig.ts b/core/config/profile/doLoadConfig.ts index 8e2326e3d..b4f3d5d35 100644 --- a/core/config/profile/doLoadConfig.ts +++ b/core/config/profile/doLoadConfig.ts @@ -20,7 +20,7 @@ import ContinueProxy from "../../llm/llms/stubs/ContinueProxy"; import { getConfigYamlPath } from "../../util/paths"; import { Telemetry } from "../../util/posthog"; import { TTS } from "../../util/tts"; -import { loadFullConfigNode } from "../load"; +import { loadContinueConfigFromJson } from "../load"; import { loadContinueConfigFromYaml } from "../yaml/loadYaml"; import { PlatformConfigMetadata } from "./PlatformProfileLoader"; @@ -46,7 +46,7 @@ export default async function doLoadConfig( let errors: ConfigValidationError[] | undefined; let configLoadInterrupted = false; - if (fs.existsSync(configYamlPath) || overrideConfigYaml) { + if (overrideConfigYaml || fs.existsSync(configYamlPath)) { const result = await loadContinueConfigFromYaml( ide, workspaceConfigs.map((c) => JSON.stringify(c)), @@ -63,7 +63,7 @@ export default async function doLoadConfig( errors = result.errors; configLoadInterrupted = result.configLoadInterrupted; } else { - const result = await loadFullConfigNode( + const result = await loadContinueConfigFromJson( ide, workspaceConfigs, ideSettings, diff --git a/core/config/sharedConfig.ts b/core/config/sharedConfig.ts new file mode 100644 index 000000000..23a0e1c2f --- /dev/null +++ b/core/config/sharedConfig.ts @@ -0,0 +1,63 @@ +import z from "zod"; + +const sharedConfigTabAutoCompleteOptionsSchema = z + .object({ + disable: z.boolean(), + useCache: z.boolean(), + disableInFiles: z.array(z.string()), + multilineCompletions: z.enum(["always", "never", "auto"]), + }) + .partial(); + +export const sharedConfigSchema = z + .object({ + allowAnonymousTelemetry: z.boolean(), + disableIndexing: z.boolean(), + disableSessionTitles: z.boolean(), + useChromiumForDocsCrawling: z.boolean(), + readResponseTTS: z.boolean(), + promptPath: z.string(), + tabAutocompleteOptions: sharedConfigTabAutoCompleteOptionsSchema, + + // UI-only, and user-specific: + codeBlockToolbarPosition: z.enum(["top", "bottom"]), + fontSize: z.number(), + codeWrap: z.boolean(), + displayRawMarkdown: z.boolean(), + showChatScrollbar: z.boolean(), + }) + .partial(); + +export type SharedConfigSchema = z.infer; + +// For security in case of damaged config file, try to salvage any security-related values +export function salvageSharedConfig(sharedConfig: object): SharedConfigSchema { + const salvagedConfig: SharedConfigSchema = {}; + if ("allowAnonymousTelemetry" in sharedConfig) { + const val = z.boolean().safeParse(sharedConfig.allowAnonymousTelemetry); + if (val.success) { + salvagedConfig.allowAnonymousTelemetry = val.data; + } + } + if ("disableIndexing" in sharedConfig) { + const val = z.boolean().safeParse(sharedConfig.disableIndexing); + if (val.success) { + salvagedConfig.disableIndexing = val.data; + } + } + if ("disableSessionTitles" in sharedConfig) { + const val = z.boolean().safeParse(sharedConfig.disableSessionTitles); + if (val.success) { + salvagedConfig.disableSessionTitles = val.data; + } + } + if ("tabAutocompleteOptions" in sharedConfig) { + const val = sharedConfigTabAutoCompleteOptionsSchema.safeParse( + sharedConfig.tabAutocompleteOptions, + ); + if (val.success) { + salvagedConfig.tabAutocompleteOptions = val.data; + } + } + return salvagedConfig; +} diff --git a/core/config/yaml/loadYaml.ts b/core/config/yaml/loadYaml.ts index 09003f6eb..b75f83b33 100644 --- a/core/config/yaml/loadYaml.ts +++ b/core/config/yaml/loadYaml.ts @@ -35,6 +35,7 @@ import { PlatformConfigMetadata } from "../profile/PlatformProfileLoader"; import { allTools } from "../../tools"; import { clientRenderHelper } from "./clientRender"; import { llmsFromModelConfig } from "./models"; +import { GlobalContext } from "../../util/GlobalContext"; async function loadConfigYaml( workspaceConfigs: string[], @@ -187,8 +188,8 @@ async function configYamlToContinueConfig( ({ description: { title } }) => title, ); - continueConfig.contextProviders = config.context - ?.map((context) => { + continueConfig.contextProviders = (config.context ?? []) + .map((context) => { const cls = contextProviderClassFromName(context.uses) as any; if (!cls) { if (!DEFAULT_CONTEXT_PROVIDERS_TITLES.includes(context.uses)) { @@ -199,7 +200,7 @@ async function configYamlToContinueConfig( const instance: IContextProvider = new cls(context.with ?? {}); return instance; }) - .filter((p) => !!p) as IContextProvider[]; + .filter((p) => !!p); continueConfig.contextProviders.push(...DEFAULT_CONTEXT_PROVIDERS); // Embeddings Provider @@ -280,6 +281,24 @@ async function configYamlToContinueConfig( clearTimeout(mcpConnectionTimeout); }); + // Apply shared config + const sharedConfig = new GlobalContext().getSharedConfig(); + continueConfig.tabAutocompleteOptions = sharedConfig.tabAutocompleteOptions; + continueConfig.ui = { + codeBlockToolbarPosition: sharedConfig.codeBlockToolbarPosition, + fontSize: sharedConfig.fontSize, + codeWrap: sharedConfig.codeWrap, + displayRawMarkdown: sharedConfig.displayRawMarkdown, + showChatScrollbar: sharedConfig.showChatScrollbar, + }; + continueConfig.allowAnonymousTelemetry = sharedConfig.allowAnonymousTelemetry; + continueConfig.disableIndexing = sharedConfig.disableIndexing; + continueConfig.disableSessionTitles = sharedConfig.disableSessionTitles; + continueConfig.experimental!.useChromiumForDocsCrawling = sharedConfig.useChromiumForDocsCrawling; + continueConfig.experimental!.readResponseTTS = sharedConfig.readResponseTTS; + continueConfig.experimental!.promptPath = sharedConfig.promptPath; + + return continueConfig; } @@ -295,10 +314,9 @@ export async function loadContinueConfigFromYaml( platformConfigMetadata: PlatformConfigMetadata | undefined, controlPlaneClient: ControlPlaneClient, ): Promise> { - const configYamlPath = getConfigYamlPath(ideType); const rawYaml = overrideConfigYaml === undefined - ? fs.readFileSync(configYamlPath, "utf-8") + ? fs.readFileSync(getConfigYamlPath(ideType), "utf-8") : ""; const configYamlResult = await loadConfigYaml( diff --git a/core/core.ts b/core/core.ts index c74f2e539..39917abd4 100644 --- a/core/core.ts +++ b/core/core.ts @@ -294,6 +294,11 @@ export class Core { addContextProvider(msg.data); }); + on("config/updateSharedConfig", async (msg) => { + this.globalContext.updateSharedConfig(msg.data); + await this.configHandler.reloadConfig(); + }); + // Context providers on("context/addDocs", async (msg) => { void this.docsService.indexAndAdd(msg.data); diff --git a/core/protocol/core.ts b/core/protocol/core.ts index b48b11398..98d2a38dd 100644 --- a/core/protocol/core.ts +++ b/core/protocol/core.ts @@ -22,6 +22,7 @@ import type { } from "../"; import { AutocompleteInput } from "../autocomplete/util/types"; import { ProfileDescription } from "../config/ConfigHandler"; +import { SharedConfigSchema } from "../config/SharedConfig"; export type OnboardingModes = | "Local" @@ -70,6 +71,7 @@ export type ToCoreFromIdeOrWebviewProtocol = { "config/reload": [undefined, ConfigResult]; "config/listProfiles": [undefined, ProfileDescription[]]; "config/openProfile": [{ profileId: string | undefined }, void]; + "config/updateSharedConfig": [values: SharedConfigSchema, void]; "context/getContextItems": [ { name: string; diff --git a/core/util/GlobalContext.ts b/core/util/GlobalContext.ts index 336dc8293..7202cde04 100644 --- a/core/util/GlobalContext.ts +++ b/core/util/GlobalContext.ts @@ -1,5 +1,11 @@ import fs from "node:fs"; +import { + salvageSharedConfig, + sharedConfigSchema, + SharedConfigSchema, +} from "../config/SharedConfig"; + import { getGlobalContextFilePath } from "./paths"; export type GlobalContextType = { @@ -16,6 +22,7 @@ export type GlobalContextType = { hasAlreadyCreatedAPromptFile: boolean; showConfigUpdateToast: boolean; isSupportedLanceDbCpuTarget: boolean; + sharedConfig: SharedConfigSchema; }; /** @@ -26,9 +33,10 @@ export class GlobalContext { key: T, value: GlobalContextType[T], ) { - if (!fs.existsSync(getGlobalContextFilePath())) { + const filepath = getGlobalContextFilePath(); + if (!fs.existsSync(filepath)) { fs.writeFileSync( - getGlobalContextFilePath(), + filepath, JSON.stringify( { [key]: value, @@ -38,7 +46,7 @@ export class GlobalContext { ), ); } else { - const data = fs.readFileSync(getGlobalContextFilePath(), "utf-8"); + const data = fs.readFileSync(filepath, "utf-8"); let parsed; try { @@ -49,21 +57,19 @@ export class GlobalContext { } parsed[key] = value; - fs.writeFileSync( - getGlobalContextFilePath(), - JSON.stringify(parsed, null, 2), - ); + fs.writeFileSync(filepath, JSON.stringify(parsed, null, 2)); } } get( key: T, ): GlobalContextType[T] | undefined { - if (!fs.existsSync(getGlobalContextFilePath())) { + const filepath = getGlobalContextFilePath(); + if (!fs.existsSync(filepath)) { return undefined; } - const data = fs.readFileSync(getGlobalContextFilePath(), "utf-8"); + const data = fs.readFileSync(filepath, "utf-8"); try { const parsed = JSON.parse(data); return parsed[key]; @@ -72,4 +78,31 @@ export class GlobalContext { return undefined; } } + + getSharedConfig(): SharedConfigSchema { + const sharedConfig = this.get("sharedConfig") ?? {}; + const result = sharedConfigSchema.safeParse(sharedConfig); + if (result.success) { + return result.data; + } else { + // in case of damaged shared config, repair it + // Attempt to salvage any values that are security concerns + console.error("Failed to load shared config, salvaging...", result.error); + const salvagedConfig = salvageSharedConfig(sharedConfig); + this.update("sharedConfig", salvagedConfig); + return salvagedConfig; + } + } + + updateSharedConfig( + newValues: Partial, + ): SharedConfigSchema { + const currentSharedConfig = this.getSharedConfig(); + const updatedSharedConfig = { + ...currentSharedConfig, + ...newValues, + }; + this.update("sharedConfig", updatedSharedConfig); + return updatedSharedConfig; + } } diff --git a/core/util/paths.ts b/core/util/paths.ts index 562d2e819..68b7e0471 100644 --- a/core/util/paths.ts +++ b/core/util/paths.ts @@ -74,6 +74,10 @@ export function getGlobalContextFilePath(): string { return path.join(getIndexFolderPath(), "globalContext.json"); } +export function getSharedConfigFilePath(): string { + return path.join(getContinueGlobalPath(), "sharedConfig.json"); +} + export function getSessionFilePath(sessionId: string): string { return path.join(getSessionsFolderPath(), `${sessionId}.json`); } From 315c9acbe5818d7c14257f4123c79bd6d75b2af5 Mon Sep 17 00:00:00 2001 From: Dallin Romney Date: Thu, 23 Jan 2025 20:39:20 -0800 Subject: [PATCH 032/146] imports --- core/config/yaml/loadYaml.ts | 5 +++-- core/util/GlobalContext.ts | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/core/config/yaml/loadYaml.ts b/core/config/yaml/loadYaml.ts index b75f83b33..b2fe17945 100644 --- a/core/config/yaml/loadYaml.ts +++ b/core/config/yaml/loadYaml.ts @@ -282,6 +282,7 @@ async function configYamlToContinueConfig( }); // Apply shared config + // TODO: override several of these values with user/org shared config const sharedConfig = new GlobalContext().getSharedConfig(); continueConfig.tabAutocompleteOptions = sharedConfig.tabAutocompleteOptions; continueConfig.ui = { @@ -294,11 +295,11 @@ async function configYamlToContinueConfig( continueConfig.allowAnonymousTelemetry = sharedConfig.allowAnonymousTelemetry; continueConfig.disableIndexing = sharedConfig.disableIndexing; continueConfig.disableSessionTitles = sharedConfig.disableSessionTitles; - continueConfig.experimental!.useChromiumForDocsCrawling = sharedConfig.useChromiumForDocsCrawling; + continueConfig.experimental!.useChromiumForDocsCrawling = + sharedConfig.useChromiumForDocsCrawling; continueConfig.experimental!.readResponseTTS = sharedConfig.readResponseTTS; continueConfig.experimental!.promptPath = sharedConfig.promptPath; - return continueConfig; } diff --git a/core/util/GlobalContext.ts b/core/util/GlobalContext.ts index 7202cde04..90b403d41 100644 --- a/core/util/GlobalContext.ts +++ b/core/util/GlobalContext.ts @@ -4,7 +4,7 @@ import { salvageSharedConfig, sharedConfigSchema, SharedConfigSchema, -} from "../config/SharedConfig"; +} from "../config/sharedConfig"; import { getGlobalContextFilePath } from "./paths"; From 593fc2e669c15ce305320c85723c6c1824fb4d5c Mon Sep 17 00:00:00 2001 From: Dallin Romney Date: Thu, 23 Jan 2025 21:25:37 -0800 Subject: [PATCH 033/146] config page --- .../actions/ContinuePluginActions.kt | 5 ++- .../src/main/resources/META-INF/plugin.xml | 10 ++--- extensions/vscode/package.json | 4 +- gui/src/App.tsx | 5 +++ gui/src/pages/config/index.tsx | 40 +++++++++++++++++++ gui/src/util/navigation.ts | 1 + 6 files changed, 56 insertions(+), 9 deletions(-) create mode 100644 gui/src/pages/config/index.tsx diff --git a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/actions/ContinuePluginActions.kt b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/actions/ContinuePluginActions.kt index 852fb4f02..b93d294e1 100644 --- a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/actions/ContinuePluginActions.kt +++ b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/actions/ContinuePluginActions.kt @@ -120,8 +120,9 @@ class ViewHistoryAction : AnAction() { class OpenConfigAction : AnAction() { override fun actionPerformed(e: AnActionEvent) { val continuePluginService = getContinuePluginService(e.project) ?: return - val params = mapOf("profileId" to null) - continuePluginService.coreMessenger?.request("config/openProfile", params, null) { _ -> } + continuePluginService.continuePluginWindow?.content?.components?.get(0)?.requestFocus() + val params = mapOf("path" to "/config", "toggle" to true) + continuePluginService.sendToWebview("navigateTo", params) } } diff --git a/extensions/intellij/src/main/resources/META-INF/plugin.xml b/extensions/intellij/src/main/resources/META-INF/plugin.xml index a5e16ecc5..5a43ff24f 100644 --- a/extensions/intellij/src/main/resources/META-INF/plugin.xml +++ b/extensions/intellij/src/main/resources/META-INF/plugin.xml @@ -132,12 +132,12 @@ - - + text="Continue Config" + description="Continue Config"> + - + diff --git a/extensions/vscode/package.json b/extensions/vscode/package.json index 23c151699..a22b3408f 100644 --- a/extensions/vscode/package.json +++ b/extensions/vscode/package.json @@ -213,7 +213,7 @@ "group": "Continue" }, { - "command": "continue.openConfig", + "command": "continue.openConfigPage", "category": "Continue", "title": "Open Continue Config", "icon": "$(gear)", @@ -522,7 +522,7 @@ "when": "view == continue.continueGUIView" }, { - "command": "continue.openConfig", + "command": "continue.openConfigPage", "group": "navigation@4", "when": "view == continue.continueGUIView" }, diff --git a/gui/src/App.tsx b/gui/src/App.tsx index 18df91b86..73d667292 100644 --- a/gui/src/App.tsx +++ b/gui/src/App.tsx @@ -13,6 +13,7 @@ import MorePage from "./pages/More"; import Stats from "./pages/stats"; import { ROUTES } from "./util/navigation"; import { SubmenuContextProvidersProvider } from "./context/SubmenuContextProviders"; +import ConfigPage from "./pages/config"; const router = createMemoryRouter([ { @@ -52,6 +53,10 @@ const router = createMemoryRouter([ path: ROUTES.CONFIG_ERROR, element: , }, + { + path: ROUTES.CONFIG, + element: , + }, { path: "/migration", element: , diff --git a/gui/src/pages/config/index.tsx b/gui/src/pages/config/index.tsx new file mode 100644 index 000000000..a7d67b770 --- /dev/null +++ b/gui/src/pages/config/index.tsx @@ -0,0 +1,40 @@ +import { useContext } from "react"; +import { useNavigate } from "react-router-dom"; +import { IdeMessengerContext } from "../../context/IdeMessenger"; +import { useNavigationListener } from "../../hooks/useNavigationListener"; +import PageHeader from "../../components/PageHeader"; +import { useAppDispatch, useAppSelector } from "../../redux/hooks"; +import { SharedConfigSchema } from "core/config/sharedConfig"; +import { Switch } from "@headlessui/react"; +import { updateConfig } from "../../redux/slices/configSlice"; + +function ConfigPage() { + useNavigationListener(); + const dispatch = useAppDispatch(); + const navigate = useNavigate(); + const ideMessenger = useContext(IdeMessengerContext); + + const config = useAppSelector((state) => state.config.config); + + function handleUpdateSharedConfig(sharedConfig: Partial) { + ideMessenger.post("config/updateSharedConfig", sharedConfig); + + // TODO: Optimistic update in redux + // dispatch(updateConfig({ + // ...config, + // ...(sharedConfig.) + // })) + } + + return ( +
+ navigate("/")} title="Chat" /> + +
+ Hello +
+
+ ); +} + +export default ConfigPage; diff --git a/gui/src/util/navigation.ts b/gui/src/util/navigation.ts index 2416226d8..eed39333d 100644 --- a/gui/src/util/navigation.ts +++ b/gui/src/util/navigation.ts @@ -2,6 +2,7 @@ export const ROUTES = { HOME: "/", CONFIG_ERROR: "/config-error", + CONFIG: "/config", MORE: "/more", // EXAMPLE_ROUTE_WITH_PARAMS: (params: ParamsType) => `/route/${params}`, }; From eb8f9b15ba40da309c2f9897ff0902feb9086c2c Mon Sep 17 00:00:00 2001 From: Dallin Romney Date: Fri, 24 Jan 2025 09:53:05 -0800 Subject: [PATCH 034/146] migrate shared config --- core/config/load.ts | 14 +- core/config/migrateSharedConfig.ts | 165 ++++++++++++++++++ core/config/profile/doLoadConfig.ts | 10 +- core/config/sharedConfig.ts | 129 ++++++++++++-- core/config/yaml/loadYaml.ts | 30 ++-- core/index.d.ts | 1 + core/protocol/core.ts | 2 +- core/protocol/passThrough.ts | 1 + docs/docs/reference.md | 8 + .../constants/MessageTypes.kt | 1 + extensions/vscode/src/commands.ts | 6 +- gui/src/components/gui/Switch.tsx | 37 ++++ gui/src/index.css | 1 + gui/src/pages/config/index.tsx | 160 ++++++++++++++++- 14 files changed, 513 insertions(+), 52 deletions(-) create mode 100644 core/config/migrateSharedConfig.ts create mode 100644 gui/src/components/gui/Switch.tsx diff --git a/core/config/load.ts b/core/config/load.ts index 52cb8cfb9..a7244a79e 100644 --- a/core/config/load.ts +++ b/core/config/load.ts @@ -74,8 +74,9 @@ import { getSystemPromptDotFile } from "./getSystemPromptDotFile"; // import { isSupportedLanceDbCpuTarget } from "./util"; import { validateConfig } from "./validation.js"; import { localPathToUri } from "../util/pathToUri"; +import { modifyContinueConfigWithSharedConfig } from "./sharedConfig"; -function resolveSerializedConfig(filepath: string): SerializedContinueConfig { +export function resolveSerializedConfig(filepath: string): SerializedContinueConfig { let content = fs.readFileSync(filepath, "utf8"); const config = JSONC.parse(content) as unknown as SerializedContinueConfig; if (config.env && Array.isArray(config.env)) { @@ -582,6 +583,7 @@ function finalToBrowserConfig( docs: final.docs, tools: final.tools, usePlatform: usePlatform(), + tabAutocompleteOptions: final.tabAutocompleteOptions, }; } @@ -797,8 +799,16 @@ async function loadContinueConfigFromJson( serialized.systemMessage = systemPromptDotFile; } + // Apply shared config + // TODO: override several of these values with user/org shared config + const sharedConfig = new GlobalContext().getSharedConfig(); + const withShared = modifyContinueConfigWithSharedConfig( + serialized, + sharedConfig, + ); + // Convert serialized to intermediate config - let intermediate = await serializedToIntermediateConfig(serialized, ide); + let intermediate = await serializedToIntermediateConfig(withShared, ide); // Apply config.ts to modify intermediate config const configJsContents = await buildConfigTsandReadConfigJs(ide, ideType); diff --git a/core/config/migrateSharedConfig.ts b/core/config/migrateSharedConfig.ts new file mode 100644 index 000000000..c04696d10 --- /dev/null +++ b/core/config/migrateSharedConfig.ts @@ -0,0 +1,165 @@ +import * as fs from "fs"; + +import * as JSONC from "comment-json"; + +import { IDE, SerializedContinueConfig } from ".."; +import { SharedConfigSchema } from "./sharedConfig"; +import { GlobalContext } from "../util/GlobalContext"; +import { editConfigJson } from "../util/paths"; +import { resolveSerializedConfig } from "./load"; + +/* + This migration function eliminates deprecated values from the json file + And writes them to the shared config +*/ +export function migrateJsonSharedConfig(filepath: string, ide: IDE): void { + try { + let config = resolveSerializedConfig(filepath); + const shareConfigUpdates: SharedConfigSchema = {}; + + let effected = false; + + const { allowAnonymousTelemetry, ...withoutAllowTelemetry } = config; + if (allowAnonymousTelemetry !== undefined) { + shareConfigUpdates.allowAnonymousTelemetry = allowAnonymousTelemetry; + config = withoutAllowTelemetry; + effected = true; + } + + const { disableIndexing, ...withoutDisableIndexing } = config; + if (disableIndexing !== undefined) { + shareConfigUpdates.disableIndexing = disableIndexing; + config = withoutDisableIndexing; + effected = true; + } + + const { disableSessionTitles, ...withoutDisableSessionTitles } = config; + if (config.disableSessionTitles !== undefined) { + shareConfigUpdates.disableSessionTitles = config.disableSessionTitles; + config = withoutDisableSessionTitles; + effected = true; + } + + const { tabAutocompleteOptions, ...withoutAutocompleteOptions } = config; + if (tabAutocompleteOptions !== undefined) { + let migratedAutocomplete = { ...tabAutocompleteOptions }; + + const { useCache, ...withoutUseCache } = migratedAutocomplete; + if (useCache !== undefined) { + shareConfigUpdates.useAutocompleteCache = useCache; + migratedAutocomplete = withoutUseCache; + effected = true; + } + + const { multilineCompletions, ...withoutMultiline } = + migratedAutocomplete; + if (multilineCompletions !== undefined) { + shareConfigUpdates.useAutocompleteMultilineCompletions = + multilineCompletions; + migratedAutocomplete = withoutMultiline; + effected = true; + } + + const { disableInFiles, ...withoutDisableInFiles } = migratedAutocomplete; + if (disableInFiles !== undefined) { + shareConfigUpdates.disableAutocompleteInFiles = disableInFiles; + migratedAutocomplete = withoutDisableInFiles; + effected = true; + } + + config = { + ...withoutAutocompleteOptions, + tabAutocompleteOptions: migratedAutocomplete, + }; + } + + const { experimental, ...withoutExperimental } = config; + if (experimental !== undefined) { + let migratedExperimental = { ...experimental }; + + const { useChromiumForDocsCrawling, ...rest10 } = migratedExperimental; + if (useChromiumForDocsCrawling !== undefined) { + shareConfigUpdates.useChromiumForDocsCrawling = + useChromiumForDocsCrawling; + migratedExperimental = rest10; + effected = true; + } + + const { promptPath, ...withoutPromptPath } = migratedExperimental; + if (promptPath !== undefined) { + shareConfigUpdates.promptPath = promptPath; + migratedExperimental = withoutPromptPath; + effected = true; + } + + const { readResponseTTS, ...withoutReadTTS } = migratedExperimental; + if (readResponseTTS !== undefined) { + shareConfigUpdates.readResponseTTS = readResponseTTS; + migratedExperimental = withoutReadTTS; + effected = true; + } + + config = { + ...withoutExperimental, + experimental: migratedExperimental, + }; + } + + const { ui, ...withoutUI } = config; + if (ui !== undefined) { + let migratedUI = { ...ui }; + + const { codeBlockToolbarPosition, ...withoutToolbarPosition } = + migratedUI; + if (codeBlockToolbarPosition !== undefined) { + shareConfigUpdates.codeBlockToolbarPosition = codeBlockToolbarPosition; + migratedUI = withoutToolbarPosition; + effected = true; + } + + const { fontSize, ...withoutFontSize } = migratedUI; + if (fontSize !== undefined) { + shareConfigUpdates.fontSize = fontSize; + migratedUI = withoutFontSize; + effected = true; + } + + const { codeWrap, ...withoutCodeWrap } = migratedUI; + if (codeWrap !== undefined) { + shareConfigUpdates.codeWrap = codeWrap; + migratedUI = withoutCodeWrap; + effected = true; + } + + const { displayRawMarkdown, ...withoutMD } = migratedUI; + if (displayRawMarkdown !== undefined) { + shareConfigUpdates.displayRawMarkdown = displayRawMarkdown; + migratedUI = withoutMD; + effected = true; + } + + const { showChatScrollbar, ...withoutShowChatScrollbar } = migratedUI; + if (showChatScrollbar !== undefined) { + shareConfigUpdates.showChatScrollbar = showChatScrollbar; + migratedUI = withoutShowChatScrollbar; + effected = true; + } + + config = { + ...withoutUI, + ui: migratedUI, + }; + } + + if (effected) { + new GlobalContext().updateSharedConfig(shareConfigUpdates); + void ide.showToast( + "warning", + "Migrated deprecated Continue JSON settings. Edit in the Config Page", + ); + editConfigJson(() => config); + } + } catch (e) { + throw new Error(`Migration: Failed to parse config.json: ${e}`); + } +} diff --git a/core/config/profile/doLoadConfig.ts b/core/config/profile/doLoadConfig.ts index b4f3d5d35..b82cf7c21 100644 --- a/core/config/profile/doLoadConfig.ts +++ b/core/config/profile/doLoadConfig.ts @@ -17,12 +17,13 @@ import { ControlPlaneClient } from "../../control-plane/client.js"; import { controlPlaneEnv } from "../../control-plane/env.js"; import { TeamAnalytics } from "../../control-plane/TeamAnalytics.js"; import ContinueProxy from "../../llm/llms/stubs/ContinueProxy"; -import { getConfigYamlPath } from "../../util/paths"; +import { getConfigJsonPath, getConfigYamlPath } from "../../util/paths"; import { Telemetry } from "../../util/posthog"; import { TTS } from "../../util/tts"; import { loadContinueConfigFromJson } from "../load"; import { loadContinueConfigFromYaml } from "../yaml/loadYaml"; import { PlatformConfigMetadata } from "./PlatformProfileLoader"; +import { migrateJsonSharedConfig } from "../migrateSharedConfig"; export default async function doLoadConfig( ide: IDE, @@ -40,6 +41,13 @@ export default async function doLoadConfig( const ideSettings = await ideSettingsPromise; const workOsAccessToken = await controlPlaneClient.getAccessToken(); + // Migrations for old config files + // Removes + const configJsonPath = getConfigJsonPath(ideInfo.ideType); + if (fs.existsSync(configJsonPath)) { + migrateJsonSharedConfig(configJsonPath, ide); + } + const configYamlPath = getConfigYamlPath(ideInfo.ideType); let newConfig: ContinueConfig | undefined; diff --git a/core/config/sharedConfig.ts b/core/config/sharedConfig.ts index 23a0e1c2f..9f2335243 100644 --- a/core/config/sharedConfig.ts +++ b/core/config/sharedConfig.ts @@ -1,30 +1,33 @@ import z from "zod"; - -const sharedConfigTabAutoCompleteOptionsSchema = z - .object({ - disable: z.boolean(), - useCache: z.boolean(), - disableInFiles: z.array(z.string()), - multilineCompletions: z.enum(["always", "never", "auto"]), - }) - .partial(); +import { + BrowserSerializedContinueConfig, + ContinueConfig, + Config, + SerializedContinueConfig, +} from ".."; export const sharedConfigSchema = z .object({ allowAnonymousTelemetry: z.boolean(), disableIndexing: z.boolean(), disableSessionTitles: z.boolean(), + + // `experimental` in `ContinueConfig` useChromiumForDocsCrawling: z.boolean(), readResponseTTS: z.boolean(), promptPath: z.string(), - tabAutocompleteOptions: sharedConfigTabAutoCompleteOptionsSchema, - // UI-only, and user-specific: + // `ui` in `ContinueConfig` codeBlockToolbarPosition: z.enum(["top", "bottom"]), fontSize: z.number(), codeWrap: z.boolean(), displayRawMarkdown: z.boolean(), showChatScrollbar: z.boolean(), + + // `tabAutocompleteOptions` in `ContinueConfig` + useAutocompleteCache: z.boolean(), + useAutocompleteMultilineCompletions: z.enum(["always", "never", "auto"]), + disableAutocompleteInFiles: z.array(z.string()), }) .partial(); @@ -51,13 +54,109 @@ export function salvageSharedConfig(sharedConfig: object): SharedConfigSchema { salvagedConfig.disableSessionTitles = val.data; } } - if ("tabAutocompleteOptions" in sharedConfig) { - const val = sharedConfigTabAutoCompleteOptionsSchema.safeParse( - sharedConfig.tabAutocompleteOptions, + if ("disableAutocompleteInFiles" in sharedConfig) { + const val = sharedConfigSchema.shape.disableAutocompleteInFiles.safeParse( + sharedConfig.disableAutocompleteInFiles, ); if (val.success) { - salvagedConfig.tabAutocompleteOptions = val.data; + salvagedConfig.disableAutocompleteInFiles = val.data; } } return salvagedConfig; } + +export function modifyContinueConfigWithSharedConfig< + T extends + | ContinueConfig + | BrowserSerializedContinueConfig + | Config + | SerializedContinueConfig, +>(continueConfig: T, sharedConfig: SharedConfigSchema): T { + const configCopy = { ...continueConfig }; + configCopy.tabAutocompleteOptions = { + ...configCopy.tabAutocompleteOptions, + }; + if (sharedConfig.useAutocompleteCache !== undefined) { + configCopy.tabAutocompleteOptions.useCache = + sharedConfig.useAutocompleteCache; + } + if (sharedConfig.useAutocompleteMultilineCompletions !== undefined) { + configCopy.tabAutocompleteOptions.multilineCompletions = + sharedConfig.useAutocompleteMultilineCompletions; + } + if (sharedConfig.disableAutocompleteInFiles !== undefined) { + configCopy.tabAutocompleteOptions.disableInFiles = + sharedConfig.disableAutocompleteInFiles; + } + + configCopy.ui = { + ...configCopy.ui, + }; + if (sharedConfig.codeBlockToolbarPosition !== undefined) { + configCopy.ui.codeBlockToolbarPosition = + sharedConfig.codeBlockToolbarPosition; + } + if (sharedConfig.fontSize !== undefined) { + configCopy.ui.fontSize = sharedConfig.fontSize; + } + if (sharedConfig.codeWrap !== undefined) { + configCopy.ui.codeWrap = sharedConfig.codeWrap; + } + if (sharedConfig.displayRawMarkdown !== undefined) { + configCopy.ui.displayRawMarkdown = sharedConfig.displayRawMarkdown; + } + if (sharedConfig.showChatScrollbar !== undefined) { + configCopy.ui.showChatScrollbar = sharedConfig.showChatScrollbar; + } + + if (sharedConfig.allowAnonymousTelemetry !== undefined) { + configCopy.allowAnonymousTelemetry = sharedConfig.allowAnonymousTelemetry; + } + if (sharedConfig.disableIndexing !== undefined) { + configCopy.disableIndexing = sharedConfig.disableIndexing; + } + if (sharedConfig.disableSessionTitles !== undefined) { + configCopy.disableSessionTitles = sharedConfig.disableSessionTitles; + } + + configCopy.experimental = { + ...configCopy.experimental, + }; + if (sharedConfig.promptPath !== undefined) { + configCopy.experimental.promptPath = sharedConfig.promptPath; + } + if (sharedConfig.useChromiumForDocsCrawling !== undefined) { + configCopy.experimental.useChromiumForDocsCrawling = + sharedConfig.useChromiumForDocsCrawling; + } + if (sharedConfig.readResponseTTS !== undefined) { + configCopy.experimental.readResponseTTS = sharedConfig.readResponseTTS; + } + + return configCopy; +} + +// continueConfig.tabAutocompleteOptions = { +// ...continueConfig.tabAutocompleteOptions, +// useCache: sharedConfig.useAutocompleteCache, +// disableInFiles: sharedConfig.disableAutocompleteInFiles, +// multilineCompletions: sharedConfig.useAutocompleteMultilineCompletions, +// }; +// continueConfig.ui = { +// ...continueConfig.ui, +// codeBlockToolbarPosition: sharedConfig.codeBlockToolbarPosition, +// fontSize: sharedConfig.fontSize, +// codeWrap: sharedConfig.codeWrap, +// displayRawMarkdown: sharedConfig.displayRawMarkdown, +// showChatScrollbar: sharedConfig.showChatScrollbar, +// }; +// continueConfig.allowAnonymousTelemetry = sharedConfig.allowAnonymousTelemetry; +// continueConfig.disableIndexing = sharedConfig.disableIndexing; +// continueConfig.disableIndexing = sharedConfig.disableIndexing; +// continueConfig.disableSessionTitles = sharedConfig.disableSessionTitles; +// continueConfig.experimental = { +// ...continueConfig.experimental, +// useChromiumForDocsCrawling: sharedConfig.useChromiumForDocsCrawling, +// readResponseTTS: sharedConfig.readResponseTTS, +// promptPath: sharedConfig.promptPath, +// }; diff --git a/core/config/yaml/loadYaml.ts b/core/config/yaml/loadYaml.ts index b2fe17945..03a2fdbc7 100644 --- a/core/config/yaml/loadYaml.ts +++ b/core/config/yaml/loadYaml.ts @@ -36,6 +36,7 @@ import { allTools } from "../../tools"; import { clientRenderHelper } from "./clientRender"; import { llmsFromModelConfig } from "./models"; import { GlobalContext } from "../../util/GlobalContext"; +import { modifyContinueConfigWithSharedConfig } from "../sharedConfig"; async function loadConfigYaml( workspaceConfigs: string[], @@ -281,25 +282,6 @@ async function configYamlToContinueConfig( clearTimeout(mcpConnectionTimeout); }); - // Apply shared config - // TODO: override several of these values with user/org shared config - const sharedConfig = new GlobalContext().getSharedConfig(); - continueConfig.tabAutocompleteOptions = sharedConfig.tabAutocompleteOptions; - continueConfig.ui = { - codeBlockToolbarPosition: sharedConfig.codeBlockToolbarPosition, - fontSize: sharedConfig.fontSize, - codeWrap: sharedConfig.codeWrap, - displayRawMarkdown: sharedConfig.displayRawMarkdown, - showChatScrollbar: sharedConfig.showChatScrollbar, - }; - continueConfig.allowAnonymousTelemetry = sharedConfig.allowAnonymousTelemetry; - continueConfig.disableIndexing = sharedConfig.disableIndexing; - continueConfig.disableSessionTitles = sharedConfig.disableSessionTitles; - continueConfig.experimental!.useChromiumForDocsCrawling = - sharedConfig.useChromiumForDocsCrawling; - continueConfig.experimental!.readResponseTTS = sharedConfig.readResponseTTS; - continueConfig.experimental!.promptPath = sharedConfig.promptPath; - return continueConfig; } @@ -355,8 +337,16 @@ export async function loadContinueConfigFromYaml( } } + // Apply shared config + // TODO: override several of these values with user/org shared config + const sharedConfig = new GlobalContext().getSharedConfig(); + const withShared = modifyContinueConfigWithSharedConfig( + continueConfig, + sharedConfig, + ); + return { - config: continueConfig, + config: withShared, errors: configYamlResult.errors, configLoadInterrupted: false, }; diff --git a/core/index.d.ts b/core/index.d.ts index aef68e85a..0713f55cb 100644 --- a/core/index.d.ts +++ b/core/index.d.ts @@ -1211,6 +1211,7 @@ export interface BrowserSerializedContinueConfig { docs?: SiteIndexingConfig[]; tools: Tool[]; usePlatform: boolean; + tabAutocompleteOptions?: Partial; } // DOCS SUGGESTIONS AND PACKAGE INFO diff --git a/core/protocol/core.ts b/core/protocol/core.ts index 98d2a38dd..fc9344666 100644 --- a/core/protocol/core.ts +++ b/core/protocol/core.ts @@ -22,7 +22,7 @@ import type { } from "../"; import { AutocompleteInput } from "../autocomplete/util/types"; import { ProfileDescription } from "../config/ConfigHandler"; -import { SharedConfigSchema } from "../config/SharedConfig"; +import { SharedConfigSchema } from "../config/sharedConfig"; export type OnboardingModes = | "Local" diff --git a/core/protocol/passThrough.ts b/core/protocol/passThrough.ts index a638eafb4..072426eab 100644 --- a/core/protocol/passThrough.ts +++ b/core/protocol/passThrough.ts @@ -23,6 +23,7 @@ export const WEBVIEW_TO_CORE_PASS_THROUGH: (keyof ToCoreFromWebviewProtocol)[] = "config/deleteModel", "config/listProfiles", "config/openProfile", + "config/updateSharedConfig", "context/getContextItems", "context/getSymbolsForFiles", "context/loadSubmenuItems", diff --git a/docs/docs/reference.md b/docs/docs/reference.md index 0f24e2a15..4a8032262 100644 --- a/docs/docs/reference.md +++ b/docs/docs/reference.md @@ -446,3 +446,11 @@ Example } } ``` + +### Deprecated settings + +Some deprecated `config.json` settings are no longer stored in config and have been moved to be editable through the Config Page (Gear Icon) + + +If config.json is +For security purposes, ifsome settings present in `config.json` will always migrated from the old config if any config.json is detected \ No newline at end of file diff --git a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/constants/MessageTypes.kt b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/constants/MessageTypes.kt index 9c2b8c2dc..dbc8c457a 100644 --- a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/constants/MessageTypes.kt +++ b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/constants/MessageTypes.kt @@ -80,6 +80,7 @@ class MessageTypes { "config/deleteModel", "config/listProfiles", "config/openProfile", + "config/updateSharedConfig", "context/getContextItems", "context/getSymbolsForFiles", "context/loadSubmenuItems", diff --git a/extensions/vscode/src/commands.ts b/extensions/vscode/src/commands.ts index d8019cfe1..da5e7db94 100644 --- a/extensions/vscode/src/commands.ts +++ b/extensions/vscode/src/commands.ts @@ -792,10 +792,8 @@ const getCommandsMap: ( vscode.commands.executeCommand("workbench.action.copyEditorToNewWindow"); vscode.commands.executeCommand("workbench.action.closeAuxiliaryBar"); }, - "continue.openConfig": () => { - core.invoke("config/openProfile", { - profileId: undefined, - }); + "continue.openConfigPage": () => { + vscode.commands.executeCommand("continue.navigateTo", "/config", true); }, "continue.selectFilesAsContext": async ( firstUri: vscode.Uri, diff --git a/gui/src/components/gui/Switch.tsx b/gui/src/components/gui/Switch.tsx new file mode 100644 index 000000000..ab71510f2 --- /dev/null +++ b/gui/src/components/gui/Switch.tsx @@ -0,0 +1,37 @@ +import React from "react"; + +type ToggleSwitchProps = { + isToggled: boolean; + onToggle: () => void; + text: string; +}; + +const ToggleSwitch: React.FC = ({ + isToggled, + onToggle, + text, +}) => { + return ( +