Compare commits

...
Author SHA1 Message Date
Sarah Fortuneandellipsis-dev[bot] e52f630c03 Update src/core/controller/ui/getWebviewHtml.ts
Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com>
2025-08-09 11:34:04 +01:00
Sarah Fortune b390915010 Use the active webview in getWebviewHtml.
Don't create a new webview just to get the HTML contents of the
webview because this creates another Controller.
2025-08-08 14:52:35 +01:00
+10 -9
View File
@@ -1,16 +1,17 @@
import type { Controller } from "../index"
import { WebviewProvider } from "@/core/webview"
import { EmptyRequest, String } from "@shared/proto/cline/common"
import { HostProvider } from "@/hosts/host-provider"
import { WebviewProviderType } from "@/shared/webview/types"
import type { Controller } from "../index"
/**
* Initialize webview when it launches
* @param controller The controller instance
* @param request The empty request
* @returns Empty response
* Returns the HTML content of the webview.
*
* This is only used by the standalone service. The Vscode extension gets the HTML directly from the webview when it
* resolved through `resolveWebviewView()`.
*/
export async function getWebviewHtml(_controller: Controller, _: EmptyRequest): Promise<String> {
const webviewProvider = HostProvider.get().createWebviewProvider(WebviewProviderType.SIDEBAR)
const webviewProvider = WebviewProvider.getLastActiveInstance()
if (!webviewProvider) {
throw new Error("No active webview")
}
return Promise.resolve(String.create({ value: webviewProvider.getHtmlContent() }))
}