From fa4fa01ec391a564d14e49e9933b85bf687752d1 Mon Sep 17 00:00:00 2001 From: kvyb Date: Fri, 29 Aug 2025 00:38:19 +0800 Subject: [PATCH] feat: add openClineSidebarPanel RPC and route VS Code focus via hostbridge (#5859) --- proto/host/workspace.proto | 7 +++++++ src/common.ts | 2 +- src/extension.ts | 4 ++-- .../vscode/hostbridge/workspace/openClineSidebarPanel.ts | 7 +++++++ 4 files changed, 17 insertions(+), 3 deletions(-) create mode 100644 src/hosts/vscode/hostbridge/workspace/openClineSidebarPanel.ts diff --git a/proto/host/workspace.proto b/proto/host/workspace.proto index 2080fe2c..832c1367 100644 --- a/proto/host/workspace.proto +++ b/proto/host/workspace.proto @@ -26,6 +26,9 @@ service WorkspaceService { // Opens the IDE file explorer panel and selects a file or directory. rpc openInFileExplorerPanel(OpenInFileExplorerPanelRequest) returns (OpenInFileExplorerPanelResponse); + + // Opens and focuses the Cline sidebar panel in the host IDE. + rpc openClineSidebarPanel(OpenClineSidebarPanelRequest) returns (OpenClineSidebarPanelResponse); } message GetWorkspacePathsRequest { @@ -86,3 +89,7 @@ message OpenInFileExplorerPanelRequest { string path = 1; } message OpenInFileExplorerPanelResponse {} + +// Request/response for opening the Cline sidebar +message OpenClineSidebarPanelRequest {} +message OpenClineSidebarPanelResponse {} diff --git a/src/common.ts b/src/common.ts index b1b52315..2cf086f7 100644 --- a/src/common.ts +++ b/src/common.ts @@ -75,7 +75,7 @@ async function showVersionUpdateAnnouncement(context: vscode.ExtensionContext) { const message = previousVersion ? `Cline has been updated to v${currentVersion}` : `Welcome to Cline v${currentVersion}` - await vscode.commands.executeCommand("claude-dev.SidebarProvider.focus") + await HostProvider.workspace.openClineSidebarPanel({}) await new Promise((resolve) => setTimeout(resolve, 200)) HostProvider.window.showMessage({ type: ShowMessageType.INFORMATION, diff --git a/src/extension.ts b/src/extension.ts index 31766e48..5b36e088 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -443,8 +443,8 @@ export async function activate(context: vscode.ExtensionContext) { if (tabInstances.length > 0) { activeWebview = tabInstances[tabInstances.length - 1] } else { - // Try to focus sidebar - await vscode.commands.executeCommand("claude-dev.SidebarProvider.focus") + // Try to focus sidebar via hostbridge + await HostProvider.workspace.openClineSidebarPanel({}) // Small delay for focus to complete await new Promise((resolve) => setTimeout(resolve, 200)) diff --git a/src/hosts/vscode/hostbridge/workspace/openClineSidebarPanel.ts b/src/hosts/vscode/hostbridge/workspace/openClineSidebarPanel.ts new file mode 100644 index 00000000..e368cd36 --- /dev/null +++ b/src/hosts/vscode/hostbridge/workspace/openClineSidebarPanel.ts @@ -0,0 +1,7 @@ +import * as vscode from "vscode" +import { OpenClineSidebarPanelRequest, OpenClineSidebarPanelResponse } from "@/shared/proto/index.host" + +export async function openClineSidebarPanel(_: OpenClineSidebarPanelRequest): Promise { + await vscode.commands.executeCommand("claude-dev.SidebarProvider.focus") + return {} +}