Skip to content

Commit

Permalink
[vscode] Don't block on Python Initialization
Browse files Browse the repository at this point in the history
This diff removes the await statement on the initialize python flow when resolving a custom editor, to ensure that it is not blocking. 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
  • Loading branch information
Ankush Pala [email protected] committed Feb 23, 2024
1 parent c361a24 commit 067c1e2
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 067c1e2

Please sign in to comment.