Compare commits

...

1 Commits

Author SHA1 Message Date
Saoud Rizwan 34c1d8a58f Fix bug where menu buttons wouldn't open view in sidebar 2025-04-01 10:22:20 -07:00
2 changed files with 31 additions and 49 deletions
+4
View File
@@ -44,6 +44,10 @@ export class WebviewProvider implements vscode.WebviewViewProvider {
return findLast(Array.from(this.activeInstances), (instance) => instance.view?.visible === true)
}
public static getAllInstances(): WebviewProvider[] {
return Array.from(this.activeInstances)
}
async resolveWebviewView(webviewView: vscode.WebviewView | vscode.WebviewPanel) {
this.view = webviewView
+27 -49
View File
@@ -42,33 +42,24 @@ export function activate(context: vscode.ExtensionContext) {
context.subscriptions.push(
vscode.commands.registerCommand("cline.plusButtonClicked", async () => {
Logger.log("Plus button Clicked")
const visibleWebview = WebviewProvider.getVisibleInstance()
if (!visibleWebview) {
Logger.log("Cannot find any visible Cline instances.")
return
}
await visibleWebview.controller.clearTask()
await visibleWebview.controller.postStateToWebview()
await visibleWebview.controller.postMessageToWebview({
type: "action",
action: "chatButtonClicked",
WebviewProvider.getAllInstances().forEach(async (instance) => {
await instance.controller.clearTask()
await instance.controller.postStateToWebview()
await instance.controller.postMessageToWebview({
type: "action",
action: "chatButtonClicked",
})
})
}),
)
context.subscriptions.push(
vscode.commands.registerCommand("cline.mcpButtonClicked", () => {
const visibleWebview = WebviewProvider.getVisibleInstance()
if (!visibleWebview) {
Logger.log("Cannot find any visible Cline instances.")
return
}
visibleWebview.controller.postMessageToWebview({
type: "action",
action: "mcpButtonClicked",
WebviewProvider.getAllInstances().forEach((instance) => {
instance.controller.postMessageToWebview({
type: "action",
action: "mcpButtonClicked",
})
})
}),
)
@@ -111,46 +102,33 @@ export function activate(context: vscode.ExtensionContext) {
context.subscriptions.push(
vscode.commands.registerCommand("cline.settingsButtonClicked", () => {
//vscode.window.showInformationMessage(message)
const visibleWebview = WebviewProvider.getVisibleInstance()
if (!visibleWebview) {
Logger.log("Cannot find any visible Cline instances.")
return
}
visibleWebview.controller.postMessageToWebview({
type: "action",
action: "settingsButtonClicked",
WebviewProvider.getAllInstances().forEach((instance) => {
instance.controller.postMessageToWebview({
type: "action",
action: "settingsButtonClicked",
})
})
}),
)
context.subscriptions.push(
vscode.commands.registerCommand("cline.historyButtonClicked", () => {
const visibleWebview = WebviewProvider.getVisibleInstance()
if (!visibleWebview) {
Logger.log("Cannot find any visible Cline instances.")
return
}
visibleWebview.controller.postMessageToWebview({
type: "action",
action: "historyButtonClicked",
WebviewProvider.getAllInstances().forEach((instance) => {
instance.controller.postMessageToWebview({
type: "action",
action: "historyButtonClicked",
})
})
}),
)
context.subscriptions.push(
vscode.commands.registerCommand("cline.accountButtonClicked", () => {
const visibleWebview = WebviewProvider.getVisibleInstance()
if (!visibleWebview) {
Logger.log("Cannot find any visible Cline instances.")
return
}
visibleWebview.controller.postMessageToWebview({
type: "action",
action: "accountButtonClicked",
WebviewProvider.getAllInstances().forEach((instance) => {
instance.controller.postMessageToWebview({
type: "action",
action: "accountButtonClicked",
})
})
}),
)