-
Notifications
You must be signed in to change notification settings - Fork 6.9k
Fix: webview panel state change steals focus #5193
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Fix webview visibility detection to check both visible and active states before taking focus. If a panel is visible but not active (focused), it should not steals editor focus. Also removes unused import & add type imports
🦋 Changeset detectedLatest commit: 38e7050 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
There was a problem hiding this comment.
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 fixes a focus management issue where the Cline webview panel would steal focus from the editor in side-by-side mode. The fix ensures that focus is only taken when the panel is both visible and active (focused), preventing unwanted focus stealing when the panel is visible but not the active tab.
Key changes:
- Updated webview visibility detection logic to check both
visible
andactive
states - Cleaned up imports by converting some to type-only imports and removing unused code
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
File | Description |
---|---|
src/hosts/vscode/VscodeWebviewProvider.ts | Fixed focus stealing by checking both visible and active states, cleaned up imports and removed unused code |
.changeset/sweet-days-whisper.md | Added changeset entry documenting the focus management fix |
Coverage ReportExtension CoverageBase branch: 46% PR branch: 47% ✅ Coverage increased or remained the same Webview CoverageBase branch: 17% PR branch: 17% ✅ Coverage increased or remained the same Overall Assessment✅ Test coverage has been maintained or improved Last updated: 2025-07-26T19:58:14.158588 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approving this PR because the code makes sense.
Full disclosure: despite my repeated attempts I could not replicate the case in #4700
And the before case mentioned in this PR description. That being said since Bee replicated it I will take her word for it and approve because the code is good.
Related Issue
Issue: #4700
Description
Fix webview visibility detection to check both visible and active states before taking focus. If a panel is visible but not active (focused), it should not steals editor focus.
Also removes unused import & add type imports
Test Procedure
Type of Change
Pre-flight Checklist
npm test
) and code is formatted and linted (npm run format && npm run lint
)npm run changeset
(required for user-facing changes)Screenshots
Same tab group - keeps focus when switching between tabs:
Screen.Recording.2025-07-26.at.11.22.21.AM.mov
Side by side mode:
Screen.Recording.2025-07-26.at.11.29.15.AM.mov
Before
Focus keeps being stole from cline panel in side by side mode because
this.webview.visible
will always be trueScreen.Recording.2025-07-26.at.11.35.29.AM.mov
Additional Notes
Important
Fixes focus issue in
VscodeWebviewProvider
by checking both visibility and active states before focusing, preventing webview from stealing focus when not active.VscodeWebviewProvider
by checking bothvisible
andactive
states before focusing.Uri
import fromvscode
.This description was created by
for 29759a0. You can customize this summary. It will automatically update as commits are pushed.