From 0871f64503f6adbc8d253ce70dd1a84e81a125c3 Mon Sep 17 00:00:00 2001 From: Nate Sesti Date: Mon, 6 Nov 2023 16:35:57 -0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20useEffect,=20config,=20and=20chu?= =?UTF-8?q?nking=20fixes?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- extensions/vscode/src/continueIdeClient.ts | 2 +- gui/src/components/ComboBox.tsx | 6 +-- server/continuedev/core/config.py | 43 ++++++++++--------- .../libs/index/chunkers/chunk_directory.py | 13 ++++++ server/continuedev/libs/util/paths.py | 1 + 5 files changed, 40 insertions(+), 25 deletions(-) diff --git a/extensions/vscode/src/continueIdeClient.ts b/extensions/vscode/src/continueIdeClient.ts index 3e74eb171..314d9fa99 100644 --- a/extensions/vscode/src/continueIdeClient.ts +++ b/extensions/vscode/src/continueIdeClient.ts @@ -575,7 +575,7 @@ class IdeProtocolClient { } async readFile(filepath: string): Promise { - const MAX_BYTES = 500000; // 0.5MB - socket.io has a 1MB limit, but seems to die a bit above 0.5MB + const MAX_BYTES = 100000; // 0.1MB - socket.io has a 1MB limit, but seems to die a around 0.5MB let contents: string | undefined; if (typeof contents === "undefined") { try { diff --git a/gui/src/components/ComboBox.tsx b/gui/src/components/ComboBox.tsx index 0c103c4d0..b074add0d 100644 --- a/gui/src/components/ComboBox.tsx +++ b/gui/src/components/ComboBox.tsx @@ -671,9 +671,9 @@ const ComboBox = React.forwardRef((props: ComboBoxProps, ref) => { }; }, []); - const persistSession = useCallback(() => { + const persistSession = () => { client?.persistSession(sessionState, workspacePaths[0] || ""); - }, [client, sessionState, workspacePaths]); + }; useEffect(() => { if (!inputRef.current || !props.isMainInput) { @@ -704,7 +704,7 @@ const ComboBox = React.forwardRef((props: ComboBoxProps, ref) => { return () => { window.removeEventListener("message", handler); }; - }, [inputRef.current, props.isMainInput, persistSession]); + }, [inputRef.current, props.isMainInput]); const deleteButtonDivRef = React.useRef(null); const stickyDropdownHeaderDiv = React.useRef(null); diff --git a/server/continuedev/core/config.py b/server/continuedev/core/config.py index 28168dd34..78bc7c6fa 100644 --- a/server/continuedev/core/config.py +++ b/server/continuedev/core/config.py @@ -15,6 +15,7 @@ from .context import ContextProvider from .main import ContextProviderDescription, Policy, SlashCommandDescription, Step from .models import Models from ..libs.util.telemetry import posthog_logger +from ..libs.util.logging import logger class SlashCommand(BaseModel): @@ -159,32 +160,32 @@ class ContinueConfig(BaseModel): return max(0.0, min(1.0, v)) @staticmethod - def from_filepath(filepath: str) -> "ContinueConfig": + def from_filepath(filepath: str, retry: bool = True) -> "ContinueConfig": # Use importlib to load the config file config.py at the given path - import importlib.util + try: + import importlib.util - spec = importlib.util.spec_from_file_location("config", filepath) - config = importlib.util.module_from_spec(spec) - spec.loader.exec_module(config) + spec = importlib.util.spec_from_file_location("config", filepath) + config = importlib.util.module_from_spec(spec) + spec.loader.exec_module(config) - return config.config + return config.config + except ModuleNotFoundError as e: + # Check if the module was "continuedev.src" + if retry and e.name == "continuedev.src": + convertConfigImports(shorten=True) + return ContinueConfig.from_filepath(filepath, retry=False) + else: + logger.critical(f"Failed to load config.py: {e}") + except Exception as e: + logger.critical(f"Failed to load config.py: {e}") + + return ContinueConfig() @staticmethod - def load_default(retry: bool = True) -> "ContinueConfig": - try: - path = getConfigFilePath() - config = ContinueConfig.from_filepath(path) - - return config - except ModuleNotFoundError as e: - if not retry: - raise e - # Check if the module was "continuedev.src" - if e.name == "continuedev.src": - convertConfigImports(shorten=True) - return ContinueConfig.load_default(retry=False) - else: - raise e + def load_default() -> "ContinueConfig": + path = getConfigFilePath() + return ContinueConfig.from_filepath(path) def get_slash_command_descriptions(self) -> List[SlashCommandDescription]: custom_commands = ( diff --git a/server/continuedev/libs/index/chunkers/chunk_directory.py b/server/continuedev/libs/index/chunkers/chunk_directory.py index 412a5e0c6..0eec9d827 100644 --- a/server/continuedev/libs/index/chunkers/chunk_directory.py +++ b/server/continuedev/libs/index/chunkers/chunk_directory.py @@ -40,6 +40,19 @@ FILE_IGNORE_PATTERNS = [ "*.dylib", "*.ncb", "*.sdf", + "*.woff", + "*.woff2", + "*.eot", + "*.cur", + "*.avi", + "*.mpg", + "*.mpeg", + "*.mov", + "*.mp3", + "*.mp4", + "*.mkv", + "*.mkv", + "*.webm", ] MAX_SIZE_IN_CHARS = 50_000 diff --git a/server/continuedev/libs/util/paths.py b/server/continuedev/libs/util/paths.py index 0c2c63136..dbd27f09e 100644 --- a/server/continuedev/libs/util/paths.py +++ b/server/continuedev/libs/util/paths.py @@ -115,6 +115,7 @@ def migrateConfigFile(existing: str) -> Optional[str]: .replace("TextGenUI", "TextGenWebUI") .replace("text_gen_interface", "text_gen_webui") .replace(".steps.chroma", ".steps.codebase") + .replace("\xa0", " ") ) if migrated != existing: return migrated