fix: 🐛 handle when vscode workspace not open
This commit is contained in:
parent
8db5b39170
commit
73c6827d02
5 changed files with 80 additions and 28 deletions
|
|
@ -10,7 +10,8 @@ def get_file_contents(filepath: str) -> str:
|
|||
try:
|
||||
with open(filepath, "r") as f:
|
||||
return f.read()
|
||||
except UnicodeDecodeError:
|
||||
except Exception as e:
|
||||
print("Error reading file contents", e)
|
||||
return ""
|
||||
|
||||
|
||||
|
|
@ -53,6 +54,12 @@ class FileContextProvider(ContextProvider):
|
|||
for file_name in file_names:
|
||||
filepaths.append(os.path.join(root, file_name))
|
||||
|
||||
if len(filepaths) > 1000:
|
||||
break
|
||||
|
||||
if len(filepaths) > 1000:
|
||||
break
|
||||
|
||||
return [ContextItem(
|
||||
content=get_file_contents(file)[:min(
|
||||
2000, len(get_file_contents(file)))],
|
||||
|
|
|
|||
|
|
@ -313,6 +313,9 @@ function GUI(props: GUIProps) {
|
|||
<>
|
||||
<Loader />
|
||||
<p style={{ textAlign: "center" }}>Loading Continue server...</p>
|
||||
{/* <p style={{ textAlign: "center" }}>
|
||||
Make sure you have a folder opened in VS Code
|
||||
</p> */}
|
||||
</>
|
||||
)}
|
||||
{history?.timeline.map((node: HistoryNode, index: number) => {
|
||||
|
|
|
|||
|
|
@ -6,7 +6,28 @@ def run(cmd: str):
|
|||
return subprocess.run(cmd, shell=True, capture_output=False)
|
||||
|
||||
|
||||
def get_latest_version() -> str:
|
||||
latest = None
|
||||
latest_major = 0
|
||||
latest_minor = 0
|
||||
latest_patch = 0
|
||||
for file in os.listdir("../build"):
|
||||
if file.endswith(".vsix"):
|
||||
version = file.split("-")[1].split(".vsix")[0]
|
||||
major, minor, patch = list(
|
||||
map(lambda x: int(x), version.split(".")))
|
||||
if latest is None or (major >= latest_major and minor >= latest_minor and patch > latest_patch):
|
||||
latest = file
|
||||
latest_major = major
|
||||
latest_minor = minor
|
||||
latest_patch = patch
|
||||
|
||||
|
||||
def main():
|
||||
# Clear out old stuff
|
||||
run(f"rm -rf ../build/{get_latest_version()}")
|
||||
run("rm ../server/continuedev-0.1.2-py3-none-any.whl")
|
||||
|
||||
# Check for Python and Node - we won't install them, but will warn
|
||||
resp1 = run("python --version")
|
||||
resp2 = run("python3 --version")
|
||||
|
|
@ -39,21 +60,7 @@ def main():
|
|||
print("This was the error: ", resp.stderr)
|
||||
return
|
||||
|
||||
latest = None
|
||||
latest_major = 0
|
||||
latest_minor = 0
|
||||
latest_patch = 0
|
||||
for file in os.listdir("../build"):
|
||||
if file.endswith(".vsix"):
|
||||
version = file.split("-")[1].split(".vsix")[0]
|
||||
major, minor, patch = list(
|
||||
map(lambda x: int(x), version.split(".")))
|
||||
if latest is None or (major >= latest_major and minor >= latest_minor and patch > latest_patch):
|
||||
latest = file
|
||||
latest_major = major
|
||||
latest_minor = minor
|
||||
latest_patch = patch
|
||||
|
||||
latest = get_latest_version()
|
||||
resp = run(f"cd ..; code --install-extension ./build/{latest}")
|
||||
|
||||
print("Continue VS Code extension installed successfully. Please restart VS Code to use it.")
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ import path = require("path");
|
|||
import { registerAllCodeLensProviders } from "./lang-server/codeLens";
|
||||
import { registerAllCommands } from "./commands";
|
||||
import registerQuickFixProvider from "./lang-server/codeActions";
|
||||
const os = require("os");
|
||||
|
||||
const continueVirtualDocumentScheme = "continue";
|
||||
|
||||
|
|
@ -70,7 +71,11 @@ class IdeProtocolClient {
|
|||
reconnect();
|
||||
});
|
||||
messenger.onMessage((messageType, data, messenger) => {
|
||||
this.handleMessage(messageType, data, messenger);
|
||||
this.handleMessage(messageType, data, messenger).catch((err) => {
|
||||
vscode.window.showErrorMessage(
|
||||
"Error handling message from Continue server: " + err.message
|
||||
);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
|
@ -267,7 +272,7 @@ class IdeProtocolClient {
|
|||
getWorkspaceDirectory() {
|
||||
if (!vscode.workspace.workspaceFolders) {
|
||||
// Return the home directory
|
||||
return process.env.HOME || process.env.USERPROFILE || "/";
|
||||
return os.homedir();
|
||||
}
|
||||
return vscode.workspace.workspaceFolders[0].uri.fsPath;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,7 +15,10 @@
|
|||
"type": "string"
|
||||
}
|
||||
},
|
||||
"required": ["name", "arguments"]
|
||||
"required": [
|
||||
"name",
|
||||
"arguments"
|
||||
]
|
||||
},
|
||||
"ChatMessage": {
|
||||
"title": "ChatMessage",
|
||||
|
|
@ -23,7 +26,12 @@
|
|||
"properties": {
|
||||
"role": {
|
||||
"title": "Role",
|
||||
"enum": ["assistant", "user", "system", "function"],
|
||||
"enum": [
|
||||
"assistant",
|
||||
"user",
|
||||
"system",
|
||||
"function"
|
||||
],
|
||||
"type": "string"
|
||||
},
|
||||
"content": {
|
||||
|
|
@ -42,7 +50,10 @@
|
|||
"$ref": "#/definitions/FunctionCall"
|
||||
}
|
||||
},
|
||||
"required": ["role", "summary"]
|
||||
"required": [
|
||||
"role",
|
||||
"summary"
|
||||
]
|
||||
},
|
||||
"Step": {
|
||||
"title": "Step",
|
||||
|
|
@ -119,7 +130,10 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
"required": ["step", "depth"]
|
||||
"required": [
|
||||
"step",
|
||||
"depth"
|
||||
]
|
||||
},
|
||||
"History": {
|
||||
"title": "History",
|
||||
|
|
@ -138,7 +152,10 @@
|
|||
"type": "integer"
|
||||
}
|
||||
},
|
||||
"required": ["timeline", "current_index"]
|
||||
"required": [
|
||||
"timeline",
|
||||
"current_index"
|
||||
]
|
||||
},
|
||||
"SlashCommandDescription": {
|
||||
"title": "SlashCommandDescription",
|
||||
|
|
@ -153,7 +170,10 @@
|
|||
"type": "string"
|
||||
}
|
||||
},
|
||||
"required": ["name", "description"]
|
||||
"required": [
|
||||
"name",
|
||||
"description"
|
||||
]
|
||||
},
|
||||
"ContextItemId": {
|
||||
"title": "ContextItemId",
|
||||
|
|
@ -169,7 +189,10 @@
|
|||
"type": "string"
|
||||
}
|
||||
},
|
||||
"required": ["provider_title", "item_id"]
|
||||
"required": [
|
||||
"provider_title",
|
||||
"item_id"
|
||||
]
|
||||
},
|
||||
"ContextItemDescription": {
|
||||
"title": "ContextItemDescription",
|
||||
|
|
@ -188,7 +211,11 @@
|
|||
"$ref": "#/definitions/ContextItemId"
|
||||
}
|
||||
},
|
||||
"required": ["name", "description", "id"]
|
||||
"required": [
|
||||
"name",
|
||||
"description",
|
||||
"id"
|
||||
]
|
||||
},
|
||||
"ContextItem": {
|
||||
"title": "ContextItem",
|
||||
|
|
@ -213,7 +240,10 @@
|
|||
"type": "boolean"
|
||||
}
|
||||
},
|
||||
"required": ["description", "content"]
|
||||
"required": [
|
||||
"description",
|
||||
"content"
|
||||
]
|
||||
},
|
||||
"src__continuedev__core__main__FullState": {
|
||||
"title": "FullState",
|
||||
|
|
@ -268,4 +298,4 @@
|
|||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Reference in a new issue