Skip to content

Commit

Permalink
[vscode] Don't block on Python Initialization (#1315)
Browse files Browse the repository at this point in the history
[vscode] Don't block on Python Initialization

This diff removes the await statement on the initialize python flow when
resolving a custom editor, to ensure that it is not blocking the rest of
the flow. Now, only the aiconfig server is blocked on python
initialization. The webview server is not blocked.


Previously this was blocking the webview and not letting the webview
server start.



## Testplan


https://github.com/lastmile-ai/aiconfig/assets/141073967/ee180bb4-7fb7-40c6-a33e-b7dc3546ae70

---
[//]: # (BEGIN SAPLING FOOTER)
Stack created with [Sapling](https://sapling-scm.com). Best reviewed
with
[ReviewStack](https://reviewstack.dev/lastmile-ai/aiconfig/pull/1315).
* #1320
* __->__ #1315
  • Loading branch information
Ankush-lastmile authored Feb 23, 2024
2 parents f6145f5 + 067c1e2 commit d388e9f
Showing 1 changed file with 31 additions and 29 deletions.
60 changes: 31 additions & 29 deletions vscode-extension/src/aiConfigEditor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,40 +103,42 @@ export class AIConfigEditorProvider implements vscode.CustomTextEditorProvider {
updateWebview();

// Do not start the server until we ensure the Python setup is ready
await initializePythonFlow(this.context, this.extensionOutputChannel);

// Start the AIConfig editor server process. Don't await at the top level here since that blocks the
// webview render (which happens only when resolveCustomTextEditor returns)
this.startEditorServer(document).then(async (startedServer) => {
editorServer = startedServer;

this.aiconfigEditorManager.addEditor(
new AIConfigEditorState(
document,
webviewPanel,
startedServer,
this.aiconfigEditorManager
)
);
initializePythonFlow(this.context, this.extensionOutputChannel).then(
async () => {
// Start the AIConfig editor server process. Don't await at the top level here since that blocks the
// webview render (which happens only when resolveCustomTextEditor returns)
this.startEditorServer(document).then(async (startedServer) => {
editorServer = startedServer;

this.aiconfigEditorManager.addEditor(
new AIConfigEditorState(
document,
webviewPanel,
startedServer,
this.aiconfigEditorManager
)
);

// Wait for server ready
await waitUntilServerReady(startedServer.url);
// Wait for server ready
await waitUntilServerReady(startedServer.url);

// Now set up the server with the latest document content
await this.startServerWithRetry(
startedServer.url,
document,
webviewPanel
);
// Now set up the server with the latest document content
await this.startServerWithRetry(
startedServer.url,
document,
webviewPanel
);

// Inform the webview of the server URL
if (!isWebviewDisposed) {
webviewPanel.webview.postMessage({
type: "set_server_url",
url: startedServer.url,
// Inform the webview of the server URL
if (!isWebviewDisposed) {
webviewPanel.webview.postMessage({
type: "set_server_url",
url: startedServer.url,
});
}
});
}
});
);

// Hook up event handlers so that we can synchronize the webview with the text document.
//
Expand Down

0 comments on commit d388e9f

Please sign in to comment.