diff options
author | Nate Sesti <sestinj@gmail.com> | 2023-07-30 22:30:00 -0700 |
---|---|---|
committer | Nate Sesti <sestinj@gmail.com> | 2023-07-30 22:30:00 -0700 |
commit | 57a572a420e16b08301f0c6738a1b414c59bce85 (patch) | |
tree | 2bdbc7831d66aafefe30a9e236ecc150d80024cc /extension/src/debugPanel.ts | |
parent | 1bc5777ed168e47e2ef2ab1b33eecf6cbd170a61 (diff) | |
parent | 8bd76be6c0925e0d5e5f6d239e9c6907df3cfd23 (diff) | |
download | sncontinue-57a572a420e16b08301f0c6738a1b414c59bce85.tar.gz sncontinue-57a572a420e16b08301f0c6738a1b414c59bce85.tar.bz2 sncontinue-57a572a420e16b08301f0c6738a1b414c59bce85.zip |
Merge remote-tracking branch 'continuedev/main' into llm-object-config-merge-main
Diffstat (limited to 'extension/src/debugPanel.ts')
-rw-r--r-- | extension/src/debugPanel.ts | 38 |
1 files changed, 26 insertions, 12 deletions
diff --git a/extension/src/debugPanel.ts b/extension/src/debugPanel.ts index 3c4f8481..643563a2 100644 --- a/extension/src/debugPanel.ts +++ b/extension/src/debugPanel.ts @@ -17,17 +17,20 @@ class WebsocketConnection { private _onMessage: (message: string) => void; private _onOpen: () => void; private _onClose: () => void; + private _onError: (e: any) => void; constructor( url: string, onMessage: (message: string) => void, onOpen: () => void, - onClose: () => void + onClose: () => void, + onError: (e: any) => void ) { this._ws = new WebSocket(url); this._onMessage = onMessage; this._onOpen = onOpen; this._onClose = onClose; + this._onError = onError; this._ws.addEventListener("message", (event) => { this._onMessage(event.data); @@ -38,6 +41,9 @@ class WebsocketConnection { this._ws.addEventListener("open", () => { this._onOpen(); }); + this._ws.addEventListener("error", (e: any) => { + this._onError(e); + }); } public send(message: string) { @@ -147,12 +153,20 @@ export function setupDebugPanel( url, }); }; + const onError = (e: any) => { + panel.webview.postMessage({ + type: "websocketForwardingError", + url, + error: e, + }); + }; try { const connection = new WebsocketConnection( url, onMessage, onOpen, - onClose + onClose, + onError ); websocketConnections[url] = connection; resolve(null); @@ -197,6 +211,15 @@ export function setupDebugPanel( let url = data.url; if (typeof websocketConnections[url] === "undefined") { await connectWebsocket(url); + } else { + console.log( + "Websocket connection requested by GUI already open at", + url + ); + panel.webview.postMessage({ + type: "websocketForwardingOpen", + url, + }); } break; } @@ -249,16 +272,7 @@ export function setupDebugPanel( }); } ); - vscode.window - .showInformationMessage( - "Click here to view the server logs, or use the 'continue.viewLogs' VS Code command.", - "View Logs" - ) - .then((selection) => { - if (selection === "View Logs") { - vscode.commands.executeCommand("continue.viewLogs"); - } - }); + break; } } |