@@ -41,26 +41,37 @@ export function activate(context: vscode.ExtensionContext) {
4141 )
4242
4343 context . subscriptions . push (
44- vscode . commands . registerCommand ( "cline.plusButtonClicked" , async ( ) => {
45- WebviewProvider . getAllInstances ( ) . forEach ( async ( instance ) => {
46- await instance . controller . clearTask ( )
47- await instance . controller . postStateToWebview ( )
48- await instance . controller . postMessageToWebview ( {
44+ vscode . commands . registerCommand ( "cline.plusButtonClicked" , async ( webview : any ) => {
45+ const openChat = async ( instance ?: WebviewProvider ) => {
46+ await instance ? .controller . clearTask ( )
47+ await instance ? .controller . postStateToWebview ( )
48+ await instance ? .controller . postMessageToWebview ( {
4949 type : "action" ,
5050 action : "chatButtonClicked" ,
5151 } )
52- } )
52+ }
53+ const isSidebar = ! webview
54+ if ( isSidebar ) {
55+ openChat ( WebviewProvider . getSidebarInstance ( ) )
56+ } else {
57+ WebviewProvider . getTabInstances ( ) . forEach ( openChat )
58+ }
5359 } ) ,
5460 )
5561
5662 context . subscriptions . push (
57- vscode . commands . registerCommand ( "cline.mcpButtonClicked" , ( ) => {
58- WebviewProvider . getAllInstances ( ) . forEach ( ( instance ) => {
59- instance . controller . postMessageToWebview ( {
63+ vscode . commands . registerCommand ( "cline.mcpButtonClicked" , ( webview : any ) => {
64+ const openMcp = ( instance ?: WebviewProvider ) =>
65+ instance ? .controller . postMessageToWebview ( {
6066 type : "action" ,
6167 action : "mcpButtonClicked" ,
6268 } )
63- } )
69+ const isSidebar = ! webview
70+ if ( isSidebar ) {
71+ openMcp ( WebviewProvider . getSidebarInstance ( ) )
72+ } else {
73+ WebviewProvider . getTabInstances ( ) . forEach ( openMcp )
74+ }
6475 } ) ,
6576 )
6677
@@ -101,34 +112,58 @@ export function activate(context: vscode.ExtensionContext) {
101112 context . subscriptions . push ( vscode . commands . registerCommand ( "cline.openInNewTab" , openClineInNewTab ) )
102113
103114 context . subscriptions . push (
104- vscode . commands . registerCommand ( "cline.settingsButtonClicked" , ( ) => {
115+ vscode . commands . registerCommand ( "cline.settingsButtonClicked" , ( webview : any ) => {
105116 WebviewProvider . getAllInstances ( ) . forEach ( ( instance ) => {
106- instance . controller . postMessageToWebview ( {
107- type : "action" ,
108- action : "settingsButtonClicked" ,
109- } )
117+ const openSettings = async ( instance ?: WebviewProvider ) => {
118+ instance ?. controller . postMessageToWebview ( {
119+ type : "action" ,
120+ action : "settingsButtonClicked" ,
121+ } )
122+ }
123+ const isSidebar = ! webview
124+ if ( isSidebar ) {
125+ openSettings ( WebviewProvider . getSidebarInstance ( ) )
126+ } else {
127+ WebviewProvider . getTabInstances ( ) . forEach ( openSettings )
128+ }
110129 } )
111130 } ) ,
112131 )
113132
114133 context . subscriptions . push (
115- vscode . commands . registerCommand ( "cline.historyButtonClicked" , ( ) => {
134+ vscode . commands . registerCommand ( "cline.historyButtonClicked" , ( webview : any ) => {
116135 WebviewProvider . getAllInstances ( ) . forEach ( ( instance ) => {
117- instance . controller . postMessageToWebview ( {
118- type : "action" ,
119- action : "historyButtonClicked" ,
120- } )
136+ const openHistory = async ( instance ?: WebviewProvider ) => {
137+ instance ?. controller . postMessageToWebview ( {
138+ type : "action" ,
139+ action : "historyButtonClicked" ,
140+ } )
141+ }
142+ const isSidebar = ! webview
143+ if ( isSidebar ) {
144+ openHistory ( WebviewProvider . getSidebarInstance ( ) )
145+ } else {
146+ WebviewProvider . getTabInstances ( ) . forEach ( openHistory )
147+ }
121148 } )
122149 } ) ,
123150 )
124151
125152 context . subscriptions . push (
126- vscode . commands . registerCommand ( "cline.accountButtonClicked" , ( ) => {
153+ vscode . commands . registerCommand ( "cline.accountButtonClicked" , ( webview : any ) => {
127154 WebviewProvider . getAllInstances ( ) . forEach ( ( instance ) => {
128- instance . controller . postMessageToWebview ( {
129- type : "action" ,
130- action : "accountButtonClicked" ,
131- } )
155+ const openAccount = async ( instance ?: WebviewProvider ) => {
156+ instance ?. controller . postMessageToWebview ( {
157+ type : "action" ,
158+ action : "accountButtonClicked" ,
159+ } )
160+ }
161+ const isSidebar = ! webview
162+ if ( isSidebar ) {
163+ openAccount ( WebviewProvider . getSidebarInstance ( ) )
164+ } else {
165+ WebviewProvider . getTabInstances ( ) . forEach ( openAccount )
166+ }
132167 } )
133168 } ) ,
134169 )
0 commit comments