From 8bc4968e0d9e0214756cc4576c8a7cdb6a84534d Mon Sep 17 00:00:00 2001 From: Matt Rubens Date: Thu, 3 Apr 2025 23:42:23 -0400 Subject: [PATCH 1/2] Better logic for choosing the view column when opening Roo in a tab --- src/activate/registerCommands.ts | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/src/activate/registerCommands.ts b/src/activate/registerCommands.ts index 4af6b81c544..34a3fcbb06f 100644 --- a/src/activate/registerCommands.ts +++ b/src/activate/registerCommands.ts @@ -123,18 +123,26 @@ export const openClineInNewTab = async ({ context, outputChannel }: Omit editor.viewColumn || 0)) - // Check if there are any visible text editors, otherwise open a new group - // to the right. + const activeEditor = vscode.window.activeTextEditor const hasVisibleEditors = vscode.window.visibleTextEditors.length > 0 + let targetCol: vscode.ViewColumn + if (!hasVisibleEditors) { + // No editors open, open in first column + targetCol = vscode.ViewColumn.One + } else if (activeEditor && activeEditor.document.fileName === "" && vscode.window.visibleTextEditors.length === 1) { + // Only one editor and it's empty (untitled), reuse it + targetCol = activeEditor.viewColumn ?? vscode.ViewColumn.One + } else { + // Otherwise, create a new group to the right await vscode.commands.executeCommand("workbench.action.newGroupRight") + // New group becomes the last + 1 + const lastCol = Math.max(...vscode.window.visibleTextEditors.map((e) => e.viewColumn || 1)) + targetCol = (lastCol + 1) as vscode.ViewColumn } - const targetCol = hasVisibleEditors ? Math.max(lastCol + 1, 1) : vscode.ViewColumn.Two - const newPanel = vscode.window.createWebviewPanel(ClineProvider.tabPanelId, "Roo Code", targetCol, { enableScripts: true, retainContextWhenHidden: true, From 2cd4a28781279fa727139ad4287094cd75daaf88 Mon Sep 17 00:00:00 2001 From: Matt Rubens Date: Thu, 3 Apr 2025 23:50:48 -0400 Subject: [PATCH 2/2] PR feedback --- src/activate/registerCommands.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/activate/registerCommands.ts b/src/activate/registerCommands.ts index 34a3fcbb06f..a544d6c707c 100644 --- a/src/activate/registerCommands.ts +++ b/src/activate/registerCommands.ts @@ -132,7 +132,7 @@ export const openClineInNewTab = async ({ context, outputChannel }: Omit