Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/types/src/vscode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ export const commandIds = [
"settingsButtonClicked",

"openInNewTab",
"openInThisTab",

"showHumanRelayDialog",
"registerHumanRelayCallback",
Expand Down
58 changes: 38 additions & 20 deletions src/activate/registerCommands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ const getCommandsMap = ({ context, outputChannel, provider }: RegisterCommandOpt
return openClineInNewTab({ context, outputChannel })
},
openInNewTab: () => openClineInNewTab({ context, outputChannel }),
openInThisTab: () => openClineInThisTab({ context, outputChannel }),
settingsButtonClicked: () => {
const visibleProvider = getVisibleProviderOrLog(outputChannel)

Expand Down Expand Up @@ -220,35 +221,42 @@ const getCommandsMap = ({ context, outputChannel, provider }: RegisterCommandOpt
},
})

export const openClineInNewTab = async ({ context, outputChannel }: Omit<RegisterCommandOptions, "provider">) => {
/**
* Opens Roo Code in a tab with configurable column targeting and locking behavior
*/
const openClineInTab = async (
{ context, outputChannel }: Omit<RegisterCommandOptions, "provider">,
options: {
useNewColumn: boolean
lockEditorGroup: boolean
},
): Promise<ClineProvider> => {
// (This example uses webviewProvider activation event which is necessary to
// deserialize cached webview, but since we use retainContextWhenHidden, we
// don't need to use that event).
// https://github.com/microsoft/vscode-extension-samples/blob/main/webview-sample/src/extension.ts
const contextProxy = await ContextProxy.getInstance(context)
const codeIndexManager = CodeIndexManager.getInstance(context)
const tabProvider = new ClineProvider(context, outputChannel, "editor", contextProxy, codeIndexManager)

// 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
}
let targetCol: vscode.ViewColumn

const tabProvider = new ClineProvider(context, outputChannel, "editor", contextProxy, codeIndexManager, mdmService)
const lastCol = Math.max(...vscode.window.visibleTextEditors.map((editor) => editor.viewColumn || 0))
if (options.useNewColumn) {
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
// 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")
}
if (!hasVisibleEditors) {
await vscode.commands.executeCommand("workbench.action.newGroupRight")
}

const targetCol = hasVisibleEditors ? Math.max(lastCol + 1, 1) : vscode.ViewColumn.Two
targetCol = hasVisibleEditors ? Math.max(lastCol + 1, 1) : vscode.ViewColumn.Two
} else {
// Use the active column instead of creating a new one
targetCol = vscode.ViewColumn.Active
}

