summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNate Sesti <sestinj@gmail.com>2023-07-27 11:23:55 -0700
committerNate Sesti <sestinj@gmail.com>2023-07-27 11:23:55 -0700
commit5d973490687c40922f2b7a2ddf2a3e19c207eb0f (patch)
treefab63009bd6014cd8ded1bd0a536727e0228b055
parent4e47da8398ac1cecb6f7100568f0f7296baaeac9 (diff)
downloadsncontinue-5d973490687c40922f2b7a2ddf2a3e19c207eb0f.tar.gz
sncontinue-5d973490687c40922f2b7a2ddf2a3e19c207eb0f.tar.bz2
sncontinue-5d973490687c40922f2b7a2ddf2a3e19c207eb0f.zip
feat: :loud_sound: give users access to Continue server logs
can see logs in ~/.continue/continue.log
-rw-r--r--continuedev/src/continuedev/libs/util/paths.py5
-rw-r--r--continuedev/src/continuedev/plugins/context_providers/file.py35
-rw-r--r--continuedev/src/continuedev/server/main.py29
-rw-r--r--extension/package-lock.json4
-rw-r--r--extension/package.json7
-rw-r--r--extension/src/activation/activate.ts4
-rw-r--r--extension/src/activation/environmentSetup.ts11
-rw-r--r--extension/src/commands.ts13
-rw-r--r--extension/src/continueIdeClient.ts13
-rw-r--r--extension/src/extension.ts17
10 files changed, 105 insertions, 33 deletions
diff --git a/continuedev/src/continuedev/libs/util/paths.py b/continuedev/src/continuedev/libs/util/paths.py
index 14a97f57..b08b0949 100644
--- a/continuedev/src/continuedev/libs/util/paths.py
+++ b/continuedev/src/continuedev/libs/util/paths.py
@@ -44,3 +44,8 @@ def getConfigFilePath() -> str:
f.write(getDefaultConfigFile())
return path
+
+
+def getLogFilePath():
+ path = os.path.join(getGlobalFolderPath(), "continue.log")
+ return path
diff --git a/continuedev/src/continuedev/plugins/context_providers/file.py b/continuedev/src/continuedev/plugins/context_providers/file.py
index 90835d98..31c8e1d9 100644
--- a/continuedev/src/continuedev/plugins/context_providers/file.py
+++ b/continuedev/src/continuedev/plugins/context_providers/file.py
@@ -13,14 +13,13 @@ def get_file_contents(filepath: str) -> str:
try:
filesize = os.path.getsize(filepath)
if filesize > MAX_SIZE_IN_BYTES:
- print("File is over 1MB size limit: ", filepath, filesize)
- return ""
+ return None
with open(filepath, "r") as f:
return f.read()
except Exception as e:
- print("Error reading file contents", filepath, e)
- return ""
+ # Some files cannot be read, e.g. binary files
+ return None
DEFAULT_IGNORE_DIRS = [
@@ -68,15 +67,21 @@ class FileContextProvider(ContextProvider):
if len(filepaths) > 1000:
break
- return [ContextItem(
- content=get_file_contents(file)[:min(
- 2000, len(get_file_contents(file)))],
- description=ContextItemDescription(
- name=os.path.basename(file),
- description=file,
- id=ContextItemId(
- provider_title=self.title,
- item_id=re.sub(r'[^0-9a-zA-Z_-]', '', file)
+ items = []
+ for file in filepaths:
+ content = get_file_contents(file)
+ if content is None:
+ continue # no pun intended
+
+ items.append(ContextItem(
+ content=content[:min(2000, len(content))],
+ description=ContextItemDescription(
+ name=os.path.basename(file),
+ description=file,
+ id=ContextItemId(
+ provider_title=self.title,
+ item_id=re.sub(r'[^0-9a-zA-Z_-]', '', file)
+ )
)
- )
- ) for file in filepaths]
+ ))
+ return items
diff --git a/continuedev/src/continuedev/server/main.py b/continuedev/src/continuedev/server/main.py
index 0b59d4fe..e155fad4 100644
--- a/continuedev/src/continuedev/server/main.py
+++ b/continuedev/src/continuedev/server/main.py
@@ -1,4 +1,5 @@
import asyncio
+import sys
import time
import psutil
import os
@@ -7,10 +8,13 @@ from fastapi.middleware.cors import CORSMiddleware
import atexit
import uvicorn
import argparse
+import logging.config
+
from .ide import router as ide_router
from .gui import router as gui_router
from .session_manager import session_manager
+from ..libs.util.paths import getLogFilePath
app = FastAPI()
@@ -39,12 +43,31 @@ parser.add_argument("-p", "--port", help="server port",
type=int, default=65432)
args = parser.parse_args()
+LOGGING_CONFIG = {
+ 'version': 1,
+ 'disable_existing_loggers': False,
+ 'handlers': {
+ 'file': {
+ 'level': 'DEBUG',
+ 'class': 'logging.FileHandler',
+ 'filename': 'uvicorn.log',
+ },
+ },
+ 'root': {
+ 'level': 'DEBUG',
+ 'handlers': ['file']
+ }
+}
+
+logging.config.dictConfig(LOGGING_CONFIG)
+sys.stdout = open(getLogFilePath(), 'w')
-# log_file = open('output.log', 'a')
-# sys.stdout = log_file
def run_server():
- uvicorn.run(app, host="0.0.0.0", port=args.port)
+ config = uvicorn.Config(app, host="0.0.0.0", port=args.port)
+ server = uvicorn.Server(config)
+
+ server.run()
async def cleanup_coroutine():
diff --git a/extension/package-lock.json b/extension/package-lock.json
index f232333e..d70370b7 100644
--- a/extension/package-lock.json
+++ b/extension/package-lock.json
@@ -1,12 +1,12 @@
{
"name": "continue",
- "version": "0.0.209",
+ "version": "0.0.210",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "continue",
- "version": "0.0.209",
+ "version": "0.0.210",
"license": "Apache-2.0",
"dependencies": {
"@electron/rebuild": "^3.2.10",
diff --git a/extension/package.json b/extension/package.json
index 31eb3cac..e53b686d 100644
--- a/extension/package.json
+++ b/extension/package.json
@@ -14,7 +14,7 @@
"displayName": "Continue",
"pricing": "Free",
"description": "The open-source coding autopilot",
- "version": "0.0.209",
+ "version": "0.0.210",
"publisher": "Continue",
"engines": {
"vscode": "^1.67.0"
@@ -106,6 +106,11 @@
"command": "continue.quickFix",
"category": "Continue",
"title": "Quick Fix"
+ },
+ {
+ "command": "continue.viewLogs",
+ "category": "Continue",
+ "title": "View Logs"
}
],
"keybindings": [
diff --git a/extension/src/activation/activate.ts b/extension/src/activation/activate.ts
index 430f9f4a..40f1bbd5 100644
--- a/extension/src/activation/activate.ts
+++ b/extension/src/activation/activate.ts
@@ -22,6 +22,10 @@ function getExtensionVersionInt(versionString: string): number {
export async function activateExtension(context: vscode.ExtensionContext) {
extensionContext = context;
console.log("Using Continue version: ", getExtensionVersion());
+ console.log(
+ "In workspace: ",
+ vscode.workspace.workspaceFolders?.[0].uri.fsPath
+ );
// Before anything else, check whether this is an out-of-date version of the extension
// Do so by grabbing the package.json off of the GitHub respository for now.
fetch(PACKAGE_JSON_RAW_GITHUB_URL)
diff --git a/extension/src/activation/environmentSetup.ts b/extension/src/activation/environmentSetup.ts
index 5a9345a6..c8998bee 100644
--- a/extension/src/activation/environmentSetup.ts
+++ b/extension/src/activation/environmentSetup.ts
@@ -53,7 +53,16 @@ async function retryThenFail(
}
} finally {
console.log("After retries, failed to set up Continue extension", msg);
- vscode.window.showErrorMessage(msg);
+ vscode.window
+ .showErrorMessage(msg, "View Logs", "Retry")
+ .then((selection) => {
+ if (selection === "View Logs") {
+ vscode.commands.executeCommand("continue.viewLogs");
+ } else if (selection === "Retry") {
+ // Reload VS Code window
+ vscode.commands.executeCommand("workbench.action.reloadWindow");
+ }
+ });
}
throw e;
diff --git a/extension/src/commands.ts b/extension/src/commands.ts
index 1da2f04e..35d466e8 100644
--- a/extension/src/commands.ts
+++ b/extension/src/commands.ts
@@ -1,9 +1,6 @@
import * as vscode from "vscode";
-import {
- decorationManager,
- showAnswerInTextEditor,
- showGutterSpinner,
-} from "./decorations";
+import * as path from "path";
+import * as os from "os";
import {
acceptSuggestionCommand,
rejectSuggestionCommand,
@@ -65,6 +62,12 @@ const commandsMap: { [command: string]: (...args: any) => any } = {
ideProtocolClient.sendMainUserInput(text);
}
},
+ "continue.viewLogs": async () => {
+ // Open ~/.continue/continue.log
+ const logFile = path.join(os.homedir(), ".continue", "continue.log");
+ const uri = vscode.Uri.file(logFile);
+ await vscode.window.showTextDocument(uri);
+ },
};
export function registerAllCommands(context: vscode.ExtensionContext) {
diff --git a/extension/src/continueIdeClient.ts b/extension/src/continueIdeClient.ts
index 4e6f0494..157b59cb 100644
--- a/extension/src/continueIdeClient.ts
+++ b/extension/src/continueIdeClient.ts
@@ -72,9 +72,16 @@ class IdeProtocolClient {
});
messenger.onMessage((messageType, data, messenger) => {
this.handleMessage(messageType, data, messenger).catch((err) => {
- vscode.window.showErrorMessage(
- "Error handling message from Continue server: " + err.message
- );
+ vscode.window
+ .showErrorMessage(
+ "Error handling message from Continue server: " + err.message,
+ "View Logs"
+ )
+ .then((selection) => {
+ if (selection === "View Logs") {
+ vscode.commands.executeCommand("continue.viewLogs");
+ }
+ });
});
});
}
diff --git a/extension/src/extension.ts b/extension/src/extension.ts
index f2e580a1..802b12bc 100644
--- a/extension/src/extension.ts
+++ b/extension/src/extension.ts
@@ -10,9 +10,20 @@ async function dynamicImportAndActivate(context: vscode.ExtensionContext) {
await activateExtension(context);
} catch (e) {
console.log("Error activating extension: ", e);
- vscode.window.showInformationMessage(
- "Error activating the Continue extension."
- );
+ vscode.window
+ .showInformationMessage(
+ "Error activating the Continue extension.",
+ "View Logs",
+ "Retry"
+ )
+ .then((selection) => {
+ if (selection === "View Logs") {
+ vscode.commands.executeCommand("continue.viewLogs");
+ } else if (selection === "Retry") {
+ // Reload VS Code window
+ vscode.commands.executeCommand("workbench.action.reloadWindow");
+ }
+ });
}
}