From d46cdca142ca776970209b2e7d6f65f958375d63 Mon Sep 17 00:00:00 2001 From: Roo Code Date: Tue, 23 Sep 2025 09:55:43 +0000 Subject: [PATCH] feat: open settings in new full tab similar to VSCode - Added new openSettingsInNewTab function to create dedicated webview panel for settings - Updated settings button click handler to open settings in new tab instead of within extension - Added localized 'Roo Code Settings' title for the new settings tab - Settings now open in a full VSCode tab with proper state management - All localization files updated with new tabTitle key --- src/activate/registerCommands.ts | 92 +++++++++++++++++-- webview-ui/src/i18n/locales/ca/settings.json | 1 + webview-ui/src/i18n/locales/de/settings.json | 1 + webview-ui/src/i18n/locales/en/settings.json | 1 + webview-ui/src/i18n/locales/es/settings.json | 1 + webview-ui/src/i18n/locales/fr/settings.json | 1 + webview-ui/src/i18n/locales/hi/settings.json | 1 + webview-ui/src/i18n/locales/id/settings.json | 1 + webview-ui/src/i18n/locales/it/settings.json | 1 + webview-ui/src/i18n/locales/ja/settings.json | 1 + webview-ui/src/i18n/locales/ko/settings.json | 1 + webview-ui/src/i18n/locales/nl/settings.json | 1 + webview-ui/src/i18n/locales/pl/settings.json | 1 + .../src/i18n/locales/pt-BR/settings.json | 1 + webview-ui/src/i18n/locales/ru/settings.json | 1 + webview-ui/src/i18n/locales/tr/settings.json | 1 + webview-ui/src/i18n/locales/vi/settings.json | 1 + .../src/i18n/locales/zh-CN/settings.json | 1 + .../src/i18n/locales/zh-TW/settings.json | 1 + 19 files changed, 101 insertions(+), 9 deletions(-) diff --git a/src/activate/registerCommands.ts b/src/activate/registerCommands.ts index 41c127333d..7e6eb1a1ce 100644 --- a/src/activate/registerCommands.ts +++ b/src/activate/registerCommands.ts @@ -130,17 +130,10 @@ const getCommandsMap = ({ context, outputChannel, provider }: RegisterCommandOpt }, openInNewTab: () => openClineInNewTab({ context, outputChannel }), settingsButtonClicked: () => { - const visibleProvider = getVisibleProviderOrLog(outputChannel) - - if (!visibleProvider) { - return - } - TelemetryService.instance.captureTitleButtonClicked("settings") - visibleProvider.postMessageToWebview({ type: "action", action: "settingsButtonClicked" }) - // Also explicitly post the visibility message to trigger scroll reliably - visibleProvider.postMessageToWebview({ type: "action", action: "didBecomeVisible" }) + // Open settings in a new tab instead of within the extension + return openSettingsInNewTab({ context, outputChannel }) }, historyButtonClicked: () => { const visibleProvider = getVisibleProviderOrLog(outputChannel) @@ -310,3 +303,84 @@ export const openClineInNewTab = async ({ context, outputChannel }: Omit) => { + const contextProxy = await ContextProxy.getInstance(context) + + // Get the existing MDM service instance to ensure consistent policy enforcement + let mdmService: MdmService | undefined + try { + mdmService = MdmService.getInstance() + } catch (error) { + // MDM service not initialized, which is fine - extension can work without it + mdmService = undefined + } + + const tabProvider = new ClineProvider(context, outputChannel, "editor", contextProxy, mdmService) + const lastCol = Math.max(...vscode.window.visibleTextEditors.map((editor) => editor.viewColumn || 0)) + + // Check if there are any visible text editors, otherwise open a new group + // to the right. + const hasVisibleEditors = vscode.window.visibleTextEditors.length > 0 + + if (!hasVisibleEditors) { + await vscode.commands.executeCommand("workbench.action.newGroupRight") + } + + const targetCol = hasVisibleEditors ? Math.max(lastCol + 1, 1) : vscode.ViewColumn.Two + + // Get the localized title for the settings tab + const settingsTitle = t("settings:tabTitle") || "Roo Code Settings" + + const newPanel = vscode.window.createWebviewPanel( + "rooCodeSettings", // Unique ID for settings panel + settingsTitle, + targetCol, + { + enableScripts: true, + retainContextWhenHidden: true, + localResourceRoots: [context.extensionUri], + }, + ) + + // Save as tab type panel. + setPanel(newPanel, "tab") + + // Use the same icon as the main panel + newPanel.iconPath = { + light: vscode.Uri.joinPath(context.extensionUri, "assets", "icons", "panel_light.png"), + dark: vscode.Uri.joinPath(context.extensionUri, "assets", "icons", "panel_dark.png"), + } + + await tabProvider.resolveWebviewView(newPanel) + + // Immediately send a message to open the settings view + newPanel.webview.postMessage({ type: "action", action: "settingsButtonClicked" }) + + // Add listener for visibility changes to notify webview + newPanel.onDidChangeViewState( + (e) => { + const panel = e.webviewPanel + if (panel.visible) { + panel.webview.postMessage({ type: "action", action: "didBecomeVisible" }) + } + }, + null, + context.subscriptions, + ) + + // Handle panel closing events. + newPanel.onDidDispose( + () => { + setPanel(undefined, "tab") + }, + null, + context.subscriptions, + ) + + // Lock the editor group so clicking on files doesn't open them over the panel. + await delay(100) + await vscode.commands.executeCommand("workbench.action.lockEditorGroup") + + return tabProvider +} diff --git a/webview-ui/src/i18n/locales/ca/settings.json b/webview-ui/src/i18n/locales/ca/settings.json index 91a02e7a1c..7eb3eb0858 100644 --- a/webview-ui/src/i18n/locales/ca/settings.json +++ b/webview-ui/src/i18n/locales/ca/settings.json @@ -8,6 +8,7 @@ "add": "Afegir capçalera", "remove": "Eliminar" }, + "tabTitle": "Roo Code Settings", "header": { "title": "Configuració", "saveButtonTooltip": "Desar canvis", diff --git a/webview-ui/src/i18n/locales/de/settings.json b/webview-ui/src/i18n/locales/de/settings.json index fd89eb9637..912ae8b541 100644 --- a/webview-ui/src/i18n/locales/de/settings.json +++ b/webview-ui/src/i18n/locales/de/settings.json @@ -8,6 +8,7 @@ "add": "Header hinzufügen", "remove": "Entfernen" }, + "tabTitle": "Roo Code Settings", "header": { "title": "Einstellungen", "saveButtonTooltip": "Änderungen speichern", diff --git a/webview-ui/src/i18n/locales/en/settings.json b/webview-ui/src/i18n/locales/en/settings.json index 50d8470abf..23ab8fd012 100644 --- a/webview-ui/src/i18n/locales/en/settings.json +++ b/webview-ui/src/i18n/locales/en/settings.json @@ -8,6 +8,7 @@ "add": "Add Header", "remove": "Remove" }, + "tabTitle": "Roo Code Settings", "header": { "title": "Settings", "saveButtonTooltip": "Save changes", diff --git a/webview-ui/src/i18n/locales/es/settings.json b/webview-ui/src/i18n/locales/es/settings.json index 8e6968e8c2..8309afde1b 100644 --- a/webview-ui/src/i18n/locales/es/settings.json +++ b/webview-ui/src/i18n/locales/es/settings.json @@ -8,6 +8,7 @@ "add": "Añadir encabezado", "remove": "Eliminar" }, + "tabTitle": "Roo Code Settings", "header": { "title": "Configuración", "saveButtonTooltip": "Guardar cambios", diff --git a/webview-ui/src/i18n/locales/fr/settings.json b/webview-ui/src/i18n/locales/fr/settings.json index fd48e1e358..e97af0df92 100644 --- a/webview-ui/src/i18n/locales/fr/settings.json +++ b/webview-ui/src/i18n/locales/fr/settings.json @@ -8,6 +8,7 @@ "add": "Ajouter un en-tête", "remove": "Supprimer" }, + "tabTitle": "Roo Code Settings", "header": { "title": "Paramètres", "saveButtonTooltip": "Enregistrer les modifications", diff --git a/webview-ui/src/i18n/locales/hi/settings.json b/webview-ui/src/i18n/locales/hi/settings.json index 1383eb8703..e62e623c48 100644 --- a/webview-ui/src/i18n/locales/hi/settings.json +++ b/webview-ui/src/i18n/locales/hi/settings.json @@ -8,6 +8,7 @@ "add": "हेडर जोड़ें", "remove": "हटाएं" }, + "tabTitle": "Roo Code Settings", "header": { "title": "सेटिंग्स", "saveButtonTooltip": "परिवर्तन सहेजें", diff --git a/webview-ui/src/i18n/locales/id/settings.json b/webview-ui/src/i18n/locales/id/settings.json index c29f6cf88c..980980e7c5 100644 --- a/webview-ui/src/i18n/locales/id/settings.json +++ b/webview-ui/src/i18n/locales/id/settings.json @@ -8,6 +8,7 @@ "add": "Tambah Header", "remove": "Hapus" }, + "tabTitle": "Roo Code Settings", "header": { "title": "Pengaturan", "saveButtonTooltip": "Simpan perubahan", diff --git a/webview-ui/src/i18n/locales/it/settings.json b/webview-ui/src/i18n/locales/it/settings.json index a930c53a5e..5a0507e07e 100644 --- a/webview-ui/src/i18n/locales/it/settings.json +++ b/webview-ui/src/i18n/locales/it/settings.json @@ -8,6 +8,7 @@ "add": "Aggiungi intestazione", "remove": "Rimuovi" }, + "tabTitle": "Roo Code Settings", "header": { "title": "Impostazioni", "saveButtonTooltip": "Salva modifiche", diff --git a/webview-ui/src/i18n/locales/ja/settings.json b/webview-ui/src/i18n/locales/ja/settings.json index c6b24dcd58..b4806c3517 100644 --- a/webview-ui/src/i18n/locales/ja/settings.json +++ b/webview-ui/src/i18n/locales/ja/settings.json @@ -8,6 +8,7 @@ "add": "ヘッダーを追加", "remove": "削除" }, + "tabTitle": "Roo Code Settings", "header": { "title": "設定", "saveButtonTooltip": "変更を保存", diff --git a/webview-ui/src/i18n/locales/ko/settings.json b/webview-ui/src/i18n/locales/ko/settings.json index 49ff40ebc7..b67956feda 100644 --- a/webview-ui/src/i18n/locales/ko/settings.json +++ b/webview-ui/src/i18n/locales/ko/settings.json @@ -8,6 +8,7 @@ "add": "헤더 추가", "remove": "삭제" }, + "tabTitle": "Roo Code Settings", "header": { "title": "설정", "saveButtonTooltip": "변경 사항 저장", diff --git a/webview-ui/src/i18n/locales/nl/settings.json b/webview-ui/src/i18n/locales/nl/settings.json index 571453c4b3..6c399a2b28 100644 --- a/webview-ui/src/i18n/locales/nl/settings.json +++ b/webview-ui/src/i18n/locales/nl/settings.json @@ -8,6 +8,7 @@ "add": "Header toevoegen", "remove": "Verwijderen" }, + "tabTitle": "Roo Code Settings", "header": { "title": "Instellingen", "saveButtonTooltip": "Wijzigingen opslaan", diff --git a/webview-ui/src/i18n/locales/pl/settings.json b/webview-ui/src/i18n/locales/pl/settings.json index 51a5b4c389..601a9867dd 100644 --- a/webview-ui/src/i18n/locales/pl/settings.json +++ b/webview-ui/src/i18n/locales/pl/settings.json @@ -8,6 +8,7 @@ "add": "Dodaj nagłówek", "remove": "Usuń" }, + "tabTitle": "Roo Code Settings", "header": { "title": "Ustawienia", "saveButtonTooltip": "Zapisz zmiany", diff --git a/webview-ui/src/i18n/locales/pt-BR/settings.json b/webview-ui/src/i18n/locales/pt-BR/settings.json index 09320ea719..9e954205e7 100644 --- a/webview-ui/src/i18n/locales/pt-BR/settings.json +++ b/webview-ui/src/i18n/locales/pt-BR/settings.json @@ -8,6 +8,7 @@ "add": "Adicionar cabeçalho", "remove": "Remover" }, + "tabTitle": "Roo Code Settings", "header": { "title": "Configurações", "saveButtonTooltip": "Salvar alterações", diff --git a/webview-ui/src/i18n/locales/ru/settings.json b/webview-ui/src/i18n/locales/ru/settings.json index 3bed3624da..2088c48b71 100644 --- a/webview-ui/src/i18n/locales/ru/settings.json +++ b/webview-ui/src/i18n/locales/ru/settings.json @@ -8,6 +8,7 @@ "add": "Добавить заголовок", "remove": "Удалить" }, + "tabTitle": "Roo Code Settings", "header": { "title": "Настройки", "saveButtonTooltip": "Сохранить изменения", diff --git a/webview-ui/src/i18n/locales/tr/settings.json b/webview-ui/src/i18n/locales/tr/settings.json index 7de08d4826..c2205f8516 100644 --- a/webview-ui/src/i18n/locales/tr/settings.json +++ b/webview-ui/src/i18n/locales/tr/settings.json @@ -8,6 +8,7 @@ "add": "Başlık Ekle", "remove": "Kaldır" }, + "tabTitle": "Roo Code Settings", "header": { "title": "Ayarlar", "saveButtonTooltip": "Değişiklikleri kaydet", diff --git a/webview-ui/src/i18n/locales/vi/settings.json b/webview-ui/src/i18n/locales/vi/settings.json index 46dc077d4d..8a49a32c1b 100644 --- a/webview-ui/src/i18n/locales/vi/settings.json +++ b/webview-ui/src/i18n/locales/vi/settings.json @@ -8,6 +8,7 @@ "add": "Thêm tiêu đề", "remove": "Xóa" }, + "tabTitle": "Roo Code Settings", "header": { "title": "Cài đặt", "saveButtonTooltip": "Lưu thay đổi", diff --git a/webview-ui/src/i18n/locales/zh-CN/settings.json b/webview-ui/src/i18n/locales/zh-CN/settings.json index ab47a2c9e0..57de075378 100644 --- a/webview-ui/src/i18n/locales/zh-CN/settings.json +++ b/webview-ui/src/i18n/locales/zh-CN/settings.json @@ -8,6 +8,7 @@ "add": "添加标头", "remove": "移除" }, + "tabTitle": "Roo Code Settings", "header": { "title": "设置", "saveButtonTooltip": "保存更改", diff --git a/webview-ui/src/i18n/locales/zh-TW/settings.json b/webview-ui/src/i18n/locales/zh-TW/settings.json index 57d647d9cf..46b80ea5db 100644 --- a/webview-ui/src/i18n/locales/zh-TW/settings.json +++ b/webview-ui/src/i18n/locales/zh-TW/settings.json @@ -8,6 +8,7 @@ "add": "新增標頭", "remove": "移除" }, + "tabTitle": "Roo Code Settings", "header": { "title": "設定", "saveButtonTooltip": "儲存變更",