Skip to content

fix: prevent Terminal view from stealing focus after CLI command execution#195

Merged
jdneo merged 4 commits into
microsoft:mainfrom
rsd-darshan:fix/terminal-focus-steal
May 15, 2026
Merged

fix: prevent Terminal view from stealing focus after CLI command execution#195
jdneo merged 4 commits into
microsoft:mainfrom
rsd-darshan:fix/terminal-focus-steal

Conversation

@rsd-darshan

@rsd-darshan rsd-darshan commented May 14, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Fixes [Bug] Prevent focusing the Terminal view after executing a CLI command in Chat view #188
  • When a terminal command is executed in agent mode, page.showView() was called with the default VIEW_ACTIVATE mode, which brought the Terminal view to the front and stole focus from the Chat view
  • Changed both getTerminalControl() and bringTerminalViewAndCopilotConsoleToFront() in both RunInTerminalTool implementations to use IWorkbenchPage.VIEW_VISIBLE instead, so the Terminal view is shown without stealing focus

Test plan

  • Open the Chat view and Terminal view side by side in Eclipse
  • Run an agent prompt that triggers a terminal command (e.g. echo hello world)
  • Approve the command
  • Verify the Chat view remains focused and the Terminal runs in the background without stealing focus
  • Verify the terminal command still executes correctly and output is captured

…ution

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 microsoft#188
Copilot AI review requested due to automatic review settings May 14, 2026 12:38

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR prevents the Eclipse Terminal view from taking focus during Copilot agent terminal command execution by switching Terminal view display calls to non-activating visibility mode.

Changes:

  • Uses IWorkbenchPage.VIEW_VISIBLE instead of the default activating showView() behavior in both terminal implementations.
  • Applies the focus-preserving behavior to both modern Terminal and legacy TM Terminal integrations.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
com.microsoft.copilot.eclipse.ui.terminal/src/com/microsoft/copilot/eclipse/ui/terminal/RunInTerminalTool.java Updates modern Terminal view display calls to avoid activating the view.
com.microsoft.copilot.eclipse.ui.terminal.tm/src/com/microsoft/copilot/eclipse/ui/terminal/tm/RunInTerminalTool.java Applies the same non-activating Terminal view behavior for legacy TM Terminal.

@rsd-darshan

Copy link
Copy Markdown
Contributor Author

@microsoft-github-policy-service agree

@jdneo jdneo left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the contribution. Overall looks good to me, just one minor renaming issue.

…erminal

The function no longer activates/focuses the view, so the old name was
misleading. revealTerminal better reflects the updated behavior.
@rsd-darshan

Copy link
Copy Markdown
Contributor Author

@jdneo Done, renamed to revealTerminal() in both implementations:)

@rsd-darshan rsd-darshan requested a review from jdneo May 15, 2026 03:22

@jdneo jdneo left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thank you for your contribution.

@jdneo jdneo merged commit 04a2a20 into microsoft:main May 15, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Prevent focusing the Terminal view after executing a CLI command in Chat view

3 participants