diff --git a/extensions/void/src/SidebarWebviewProvider.ts b/extensions/void/src/SidebarWebviewProvider.ts index a6cdf85c..c8aaffba 100644 --- a/extensions/void/src/SidebarWebviewProvider.ts +++ b/extensions/void/src/SidebarWebviewProvider.ts @@ -19,7 +19,7 @@ export class SidebarWebviewProvider implements vscode.WebviewViewProvider { private readonly _extensionUri: vscode.Uri - private _webviewView?: vscode.WebviewView; // only used inside onDidChangeConfiguration + // private _webviewView?: vscode.WebviewView; private _webviewDeps: string[] = []; constructor(context: vscode.ExtensionContext) { @@ -28,35 +28,14 @@ export class SidebarWebviewProvider implements vscode.WebviewViewProvider { let temp_res: typeof this._res | undefined = undefined this.webview = new Promise((res, rej) => { temp_res = res }) - if (!temp_res) throw new Error("sidebar provider: resolver was undefined") + if (!temp_res) throw new Error("Void sidebar provider: resolver was undefined") this._res = temp_res - - // if it affects one of the config items webview depends on, update the webview - // TODO should be able to move this entirely to React - make updateWebviewHTML mount once, and then send updates via postMessage from then on - vscode.workspace.onDidChangeConfiguration(event => { - if (this._webviewDeps.map(dep => event.affectsConfiguration(dep)).some(v => !!v)) { - if (this._webviewView) { - this.updateWebviewHTML(this._webviewView.webview); - } - } - }); } - // this is updated - private updateWebviewHTML(webview: vscode.Webview) { - const allowed_urls = ['https://api.anthropic.com', 'https://api.openai.com', 'https://api.greptile.com']; + // called by us + updateWebviewHTML(webview: vscode.Webview) { this._webviewDeps = [] - const ollamaEndpoint: string | undefined = vscode.workspace.getConfiguration('void.ollama').get('endpoint'); - this._webviewDeps.push('void.ollama.endpoint'); - if (ollamaEndpoint) - allowed_urls.push(ollamaEndpoint); - - const openAICompatibleEndpoint: string | undefined = vscode.workspace.getConfiguration('void.openAICompatible').get('endpoint'); - this._webviewDeps.push('void.openAICompatible.endpoint'); - if (openAICompatibleEndpoint) - allowed_urls.push(openAICompatibleEndpoint+'/chat/completions'); - const scriptUri = webview.asWebviewUri(vscode.Uri.joinPath(this._extensionUri, 'dist/sidebar/index.js')); const stylesUri = webview.asWebviewUri(vscode.Uri.joinPath(this._extensionUri, 'dist/sidebar/styles.css')); const rootUri = webview.asWebviewUri(vscode.Uri.joinPath(this._extensionUri)); @@ -68,7 +47,7 @@ export class SidebarWebviewProvider implements vscode.WebviewViewProvider {