@@ -125,6 +125,7 @@ const getCommandsMap = ({ context, outputChannel, provider }: RegisterCommandOpt
125125 return openClineInNewTab ( { context, outputChannel } )
126126 } ,
127127 openInNewTab : ( ) => openClineInNewTab ( { context, outputChannel } ) ,
128+ openInThisTab : ( ) => openClineInThisTab ( { context, outputChannel } ) ,
128129 settingsButtonClicked : ( ) => {
129130 const visibleProvider = getVisibleProviderOrLog ( outputChannel )
130131
@@ -284,3 +285,53 @@ export const openClineInNewTab = async ({ context, outputChannel }: Omit<Registe
284285
285286 return tabProvider
286287}
288+
289+ export const openClineInThisTab = async ( { context, outputChannel } : Omit < RegisterCommandOptions , "provider" > ) => {
290+ const contextProxy = await ContextProxy . getInstance ( context )
291+ const codeIndexManager = CodeIndexManager . getInstance ( context )
292+ const tabProvider = new ClineProvider ( context , outputChannel , "editor" , contextProxy , codeIndexManager )
293+
294+ // Use the active column instead of creating a new one
295+ const targetCol = vscode . ViewColumn . Active
296+
297+ const newPanel = vscode . window . createWebviewPanel ( ClineProvider . tabPanelId , "Roo Code" , targetCol , {
298+ enableScripts : true ,
299+ retainContextWhenHidden : true ,
300+ localResourceRoots : [ context . extensionUri ] ,
301+ } )
302+
303+ // Save as tab type panel.
304+ setPanel ( newPanel , "tab" )
305+
306+ // TODO: Use better svg icon with light and dark variants (see
307+ // https://stackoverflow.com/questions/58365687/vscode-extension-iconpath).
308+ newPanel . iconPath = {
309+ light : vscode . Uri . joinPath ( context . extensionUri , "assets" , "icons" , "panel_light.png" ) ,
310+ dark : vscode . Uri . joinPath ( context . extensionUri , "assets" , "icons" , "panel_dark.png" ) ,
311+ }
312+
313+ await tabProvider . resolveWebviewView ( newPanel )
314+
315+ // Add listener for visibility changes to notify webview
316+ newPanel . onDidChangeViewState (
317+ ( e ) => {
318+ const panel = e . webviewPanel
319+ if ( panel . visible ) {
320+ panel . webview . postMessage ( { type : "action" , action : "didBecomeVisible" } ) // Use the same message type as in SettingsView.tsx
321+ }
322+ } ,
323+ null , // First null is for `thisArgs`
324+ context . subscriptions , // Register listener for disposal
325+ )
326+
327+ // Handle panel closing events.
328+ newPanel . onDidDispose (
329+ ( ) => {
330+ setPanel ( undefined , "tab" )
331+ } ,
332+ null ,
333+ context . subscriptions , // Also register dispose listener
334+ )
335+
336+ return tabProvider
337+ }
0 commit comments