Skip to content

Commit c906350

Browse files
committed
feat: add 'Open in This Tab' command (#5457)
- Add new openInThisTab command ID to vscode.ts types - Implement openClineInThisTab function in registerCommands.ts - Add command definition to package.json manifest - Add localized titles across all 19 supported languages - Command opens Roo Code in current tab instead of creating new tab Fixes #5457
1 parent 7645aad commit c906350

21 files changed

+75
-0
lines changed

packages/types/src/vscode.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ export const commandIds = [
3939
"settingsButtonClicked",
4040

4141
"openInNewTab",
42+
"openInThisTab",
4243

4344
"showHumanRelayDialog",
4445
"registerHumanRelayCallback",

src/activate/registerCommands.ts

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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+
}

src/package.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,11 @@
110110
"title": "%command.openInNewTab.title%",
111111
"category": "%configuration.title%"
112112
},
113+
{
114+
"command": "roo-cline.openInThisTab",
115+
"title": "%command.openInThisTab.title%",
116+
"category": "%configuration.title%"
117+
},
113118
{
114119
"command": "roo-cline.explainCode",
115120
"title": "%command.explainCode.title%",

src/package.nls.ca.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
"command.improveCode.title": "Millorar Codi",
88
"command.addToContext.title": "Afegir al Context",
99
"command.openInNewTab.title": "Obrir en una Nova Pestanya",
10+
"command.openInThisTab.title": "Obrir en Aquesta Pestanya",
1011
"command.focusInput.title": "Enfocar Camp d'Entrada",
1112
"command.setCustomStoragePath.title": "Establir Ruta d'Emmagatzematge Personalitzada",
1213
"command.importSettings.title": "Importar Configuració",

src/package.nls.de.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
"command.improveCode.title": "Code Verbessern",
88
"command.addToContext.title": "Zum Kontext Hinzufügen",
99
"command.openInNewTab.title": "In Neuem Tab Öffnen",
10+
"command.openInThisTab.title": "In Diesem Tab Öffnen",
1011
"command.focusInput.title": "Eingabefeld Fokussieren",
1112
"command.setCustomStoragePath.title": "Benutzerdefinierten Speicherpfad Festlegen",
1213
"command.importSettings.title": "Einstellungen Importieren",

src/package.nls.es.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
"command.improveCode.title": "Mejorar Código",
88
"command.addToContext.title": "Añadir al Contexto",
99
"command.openInNewTab.title": "Abrir en Nueva Pestaña",
10+
"command.openInThisTab.title": "Abrir en Esta Pestaña",
1011
"command.focusInput.title": "Enfocar Campo de Entrada",
1112
"command.setCustomStoragePath.title": "Establecer Ruta de Almacenamiento Personalizada",
1213
"command.importSettings.title": "Importar Configuración",

src/package.nls.fr.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
"command.improveCode.title": "Améliorer le Code",
88
"command.addToContext.title": "Ajouter au Contexte",
99
"command.openInNewTab.title": "Ouvrir dans un Nouvel Onglet",
10+
"command.openInThisTab.title": "Ouvrir dans Cet Onglet",
1011
"command.focusInput.title": "Focus sur le Champ de Saisie",
1112
"command.setCustomStoragePath.title": "Définir le Chemin de Stockage Personnalisé",
1213
"command.importSettings.title": "Importer les Paramètres",

src/package.nls.hi.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
"command.improveCode.title": "कोड सुधारें",
88
"command.addToContext.title": "संदर्भ में जोड़ें",
99
"command.openInNewTab.title": "नए टैब में खोलें",
10+
"command.openInThisTab.title": "इस टैब में खोलें",
1011
"command.focusInput.title": "इनपुट फ़ील्ड पर फोकस करें",
1112
"command.setCustomStoragePath.title": "कस्टम स्टोरेज पाथ सेट करें",
1213
"command.importSettings.title": "सेटिंग्स इम्पोर्ट करें",

src/package.nls.id.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
"command.settings.title": "Pengaturan",
1515
"command.documentation.title": "Dokumentasi",
1616
"command.openInNewTab.title": "Buka di Tab Baru",
17+
"command.openInThisTab.title": "Buka di Tab Ini",
1718
"command.explainCode.title": "Jelaskan Kode",
1819
"command.fixCode.title": "Perbaiki Kode",
1920
"command.improveCode.title": "Tingkatkan Kode",

src/package.nls.it.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
"command.improveCode.title": "Migliora Codice",
88
"command.addToContext.title": "Aggiungi al Contesto",
99
"command.openInNewTab.title": "Apri in Nuova Scheda",
10+
"command.openInThisTab.title": "Apri in Questa Scheda",
1011
"command.focusInput.title": "Focalizza Campo di Input",
1112
"command.setCustomStoragePath.title": "Imposta Percorso di Archiviazione Personalizzato",
1213
"command.importSettings.title": "Importa Impostazioni",

0 commit comments

Comments
 (0)