const newPanel = vscode.window.createWebviewPanel(ClineProvider.tabPanelId, "Roo Code", targetCol, {
enableScripts: true,
Expand Down Expand Up @@ -290,8 +298,18 @@ export const openClineInNewTab = async ({ context, outputChannel }: Omit<Registe
)

// 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")
if (options.lockEditorGroup) {
await delay(100)
await vscode.commands.executeCommand("workbench.action.lockEditorGroup")
}

return tabProvider
}

export const openClineInNewTab = async ({ context, outputChannel }: Omit<RegisterCommandOptions, "provider">) => {
return openClineInTab({ context, outputChannel }, { useNewColumn: true, lockEditorGroup: true })
}

export const openClineInThisTab = async ({ context, outputChannel }: Omit<RegisterCommandOptions, "provider">) => {
return openClineInTab({ context, outputChannel }, { useNewColumn: false, lockEditorGroup: false })
}
5 changes: 5 additions & 0 deletions src/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,11 @@
"title": "%command.openInNewTab.title%",
"category": "%configuration.title%"
},
{
"command": "roo-cline.openInThisTab",
"title": "%command.openInThisTab.title%",
"category": "%configuration.title%"
},
{
"command": "roo-cline.explainCode",
"title": "%command.explainCode.title%",
Expand Down
1 change: 1 addition & 0 deletions src/package.nls.ca.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"command.improveCode.title": "Millorar Codi",
"command.addToContext.title": "Afegir al Context",
"command.openInNewTab.title": "Obrir en una Nova Pestanya",
"command.openInThisTab.title": "Obrir en Aquesta Pestanya",
"command.focusInput.title": "Enfocar Camp d'Entrada",
"command.setCustomStoragePath.title": "Establir Ruta d'Emmagatzematge Personalitzada",
"command.importSettings.title": "Importar Configuració",
Expand Down
1 change: 1 addition & 0 deletions src/package.nls.de.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"command.improveCode.title": "Code Verbessern",
"command.addToContext.title": "Zum Kontext Hinzufügen",
"command.openInNewTab.title": "In Neuem Tab Öffnen",
"command.openInThisTab.title": "In Diesem Tab Öffnen",
"command.focusInput.title": "Eingabefeld Fokussieren",
"command.setCustomStoragePath.title": "Benutzerdefinierten Speicherpfad Festlegen",
"command.importSettings.title": "Einstellungen Importieren",
Expand Down
1 change: 1 addition & 0 deletions src/package.nls.es.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"command.improveCode.title": "Mejorar Código",
"command.addToContext.title": "Añadir al Contexto",
"command.openInNewTab.title": "Abrir en Nueva Pestaña",
"command.openInThisTab.title": "Abrir en Esta Pestaña",
"command.focusInput.title": "Enfocar Campo de Entrada",
"command.setCustomStoragePath.title": "Establecer Ruta de Almacenamiento Personalizada",
"command.importSettings.title": "Importar Configuración",
Expand Down
1 change: 1 addition & 0 deletions src/package.nls.fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"command.improveCode.title": "Améliorer le Code",
"command.addToContext.title": "Ajouter au Contexte",
"command.openInNewTab.title": "Ouvrir dans un Nouvel Onglet",
"command.openInThisTab.title": "Ouvrir dans Cet Onglet",
"command.focusInput.title": "Focus sur le Champ de Saisie",
"command.setCustomStoragePath.title": "Définir le Chemin de Stockage Personnalisé",
"command.importSettings.title": "Importer les Paramètres",
Expand Down
1 change: 1 addition & 0 deletions src/package.nls.hi.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"command.improveCode.title": "कोड सुधारें",
"command.addToContext.title": "संदर्भ में जोड़ें",
"command.openInNewTab.title": "नए टैब में खोलें",
"command.openInThisTab.title": "इस टैब में खोलें",
"command.focusInput.title": "इनपुट फ़ील्ड पर फोकस करें",
"command.setCustomStoragePath.title": "कस्टम स्टोरेज पाथ सेट करें",
"command.importSettings.title": "सेटिंग्स इम्पोर्ट करें",
Expand Down
1 change: 1 addition & 0 deletions src/package.nls.id.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"command.settings.title": "Pengaturan",
"command.documentation.title": "Dokumentasi",
"command.openInNewTab.title": "Buka di Tab Baru",
"command.openInThisTab.title": "Buka di Tab Ini",
"command.explainCode.title": "Jelaskan Kode",
"command.fixCode.title": "Perbaiki Kode",
"command.improveCode.title": "Tingkatkan Kode",
Expand Down
1 change: 1 addition & 0 deletions src/package.nls.it.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"command.improveCode.title": "Migliora Codice",
"command.addToContext.title": "Aggiungi al Contesto",
"command.openInNewTab.title": "Apri in Nuova Scheda",
"command.openInThisTab.title": "Apri in Questa Scheda",
"command.focusInput.title": "Focalizza Campo di Input",
"command.setCustomStoragePath.title": "Imposta Percorso di Archiviazione Personalizzato",
"command.importSettings.title": "Importa Impostazioni",
Expand Down
1 change: 1 addition & 0 deletions src/package.nls.ja.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"command.settings.title": "設定",
"command.documentation.title": "ドキュメント",
"command.openInNewTab.title": "新しいタブで開く",
"command.openInThisTab.title": "このタブで開く",
"command.explainCode.title": "コードの説明",
"command.fixCode.title": "コードの修正",
"command.improveCode.title": "コードの改善",
Expand Down
1 change: 1 addition & 0 deletions src/package.nls.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"command.settings.title": "Settings",
"command.documentation.title": "Documentation",
"command.openInNewTab.title": "Open In New Tab",
"command.openInThisTab.title": "Open In This Tab",
"command.explainCode.title": "Explain Code",
"command.fixCode.title": "Fix Code",
"command.improveCode.title": "Improve Code",
Expand Down
1 change: 1 addition & 0 deletions src/package.nls.ko.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"command.improveCode.title": "코드 개선",
"command.addToContext.title": "컨텍스트에 추가",
"command.openInNewTab.title": "새 탭에서 열기",
"command.openInThisTab.title": "이 탭에서 열기",
"command.focusInput.title": "입력 필드 포커스",
"command.setCustomStoragePath.title": "사용자 지정 저장소 경로 설정",
"command.importSettings.title": "설정 가져오기",
Expand Down
1 change: 1 addition & 0 deletions src/package.nls.nl.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"command.settings.title": "Instellingen",
"command.documentation.title": "Documentatie",
"command.openInNewTab.title": "Openen in Nieuw Tabblad",
"command.openInThisTab.title": "Openen in Dit Tabblad",
"command.explainCode.title": "Leg Code Uit",
"command.fixCode.title": "Repareer Code",
"command.improveCode.title": "Verbeter Code",
Expand Down
1 change: 1 addition & 0 deletions src/package.nls.pl.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"command.improveCode.title": "Ulepsz Kod",
"command.addToContext.title": "Dodaj do Kontekstu",
"command.openInNewTab.title": "Otwórz w Nowej Karcie",
"command.openInThisTab.title": "Otwórz w Tej Karcie",
"command.focusInput.title": "Fokus na Pole Wprowadzania",
"command.setCustomStoragePath.title": "Ustaw Niestandardową Ścieżkę Przechowywania",
"command.importSettings.title": "Importuj Ustawienia",
Expand Down
1 change: 1 addition & 0 deletions src/package.nls.pt-BR.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"command.improveCode.title": "Melhorar Código",
"command.addToContext.title": "Adicionar ao Contexto",
"command.openInNewTab.title": "Abrir em Nova Aba",
"command.openInThisTab.title": "Abrir nesta Aba",
"command.focusInput.title": "Focar Campo de Entrada",
"command.setCustomStoragePath.title": "Definir Caminho de Armazenamento Personalizado",
"command.importSettings.title": "Importar Configurações",
Expand Down
1 change: 1 addition & 0 deletions src/package.nls.ru.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"command.settings.title": "Настройки",
"command.documentation.title": "Документация",
"command.openInNewTab.title": "Открыть в новой вкладке",
"command.openInThisTab.title": "Открыть в этой вкладке",
"command.explainCode.title": "Объяснить код",
"command.fixCode.title": "Исправить код",
"command.improveCode.title": "Улучшить код",
Expand Down
1 change: 1 addition & 0 deletions src/package.nls.tr.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"command.improveCode.title": "Kodu İyileştir",
"command.addToContext.title": "Bağlama Ekle",
"command.openInNewTab.title": "Yeni Sekmede Aç",
"command.openInThisTab.title": "Bu Sekmede Aç",
"command.focusInput.title": "Giriş Alanına Odaklan",
"command.setCustomStoragePath.title": "Özel Depolama Yolunu Ayarla",
"command.importSettings.title": "Ayarları İçe Aktar",
Expand Down
1 change: 1 addition & 0 deletions src/package.nls.vi.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"command.improveCode.title": "Cải Thiện Mã",
"command.addToContext.title": "Thêm vào Ngữ Cảnh",
"command.openInNewTab.title": "Mở trong Tab Mới",
"command.openInThisTab.title": "Mở trong Tab Này",
"command.focusInput.title": "Tập Trung vào Trường Nhập",
"command.setCustomStoragePath.title": "Đặt Đường Dẫn Lưu Trữ Tùy Chỉnh",
"command.importSettings.title": "Nhập Cài Đặt",
Expand Down
1 change: 1 addition & 0 deletions src/package.nls.zh-CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"command.improveCode.title": "改进代码",
"command.addToContext.title": "添加到上下文",
"command.openInNewTab.title": "在新标签页中打开",
"command.openInThisTab.title": "在此标签页中打开",
"command.focusInput.title": "聚焦输入框",
"command.setCustomStoragePath.title": "设置自定义存储路径",
"command.importSettings.title": "导入设置",
Expand Down
1 change: 1 addition & 0 deletions src/package.nls.zh-TW.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"command.improveCode.title": "改進程式碼",
"command.addToContext.title": "新增到上下文",
"command.openInNewTab.title": "在新分頁中開啟",
"command.openInThisTab.title": "在此分頁中開啟",
"command.focusInput.title": "聚焦輸入框",
"command.setCustomStoragePath.title": "設定自訂儲存路徑",
"command.importSettings.title": "匯入設定",
Expand Down