From faf414fbee4a46821b1274af6dfd18b70693ea86 Mon Sep 17 00:00:00 2001 From: rsd-darshan Date: Thu, 14 May 2026 18:22:40 +0545 Subject: [PATCH 1/2] fix: prevent Terminal view from stealing focus after CLI command execution Use IWorkbenchPage.VIEW_VISIBLE instead of the default VIEW_ACTIVATE when showing the Terminal view, so it does not steal focus from the Chat view after approving a terminal command in agent mode. Fixes #188 --- .../copilot/eclipse/ui/terminal/tm/RunInTerminalTool.java | 4 ++-- .../copilot/eclipse/ui/terminal/RunInTerminalTool.java | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/com.microsoft.copilot.eclipse.ui.terminal.tm/src/com/microsoft/copilot/eclipse/ui/terminal/tm/RunInTerminalTool.java b/com.microsoft.copilot.eclipse.ui.terminal.tm/src/com/microsoft/copilot/eclipse/ui/terminal/tm/RunInTerminalTool.java index 6844799f..62f43577 100644 --- a/com.microsoft.copilot.eclipse.ui.terminal.tm/src/com/microsoft/copilot/eclipse/ui/terminal/tm/RunInTerminalTool.java +++ b/com.microsoft.copilot.eclipse.ui.terminal.tm/src/com/microsoft/copilot/eclipse/ui/terminal/tm/RunInTerminalTool.java @@ -205,7 +205,7 @@ private ITerminalControl getTerminalControl(String terminalTitle, boolean isBack try { IWorkbenchPage page = getActivePage(); if (page != null) { - IViewPart view = page.showView(IUIConstants.ID); + IViewPart view = page.showView(IUIConstants.ID, null, IWorkbenchPage.VIEW_VISIBLE); if (view != null) { tabFolder = view.getAdapter(CTabFolder.class); if (tabFolder != null) { @@ -366,7 +366,7 @@ private void bringTerminalViewAndCopilotConsoleToFront() { try { IWorkbenchPage page = getActivePage(); if (page != null) { - IViewPart view = page.showView(IUIConstants.ID); + IViewPart view = page.showView(IUIConstants.ID, null, IWorkbenchPage.VIEW_VISIBLE); if (tabFolder.isDisposed() && view != null) { tabFolder = view.getAdapter(CTabFolder.class); } diff --git a/com.microsoft.copilot.eclipse.ui.terminal/src/com/microsoft/copilot/eclipse/ui/terminal/RunInTerminalTool.java b/com.microsoft.copilot.eclipse.ui.terminal/src/com/microsoft/copilot/eclipse/ui/terminal/RunInTerminalTool.java index 2edacc0b..d5cd3a8d 100644 --- a/com.microsoft.copilot.eclipse.ui.terminal/src/com/microsoft/copilot/eclipse/ui/terminal/RunInTerminalTool.java +++ b/com.microsoft.copilot.eclipse.ui.terminal/src/com/microsoft/copilot/eclipse/ui/terminal/RunInTerminalTool.java @@ -208,7 +208,7 @@ private ITerminalControl getTerminalControl(String terminalTitle, boolean isBack try { IWorkbenchPage page = getActivePage(); if (page != null) { - IViewPart view = page.showView(IUIConstants.ID); + IViewPart view = page.showView(IUIConstants.ID, null, IWorkbenchPage.VIEW_VISIBLE); if (view != null) { tabFolder = view.getAdapter(CTabFolder.class); if (tabFolder != null) { @@ -366,7 +366,7 @@ private void bringTerminalViewAndCopilotConsoleToFront() { try { IWorkbenchPage page = getActivePage(); if (page != null) { - IViewPart view = page.showView(IUIConstants.ID); + IViewPart view = page.showView(IUIConstants.ID, null, IWorkbenchPage.VIEW_VISIBLE); if (tabFolder.isDisposed() && view != null) { tabFolder = view.getAdapter(CTabFolder.class); } From ddea8cbd1f21a42955e2426218d80a1e18ae91a8 Mon Sep 17 00:00:00 2001 From: rsd-darshan Date: Fri, 15 May 2026 08:58:28 +0545 Subject: [PATCH 2/2] refactor: rename bringTerminalViewAndCopilotConsoleToFront to revealTerminal The function no longer activates/focuses the view, so the old name was misleading. revealTerminal better reflects the updated behavior. --- .../copilot/eclipse/ui/terminal/tm/RunInTerminalTool.java | 6 +++--- .../copilot/eclipse/ui/terminal/RunInTerminalTool.java | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/com.microsoft.copilot.eclipse.ui.terminal.tm/src/com/microsoft/copilot/eclipse/ui/terminal/tm/RunInTerminalTool.java b/com.microsoft.copilot.eclipse.ui.terminal.tm/src/com/microsoft/copilot/eclipse/ui/terminal/tm/RunInTerminalTool.java index 62f43577..78f12c39 100644 --- a/com.microsoft.copilot.eclipse.ui.terminal.tm/src/com/microsoft/copilot/eclipse/ui/terminal/tm/RunInTerminalTool.java +++ b/com.microsoft.copilot.eclipse.ui.terminal.tm/src/com/microsoft/copilot/eclipse/ui/terminal/tm/RunInTerminalTool.java @@ -97,7 +97,7 @@ public CompletableFuture executeCommand(String command, boolean isBackgr synchronized (lock) { if (!isBackground && this.persistentTerminalViewControl != null) { - bringTerminalViewAndCopilotConsoleToFront(); + revealTerminal(); this.persistentTerminalViewControl.pasteString(finalCommand); return this.resultFuture; } @@ -122,7 +122,7 @@ public CompletableFuture executeCommand(String command, boolean isBackgr if (!isBackground) { this.persistentTerminalViewControl = terminalViewControl; - bringTerminalViewAndCopilotConsoleToFront(); + revealTerminal(); } terminalViewControl.pasteString(finalCommand); } else { @@ -360,7 +360,7 @@ private DisposeListener buildDisposeListener(String executionId, boolean isBackg }; } - private void bringTerminalViewAndCopilotConsoleToFront() { + private void revealTerminal() { if (tabFolder != null && copilotTabItem != null) { Display.getDefault().syncExec(() -> { try { diff --git a/com.microsoft.copilot.eclipse.ui.terminal/src/com/microsoft/copilot/eclipse/ui/terminal/RunInTerminalTool.java b/com.microsoft.copilot.eclipse.ui.terminal/src/com/microsoft/copilot/eclipse/ui/terminal/RunInTerminalTool.java index d5cd3a8d..721dc954 100644 --- a/com.microsoft.copilot.eclipse.ui.terminal/src/com/microsoft/copilot/eclipse/ui/terminal/RunInTerminalTool.java +++ b/com.microsoft.copilot.eclipse.ui.terminal/src/com/microsoft/copilot/eclipse/ui/terminal/RunInTerminalTool.java @@ -99,7 +99,7 @@ public CompletableFuture executeCommand(String command, boolean isBackgr synchronized (lock) { if (!isBackground && this.persistentTerminalViewControl != null) { - bringTerminalViewAndCopilotConsoleToFront(); + revealTerminal(); this.persistentTerminalViewControl.pasteString(finalCommand); return this.resultFuture; } @@ -124,7 +124,7 @@ public CompletableFuture executeCommand(String command, boolean isBackgr if (!isBackground) { this.persistentTerminalViewControl = terminalViewControl; - bringTerminalViewAndCopilotConsoleToFront(); + revealTerminal(); } terminalViewControl.pasteString(finalCommand); } else { @@ -360,7 +360,7 @@ private DisposeListener buildDisposeListener(String executionId, boolean isBackg }; } - private void bringTerminalViewAndCopilotConsoleToFront() { + private void revealTerminal() { if (tabFolder != null && copilotTabItem != null) { Display.getDefault().syncExec(() -> { try {