insidious client_state vs application_state err
This commit is contained in:
parent
b19076ddb6
commit
c5102b0997
9 changed files with 34 additions and 11 deletions
|
|
@ -37,6 +37,8 @@ def get_error_title(e: Exception) -> str:
|
|||
return "The request failed. Please check your internet connection and try again. If this issue persists, you can use our API key for free by going to VS Code settings and changing the value of continue.OPENAI_API_KEY to \"\""
|
||||
elif isinstance(e, openai_errors.InvalidRequestError):
|
||||
return 'Your API key does not have access to GPT-4. You can use ours for free by going to VS Code settings and changing the value of continue.OPENAI_API_KEY to ""'
|
||||
elif e.__str__().startswith("Cannot connect to host"):
|
||||
return "The request failed. Please check your internet connection and try again."
|
||||
return e.__str__() or e.__repr__()
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ class GUIProtocolServer(AbstractGUIProtocolServer):
|
|||
self.session = session
|
||||
|
||||
async def _send_json(self, message_type: str, data: Any):
|
||||
if self.websocket.client_state == WebSocketState.DISCONNECTED:
|
||||
if self.websocket.application_state == WebSocketState.DISCONNECTED:
|
||||
return
|
||||
await self.websocket.send_json({
|
||||
"messageType": message_type,
|
||||
|
|
|
|||
|
|
@ -149,7 +149,7 @@ class IdeProtocolServer(AbstractIdeProtocolServer):
|
|||
return other_msgs
|
||||
|
||||
async def _send_json(self, message_type: str, data: Any):
|
||||
if self.websocket.client_state == WebSocketState.DISCONNECTED:
|
||||
if self.websocket.application_state == WebSocketState.DISCONNECTED:
|
||||
return
|
||||
await self.websocket.send_json({
|
||||
"messageType": message_type,
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ from ...libs.llm.prompt_utils import MarkdownStyleEncoderDecoder
|
|||
from ...models.filesystem_edit import EditDiff, FileEdit, FileEditWithFullContents, FileSystemEdit
|
||||
from ...models.filesystem import FileSystem, RangeInFile, RangeInFileWithContents
|
||||
from ...core.observation import Observation, TextObservation, TracebackObservation, UserInputObservation
|
||||
from ...core.main import ChatMessage, Step, SequentialStep
|
||||
from ...core.main import ChatMessage, ContinueCustomException, Step, SequentialStep
|
||||
from ...libs.util.count_tokens import MAX_TOKENS_FOR_MODEL, DEFAULT_MAX_TOKENS
|
||||
from ...libs.util.dedent import dedent_and_get_common_whitespace
|
||||
import difflib
|
||||
|
|
@ -608,6 +608,13 @@ Please output the code to be inserted at the cursor in order to fulfill the user
|
|||
rif_dict[rif.filepath] = rif.contents
|
||||
|
||||
for rif in rif_with_contents:
|
||||
# If the file doesn't exist, ask them to save it first
|
||||
if not os.path.exists(rif.filepath):
|
||||
message = f"The file {rif.filepath} does not exist. Please save it first."
|
||||
raise ContinueCustomException(
|
||||
title=message, message=message
|
||||
)
|
||||
|
||||
await sdk.ide.setFileOpen(rif.filepath)
|
||||
await sdk.ide.setSuggestionsLocked(rif.filepath, True)
|
||||
await self.stream_rif(rif, sdk)
|
||||
|
|
|
|||
|
|
@ -169,6 +169,7 @@ const ComboBox = React.forwardRef((props: ComboBoxProps, ref) => {
|
|||
useImperativeHandle(ref, () => downshiftProps, [downshiftProps]);
|
||||
|
||||
const [metaKeyPressed, setMetaKeyPressed] = useState(false);
|
||||
const [focused, setFocused] = useState(false);
|
||||
useEffect(() => {
|
||||
const handleKeyDown = (e: KeyboardEvent) => {
|
||||
if (e.key === "Meta") {
|
||||
|
|
@ -298,7 +299,11 @@ const ComboBox = React.forwardRef((props: ComboBoxProps, ref) => {
|
|||
|
||||
// setShowContextDropdown(target.value.endsWith("@"));
|
||||
},
|
||||
onFocus: (e) => {
|
||||
setFocused(true);
|
||||
},
|
||||
onBlur: (e) => {
|
||||
setFocused(false);
|
||||
postVscMessage("blurContinueInput", {});
|
||||
},
|
||||
onKeyDown: (event) => {
|
||||
|
|
@ -374,7 +379,9 @@ const ComboBox = React.forwardRef((props: ComboBoxProps, ref) => {
|
|||
</div>
|
||||
{highlightedCodeSections.length === 0 &&
|
||||
(downshiftProps.inputValue?.startsWith("/edit") ||
|
||||
(metaKeyPressed && downshiftProps.inputValue?.length > 0)) && (
|
||||
(focused &&
|
||||
metaKeyPressed &&
|
||||
downshiftProps.inputValue?.length > 0)) && (
|
||||
<div className="text-trueGray-400 pr-4 text-xs text-right">
|
||||
Inserting at cursor
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -253,9 +253,12 @@ function StepContainer(props: StepContainerProps) {
|
|||
)}
|
||||
|
||||
{props.historyNode.observation?.error ? (
|
||||
<pre className="overflow-x-scroll">
|
||||
{props.historyNode.observation.error as string}
|
||||
</pre>
|
||||
<details>
|
||||
<summary>View Traceback</summary>
|
||||
<pre className="overflow-x-scroll">
|
||||
{props.historyNode.observation.error as string}
|
||||
</pre>
|
||||
</details>
|
||||
) : (
|
||||
<StyledMarkdownPreview
|
||||
source={props.historyNode.step.description || ""}
|
||||
|
|
|
|||
|
|
@ -386,8 +386,12 @@ class IdeProtocolClient {
|
|||
contents = editor.document.getText();
|
||||
}
|
||||
});
|
||||
if (!contents) {
|
||||
contents = fs.readFileSync(filepath, "utf-8");
|
||||
if (typeof contents === "undefined") {
|
||||
if (fs.existsSync(filepath)) {
|
||||
contents = fs.readFileSync(filepath, "utf-8");
|
||||
} else {
|
||||
contents = "";
|
||||
}
|
||||
}
|
||||
return contents;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -129,7 +129,7 @@ class DiffManager {
|
|||
// Open the diff editor if this is a new diff
|
||||
if (!this.diffs.has(newFilepath)) {
|
||||
// Figure out the first line that is different
|
||||
const oldContent = fs.readFileSync(originalFilepath).toString("utf-8");
|
||||
const oldContent = ideProtocolClient.readFile(originalFilepath);
|
||||
const line = this._findFirstDifferentLine(oldContent, newContent);
|
||||
|
||||
const diffInfo: DiffInfo = {
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ export abstract class Messenger {
|
|||
abstract onOpen(callback: () => void): void;
|
||||
|
||||
abstract onClose(callback: () => void): void;
|
||||
|
||||
|
||||
abstract onError(callback: () => void): void;
|
||||
|
||||
abstract sendAndReceive(messageType: string, data: any): Promise<any>;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue